applyCancel.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view>
  3. <view class="cancel-head">
  4. <u-cell-group>
  5. <u-cell-item title="未收货" :arrow="false">
  6. <u-radio-group wrap v-model="rog"><u-radio active-color="#1ABC9C" name="NO" @click="radioChange('NO')"></u-radio></u-radio-group>
  7. </u-cell-item>
  8. <u-cell-item title="已收货" v-if="applyService" :arrow="false">
  9. <u-radio-group wrap v-model="rog"><u-radio active-color="#1ABC9C" name="YES" @click="radioChange('YES')"></u-radio></u-radio-group>
  10. </u-cell-item>
  11. </u-cell-group>
  12. </view>
  13. <view class="cancle-body" v-if="rog === 'NO'">
  14. <view class="cancel-tips">
  15. <view class="tips-header">温馨提示:</view>
  16. <view>1. 订单取消后无法恢复;</view>
  17. <view>2. 订单取消后,使用的优惠券将不再返还,积分可以退回;</view>
  18. <view>3. 订单取消后,订单中的赠品要随商品一起返还给商家;</view>
  19. </view>
  20. <u-cell-group>
  21. <u-cell-item title="退款方式" value="原路退回" :arrow="false" v-if="isRetrace"></u-cell-item>
  22. <u-cell-item title="退款方式" value="账号退款" :arrow="false" v-else></u-cell-item>
  23. <u-cell-item title="退款金额" :value="refund_info.refund_price" :arrow="false"></u-cell-item>
  24. <u-cell-item title="取消原因" :value="refund_info.reason" @click="handleShowReason" :arrow="true" arrow-direction="down" required></u-cell-item>
  25. <u-action-sheet :list="reasonSelectActions" v-model="reasonSelectShow" @click="onSelectReason"></u-action-sheet>
  26. <view v-if="!isRetrace">
  27. <u-cell-item title="账户类型" :value="accountTypeText" @click="handleShowAccountType" :arrow="true" arrow-direction="down" required></u-cell-item>
  28. <u-action-sheet :list="accountTypeSelectActions" v-model="accountTypeSelectShow" @click="onSelectAccountType"></u-action-sheet>
  29. <view v-if="refund_info.account_type === 'BANK_TRANSFER'">
  30. <u-field v-model="refund_info.bank_name" required clearable label="银行名称" input-align="right" placeholder="请输入银行名称"></u-field>
  31. <u-field v-model="refund_info.bank_deposit_name" label-width="150" required clearable label="银行开户行" input-align="right" placeholder="请输入银行开户行"></u-field>
  32. <u-field v-model="refund_info.bank_account_name" label-width="150" required clearable label="银行开户名" input-align="right" placeholder="请输入银行开户名"></u-field>
  33. <u-field v-model="refund_info.bank_account_number" required clearable label="银行账号" input-align="right" placeholder="请输入银行账号"></u-field>
  34. </view>
  35. <u-field v-model="refund_info.return_account" required clearable label="退款账号" input-align="right" placeholder="请输入退款账号"></u-field>
  36. </view>
  37. <u-field v-model="refund_info.mobile" required clearable label="联系方式" input-align="right" placeholder="请输入手机号码"></u-field>
  38. </u-cell-group>
  39. <view class="submit-btn">
  40. <u-button shape="circle" class="cancel-btn" @click="handleCancelSubmit">取消</u-button>
  41. <u-button shape="circle" class="main-btn" @click="handleSubmitApply">提交</u-button>
  42. </view>
  43. </view>
  44. <view class="service-body" v-else>
  45. <view class="cancel-tips">
  46. <view class="tips-header">温馨提示:</view>
  47. <view>1. 当前订单还未确认收货,如果申请售后,则订单自动确认收货;</view>
  48. <view>2. 如申请售后,使用的优惠券和积分等将不再返还;</view>
  49. <view>3. 订单中的赠品要随申请售后的商品一起返还给商家;</view>
  50. </view>
  51. <view class="submit-btn"><u-button shape="circle" class="main-btn" @click="handleApplyService">申请售后</u-button></view>
  52. </view>
  53. <u-toast ref="uToast" />
  54. </view>
  55. </template>
  56. <script>
  57. import Foundation from '@/utils/Foundation.js';
  58. import RegExp from '@/utils/RegExp.js';
  59. import { applyCancelOrder } from '@/api/after-sale.js';
  60. import { confirmReceipt, getOrderDetail } from '@/api/order.js';
  61. export default {
  62. data() {
  63. return {
  64. /** 订单编号 */
  65. order_sn: 0,
  66. /** 订单详细 */
  67. order: '',
  68. /** 是否允许申请售后 */
  69. applyService: false,
  70. /** 是否已收货 */
  71. rog: 'NO',
  72. /** 是否支持原路退款 */
  73. isRetrace: false,
  74. /** 申请取消订单参数 */
  75. refund_info: {
  76. reason: '请选择取消原因',
  77. mobile: '',
  78. account_type: '',
  79. return_account: '',
  80. refund_price: 0.0
  81. },
  82. /** 是否展示取消原因下拉框 */
  83. reasonSelectShow: false,
  84. /** 取消原因下拉框数据 */
  85. reasonSelectActions: [
  86. { text: '商品无货' },
  87. { text: '配送时间问题' },
  88. { text: '不想要了' },
  89. { text: '商品信息填写错误' },
  90. { text: '地址信息填写错误' },
  91. { text: '商品降价' },
  92. { text: '货物破损已拒签' },
  93. { text: '订单无物流跟踪记录' },
  94. { text: '非本人签收' },
  95. { text: '其他' }
  96. ],
  97. /** 账户类型下拉框选中的值 */
  98. accountTypeText: '请选择账户类型',
  99. /** 是否展示账户类型下拉框 */
  100. accountTypeSelectShow: false,
  101. /** 账户类型下拉框数据 */
  102. accountTypeSelectActions: [{ text: '支付宝', value: 'ALIPAY' }, { text: '微信', value: 'WEIXINPAY' }, { text: '银行卡', value: 'BANK_TRANSFER' }]
  103. };
  104. },
  105. onLoad(options) {
  106. this.order_sn = options.sn;
  107. this.GET_OrderCancelDetail();
  108. },
  109. methods: {
  110. // 选中任一radio时,由radio-group触发
  111. radioChange(e) {
  112. this.rog = e;
  113. },
  114. /** 展示申请原因上拉框事件绑定 */
  115. handleShowReason() {
  116. this.reasonSelectShow = true;
  117. },
  118. /** 申请原因选中事件绑定 */
  119. onSelectReason(index) {
  120. this.reasonSelectShow = false;
  121. this.refund_info.reason = this.reasonSelectActions[index].text;
  122. },
  123. /** 展示账户类型上拉框事件绑定 */
  124. handleShowAccountType() {
  125. this.accountTypeSelectShow = true;
  126. },
  127. /** 账户类型选中事件绑定 */
  128. onSelectAccountType(index) {
  129. this.accountTypeSelectShow = false;
  130. this.accountTypeText = this.accountTypeSelectActions[index].text;
  131. this.refund_info.account_type = this.accountTypeSelectActions[index].value;
  132. },
  133. /** 跳转至订单列表页面 */
  134. handleCancelSubmit() {
  135. uni.redirectTo({
  136. url: '/pages/order/myOrder?status=0'
  137. });
  138. },
  139. /** 申请售后 */
  140. handleApplyService() {
  141. confirmReceipt(this.order_sn).then(() => {
  142. uni.redirectTo({
  143. url: '/pages/order/afterSales/afterSales'
  144. });
  145. });
  146. },
  147. /** 校验参数 */
  148. handleCheckParams() {
  149. // 取消原因校验
  150. if (!this.refund_info.reason || this.refund_info.reason === '请选择取消原因') {
  151. this.$refs.uToast.show({ title: '请选择取消原因!', type: 'error' });
  152. return false;
  153. }
  154. // 联系方式校验
  155. if (!this.refund_info.mobile || !this.$u.test.mobile(this.refund_info.mobile)) {
  156. this.$refs.uToast.show({ title: '请输入正确格式的手机号码!', type: 'error' });
  157. return false;
  158. }
  159. // 如果不支持原路退款
  160. if (!this.isRetrace) {
  161. // 账户类型校验
  162. if (!this.refund_info.account_type) {
  163. this.$refs.uToast.show({ title: '请选择账户类型!', type: 'error' });
  164. return false;
  165. }
  166. // 如果账户类型不为银行卡
  167. if (this.refund_info.account_type != 'BANK_TRANSFER') {
  168. // 退款账号校验
  169. if (!this.refund_info.return_account) {
  170. this.$refs.uToast.show({ title: '请输入退款账号!', type: 'error' });
  171. return false;
  172. }
  173. } else {
  174. // 银行名称校验
  175. if (!this.refund_info.bank_name) {
  176. this.$refs.uToast.show({ title: '请输入银行名称!', type: 'error' });
  177. return false;
  178. }
  179. // 银行开户行校验
  180. if (!this.refund_info.bank_deposit_name) {
  181. this.$refs.uToast.show({ title: '请输入银行开户行!', type: 'error' });
  182. return false;
  183. }
  184. // 银行开户名校验
  185. if (!this.refund_info.bank_account_name) {
  186. this.$refs.uToast.show({ title: '请输入银行开户名!', type: 'error' });
  187. return false;
  188. }
  189. // 银行账号校验
  190. if (!this.refund_info.bank_account_number) {
  191. this.$refs.uToast.show({ title: '请输入银行账号!', type: 'error' });
  192. return false;
  193. }
  194. }
  195. }
  196. return true;
  197. },
  198. /** 提交取消订单申请 */
  199. handleSubmitApply() {
  200. // 校验参数
  201. if (!this.handleCheckParams()) {
  202. return false;
  203. }
  204. this.refund_info.order_sn = this.order_sn;
  205. applyCancelOrder(this.refund_info).then(() => {
  206. this.$refs.uToast.show({ title: '提交成功!', type: 'success' });
  207. this.handleCancelSubmit();
  208. });
  209. },
  210. /** 获取订单详情信息 */
  211. GET_OrderCancelDetail() {
  212. getOrderDetail(this.order_sn).then(response => {
  213. this.order = response.data;
  214. this.isRetrace = this.order.is_retrace;
  215. this.refund_info.refund_price = Foundation.formatPrice(this.order.order_price);
  216. this.applyService = this.order.order_status === 'SHIPPED' && this.order.ship_status === 'SHIP_YES';
  217. });
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss">
  223. /deep/ .u-cell {
  224. // #ifdef MP-WEIXIN
  225. width: 100vw !important;
  226. overflow: hidden !important;
  227. display: block !important;
  228. // #endif
  229. }
  230. /deep/ .u-cell_title{
  231. // #ifdef MP-WEIXIN
  232. float: left;
  233. // #endif
  234. }
  235. /deep/ .u-cell__value{
  236. // #ifdef MP-WEIXIN
  237. float: right;
  238. // #endif
  239. }
  240. .cancel-head {
  241. display: flex;
  242. justify-content: flex-end;
  243. align-items: flex-end;
  244. }
  245. .submit-btn {
  246. display: flex;
  247. margin-top: 40rpx;
  248. margin-bottom: 40rpx;
  249. text-align: center;
  250. justify-content: center;
  251. align-items: center;
  252. }
  253. .cancel-tips {
  254. display: flex;
  255. flex-direction: column;
  256. padding: 20rpx;
  257. font-size: 22rpx;
  258. font-family: PingFang SC, PingFang SC-Regular;
  259. color: #999999;
  260. view {
  261. margin-top: 6rpx;
  262. }
  263. .tips-header {
  264. color: #ff6262;
  265. font-size: 26rpx;
  266. margin-bottom: 6rpx;
  267. }
  268. }
  269. .main-btn {
  270. width: 40%;
  271. background-color: $light-color;
  272. color: #ffffff;
  273. }
  274. .cancel-btn {
  275. margin-right: 30px;
  276. width: 40%;
  277. border-color: $light-color;
  278. color: $light-color;
  279. }
  280. </style>