index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <view>
  3. <view class="apply-return">
  4. <view class="apply-return-top">
  5. <view class="apply-return-list">
  6. <view class="apply-return-card" v-for="(item, idx) in orderInfo.orderInfoList" :key="idx">
  7. <image :src="item.image" mode="aspectFill"></image>
  8. <view class="con">
  9. <view class="name">
  10. <view class="">{{ item.storeName }}</view>
  11. <view class="">¥{{ item.price }}</view>
  12. </view>
  13. <view class="num">
  14. <view class="">{{ item.sku }}</view>
  15. <view class="">X{{ item.cartNum }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="apply-return-b">
  21. <view class="item">
  22. <view>退货件数</view>
  23. <view class="num">{{ orderInfo.totalNum }}</view>
  24. </view>
  25. <view class="item">
  26. <view>订单金额</view>
  27. <view class="red">¥{{ orderInfo.payPrice }}</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="list">
  32. <view class="item acea-row row-between-wrapper" @tap="toggleTab('region')">
  33. <view>退货原因</view>
  34. <picker class="num" @change="bindPickerChange" :value="index" :range="RefundArray">
  35. <view class="picker acea-row row-between-wrapper">
  36. <view class="reason">{{ RefundArray[index] }}</view>
  37. <image class="iconfont" src="/static/images/shop/go@2x.png" mode=""></image>
  38. </view>
  39. </picker>
  40. </view>
  41. <view class="item">
  42. <view>快递单号</view>
  43. <input v-model="form.returnDeliveryId" placeholder-class="express-num" placeholder="请输入快递单号" />
  44. </view>
  45. <view class="textarea">
  46. <view>退货物流截图</view>
  47. <up-upload @afterRead="async (e) => {
  48. await afterRead(e);
  49. getImage();
  50. }" @delete="onImageDelete" name="product" multiple :maxCount="1" :fileList="previewImages">
  51. <view class="upload-btn">
  52. <up-icon name="plus" size="20" color="#ccc"></up-icon>
  53. <text class="upload-tip">点击上传</text>
  54. </view>
  55. </up-upload>
  56. <text class="format-tip">支持上传PNG、JPG格式的图片,每张不超过5MB。</text>
  57. </view>
  58. <view class="textarea">
  59. <view>备注说明</view>
  60. <textarea v-model="form.refund_reason_wap_explain" count placeholder="填写备注信息,100字以内" class="num"></textarea>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="kong"></view>
  65. <view class="footer">
  66. <button @click="subRefund" class="returnBnt" form-type="submit">
  67. 申请退货
  68. </button>
  69. </view>
  70. </view>
  71. </template>
  72. <script setup>
  73. import {
  74. ref,
  75. reactive,
  76. watch,
  77. } from "vue";
  78. import {
  79. useAppStore
  80. } from "@/stores/app";
  81. import {
  82. onLoad
  83. } from "@dcloudio/uni-app";
  84. import {
  85. ordeRefundReason,
  86. applyRefund,
  87. exchangeDelivery
  88. } from "@/api/order.js";
  89. import {
  90. toLogin
  91. } from "@/libs/login.js";
  92. import {
  93. useImageUpload
  94. } from "@/hooks/useImageUpload";
  95. const appStore = useAppStore();
  96. import {
  97. useToast
  98. } from "@/hooks/useToast";
  99. import {applyExchangeInfo} from "../../../api/order";
  100. const refund_reason_wap_imgPath = ref([]);
  101. const orderInfo = reactive({});
  102. const RefundArray = ref([]);
  103. const index = ref(0);
  104. const orderId = ref(0);
  105. const {
  106. Toast
  107. } = useToast();
  108. const form = ref({
  109. text:'',
  110. returnDeliveryId: '',
  111. refund_reason_wap_explain: '',
  112. uni: '',
  113. refund_reason_wap_img: ''
  114. })
  115. const previewImages = ref([]);
  116. const {
  117. imageList,
  118. afterRead,
  119. deletePic,
  120. uploadLoading
  121. } = useImageUpload({
  122. pid: 1,
  123. model: "product",
  124. });
  125. watch(() => appStore.isLogin, (newV) => {
  126. if (newV) {
  127. getOrderInfo();
  128. getRefundReason();
  129. }
  130. });
  131. onLoad((options) => {
  132. if (!options.orderId)
  133. return Toast({
  134. title: "缺少订单id,无法退款"
  135. }, {
  136. tab: 3,
  137. url: 1
  138. });
  139. form.value.uni = options.orderId
  140. orderId.value = options.orderId;
  141. if (appStore.isLogin) {
  142. getOrderInfo();
  143. getRefundReason();
  144. } else {
  145. toLogin();
  146. }
  147. });
  148. function onLoadFun() {
  149. getOrderInfo();
  150. getRefundReason();
  151. }
  152. /**
  153. * 获取订单详情
  154. */
  155. function getOrderInfo() {
  156. applyExchangeInfo(orderId.value).then((res) => {
  157. Object.assign(orderInfo, res.data);
  158. });
  159. }
  160. /**
  161. * 获取退款理由
  162. */
  163. function getRefundReason() {
  164. ordeRefundReason().then((res) => {
  165. RefundArray.value = res.data;
  166. if (res.data.length) {
  167. form.value.text = res.data[index.value]
  168. }
  169. });
  170. }
  171. /**
  172. * 申请退货
  173. */
  174. function subRefund(e) {
  175. form.value.id = orderInfo.id;
  176. form.value.returnDeliveryImgUrl = previewImages.value[0]?.info?.url || previewImages.value[0]?.url;
  177. console.log(form.value)
  178. exchangeDelivery(form.value)
  179. .then((res) => {
  180. return Toast({
  181. title: "申请成功",
  182. icon: "success"
  183. }, {
  184. tab: 5,
  185. url: "/pages/users/user_return_list/index?isT=1"
  186. });
  187. })
  188. .catch((err) => {
  189. return Toast({
  190. title: err
  191. });
  192. });
  193. }
  194. function bindPickerChange(e) {
  195. index.value = e.detail.value;
  196. form.value.text = RefundArray.value[e.detail.value]
  197. }
  198. function toggleTab() {
  199. // 保留原逻辑
  200. }
  201. async function getImage() {
  202. if (imageList.value.length > 0) {
  203. if (imageList.value[0].status == "success") {
  204. previewImages.value = imageList.value;
  205. } else {
  206. Toast({
  207. title: "上传失败"
  208. });
  209. }
  210. }
  211. imageList.value = [];
  212. }
  213. const onImageDelete = (e) => {
  214. previewImages.value.splice(e.index, 1);
  215. };
  216. </script>
  217. <style>
  218. page {
  219. background: #F9F7F0;
  220. }
  221. </style>
  222. <style scoped lang="scss">
  223. .apply-return {
  224. padding: 16rpx;
  225. .apply-return-top {
  226. padding: 16rpx;
  227. border-radius: 16rpx;
  228. background: #FFFFFF;
  229. .apply-return-card {
  230. display: flex;
  231. margin-bottom: 16rpx;
  232. image {
  233. width: 160rpx;
  234. height: 160rpx;
  235. margin-right: 16rpx;
  236. border-radius: 16rpx;
  237. }
  238. .con {
  239. flex: 1;
  240. .name {
  241. font-size: 28rpx;
  242. display: flex;
  243. font-weight: bold;
  244. align-items: center;
  245. justify-content: space-between;
  246. }
  247. .num {
  248. margin-top: 8rpx;
  249. color: #666666;
  250. font-size: 24rpx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. }
  255. }
  256. }
  257. }
  258. .apply-return-top {
  259. .item {
  260. margin-bottom: 16rpx;
  261. display: flex;
  262. align-items: center;
  263. justify-content: space-between;
  264. &:last-child {
  265. margin-bottom: 0;
  266. }
  267. color: #333333;
  268. font-size: 28rpx;
  269. .red {
  270. color: #FD5F3C;
  271. font-weight: bold;
  272. }
  273. }
  274. }
  275. .list {
  276. .item {
  277. padding: 0 16rpx;
  278. height: 100rpx;
  279. margin-top: 16rpx;
  280. border-radius: 16rpx;
  281. background-color: #fff;
  282. font-size: 28rpx;
  283. color: #333333;
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-between;
  287. input {
  288. font-size: 28rpx;
  289. text-align: right;
  290. }
  291. .num {
  292. color: #282828;
  293. width: 427rpx;
  294. text-align: right;
  295. .picker {
  296. .reason {
  297. width: 385rpx;
  298. }
  299. }
  300. }
  301. .iconfont {
  302. width: 32rpx;
  303. height: 32rpx;
  304. margin-left: 8rpx;
  305. }
  306. ::v-deep .express-num {
  307. text-align: right;
  308. }
  309. .placeholder {
  310. color: #bbb;
  311. }
  312. .title {
  313. height: 95rpx;
  314. width: 100%;
  315. .tip {
  316. font-size: 30rpx;
  317. color: #bbb;
  318. }
  319. }
  320. .upload {
  321. padding-bottom: 36rpx;
  322. .pictrue {
  323. border-radius: 14rpx;
  324. margin: 22rpx 23rpx 0 0;
  325. width: 156rpx;
  326. height: 156rpx;
  327. position: relative;
  328. font-size: 24rpx;
  329. color: #bbb;
  330. &:nth-of-type(4n) {
  331. margin-right: 0;
  332. }
  333. image {
  334. width: 100%;
  335. height: 100%;
  336. border-radius: 14rpx;
  337. }
  338. .icon-guanbi1 {
  339. position: absolute;
  340. font-size: 45rpx;
  341. top: -10rpx;
  342. right: -10rpx;
  343. }
  344. .icon-icon25201 {
  345. color: #bfbfbf;
  346. font-size: 50rpx;
  347. }
  348. &:nth-last-child(1) {
  349. border: 1rpx solid #ddd;
  350. box-sizing: border-box;
  351. }
  352. }
  353. }
  354. }
  355. }
  356. .textarea {
  357. padding: 16rpx;
  358. border-radius: 16rpx;
  359. margin-top: 16rpx;
  360. background: #FFFFFF;
  361. view {
  362. margin-bottom: 16rpx;
  363. }
  364. textarea {
  365. width: 100%;
  366. padding: 16rpx;
  367. font-size: 28rpx;
  368. height: 264rpx;
  369. background: #F9F7F0;
  370. border-radius: 16rpx;
  371. }
  372. }
  373. }
  374. .kong {
  375. height: calc(132rpx + constant(safe-area-inset-bottom));
  376. height: calc(132rpx + env(safe-area-inset-bottom));
  377. background: #F9F7F0;
  378. }
  379. .footer {
  380. padding: 22rpx 32rpx calc(22rpx + constant(safe-area-inset-bottom));
  381. padding: 22rpx 32rpx calc(22rpx + env(safe-area-inset-bottom));
  382. position: fixed;
  383. bottom: 0;
  384. width: 100%;
  385. background-color: #fff;
  386. z-index: 277;
  387. box-shadow: inset 0rpx 1rpx 0rpx 0rpx #F1F3F8;
  388. }
  389. .returnBnt {
  390. text-align: center;
  391. color: #333333;
  392. font-size: 32rpx;
  393. line-height: 88rpx;
  394. border-radius: 16rpx;
  395. background: #F8C008;
  396. font-weight: bold;
  397. &::after {
  398. width: 0;
  399. border: none;
  400. }
  401. }
  402. .upload-btn {
  403. display: flex;
  404. flex-direction: column;
  405. align-items: center;
  406. justify-content: center;
  407. width: 150rpx;
  408. height: 150rpx;
  409. border: 1rpx dashed #DCDFE6;
  410. border-radius: 8rpx;
  411. background: #fff;
  412. }
  413. .upload-tip {
  414. font-size: 20rpx;
  415. color: #666;
  416. margin-top: 6rpx;
  417. }
  418. </style>