apply.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="page">
  3. <!-- 商品卡片 -->
  4. <TitleOperate title="售后商品" padding="10rpx 30rpx 24rpx 30rpx"></TitleOperate>
  5. <view class="goods">
  6. <template v-for="(goods, index) in selSalesGoods">
  7. <orderDetailGoodsCard :data="goods" :key="index"></orderDetailGoodsCard>
  8. </template>
  9. <view class="selgoodsb" v-if="canApplyList.length>1">
  10. <view class="t" v-if="selSalesGoods.length==0">
  11. 该订单包含多个商品,请手动选择您要退款的商品
  12. </view>
  13. <u-button size="small" type="primary" @click="selSalesGoodsFun()">
  14. {{selSalesGoods.length>0?'重新选择':'选择商品'}}</u-button>
  15. </view>
  16. <view class="selgoodsb" v-else-if="canApplyList.length<1">
  17. <view class="t">
  18. 未找到可申请售后的商品
  19. </view>
  20. </view>
  21. </view>
  22. <TitleOperate title="仅退款" padding="10rpx 30rpx 24rpx 30rpx" v-if="backType == '1'" showMore moreLabel="重新选择" @clickMore="backType='home'">
  23. <!-- <view>
  24. 重新选择<u-icon size="20" name="arrow-right" :color="arrowColor"></u-icon>
  25. </view> -->
  26. </TitleOperate>
  27. <TitleOperate title="退货退款" padding="10rpx 30rpx 24rpx 30rpx" v-if="backType == '2'" showMore moreLabel="重新选择" @clickMore="backType='home'">
  28. <!-- <view>
  29. 重新选择<u-icon size="20" name="arrow-right" :color="arrowColor"></u-icon>
  30. </view> -->
  31. </TitleOperate>
  32. <template v-if="selSalesGoods.length>0">
  33. <!-- 操作项 -->
  34. <SelectItem v-if="backType == 'home'" :ops="selectOps" @change="changBackType"></SelectItem>
  35. <!-- 售后原因 -->
  36. <ApplyReason v-else :backType="backType" :totalPrice="totalPrice" :goodslist="selSalesGoods"
  37. @done="confirmApply"></ApplyReason>
  38. <!-- 仅退款 -->
  39. <!-- <BackMoney v-if="backType == '1'" :totalPrice="totalPrice" :goodslist="selSalesGoods"
  40. @done="confirmApply"></BackMoney> -->
  41. <!-- 退货退款 -->
  42. <!-- <BackAll v-if="backType == '2'"></BackAll> -->
  43. </template>
  44. <selectGoodsPopup ref="selectGoodsPopup" @done="comfirmSel"></selectGoodsPopup>
  45. </view>
  46. </template>
  47. <script>
  48. // 组件
  49. import orderDetailGoodsCard from '@/pages-mall/components/order/orderdetail-goods-card.vue';
  50. import SelectItem from '@/pages-mall/components/after-sales/select-item.vue';
  51. import ApplyReason from '@/pages-mall/components/after-sales/apply-reason.vue';
  52. import BackGoods from '@/pages-mall/components/after-sales/back-goods.vue';
  53. import selectGoodsPopup from '@/pages-mall/components/after-sales/select-goods-pop.vue';
  54. import TitleOperate from '@/components/title-operate.vue';
  55. export default {
  56. components: {
  57. orderDetailGoodsCard,
  58. SelectItem,
  59. BackGoods,
  60. selectGoodsPopup,
  61. TitleOperate,
  62. ApplyReason
  63. },
  64. data() {
  65. return {
  66. orderId: null,
  67. // 选择的售后类型
  68. backType: 'home',
  69. canApplyList:[],
  70. selOpt: {},
  71. // 详情
  72. orderInfo: {},
  73. // 售后类型的配置项
  74. selectOps: [{
  75. title: '仅退款',
  76. desc: '未收到货(包含未签收),或与卖家协商同意前提下',
  77. icon: require('@/pages-mall/static/select-item-1.png'),
  78. type: '1',
  79. value: 1
  80. },
  81. {
  82. title: '退货退款',
  83. desc: '未收到货(包含未签收),或与卖家协商同意前提下',
  84. icon: require('@/pages-mall/static/select-item-2.png'),
  85. type: '2',
  86. value: 2
  87. },
  88. // {
  89. // title: '换货',
  90. // desc: '已收到货,需要退还收到的货物',
  91. // icon: require('@/pages-mall/static/select-item-3.png'),
  92. // type: 'goods'
  93. // }
  94. ],
  95. // 选择的退款商品
  96. selSalesGoods: [],
  97. };
  98. },
  99. computed: {
  100. totalPrice() {
  101. let totalPrice = 0;
  102. this.selSalesGoods.map(item => (totalPrice += Number(item.actual_total_amount)));
  103. return totalPrice;
  104. },
  105. },
  106. onLoad(opt) {
  107. this.orderId = opt.orderId;
  108. console.log('this.orderId>>>',this.orderId)
  109. if (!this.orderId) {
  110. uni.navigateBack();
  111. }
  112. this.getOrderDetail();
  113. },
  114. methods: {
  115. // 导航栏返回自定义函数
  116. goBack() {
  117. if (this.backType == 'home') {
  118. uni.navigateBack({
  119. delta: 1
  120. });
  121. } else {
  122. this.backType = 'home';
  123. }
  124. },
  125. // 选择退款商品
  126. selSalesGoodsFun() {
  127. this.$refs.selectGoodsPopup.showPop(this.orderInfo)
  128. },
  129. getOrderDetail() {
  130. this.$u.api.getOrderDetailAjax(this.orderId).then(({code,data}) => {
  131. if (code == 1) {
  132. this.orderInfo = data;
  133. console.log('>>>>>>>11111',data);
  134. if(data.order_info.status=='11'){
  135. this.selectOps = [{
  136. title: '仅退款',
  137. desc: '未收到货(包含未签收),或与卖家协商同意前提下',
  138. icon: require('@/pages-mall/static/select-item-1.png'),
  139. type: '1',
  140. value: 1
  141. }]
  142. }
  143. // 过滤可申请的商品列表
  144. this.filCanApplyList();
  145. }
  146. }).catch()
  147. },
  148. // 过滤可申请售后的商品列表
  149. filCanApplyList(){
  150. console.log(this.orderInfo.order_goods_info);
  151. this.canApplyList = this.orderInfo.order_goods_info.filter(e=>(e.sub_status=='10'||e.sub_status=='22'||e.sub_status=='32'));
  152. console.log(this.canApplyList);
  153. if (this.canApplyList.length == 1) {
  154. this.selSalesGoods = this.canApplyList;
  155. }
  156. },
  157. // 选择售后类型
  158. changBackType(e) {
  159. this.backType = e.item.type;
  160. this.selOpt = e.item;
  161. },
  162. // 多商品确认选择
  163. comfirmSel(e) {
  164. this.selSalesGoods = e;
  165. },
  166. // 确认退款
  167. confirmApply(e) {
  168. // uni.redirectTo({
  169. // url: '/pages-mall/pages/after-sales/apply-status?refund_type='+this.backType+'&status=10'
  170. // })
  171. // return;
  172. let ids = this.selSalesGoods.map((e) => {
  173. return e.id
  174. });
  175. this.$u.api.refundOrderAjax({
  176. order_id: this.orderInfo.order_info.id,
  177. order_detail_ids: ids.toString(),
  178. refund_type:this.selOpt.value,
  179. ...e,
  180. }).then(({code,data}) => {
  181. if (code == 1) {
  182. // 默认进入对应售后场景的第一步状态
  183. // uni.redirectTo({
  184. // url: '/pages-mall/pages/after-sales/apply-status?refund_type='+this.backType+'&status=10'
  185. // })
  186. uni.redirectTo({
  187. url: '/pages-mall/pages/after-sales/success?refundId='+data.id
  188. })
  189. }
  190. }).catch(()=>{
  191. })
  192. },
  193. }
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. .page {
  198. padding: 30rpx;
  199. }
  200. .goods {
  201. border-radius: 16rpx;
  202. box-shadow: $app-theme-shadow;
  203. padding: 30rpx;
  204. margin-bottom: 24rpx;
  205. background-color: $app-theme-bg-color;
  206. }
  207. .selgoodsb {
  208. text-align: center;
  209. .t {
  210. margin-bottom: 20rpx;
  211. color: #666;
  212. }
  213. }
  214. </style>