apply.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <!-- 售后申请 -->
  2. <template>
  3. <s-layout :title="t('order.apply_for_after_sales')">
  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">{{t('order.after_sales_type')}}</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">{{t('order.refund_amount')}}</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">{{t('order.application_reason')}}</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>{{t('order.select_reason_for_application')}}</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">{{t('order.related_description')}}</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="t('order.customer_prompt')"
  64. />
  65. <!-- TODO 非繁人:上传的测试 -->
  66. <view class="upload-img">
  67. <s-uploader
  68. v-model:url="formData.applyPicUrls"
  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">{{t('common.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. {{t('order.application_reason')}}
  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. {{t('common.confirm')}}
  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 { t } from '@/locale'
  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: t('order.refund_only')
  140. // value: '10',
  141. // },
  142. {
  143. text: t('order.refund_and_return'),
  144. value: '20',
  145. },
  146. ],
  147. reasonList: [], // 可选的申请原因数组
  148. showModal: false, // 是否显示申请原因弹窗
  149. currentValue: '' // 当前选择的售后原因
  150. });
  151. const formData = reactive({
  152. way: '',
  153. applyReason: '',
  154. applyDescription: '',
  155. applyPicUrls: [],
  156. });
  157. const rules = reactive({});
  158. // 提交表单
  159. async function submit() {
  160. if(formData.way == ""){
  161. uni.showToast({
  162. title: t('order.select_after_sales_type'),
  163. icon: 'error',
  164. duration: 1000
  165. })
  166. return false;
  167. }
  168. if(state.currentValue == ""){
  169. uni.showToast({
  170. title: t('order.reason_for_application'),
  171. icon: 'error',
  172. duration: 1000
  173. })
  174. return false;
  175. }
  176. if(formData.applyDescription == ""){
  177. uni.showToast({
  178. title:t('order.please_fill_in_description'),
  179. icon: 'error',
  180. duration: 1000
  181. })
  182. return false;
  183. }
  184. // #ifdef MP
  185. sheep.$platform.useProvider('wechat').subscribeMessage('order_aftersale_change');
  186. // #endif
  187. let data = {
  188. orderItemId: state.itemId,
  189. refundPrice: state.item.payPrice,
  190. ...formData,
  191. };
  192. const { code } = await AfterSaleApi.createAfterSale(data);
  193. if (code === 0) {
  194. uni.showToast({
  195. title: t('wallet.application_successful')
  196. });
  197. sheep.$router.go('/pages/order/aftersale/list');
  198. }
  199. }
  200. // 选择售后类型
  201. function onRefundChange(e) {
  202. formData.way = e.detail.value;
  203. // 清理理由
  204. state.reasonList =
  205. formData.way === '10'
  206. ? state.config.afterSaleRefundReasons || []
  207. : state.config.afterSaleReturnReasons || [];
  208. formData.applyReason = '';
  209. state.currentValue = '';
  210. }
  211. // 选择申请原因
  212. function onChange(e) {
  213. state.currentValue = e.detail.value;
  214. }
  215. // 确定
  216. function onReason() {
  217. formData.applyReason = state.currentValue;
  218. state.showModal = false;
  219. }
  220. onLoad(async (options) => {
  221. // 解析参数
  222. if (!options.orderId || !options.itemId) {
  223. sheep.$helper.toast(`缺少订单信息,请检查`);
  224. return;
  225. }
  226. state.orderId = options.orderId;
  227. state.itemId = parseInt(options.itemId);
  228. // 读取订单信息
  229. const { code, data } = await OrderApi.getOrder(state.orderId);
  230. if (code !== 0) {
  231. return;
  232. }
  233. state.order = data;
  234. state.item = data.items.find((item) => item.id === state.itemId) || {};
  235. // 设置选项
  236. if (state.order.status === 10) {
  237. state.wayList.splice(1, 1);
  238. }
  239. // 读取配置
  240. state.config = (await TradeConfigApi.getTradeConfig()).data;
  241. // 取消仅退款,所以一进入这个页面就默认选中售后退款
  242. formData.way = '20';
  243. formData.type = '20';
  244. state.reasonList = state.config.afterSaleReturnReasons || [];
  245. });
  246. </script>
  247. <style lang="scss" scoped>
  248. .item-title {
  249. font-size: 30rpx;
  250. font-weight: bold;
  251. color: rgba(51, 51, 51, 1);
  252. // margin-bottom: 20rpx;
  253. }
  254. // 售后项目
  255. .refund-item {
  256. background-color: #fff;
  257. border-bottom: 1rpx solid #f5f5f5;
  258. padding: 30rpx;
  259. &:last-child {
  260. border: none;
  261. }
  262. // 留言
  263. .describe-box {
  264. width: 690rpx;
  265. background: rgba(249, 250, 251, 1);
  266. padding: 30rpx;
  267. box-sizing: border-box;
  268. border-radius: 20rpx;
  269. .describe-content {
  270. height: 200rpx;
  271. font-size: 24rpx;
  272. font-weight: 400;
  273. color: #333;
  274. }
  275. }
  276. // 联系方式
  277. .input-box {
  278. height: 84rpx;
  279. background: rgba(249, 250, 251, 1);
  280. border-radius: 20rpx;
  281. }
  282. }
  283. .goods-box {
  284. background: #fff;
  285. padding: 20rpx;
  286. margin-bottom: 20rpx;
  287. }
  288. .foot-wrap {
  289. height: 100rpx;
  290. width: 100%;
  291. }
  292. .foot_box {
  293. height: 100rpx;
  294. background-color: #fff;
  295. .sub-btn {
  296. width: 100%;
  297. line-height: 74rpx;
  298. border-radius: 38rpx;
  299. color: rgba(#fff, 0.9);
  300. font-size: 28rpx;
  301. }
  302. .contcat-btn {
  303. width: 336rpx;
  304. line-height: 74rpx;
  305. background: rgba(238, 238, 238, 1);
  306. border-radius: 38rpx;
  307. font-size: 28rpx;
  308. font-weight: 400;
  309. color: rgba(51, 51, 51, 1);
  310. }
  311. }
  312. .modal-box {
  313. width: 750rpx;
  314. // height: 680rpx;
  315. border-radius: 30rpx 30rpx 0 0;
  316. background: #fff;
  317. .modal-head {
  318. height: 100rpx;
  319. font-size: 30rpx;
  320. }
  321. .modal-content {
  322. font-size: 28rpx;
  323. }
  324. .modal-foot {
  325. .close-btn {
  326. width: 710rpx;
  327. line-height: 80rpx;
  328. border-radius: 40rpx;
  329. color: rgba(#fff, 0.9);
  330. }
  331. }
  332. }
  333. .success-box {
  334. width: 600rpx;
  335. padding: 90rpx 0 64rpx 0;
  336. .cicon-check-round {
  337. font-size: 96rpx;
  338. color: #04b750;
  339. }
  340. .success-title {
  341. font-weight: 500;
  342. color: #333333;
  343. font-size: 32rpx;
  344. }
  345. .success-btn {
  346. width: 492rpx;
  347. height: 70rpx;
  348. background: linear-gradient(90deg, var(--ui-BG-Main-gradient), var(--ui-BG-Main));
  349. border-radius: 35rpx;
  350. }
  351. }
  352. </style>