scan-result.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const WXAPI = require('apifm-wxapi')
  2. Page({
  3. data: {
  4. },
  5. onLoad: function (e) {
  6. // e.hxNumber = '2003201758574236'
  7. this.setData({
  8. hxNumber: e.hxNumber
  9. });
  10. },
  11. onShow: function () {
  12. var that = this;
  13. WXAPI.orderDetail(wx.getStorageSync('token'), '', this.data.hxNumber).then(function (res) {
  14. if (res.code != 0) {
  15. wx.showModal({
  16. title: '错误',
  17. content: res.msg,
  18. showCancel: false
  19. })
  20. return;
  21. }
  22. that.setData({
  23. orderDetail: res.data
  24. });
  25. })
  26. },
  27. wuliuDetailsTap: function (e) {
  28. var orderId = e.currentTarget.dataset.id;
  29. wx.navigateTo({
  30. url: "/pages/wuliu/index?id=" + orderId
  31. })
  32. },
  33. confirmBtnTap: function (e) {
  34. let that = this;
  35. let orderId = this.data.orderId;
  36. wx.showModal({
  37. title: '确认您已收到商品?',
  38. content: '',
  39. success: function (res) {
  40. if (res.confirm) {
  41. WXAPI.orderDelivery(wx.getStorageSync('token'), orderId).then(function (res) {
  42. if (res.code == 0) {
  43. that.onShow();
  44. }
  45. })
  46. }
  47. }
  48. })
  49. },
  50. submitReputation: function (e) {
  51. let that = this;
  52. let postJsonString = {};
  53. postJsonString.token = wx.getStorageSync('token');
  54. postJsonString.orderId = this.data.orderId;
  55. let reputations = [];
  56. let i = 0;
  57. while (e.detail.value["orderGoodsId" + i]) {
  58. let orderGoodsId = e.detail.value["orderGoodsId" + i];
  59. let goodReputation = e.detail.value["goodReputation" + i];
  60. let goodReputationRemark = e.detail.value["goodReputationRemark" + i];
  61. let reputations_json = {};
  62. reputations_json.id = orderGoodsId;
  63. reputations_json.reputation = goodReputation;
  64. reputations_json.remark = goodReputationRemark;
  65. reputations.push(reputations_json);
  66. i++;
  67. }
  68. postJsonString.reputations = reputations;
  69. WXAPI.orderReputation({
  70. postJsonString: JSON.stringify(postJsonString)
  71. }).then(function (res) {
  72. if (res.code == 0) {
  73. that.onShow();
  74. }
  75. })
  76. },
  77. async doneHx(){
  78. wx.showLoading({
  79. title: '处理中...',
  80. })
  81. const res = await WXAPI.orderHXV2({
  82. token: wx.getStorageSync('token'),
  83. hxNumber: this.data.hxNumber
  84. })
  85. wx.hideLoading()
  86. if (res.code != 0) {
  87. wx.showToast({
  88. title: res.msg,
  89. icon: 'none'
  90. })
  91. } else {
  92. wx.showToast({
  93. title: '核销完成',
  94. icon: 'none'
  95. })
  96. this.onShow()
  97. }
  98. },
  99. })