orderMixin.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. let app = getApp();
  2. module.exports = {
  3. data: {
  4. index: 0,
  5. shipping_no: '',
  6. expInfo: '',
  7. showRaderList: false,
  8. selectOrderId: ''
  9. },
  10. actionConfirm: function(content) {
  11. return new Promise((resolve, reject)=>{
  12. wx.showModal({
  13. title: '提示',
  14. content,
  15. showCancel: true,
  16. success: (result) => {
  17. if (result.confirm) {
  18. resolve();
  19. } else if (result.cancel) {
  20. console.log('用户点击取消')
  21. }
  22. }
  23. })
  24. })
  25. },
  26. /**
  27. * 获取快递列表
  28. * @param {*} e
  29. */
  30. getExpList: function(e) {
  31. this.actionConfirm('确认此订单发货吗?').then(()=>{
  32. let token = wx.getStorageSync('token');
  33. let order_id = e.currentTarget.dataset.id || '';
  34. wx.showLoading();
  35. app.util.ProReq('supplymobile.get_express_list', {token, order_id}).then(res=>{
  36. //快递列表
  37. let expInfo = { order_id, ...res.data };
  38. this.setData({
  39. expInfo,
  40. showExpModal: true
  41. })
  42. //弹窗
  43. }).catch(err=>{
  44. app.util.message(err.msg, '', 'error');
  45. })
  46. })
  47. },
  48. bindPickerChange: function(e) {
  49. console.log('picker发送选择改变,携带值为', e.detail.value)
  50. this.setData({
  51. index: e.detail.value
  52. })
  53. },
  54. bindKeyInput: function (e) {
  55. this.setData({
  56. shipping_no: e.detail.value
  57. })
  58. },
  59. /**
  60. * 快递确认配送
  61. * @param {*} order_id
  62. */
  63. expSend: function(e) {
  64. console.log(e)
  65. let token = wx.getStorageSync('token');
  66. let order_id = e.currentTarget.dataset.id || '';
  67. let { expInfo, index, shipping_no } = this.data;
  68. let express_id = expInfo && expInfo.express_list[index].id || '';
  69. if(express_id=='') {
  70. wx.showToast({
  71. title: '请选择物流公司',
  72. icon: 'none'
  73. })
  74. return;
  75. }
  76. if(shipping_no=='') {
  77. wx.showToast({
  78. title: '请输入物流单号',
  79. icon: 'none'
  80. })
  81. return;
  82. }
  83. wx.showLoading();
  84. app.util.ProReq('supplymobile.do_send_order_express', {token, order_id, express_id, shipping_no}).then(res=>{
  85. wx.showToast({ title: '确认配送成功' })
  86. this.setData({ shipping_no: '', showExpModal: false, index: 0, expInfo: '' })
  87. this.initFn();
  88. }).catch(err=>{
  89. app.util.message(err.msg, '', 'error');
  90. })
  91. },
  92. /**
  93. * 团长确认配送
  94. * @param {*} e
  95. */
  96. tuanSend: function(e) {
  97. this.actionConfirm('确认此订单发货吗?').then(()=>{
  98. let token = wx.getStorageSync('token');
  99. let order_id = e.currentTarget.dataset.id || '';
  100. wx.showLoading();
  101. order_id && app.util.ProReq('supplymobile.supply_do_opsend_tuanz', {token, order_id}).then(res=>{
  102. wx.showToast({ title: '确认配送成功' })
  103. this.initFn();
  104. }).catch(err=>{
  105. app.util.message(err.msg, '', 'error');
  106. })
  107. });
  108. },
  109. /**
  110. * 同城配送确认配送
  111. * @param {*} e
  112. */
  113. localtownSend: function(e) {
  114. this.actionConfirm('确认此订单发货吗?').then(()=>{
  115. let token = wx.getStorageSync('token');
  116. let order_id = e.currentTarget.dataset.id || '';
  117. wx.showLoading();
  118. order_id && app.util.ProReq('order.order_delivery', {token, order_id, is_supply: 1}).then(res=>{
  119. wx.showToast({ title: '确认配送成功' })
  120. this.initFn();
  121. }).catch(err=>{
  122. app.util.message(err.msg, '', 'error');
  123. })
  124. });
  125. },
  126. /**
  127. * 确认送达团长
  128. * @param {*} e
  129. */
  130. tuanOver: function(e) {
  131. this.actionConfirm('确认送达团长吗?').then(()=>{
  132. let token = wx.getStorageSync('token');
  133. let order_id = e.currentTarget.dataset.id || '';
  134. wx.showLoading();
  135. order_id && app.util.ProReq('supplymobile.supply_do_tuanz_over', {token, order_id}).then(res=>{
  136. this.initFn();
  137. }).catch(err=>{
  138. app.util.message(err.msg, '', 'error');
  139. })
  140. });
  141. },
  142. /**
  143. * 团长/快递确认收货 最后一步
  144. * @param {*} e
  145. */
  146. opreceive: function(e) {
  147. this.actionConfirm('确认订单收货吗?').then(()=>{
  148. let token = wx.getStorageSync('token');
  149. let order_id = e.currentTarget.dataset.id || '';
  150. wx.showLoading();
  151. order_id && app.util.ProReq('supplymobile.supply_do_opreceive', {token, order_id}).then(res=>{
  152. wx.showToast({ title: '确认收货成功' })
  153. this.initFn();
  154. }).catch(err=>{
  155. app.util.message(err.msg, '', 'error');
  156. })
  157. });
  158. },
  159. goLink: function (event) {
  160. let link = event.currentTarget.dataset.link;
  161. var pages_all = getCurrentPages();
  162. if (pages_all.length > 3) {
  163. wx.redirectTo({
  164. url: link
  165. })
  166. } else {
  167. wx.navigateTo({
  168. url: link
  169. })
  170. }
  171. },
  172. /**
  173. * 确认付款
  174. */
  175. confirmPay: function(e) {
  176. this.actionConfirm('确认此订单已付款吗?').then(()=>{
  177. let token = wx.getStorageSync('token');
  178. let order_id = e.currentTarget.dataset.id || '';
  179. wx.showLoading();
  180. order_id && app.util.ProReq('order.order_pay', {token, order_id, is_supply:1}).then(res=>{
  181. wx.showToast({ title: '付款成功' })
  182. this.initFn();
  183. }).catch(err=>{
  184. app.util.message(err.msg, '', 'error');
  185. })
  186. });
  187. },
  188. /**
  189. * 显示配送员列表
  190. */
  191. chooseRider: function(e) {
  192. let selectOrderId = e.currentTarget.dataset.id || '';
  193. this.setData({
  194. selectOrderId,
  195. showRaderList: true
  196. })
  197. },
  198. closeRiderList: function() {
  199. this.setData({
  200. selectOrderId: '',
  201. showRaderList: false
  202. })
  203. }
  204. }