order-operate.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. var _self;
  2. export const orderOperate = {
  3. data() {
  4. return {
  5. // 主题色
  6. appThemeColor: this.$appTheme.appThemeColor
  7. }
  8. },
  9. onload(){
  10. _self = this;
  11. },
  12. methods: {
  13. // 去付款
  14. goPay(e) {
  15. console.log(e);
  16. // return;
  17. this.$u.api.payAjax(e.order_no).then(({code,data})=>{
  18. if(code==1){
  19. var orderInfos = data;
  20. uni.requestPayment({
  21. "provider": "wxpay",
  22. "orderInfo":orderInfos,
  23. ...data,
  24. success: function(res) {
  25. uni.showToast({
  26. title: "支付成功",
  27. icon: 'success',
  28. success: () => {
  29. setTimeout(() => {
  30. uni.redirectTo({
  31. url: '/pages-mall/pages/order/pay-result?payTotal='+e.total_amount+'&orderId='+e.order_no
  32. })
  33. }, 500)
  34. // _self.subScribeMsg(e);
  35. }
  36. })
  37. },
  38. fail: function(err) {
  39. uni.showModal({
  40. content:'支付失败,请到我的订单中,重新支付',
  41. success() {
  42. // +this.orderInfo.order_no,
  43. // uni.redirectTo({
  44. // url:'/pages-mall/pages/order/detail'
  45. // })
  46. }
  47. })
  48. }
  49. });
  50. }
  51. })
  52. },
  53. // 支付回调
  54. subScribeMsg(e) {
  55. uni.getSetting({
  56. withSubscriptions: true,
  57. success(res) {
  58. console.log('1', res, '订阅信息', res.subscriptionsSetting);
  59. if (!res.subscriptionsSetting.mainSwitch) {
  60. uni.openSetting({ //打开设置页
  61. success(res) {
  62. console.log('打开设置页', res.authSetting);
  63. }
  64. })
  65. } else {
  66. uni.requestSubscribeMessage({
  67. tmplIds: ['Sfa68XDGAUQveX50PcP_Ep6ngNz3luvXJNwzASjzzvQ',
  68. '_VxaYVnVTj3aG_wengF8KNFDI3WRhOrFseBerx8xvXE',
  69. ],
  70. success(res) {
  71. console.log('requestSubscribeMessage 订阅信息', res);
  72. if (res['Sfa68XDGAUQveX50PcP_Ep6ngNz3luvXJNwzASjzzvQ'] == "accept") { // 用户点击确定后
  73. console.log('用户订阅点击确定按钮');
  74. // _self.getSubMsg()
  75. } else {
  76. console.log('拒绝');
  77. }
  78. },
  79. fail(errMessage) {
  80. console.log("订阅消息 失败 ", errMessage);
  81. },
  82. // 不管成功或失败都要执行
  83. complete() {
  84. // if (_self.ordercode == null) return _self.getOrder();
  85. // if (_self.ordercode != null) return _self.getPayOrder();
  86. setTimeout(() => {
  87. uni.redirectTo({
  88. url: '/pages-mall/pages/order/pay-result?payTotal='+e.total_amount
  89. })
  90. }, 500)
  91. }
  92. })
  93. }
  94. },
  95. })
  96. },
  97. // 查看详情
  98. goOrderInfo(id) {
  99. // uni.setStorageSync('orderInfo', this.data);
  100. uni.navigateTo({
  101. url: '/pages-mall/pages/order/detail?order_id='+id
  102. });
  103. },
  104. // 取消订单
  105. cancelOrder(id,page) {
  106. let _self = this;
  107. uni.showModal({
  108. title: '提示',
  109. content: '是否取消当前订单?',
  110. confirmColor: this.appThemeColor,
  111. success: function(res) {
  112. if (res.confirm) {
  113. // TODO 接口
  114. _self.$u.api.cancelOrderAjax(id).then(({code,data})=>{
  115. if(code==1){
  116. _self.$u.toast('取消成功');
  117. // uni.redirectTo({
  118. // url:'/pages-mall/pages/order/list'
  119. // });
  120. _self.$emit('refresh')
  121. /* // uni.reload();
  122. // if(page=='orderList'){
  123. // // 从订单列表过来的,刷新订单列表
  124. // uni.reload();
  125. // _self.$router.go(0);
  126. // } */
  127. }
  128. }).catch(()=>{
  129. // _self.$router.go(0);
  130. })
  131. }
  132. }
  133. });
  134. },
  135. // 提醒发货
  136. pushDelivery() {
  137. return;
  138. uni.showModal({
  139. title: '提示',
  140. content: '是否对当前订单提醒发货?',
  141. confirmColor: this.appThemeColor,
  142. success: function(res) {
  143. if (res.confirm) {
  144. // TODO 接口
  145. }
  146. }
  147. });
  148. },
  149. // 查看物流
  150. goExpress(orderInfo) {
  151. // uni.setStorageSync('orderInfo', this.data);
  152. uni.navigateTo({
  153. url: '/pages-mall/pages/order/express?orderInfo='+encodeURIComponent(JSON.stringify(orderInfo))
  154. })
  155. },
  156. // 申请售后
  157. applyAfterSales(orderId) {
  158. // console.log(data);
  159. // return;
  160. uni.navigateTo({
  161. url: '/pages-mall/pages/after-sales/apply?orderId='+orderId
  162. })
  163. },
  164. // 确认收货
  165. confirmReceipt(data) {
  166. console.log(data);
  167. let _self = this;
  168. uni.showModal({
  169. title: '提示',
  170. content: '是否确认收货?',
  171. confirmColor: this.appThemeColor,
  172. success: function(res) {
  173. if (res.confirm) {
  174. // TODO 接口
  175. let ids = [];
  176. data.order_details.forEach(e=>{
  177. ids.push(e.id);
  178. });
  179. /* console.log({
  180. order_id:data.id,
  181. order_detail_ids:ids.toString()
  182. })
  183. return false; */
  184. _self.$u.api.orderConfirmAjax({
  185. order_id:data.id,
  186. order_detail_ids:ids.toString()
  187. }).then(({code,data})=>{
  188. if(code==1){
  189. _self.$emit('refresh')
  190. }
  191. }).catch(()=>{
  192. _self.$u.toast('操作失败')
  193. })
  194. }
  195. }
  196. });
  197. },
  198. // 去评价
  199. goEvaluate() {
  200. uni.setStorageSync('orderInfo', this.data);
  201. uni.navigateTo({
  202. url: '/pages-mall/pages/evaluate/add'
  203. })
  204. },
  205. // 删除记录
  206. deleteOrder() {
  207. uni.showModal({
  208. title: '提示',
  209. content: '是否删除当前订单?',
  210. confirmColor: this.appThemeColor,
  211. success: function(res) {
  212. if (res.confirm) {
  213. // TODO 接口
  214. }
  215. }
  216. });
  217. },
  218. // 售后详情
  219. afterSalesDetail(id){
  220. uni.navigateTo({
  221. url: '/pages-mall/pages/after-sales/apply-status?id='+id
  222. })
  223. // uni.navigateTo({
  224. // url: '/pages-mall/pages/after-sales/apply-status?applyInfo='+encodeURIComponent(JSON.stringify(data))
  225. // })
  226. },
  227. // 查看退款详情
  228. goBackMoney() {
  229. uni.setStorageSync('orderInfo', this.data);
  230. uni.navigateTo({
  231. url: '/pages-mall/pages/after-sales/back'
  232. })
  233. }
  234. }
  235. }