apply.vue 8.4 KB

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