家政小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const $ = global;
  2. const orderTexts = [
  3. '已预约,等待处理',
  4. '未付款',
  5. '已付款'
  6. ]
  7. new $.Page({
  8. data: {
  9. services: [],
  10. goods: []
  11. },
  12. onShow() {
  13. this.init();
  14. },
  15. init() {
  16. $.request('my/orders', 'GET', {}).then((res) => {
  17. if (res.data) {
  18. const services = res.data.others || [];
  19. const goods = res.data.product_orders || [];
  20. services.forEach(e => {
  21. e.orderText = orderTexts[e.status];
  22. });
  23. goods.forEach(e => {
  24. e.orderText = orderTexts[e.status];
  25. if (e.status == 0) e.orderText = '待付款';
  26. e.text = '';
  27. for (let p of e.products) {
  28. let t = `${p.name}×${p.amount}`;
  29. e.text += e.text ? (';' + t) : t;
  30. }
  31. });
  32. this.setData({
  33. services,
  34. goods
  35. });
  36. }
  37. });
  38. },
  39. toPay(e) {
  40. const _this = this;
  41. const {
  42. id,
  43. type
  44. } = e.target.dataset;
  45. if (id && type) {
  46. $.wx.showToast({
  47. title: '支付中'
  48. }, 'loading');
  49. $.request('payments/pay', 'POST', {
  50. order_id: id,
  51. order_type: type
  52. }).then((res) => {
  53. if (res.msg) {
  54. const {
  55. timestamp,
  56. paySign,
  57. nonceStr
  58. } = res.msg;
  59. const pck = res.msg.package;
  60. wx.requestPayment({
  61. timeStamp: timestamp + '',
  62. nonceStr,
  63. package: pck,
  64. signType: 'MD5',
  65. paySign,
  66. success(res) {
  67. console.log('支付成功', res);
  68. $.wx.hideToast('loading');
  69. _this.init();
  70. },
  71. fail() {
  72. $.wx.showToast({
  73. title: '支付失败'
  74. });
  75. }
  76. });
  77. }
  78. });
  79. }
  80. },
  81. addComment(e) {
  82. const {
  83. id,
  84. type
  85. } = e.target.dataset;
  86. if (id) {
  87. $.router.goto({
  88. path: '/pages/addComment/index',
  89. query: {
  90. id,
  91. type
  92. }
  93. });
  94. }
  95. }
  96. });