apply.vue 9.2 KB

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