refund.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <app-layout>
  3. <view v-if="is_show">
  4. <view class="refund-box">
  5. <view class="goods-info">
  6. <app-jump-button :url="refundDetail.page_url">
  7. <app-order-goods-info :goods="refundDetail.goods_info" :is-last-one="false" :plugin-data="refundDetail.plugin_data" :plugin-index="0">
  8. </app-order-goods-info>
  9. </app-jump-button>
  10. </view>
  11. <view class="content">
  12. <view class="content-item" v-if="form.type == 3">
  13. <span class="label">
  14. 货物状态
  15. </span>
  16. <view class="select-box" @click="setVisible('goodsStatus')">
  17. <span :class="{'active': form.goods_status, 'no-active': !form.goods_status}" class="select-label">
  18. {{form.goods_status ? goodsStatus.list[goodsStatus.index] : '请选择'}}
  19. </span>
  20. <image class="arrow-right" src="/static/image/icon/arrow-right.png">
  21. </image>
  22. </view>
  23. </view>
  24. <view class="content-item" v-if="form.type != 2">
  25. <span class="label">
  26. 退款原因
  27. </span>
  28. <view class="select-box" @click="setVisible('refundList')">
  29. <span :class="{'active': form.cause, 'no-active': !form.cause}" class="select-label">
  30. {{form.cause ? refundList.list[refundList.index] : '请选择'}}
  31. </span>
  32. <image class="arrow-right" src="/static/image/icon/arrow-right.png">
  33. </image>
  34. </view>
  35. </view>
  36. <view class="content-item" v-if="form.type == 2">
  37. <span class="label">
  38. 换货原因
  39. </span>
  40. <input class="text" placeholder="请输入换货原因" placeholder-style="color:#999999;font-size:28rpx;" v-model="form.cause"/>
  41. </view>
  42. <view class="content-item" v-if="form.type != 2">
  43. <span class="label">
  44. 退款金额
  45. </span>
  46. <span v-if="form.refund_price" class="price-label">¥</span>
  47. <input :placeholder="`最多可退款${refundDetail.refund_price_text}`" class="text price-text" placeholder-style="color:#999999;font-size:28rpx;" type="digit" v-model="form.refund_price">
  48. </view>
  49. <view class="content-item">
  50. <span class="label">
  51. 备注信息
  52. </span>
  53. <input class="text" placeholder="最多可填200个字" placeholder-style="color:#999999;font-size:28rpx;" v-model="form.remark"/>
  54. </view>
  55. <view class="content-item">
  56. <span class="label">
  57. 联系方式
  58. </span>
  59. <input class="text" placeholder="请填写联系方式,便于卖家联系你 " placeholder-style="color:#999999;font-size:28rpx;" type="number" v-model="form.mobile">
  60. </view>
  61. </view>
  62. <view class="upload-box">
  63. <view class="label">
  64. 上传凭证
  65. </view>
  66. <app-upload-image :max-num="maxNum" @imageEvent="imageEvent" background-color="#fff">
  67. </app-upload-image>
  68. </view>
  69. <view style="height: 80rpx;margin-top: 80rpx;">
  70. </view>
  71. </view>
  72. <view class="btn-box">
  73. <view @click="formSubmit" class="btn main-center cross-center">
  74. 提交
  75. </view>
  76. </view>
  77. <app-select height="264rpx" title="货物状态" :is-show="goodsStatus.visible" :list="goodsStatus.list" @confirm="goodsStatusChange" ></app-select>
  78. <app-select title="退款原因" :is-show="refundList.visible" :list="refundList.list" @confirm="refundListChange"></app-select>
  79. </view>
  80. </app-layout>
  81. </template>
  82. <script>
  83. import appOrderGoodsInfo from "../../../components/page-component/app-order-goods-info/app-order-goods-info.vue";
  84. import appUploadImage from "../../../components/basic-component/app-upload-image/app-upload-image.vue";
  85. import appSelect from "./../components/app-select";
  86. export default {
  87. components: {
  88. "app-order-goods-info": appOrderGoodsInfo,
  89. 'app-upload-image': appUploadImage,
  90. 'app-select': appSelect,
  91. },
  92. data() {
  93. return {
  94. refundDetail: {},
  95. maxNum: 6, // 图片上传最大数量
  96. is_show: false,
  97. form: {
  98. id: 0,
  99. type: 0,
  100. goods_status: '',
  101. cause: '',
  102. image_list: [],
  103. mobile: '',
  104. remark: '',
  105. refund_price: '',
  106. },
  107. goodsStatus: {
  108. index: 0,
  109. visible: false,
  110. list: [],
  111. },
  112. refundList: {
  113. index: 0,
  114. visible: false,
  115. list: [],
  116. },
  117. refundCauseList: [],
  118. disabled: false
  119. }
  120. },
  121. methods: {
  122. getRefundDetail() {
  123. let self = this;
  124. self.$showLoading();
  125. self.$request({
  126. url: this.$api.order.apply_refund,
  127. data: {
  128. id: self.form.id,
  129. }
  130. }).then(response => {
  131. self.$hideLoading();
  132. self.is_show = true;
  133. if (response.code === 0) {
  134. self.refundDetail = response.data.detail;
  135. self.goodsStatus.list = response.data.list.goods_status;
  136. self.refundList.list = response.data.list.refund_list.confirm_list;
  137. self.refundCauseList = response.data.list.refund_list;
  138. } else {
  139. uni.showModal({
  140. title: '',
  141. content: response.msg,
  142. showCancel: false,
  143. });
  144. }
  145. }).catch(() => {
  146. self.$hideLoading();
  147. });
  148. },
  149. formSubmit() {
  150. let self = this;
  151. if (!self.form.goods_status && self.form.type == 3) {
  152. uni.showModal({
  153. title: '',
  154. content: '请选择货物状态',
  155. showCancel: false,
  156. });
  157. return;
  158. }
  159. if (!self.form.cause) {
  160. let content = self.form.type == 2 ? '请填写换货原因' : '请选择退款原因';
  161. uni.showModal({
  162. title: '',
  163. content: content,
  164. showCancel: false,
  165. });
  166. return;
  167. }
  168. if ((!self.form.refund_price || self.form.refund_price < 0) && self.form.type != 2) {
  169. uni.showModal({
  170. title: '',
  171. content: '请填写退款金额',
  172. showCancel: false,
  173. });
  174. return;
  175. }
  176. if (!self.form.remark) {
  177. uni.showModal({
  178. title: '',
  179. content: '请填写备注信息',
  180. showCancel: false,
  181. });
  182. return;
  183. }
  184. if (!self.form.mobile) {
  185. uni.showModal({
  186. title: '',
  187. content: '请填写联系方式',
  188. showCancel: false,
  189. });
  190. return;
  191. }
  192. this.$subscribe(this.refundDetail.template_message_list).then(response => {
  193. self.submitAction();
  194. }).catch(res => {
  195. self.submitAction();
  196. });
  197. },
  198. submitAction() {
  199. let self = this;
  200. if (self.disabled) {
  201. return
  202. }
  203. self.disabled = true;
  204. uni.showLoading({
  205. title: '提交中'
  206. });
  207. let refundPrice = self.form.type == 2 ? 0 : self.form.refund_price;
  208. self.$request({
  209. url: self.$api.order.refund_submit,
  210. method: "post",
  211. data: {
  212. id: self.form.id,
  213. type: self.form.type,
  214. pic_list: JSON.stringify(self.form.image_list),
  215. refund_price: refundPrice,
  216. remark: this.form.remark,
  217. mobile: this.form.mobile,
  218. cause: this.form.cause,
  219. goods_status: this.form.goods_status,
  220. },
  221. }).then(response => {
  222. self.disabled = false;
  223. uni.hideLoading();
  224. if (response.code === 0) {
  225. uni.redirectTo({
  226. url: '/pages/order/refund/index'
  227. })
  228. } else {
  229. uni.showModal({
  230. title: '',
  231. content: response.msg,
  232. showCancel: false,
  233. });
  234. }
  235. }).catch(() => {
  236. self.disabled = false;
  237. uni.hideLoading();
  238. });
  239. },
  240. imageEvent(e) {
  241. this.form.image_list = e.imageList;
  242. },
  243. goodsStatusChange(e) {
  244. if (!e.is_modal_confirm) {
  245. if (this.goodsStatus.index != e.index) {
  246. this.form.cause = '';
  247. }
  248. this.goodsStatus.index = e.index;
  249. this.form.goods_status = this.goodsStatus.list[this.goodsStatus.index];
  250. if (this.goodsStatus.index == 0) {
  251. this.refundList.list = this.refundCauseList.not_confirm_list;
  252. } else {
  253. this.refundList.list = this.refundCauseList.confirm_list;
  254. }
  255. }
  256. this.goodsStatus.visible = false;
  257. },
  258. refundListChange(e) {
  259. if (!e.is_modal_confirm) {
  260. this.refundList.index = e.index;
  261. this.form.cause = this.refundList.list[this.refundList.index];
  262. }
  263. this.refundList.visible = false;
  264. },
  265. // 设置页面标题
  266. setPageTitle() {
  267. let title = '订单售后';
  268. if (this.form.type == 1) {
  269. title = '退货退款'
  270. } else if (this.form.type == 2) {
  271. title = '换货';
  272. } else if (this.form.type == 3) {
  273. title = '仅退款';
  274. }
  275. uni.setNavigationBarTitle({
  276. title: title
  277. });
  278. },
  279. setVisible(key) {
  280. this[key].visible = true;
  281. }
  282. },
  283. onLoad(options) { this.$commonLoad.onload(options);
  284. this.form.id = options.id;
  285. this.form.type = options.type;
  286. this.getRefundDetail();
  287. },
  288. onReady() {
  289. this.setPageTitle();
  290. }
  291. }
  292. </script>
  293. <style lang="scss" scoped="">
  294. .refund-box {
  295. position: absolute;
  296. width: 100%;
  297. height: 100%;
  298. padding: 24#{rpx};
  299. .goods-info {
  300. background: #ffffff;
  301. border-radius: 16#{rpx};
  302. padding: 28#{rpx};
  303. margin-bottom: 24#{rpx};
  304. }
  305. .upload-box {
  306. background: #ffffff;
  307. border-radius: 16#{rpx};
  308. padding:28#{rpx};
  309. display: flex;
  310. flex-direction: column;
  311. margin-top:24#{rpx};
  312. .label {
  313. font-size: 28#{rpx};
  314. color: #353535;
  315. margin-bottom:20#{rpx};
  316. }
  317. }
  318. .content {
  319. margin-top:24#{rpx};
  320. padding:0 28#{rpx};
  321. background: #ffffff;
  322. border-radius: 16#{rpx};
  323. display: flex;
  324. flex-direction: column;
  325. .content-item {
  326. display: flex;
  327. height: 88#{rpx};
  328. align-items: center;
  329. border-bottom:1#{rpx} solid #e2e2e2;
  330. .label {
  331. font-size:28#{rpx};
  332. color: #353535;
  333. width: 152#{rpx};
  334. }
  335. .text {
  336. color: #353535;
  337. font-size:28#{rpx};
  338. flex-grow: 1;
  339. }
  340. .price-text {
  341. color: #ff4544;
  342. }
  343. .price-label {
  344. font-size:28#{rpx};
  345. color: #ff4544;
  346. }
  347. }
  348. .content-item:last-child {
  349. border-bottom: 0;
  350. }
  351. .select-box {
  352. display: flex;
  353. align-items: center;
  354. width: 100%;
  355. .select-label {
  356. font-size:28#{rpx};
  357. width: 100%;
  358. white-space: nowrap;
  359. text-overflow: ellipsis;
  360. overflow: hidden;
  361. display: inline-block;
  362. text-align: right;
  363. }
  364. .no-active {
  365. color: #999999;
  366. }
  367. .active {
  368. color: #353535;
  369. }
  370. .arrow-right {
  371. width: 12#{rpx};
  372. height: 22#{rpx};
  373. margin-left: 16#{rpx};
  374. }
  375. }
  376. }
  377. }
  378. .btn-box {
  379. position: fixed;
  380. bottom: 0;
  381. width: 100%;
  382. padding: 24#{rpx};
  383. background: #f7f7f7;
  384. z-index: 999;
  385. .btn {
  386. border-radius: 40#{rpx};
  387. height: 80#{rpx};
  388. background: #ff4544;
  389. padding: 24#{rpx} 0;
  390. color: #ffffff;
  391. font-size: 32#{rpx};
  392. }
  393. }
  394. </style>