apply.vue 9.5 KB

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