detail.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <!-- 售后详情 -->
  2. <template>
  3. <s-layout title="售后详情" :navbar="!isEmpty(state.info) && state.loading ? 'inner' : 'normal'">
  4. <view class="content_box" v-if="!isEmpty(state.info) && state.loading">
  5. <!-- 步骤条 -->
  6. <view class="steps-box ss-flex" :style="[
  7. {
  8. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  9. paddingTop: Number(statusBarHeight + 88) + 'rpx',
  10. },
  11. ]">
  12. <view class="ss-flex">
  13. <view class="steps-item" v-for="(item, index) in state.list" :key="index">
  14. <view class="ss-flex">
  15. <text class="sicon-circleclose"
  16. v-if="state.list.length - 1 === index && [61, 62, 63].includes(state.info.status)" />
  17. <text class="sicon-circlecheck" v-else
  18. :class="state.active >= index ? 'activity-color' : 'info-color'" />
  19. <view v-if="state.list.length - 1 !== index" class="line"
  20. :class="state.active >= index ? 'activity-bg' : 'info-bg'" />
  21. </view>
  22. <view class="steps-item-title" :class="state.active >= index ? 'activity-color' : 'info-color'">
  23. {{ item.title }}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 服务状态 -->
  29. <view class="status-box ss-flex ss-col-center ss-row-between ss-m-x-20"
  30. @tap="sheep.$router.go('/pages/order/aftersale/log', { id: state.id })">
  31. <view class="">
  32. <view class="status-text">
  33. {{ formatAfterSaleStatusDescription(state.info) }}
  34. </view>
  35. <view class="status-time">
  36. {{ sheep.$helper.timeFormat(state.info.updateTime, 'yyyy-mm-dd hh:MM:ss') }}
  37. </view>
  38. </view>
  39. <text class="ss-iconfont _icon-forward" style="color: #666" />
  40. </view>
  41. <!-- 退款金额 -->
  42. <view class="aftersale-money ss-flex ss-col-center ss-row-between">
  43. <view class="aftersale-money--title">退款总额</view>
  44. <view class="aftersale-money--num">¥{{ fen2yuan(state.info.refundPrice) }}</view>
  45. </view>
  46. <!-- 服务商品 -->
  47. <view class="order-shop">
  48. <s-goods-item :img=" state.info.picUrl" :title=" state.info.spuName" :titleWidth="480"
  49. :skuText="state.info.properties.map((property) => property.valueName).join(' ')"
  50. :num=" state.info.count" />
  51. </view>
  52. <!-- 服务内容 -->
  53. <view class="aftersale-content">
  54. <view class="aftersale-item ss-flex ss-col-center">
  55. <view class="item-title">服务单号:</view>
  56. <view class="item-content ss-m-r-16">{{ state.info.no }}</view>
  57. <button class="ss-reset-button copy-btn" @tap="onCopy">复制</button>
  58. </view>
  59. <view class="aftersale-item ss-flex ss-col-center">
  60. <view class="item-title">申请时间:</view>
  61. <view class="item-content">
  62. {{ sheep.$helper.timeFormat(state.info.createTime, 'yyyy-mm-dd hh:MM:ss') }}
  63. </view>
  64. </view>
  65. <view class="aftersale-item ss-flex ss-col-center">
  66. <view class="item-title">售后类型:</view>
  67. <view class="item-content">{{ state.info.way === 10 ? '仅退款' : '退款退货' }}</view>
  68. </view>
  69. <view class="aftersale-item ss-flex ss-col-center">
  70. <view class="item-title">申请原因:</view>
  71. <view class="item-content">{{ state.info.applyReason }}</view>
  72. </view>
  73. <view class="aftersale-item ss-flex ss-col-center">
  74. <view class="item-title">相关描述:</view>
  75. <view class="item-content">{{ state.info.applyDescription }}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 操作区 -->
  80. <s-empty v-if="isEmpty(state.info) && state.loading" icon="/static/order-empty.png" text="暂无该订单售后详情" />
  81. <su-fixed bottom placeholder bg="bg-white" v-if="!isEmpty(state.info)">
  82. <view class="foot_box">
  83. <button class="ss-reset-button btn" v-if="state.info.buttons?.includes('cancel')"
  84. @tap="onApply(state.info.id)">
  85. 取消申请
  86. </button>
  87. <button class="ss-reset-button btn" v-if="state.info.buttons?.includes('delivery')"
  88. @tap="sheep.$router.go('/pages/order/aftersale/return-delivery', { id: state.info.id })">
  89. 填写退货
  90. </button>
  91. <button class="ss-reset-button contcat-btn btn" @tap="sheep.$router.go('/pages/chat/index')">
  92. 联系客服
  93. </button>
  94. </view>
  95. </su-fixed>
  96. </s-layout>
  97. </template>
  98. <script setup>
  99. import sheep from '@/sheep';
  100. import {
  101. onLoad
  102. } from '@dcloudio/uni-app';
  103. import {
  104. reactive,
  105. computed,
  106. watch
  107. } from 'vue';
  108. import {
  109. isEmpty
  110. } from 'lodash';
  111. import {
  112. showAuthModal
  113. } from '@/sheep/hooks/useModal';
  114. import {
  115. fen2yuan,
  116. formatAfterSaleStatusDescription,
  117. handleAfterSaleButtons
  118. } from '@/sheep/hooks/useGoods';
  119. import AfterSaleApi from '@/sheep/api/trade/afterSale';
  120. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  121. const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
  122. const state = reactive({
  123. id: 0, // 售后编号
  124. info: {}, // 收货信息
  125. loading: false,
  126. active: 0, // 在 list 的激活位置
  127. list: [{
  128. title: '提交申请',
  129. }, {
  130. title: '处理中',
  131. }, {
  132. title: '完成'
  133. }], // 时间轴
  134. });
  135. function onApply(id) {
  136. uni.showModal({
  137. title: '提示',
  138. content: '确定要取消此申请吗?',
  139. success: async function(res) {
  140. if (!res.confirm) {
  141. return;
  142. }
  143. const {
  144. code
  145. } = await AfterSaleApi.cancelAfterSale(id);
  146. if (code === 0) {
  147. await getDetail(id);
  148. }
  149. },
  150. });
  151. }
  152. // 复制
  153. const onCopy = () => {
  154. sheep.$helper.copyText(state.info.no);
  155. };
  156. async function getDetail(id) {
  157. state.loading = true;
  158. const {
  159. code,
  160. data
  161. } = await AfterSaleApi.getAfterSale(id);
  162. if (code !== 0) {
  163. state.info = null;
  164. return;
  165. }
  166. state.info = data;
  167. handleAfterSaleButtons(state.info);
  168. // 处理时间轴
  169. if ([10].includes(state.info.status)) {
  170. state.active = 0;
  171. } else if ([20, 30].includes(state.info.status)) {
  172. state.active = 1;
  173. } else if ([40, 50].includes(state.info.status)) {
  174. state.active = 2;
  175. } else if ([61, 62, 63].includes(state.info.status)) {
  176. state.active = 2;
  177. }
  178. }
  179. const isLogin = computed(() => sheep.$store('user').isLogin);
  180. // 监听到在这个页面登陆,并刷新页面
  181. watch(
  182. () => isLogin.value,
  183. (newVal) => {
  184. if (newVal) {
  185. window.location.reload()
  186. }
  187. }
  188. );
  189. const userInfo = computed(() => sheep.$store('user').userInfo);
  190. onLoad((options) => {
  191. //如果没登陆就进来则有可能是在微信消息推送进来的 提示登陆
  192. if (!isLogin.value) {
  193. showAuthModal();
  194. sheep.$helper.toast("您尚未登录,请登录:" + options.username + "后再试", 3000);
  195. return false;
  196. } else {
  197. console.log(userInfo.value)
  198. // 如果
  199. if(options.username){
  200. // 如果登陆了但不是该订单的账号,提示有问题
  201. if (options.username != userInfo.value.username) {
  202. sheep.$helper.toast("您当前登录的账号是" + userInfo.value.username + ",请切换到" + options.username + "后再试",
  203. 3000);
  204. return false;
  205. }
  206. }
  207. }
  208. if (!options.id) {
  209. sheep.$helper.toast(`缺少订单信息,请检查`);
  210. return
  211. }
  212. state.id = options.id;
  213. getDetail(options.id);
  214. });
  215. </script>
  216. <style lang="scss" scoped>
  217. // 步骤条
  218. .steps-box {
  219. width: 100%;
  220. height: 190rpx;
  221. background: v-bind(headerBg) no-repeat,
  222. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  223. background-size: 750rpx 100%;
  224. padding-left: 72rpx;
  225. .steps-item {
  226. .sicon-circleclose {
  227. font-size: 24rpx;
  228. color: #fff;
  229. }
  230. .sicon-circlecheck {
  231. font-size: 24rpx;
  232. }
  233. .steps-item-title {
  234. font-size: 24rpx;
  235. font-weight: 400;
  236. margin-top: 16rpx;
  237. margin-left: -36rpx;
  238. width: 100rpx;
  239. text-align: center;
  240. }
  241. }
  242. }
  243. .activity-color {
  244. color: #fff;
  245. }
  246. .info-color {
  247. color: rgba(#fff, 0.4);
  248. }
  249. .activity-bg {
  250. background: #fff;
  251. }
  252. .info-bg {
  253. background: rgba(#fff, 0.4);
  254. }
  255. .line {
  256. width: 270rpx;
  257. height: 4rpx;
  258. }
  259. // 服务状态
  260. .status-box {
  261. position: relative;
  262. z-index: 3;
  263. background-color: #fff;
  264. border-radius: 20rpx 20rpx 0px 0px;
  265. padding: 20rpx;
  266. margin-top: -20rpx;
  267. .status-text {
  268. font-size: 28rpx;
  269. font-weight: 500;
  270. color: rgba(51, 51, 51, 1);
  271. margin-bottom: 20rpx;
  272. }
  273. .status-time {
  274. font-size: 24rpx;
  275. font-weight: 400;
  276. color: rgba(153, 153, 153, 1);
  277. }
  278. }
  279. // 退款金额
  280. .aftersale-money {
  281. background-color: #fff;
  282. height: 98rpx;
  283. padding: 0 20rpx;
  284. margin: 20rpx;
  285. .aftersale-money--title {
  286. font-size: 28rpx;
  287. font-weight: 500;
  288. color: rgba(51, 51, 51, 1);
  289. }
  290. .aftersale-money--num {
  291. font-size: 28rpx;
  292. font-family: OPPOSANS;
  293. font-weight: 500;
  294. color: #ff3000;
  295. }
  296. }
  297. // order-shop
  298. .order-shop {
  299. padding: 20rpx;
  300. background-color: #fff;
  301. margin: 0 20rpx 20rpx 20rpx;
  302. }
  303. // 服务内容
  304. .aftersale-content {
  305. background-color: #fff;
  306. padding: 20rpx;
  307. margin: 0 20rpx;
  308. .aftersale-item {
  309. height: 60rpx;
  310. .copy-btn {
  311. background: #eeeeee;
  312. color: #333;
  313. border-radius: 20rpx;
  314. width: 75rpx;
  315. height: 40rpx;
  316. font-size: 22rpx;
  317. }
  318. .item-title {
  319. color: #999;
  320. font-size: 28rpx;
  321. }
  322. .item-content {
  323. color: #333;
  324. font-size: 28rpx;
  325. }
  326. }
  327. }
  328. // 底部功能
  329. .foot_box {
  330. height: 100rpx;
  331. background-color: #fff;
  332. display: flex;
  333. align-items: center;
  334. justify-content: flex-end;
  335. .btn {
  336. width: 160rpx;
  337. line-height: 60rpx;
  338. background: rgba(238, 238, 238, 1);
  339. border-radius: 30rpx;
  340. padding: 0;
  341. margin-right: 20rpx;
  342. font-size: 26rpx;
  343. font-weight: 400;
  344. color: rgba(51, 51, 51, 1);
  345. }
  346. }
  347. </style>