apply.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <!-- 售后申请 -->
  2. <template>
  3. <s-layout title="申请售后">
  4. <!-- 售后商品 -->
  5. <view class="goods-box">
  6. <s-goods-item
  7. :img="state.item.picUrl"
  8. :title="state.item.spuName"
  9. :skuText="state.item.properties?.map((property) => property.valueName).join(' ')"
  10. :price="state.item.price"
  11. :num="state.item.count"
  12. />
  13. </view>
  14. <uni-forms ref="form" v-model="formData" :rules="rules" label-position="top">
  15. <!-- 售后类型 -->
  16. <view class="refund-item">
  17. <view class="item-title ss-m-b-20">售后类型</view>
  18. <view class="ss-flex-col">
  19. <radio-group @change="onRefundChange">
  20. <label
  21. class="ss-flex ss-col-center ss-p-y-10"
  22. v-for="(item, index) in state.wayList"
  23. :key="index"
  24. >
  25. <radio
  26. :checked="formData.type === item.value"
  27. color="var(--ui-BG-Main)"
  28. style="transform: scale(0.8)"
  29. :value="item.value"
  30. />
  31. <view class="item-value ss-m-l-8">{{ item.text }}</view>
  32. </label>
  33. </radio-group>
  34. </view>
  35. </view>
  36. <!-- 退款金额 -->
  37. <view class="refund-item ss-flex ss-col-center ss-row-between" @tap="state.showModal = true">
  38. <text class="item-title">退款金额</text>
  39. <view class="ss-flex refund-cause ss-col-center">
  40. <text class="ss-m-r-20">¥{{ fen2yuan(state.item.payPrice) }}</text>
  41. </view>
  42. </view>
  43. <!-- 申请原因 -->
  44. <view class="refund-item ss-flex ss-col-center ss-row-between" @tap="state.showModal = true">
  45. <text class="item-title">申请原因</text>
  46. <view class="ss-flex refund-cause ss-col-center">
  47. <text class="ss-m-r-20" v-if="formData.applyReason">{{ formData.applyReason }}</text>
  48. <text class="ss-m-r-20" v-else>请选择申请原因~</text>
  49. <text class="cicon-forward" style="height: 28rpx"></text>
  50. </view>
  51. </view>
  52. <!-- 留言 -->
  53. <view class="refund-item">
  54. <view class="item-title ss-m-b-20">相关描述</view>
  55. <view class="describe-box">
  56. <uni-easyinput
  57. :inputBorder="false"
  58. class="describe-content"
  59. type="textarea"
  60. maxlength="120"
  61. autoHeight
  62. v-model="formData.applyDescription"
  63. placeholder="客官~请描述您遇到的问题,建议上传照片"
  64. />
  65. <view class="upload-img">
  66. <s-uploader
  67. v-model:url="formData.applyPicUrls"
  68. fileMediatype="image"
  69. limit="9"
  70. mode="grid"
  71. :imageStyles="{ width: '168rpx', height: '168rpx' }"
  72. />
  73. </view>
  74. </view>
  75. </view>
  76. </uni-forms>
  77. <!-- 底部按钮 -->
  78. <su-fixed bottom placeholder>
  79. <view class="foot-wrap">
  80. <view class="foot_box ss-flex ss-col-center ss-row-between ss-p-x-30">
  81. <button class="ss-reset-button contcat-btn" @tap="sheep.$router.go('/pages/chat/index')">
  82. 联系客服
  83. </button>
  84. <button class="ss-reset-button ui-BG-Main-Gradient sub-btn" @tap="submit">提交</button>
  85. </view>
  86. </view>
  87. </su-fixed>
  88. <!-- 申请原因弹窗 -->
  89. <su-popup :show="state.showModal" round="10" :showClose="true" @close="state.showModal = false">
  90. <view class="modal-box page_box">
  91. <view class="modal-head item-title head_box ss-flex ss-row-center ss-col-center">
  92. 申请原因
  93. </view>
  94. <view class="modal-content content_box">
  95. <radio-group @change="onChange">
  96. <label class="radio ss-flex ss-col-center" v-for="item in state.reasonList" :key="item">
  97. <view class="ss-flex-1 ss-p-20">{{ item }}</view>
  98. <radio
  99. :value="item"
  100. color="var(--ui-BG-Main)"
  101. :checked="item === state.currentValue"
  102. />
  103. </label>
  104. </radio-group>
  105. </view>
  106. <view class="modal-foot foot_box ss-flex ss-row-center ss-col-center">
  107. <button class="ss-reset-button close-btn ui-BG-Main-Gradient" @tap="onReason">
  108. 确定
  109. </button>
  110. </view>
  111. </view>
  112. </su-popup>
  113. </s-layout>
  114. </template>
  115. <script setup>
  116. import sheep from '@/sheep';
  117. import { onLoad } from '@dcloudio/uni-app';
  118. import { reactive, ref } from 'vue';
  119. import OrderApi from '@/sheep/api/trade/order';
  120. import TradeConfigApi from '@/sheep/api/trade/config';
  121. import { fen2yuan } from '@/sheep/hooks/useGoods';
  122. import AfterSaleApi from '@/sheep/api/trade/afterSale';
  123. const form = ref(null);
  124. const state = reactive({
  125. orderId: 0, // 订单编号
  126. itemId: 0, // 订单项编号
  127. order: {}, // 订单
  128. item: {}, // 订单项
  129. config: {}, // 交易配置
  130. // 售后类型
  131. wayList: [
  132. {
  133. text: '仅退款',
  134. value: '10',
  135. },
  136. {
  137. text: '退款退货',
  138. value: '20',
  139. },
  140. ],
  141. reasonList: [], // 可选的申请原因数组
  142. showModal: false, // 是否显示申请原因弹窗
  143. currentValue: '', // 当前选择的售后原因
  144. });
  145. let formData = reactive({
  146. way: '',
  147. applyReason: '',
  148. applyDescription: '',
  149. applyPicUrls: [],
  150. });
  151. const rules = reactive({});
  152. // 提交表单
  153. async function submit() {
  154. let data = {
  155. orderItemId: state.itemId,
  156. refundPrice: state.item.payPrice,
  157. ...formData,
  158. };
  159. const { code } = await AfterSaleApi.createAfterSale(data);
  160. if (code === 0) {
  161. uni.showToast({
  162. title: '申请成功',
  163. });
  164. sheep.$router.redirect('/pages/order/aftersale/list');
  165. }
  166. }
  167. // 选择售后类型
  168. function onRefundChange(e) {
  169. formData.way = e.detail.value;
  170. // 清理理由
  171. state.reasonList =
  172. formData.way === '10'
  173. ? state.config.afterSaleRefundReasons || []
  174. : state.config.afterSaleReturnReasons || [];
  175. formData.applyReason = '';
  176. state.currentValue = '';
  177. }
  178. // 选择申请原因
  179. function onChange(e) {
  180. state.currentValue = e.detail.value;
  181. }
  182. // 确定
  183. function onReason() {
  184. formData.applyReason = state.currentValue;
  185. state.showModal = false;
  186. }
  187. onLoad(async (options) => {
  188. // 解析参数
  189. if (!options.orderId || !options.itemId) {
  190. sheep.$helper.toast(`缺少订单信息,请检查`);
  191. return;
  192. }
  193. state.orderId = options.orderId;
  194. state.itemId = parseInt(options.itemId);
  195. // 读取订单信息
  196. const { code, data } = await OrderApi.getOrderDetail(state.orderId);
  197. if (code !== 0) {
  198. return;
  199. }
  200. state.order = data;
  201. state.item = data.items.find((item) => item.id === state.itemId) || {};
  202. // 设置选项
  203. if (state.order.status === 10) {
  204. state.wayList.splice(1, 1);
  205. }
  206. // 读取配置
  207. state.config = (await TradeConfigApi.getTradeConfig()).data;
  208. });
  209. </script>
  210. <style lang="scss" scoped>
  211. .item-title {
  212. font-size: 30rpx;
  213. font-weight: bold;
  214. color: rgba(51, 51, 51, 1);
  215. // margin-bottom: 20rpx;
  216. }
  217. // 售后项目
  218. .refund-item {
  219. background-color: #fff;
  220. border-bottom: 1rpx solid #f5f5f5;
  221. padding: 30rpx;
  222. &:last-child {
  223. border: none;
  224. }
  225. // 留言
  226. .describe-box {
  227. width: 690rpx;
  228. background: rgba(249, 250, 251, 1);
  229. padding: 30rpx;
  230. box-sizing: border-box;
  231. border-radius: 20rpx;
  232. .describe-content {
  233. height: 200rpx;
  234. font-size: 24rpx;
  235. font-weight: 400;
  236. color: #333;
  237. }
  238. }
  239. // 联系方式
  240. .input-box {
  241. height: 84rpx;
  242. background: rgba(249, 250, 251, 1);
  243. border-radius: 20rpx;
  244. }
  245. }
  246. .goods-box {
  247. background: #fff;
  248. padding: 20rpx;
  249. margin-bottom: 20rpx;
  250. }
  251. .foot-wrap {
  252. height: 100rpx;
  253. width: 100%;
  254. }
  255. .foot_box {
  256. height: 100rpx;
  257. background-color: #fff;
  258. .sub-btn {
  259. width: 336rpx;
  260. line-height: 74rpx;
  261. border-radius: 38rpx;
  262. color: rgba(#fff, 0.9);
  263. font-size: 28rpx;
  264. }
  265. .contcat-btn {
  266. width: 336rpx;
  267. line-height: 74rpx;
  268. background: rgba(238, 238, 238, 1);
  269. border-radius: 38rpx;
  270. font-size: 28rpx;
  271. font-weight: 400;
  272. color: rgba(51, 51, 51, 1);
  273. }
  274. }
  275. .modal-box {
  276. width: 750rpx;
  277. // height: 680rpx;
  278. border-radius: 30rpx 30rpx 0 0;
  279. background: #fff;
  280. .modal-head {
  281. height: 100rpx;
  282. font-size: 30rpx;
  283. }
  284. .modal-content {
  285. font-size: 28rpx;
  286. }
  287. .modal-foot {
  288. .close-btn {
  289. width: 710rpx;
  290. line-height: 80rpx;
  291. border-radius: 40rpx;
  292. color: rgba(#fff, 0.9);
  293. }
  294. }
  295. }
  296. .success-box {
  297. width: 600rpx;
  298. padding: 90rpx 0 64rpx 0;
  299. .cicon-check-round {
  300. font-size: 96rpx;
  301. color: #04b750;
  302. }
  303. .success-title {
  304. font-weight: 500;
  305. color: #333333;
  306. font-size: 32rpx;
  307. }
  308. .success-btn {
  309. width: 492rpx;
  310. height: 70rpx;
  311. background: linear-gradient(90deg, var(--ui-BG-Main-gradient), var(--ui-BG-Main));
  312. border-radius: 35rpx;
  313. }
  314. }
  315. </style>