order-detail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const WXAPI = require('apifm-wxapi')
  2. const AUTH = require('../../utils/auth')
  3. import wxbarcode from 'wxbarcode'
  4. Page({
  5. data: {
  6. logisticsType: '0', // 0 自己送货 1 快递
  7. shopIndex: -1
  8. },
  9. onLoad(e) {
  10. // e.id = 3
  11. this.data.id = e.id
  12. this.recycleOrderDetail()
  13. },
  14. onShow() {
  15. },
  16. async recycleOrderDetail() {
  17. wx.showLoading({
  18. title: '',
  19. })
  20. const res = await WXAPI.recycleOrderDetail(wx.getStorageSync('token'), this.data.id)
  21. wx.hideLoading()
  22. if (res.code == 0) {
  23. const orderInfo = res.data.orderInfo
  24. if (orderInfo.shopId) {
  25. this.shopSubdetail(orderInfo.shopId)
  26. }
  27. if (orderInfo.logisticsType == 0) {
  28. wxbarcode.qrcode('qrcode', orderInfo.hxNumber, 650, 650);
  29. }
  30. this.setData({
  31. orderInfo,
  32. shipperName: orderInfo.shipperName,
  33. trackingNumber: orderInfo.trackingNumber
  34. })
  35. } else {
  36. wx.showModal({
  37. title: '错误',
  38. content: res.msg,
  39. showCancel: false,
  40. success: res => {
  41. wx.navigateBack()
  42. }
  43. })
  44. }
  45. },
  46. async shopSubdetail(shopId) {
  47. const res = await WXAPI.shopSubdetail(shopId)
  48. if (res.code == 0) {
  49. this.setData({
  50. shopInfodetail: res.data
  51. })
  52. }
  53. },
  54. callMobile() {
  55. wx.makePhoneCall({
  56. phoneNumber: this.data.shopInfodetail.info.linkPhone,
  57. })
  58. },
  59. goMap() {
  60. const shop = this.data.shopInfodetail.info
  61. const latitude = shop.latitude
  62. const longitude = shop.longitude
  63. wx.openLocation({
  64. latitude,
  65. longitude,
  66. scale: 18
  67. })
  68. },
  69. fahuo() {
  70. this.setData({
  71. popupShow: true
  72. })
  73. },
  74. popupClose() {
  75. this.setData({
  76. popupShow: false
  77. })
  78. },
  79. trackingNumberScan() {
  80. wx.scanCode({
  81. success: res => {
  82. this.setData({
  83. trackingNumber: res.result
  84. })
  85. }
  86. })
  87. },
  88. async submit() {
  89. if (!this.data.shipperName) {
  90. wx.showToast({
  91. title: '填写回快递公司',
  92. icon: 'none'
  93. })
  94. return
  95. }
  96. if (!this.data.trackingNumber) {
  97. wx.showToast({
  98. title: '填写回快递单号',
  99. icon: 'none'
  100. })
  101. return
  102. }
  103. this.setData({
  104. submitButtonLoading: true
  105. })
  106. const res = await WXAPI.recycleOrderFahuo({
  107. token: wx.getStorageSync('token'),
  108. id: this.data.id,
  109. shipperName: this.data.shipperName,
  110. trackingNumber: this.data.trackingNumber,
  111. })
  112. this.setData({
  113. submitButtonLoading: false
  114. })
  115. if (res.code != 0) {
  116. wx.showToast({
  117. title: res.msg,
  118. icon: 'none'
  119. })
  120. return
  121. }
  122. wx.showToast({
  123. title: '提交成功',
  124. })
  125. this.popupClose()
  126. this.recycleOrderDetail()
  127. }
  128. })