家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. const services = []
  18. const goods = []
  19. if (res.data && res.data.length > 0) {
  20. res.data.forEach(e => {
  21. e.orderText = orderTexts[e.status];
  22. if (e.order_type == 'product_order') {
  23. if (e.status == 0)
  24. e.orderText = '待付款';
  25. goods.push(e);
  26. } else {
  27. services.push(e);
  28. }
  29. });
  30. this.setData({
  31. services,
  32. goods
  33. });
  34. }
  35. });
  36. },
  37. toPay(e) {
  38. const {
  39. id,
  40. type
  41. } = e.target.dataset;
  42. if (id && type) {
  43. $.wx.showToast({
  44. title: '支付中'
  45. }, 'loading');
  46. $.request('payments/pay', 'POST', {
  47. order_id: id,
  48. order_type: type
  49. }).then((res) => {
  50. if (res.msg) {
  51. const {
  52. timestamp,
  53. paySign,
  54. nonceStr
  55. } = res.msg;
  56. const pck = res.msg.package;
  57. wx.requestPayment({
  58. timeStamp: timestamp + '',
  59. nonceStr,
  60. package: pck,
  61. signType: 'MD5',
  62. paySign,
  63. success(res) {
  64. console.log('支付成功', res);
  65. $.wx.hideToast('loading');
  66. },
  67. fail() {
  68. $.wx.showToast({
  69. title: '支付失败'
  70. });
  71. }
  72. });
  73. }
  74. });
  75. }
  76. },
  77. addComment(e) {
  78. const {
  79. id,
  80. type
  81. } = e.target.dataset;
  82. if (id) {
  83. $.router.goto({
  84. path: '/pages/addComment/index',
  85. query: {
  86. id,
  87. type
  88. }
  89. });
  90. }
  91. }
  92. });