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.

137 lines
3.5 KiB

3 years ago
  1. export default{
  2. methods: {
  3. //详情页刷新列表
  4. refreshPreList(){
  5. this.$util.prePage() && this.$util.prePage().refreshList && this.$util.prePage().refreshList();
  6. },
  7. //确认对话框点击确定触发
  8. onModalConfirm(){
  9. //根据弹出对话框时定义的modalConfirmFn决定执行事件
  10. this.$util.throttle(async ()=>{
  11. this[this.modalConfirmFn]();
  12. })
  13. },
  14. //支付订单
  15. pay(data){
  16. this.navTo('/pages/wallet/pay?data=' + JSON.stringify({
  17. sourcePage: this.curPage === 'orderList' ? 'orderList': 'orderDetail',
  18. order_id: data._id,
  19. pay_price: data.price_data.pay_price
  20. }))
  21. },
  22. //取消订单弹窗确认
  23. cancelOrder(data){
  24. this.modalText = '您是否确定要取消订单';
  25. this.modalConfirmFn = 'cancelOrderConfirm';
  26. this.curData = data;
  27. this.$refs.mixModal.open();
  28. },
  29. //取消订单提交
  30. async cancelOrderConfirm(){
  31. const res = await this.$request('order', 'cancelOrder', {
  32. id: this.curData._id
  33. }, {showLoading: true})
  34. this.$util.msg(res.msg);
  35. if(res.status === 1){
  36. if(this.curPage === 'orderList'){
  37. this.refreshList();
  38. }else{
  39. this.loadData();
  40. this.refreshPreList
  41. }
  42. }
  43. },
  44. //删除订单
  45. async deleteOrder(index){
  46. const isList = this.curPage === 'orderList';
  47. const res = await this.$request('order', 'remove', {
  48. id: isList ? this.list[index]._id: this.id
  49. }, {showLoading: true})
  50. this.$util.msg(res.msg);
  51. if(res.status === 1){
  52. if(isList){
  53. this.list.splice(index, 1);
  54. if(this.list.length === 0){
  55. this.mescroll.showEmpty()
  56. }
  57. }else{
  58. this.refreshPreList
  59. setTimeout(()=>{
  60. uni.navigateBack();
  61. }, 1000)
  62. }
  63. }
  64. },
  65. //查看物流
  66. navToExpress(data){
  67. const addr = data.address.address;
  68. const address = addr.address + ' ' + addr.room;
  69. this.navTo(`/pages/order/express?address=${address}&shipper_code=${data.shipper_code}&logistic_code=${data.logistic_code}&order_id=${data._id}`);
  70. },
  71. //申请退款选择原因
  72. showRefundAction(data){
  73. this.curData = data;
  74. this.$refs.mixActionSheet.open({
  75. title: '请选择退款原因',
  76. list: [{text:'型号拍错'}, {text:'买多了'}, {text: '不想要了'}, {text: '数量选择错误'}, {text:'其他'}]
  77. })
  78. },
  79. //申请退款提交
  80. async refund(reason){
  81. const res = await this.$request('order', 'refund', {
  82. reason: reason.text,
  83. id: this.curData._id
  84. }, {showLoading: true})
  85. this.log(res);
  86. if(res.status === 1){
  87. if(this.curPage === 'orderList'){
  88. this.refreshList();
  89. }else{
  90. this.refreshPreList
  91. this.loadData();
  92. }
  93. }
  94. this.$util.msg(res.msg);
  95. },
  96. //确认收货 弹窗确认
  97. confirmReceipt(data){
  98. this.modalText = '请确保您已收到商品,并检查无损后再确认收货';
  99. this.modalConfirmFn = 'confirmReceiptConfirm';
  100. this.curData = data;
  101. this.$refs.mixModal.open();
  102. },
  103. //确认收货提交
  104. async confirmReceiptConfirm(){
  105. const res = await this.$request('order', 'confirmReceipt', {
  106. id: this.curData._id
  107. }, {showLoading: true})
  108. this.$util.msg(res.msg);
  109. console.log(res);
  110. if(res.status === 1){
  111. if(this.curPage === 'orderList'){
  112. this.refreshList();
  113. }else{
  114. this.loadData();
  115. this.refreshPreList
  116. }
  117. }
  118. },
  119. //去评价
  120. rate(data){
  121. this.navTo('/pages/rating/add?data=' + JSON.stringify({
  122. id: data._id,
  123. products: data.products
  124. }));
  125. }
  126. }
  127. }