普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

666 lines
16 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="page__view">
  3. <navbar title="订单详情" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />
  4. <view class="main">
  5. <view class="flex address" v-if="addressData">
  6. <addressView :data="addressData" :showIcon="true" :enableCopy="true"></addressView>
  7. </view>
  8. <template v-if="orderData">
  9. <view class="card detail">
  10. <view class="flex card-top">
  11. <view class="title">订单详情</view>
  12. <view :class="['flex', 'status', `status-${status}`]">{{ statusDesc }}</view>
  13. </view>
  14. <view class="card-main">
  15. <view class="flex product" v-for="item in orderData.appletOrderProductList" :key="item.id">
  16. <image class="img" :src="getCoverImg(item.image)" mode="scaleToFill"></image>
  17. <view class="info">
  18. <view class="row">{{ item.productName }}</view>
  19. <view class="flex row">
  20. <view class="row-label">产品类型</view>
  21. <!-- todo: check key -->
  22. <view class="row-content">{{ getTypeDesc(item.type) || '--' }}</view>
  23. </view>
  24. <view class="flex row">
  25. <view class="row-label">产品内容</view>
  26. <!-- todo: check key -->
  27. <view class="row-content">{{ item.content || '--' }}</view>
  28. </view>
  29. <view class="flex price">
  30. <text class="price-label">价格</text>
  31. <text class="price-unit">¥</text><text class="price-value">{{ item.price }}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="flex row card-bottom">
  37. <view class="row-label">总价格</view>
  38. <view class="flex row-content price">¥<text class="price-value">{{ orderData.orderAmount }}</text></view>
  39. </view>
  40. </view>
  41. <view v-if="orderData.process && orderData.process.length" class="card service">
  42. <view class="flex card-top">
  43. <view class="title">售后信息</view>
  44. </view>
  45. <view class="card-main">
  46. <uv-steps
  47. current="0"
  48. direction="column"
  49. dot
  50. activeColor="#10A934"
  51. inactiveColor="#C6C6C6"
  52. >
  53. <uv-steps-item
  54. v-for="(item, index) in orderData.process"
  55. :key="item.id"
  56. >
  57. <template #title>
  58. <view class="flex step-header">
  59. <view :class="['step-title', index == 0 ? 'highlight' : '']">{{ item.title }}</view>
  60. <view class="step-time">{{ item.createTime }}</view>
  61. </view>
  62. </template>
  63. <template #desc>
  64. <view class="step-desc">{{ item.text }}</view>
  65. </template>
  66. </uv-steps-item>
  67. </uv-steps>
  68. </view>
  69. </view>
  70. <view class="card info">
  71. <view class="flex card-top">
  72. <view class="title">订单信息</view>
  73. </view>
  74. <view class="card-main">
  75. <view class="flex row">
  76. <view class="row-label">订单编号</view>
  77. <view class="row-content">{{ orderData.orderNo }}</view>
  78. </view>
  79. <view class="flex row">
  80. <view class="row-label">下单时间</view>
  81. <view class="row-content">{{ $dayjs(orderData.orderDate).format('YYYY-MM-DD HH:mm') }}</view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <view class="notice">
  87. <view class="notice-header">下单须知</view>
  88. <view class="notice-content">
  89. <uv-parse :content="configList['order_instructions']"></uv-parse>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="flex bottom" v-if="[0, 1, 2, 3, 4].includes(status)">
  94. <view class="flex bar">
  95. <button plain class="flex flex-column btn btn-service" open-type="contact">
  96. <image class="btn-service-icon" src="@/pages_order/static/order/icon-service.png" mode="widthFix"></image>
  97. <view>联系客服</view>
  98. </button>
  99. <view class="flex cols">
  100. <!-- 待支付 -->
  101. <template v-if="status == 0">
  102. <view class="flex col price">
  103. <view class="price-label">合计</view>
  104. <text class="price-unit">¥</text><text class="price-value">{{ orderData.orderAmount }}</text>
  105. </view>
  106. <button class="flex col btn btn-primary" @click="onPay">立即支付</button>
  107. </template>
  108. <!-- 待发货 -->
  109. <template v-else-if="status == 1">
  110. <button class="flex col btn" @click="onApplyService">申请售后</button>
  111. <!-- 自采检测 -->
  112. <template v-if="detectProduct && detectProduct.subscribeType == 0">
  113. <button class="flex col btn btn-primary" @click="onDetectModify">修改</button>
  114. </template>
  115. </template>
  116. <!-- 待收货 -->
  117. <template v-else-if="status == 2">
  118. <button class="flex col btn" @click="onApplyService">申请售后</button>
  119. <!-- 检测 subscribeType: 0自采1上门2到店3已取消 -->
  120. <template v-if="detectProduct">
  121. <!-- 自采检测 -->
  122. <template v-if="detectProduct.subscribeType == 0">
  123. <button class="flex col btn btn-primary" @click="onDetectSendBack">线上回寄试剂盒</button>
  124. </template>
  125. <template v-else>
  126. <button class="flex col btn btn-primary" @click="onDetectBook">检测预约</button>
  127. </template>
  128. </template>
  129. <!-- 其他商品 -->
  130. <template v-else>
  131. <button class="flex col btn btn-primary" @click="onConfirmReceipt">确认收货</button>
  132. </template>
  133. </template>
  134. <!-- 待评价 -->
  135. <template v-else-if="status == 3">
  136. <button class="flex col btn" @click="onApplyService">申请售后</button>
  137. <button class="flex col btn btn-primary" @click="onComment">立即评价</button>
  138. </template>
  139. <!-- 已完成 -->
  140. <template v-else-if="status == 4">
  141. <button class="flex col btn" @click="onApplyService">申请售后</button>
  142. </template>
  143. </view>
  144. </view>
  145. </view>
  146. <payPopup ref="payPopup" @paySuccess="getData"></payPopup>
  147. <serviceSelectPopup ref="serviceSelectPopup"></serviceSelectPopup>
  148. </view>
  149. </template>
  150. <script>
  151. import addressView from '@/pages_order/address/addressView.vue'
  152. import payPopup from '@/pages_order/order/payPopup.vue'
  153. import serviceSelectPopup from '@/pages_order/applyService/serviceSelectPopup.vue'
  154. // 订单状态 0待支付 1待发货 2待收货 3待评价 4已完成
  155. const STATUS_AND_DESC_MAPPING = {
  156. 0: '待支付',
  157. 1: '待发货',
  158. 2: '待收货',
  159. 3: '待评价',
  160. 4: '已完成',
  161. 5: '售后',
  162. }
  163. // 产品类型(0营养剂,1预约,2课程)
  164. const TYPE_AND_DESC_MAPPING = {
  165. 0: '营养剂',
  166. 1: '检测',
  167. 2: '课程',
  168. }
  169. export default {
  170. components: {
  171. addressView,
  172. payPopup,
  173. serviceSelectPopup,
  174. },
  175. data() {
  176. return {
  177. id: null,
  178. addressData: null,
  179. orderData: null,
  180. }
  181. },
  182. computed: {
  183. status() {
  184. const { orderStatus, afterSales } = this.orderData || {}
  185. if (afterSales) {
  186. return 5
  187. }
  188. return orderStatus
  189. },
  190. statusDesc() {
  191. return STATUS_AND_DESC_MAPPING[this.status]
  192. },
  193. detectProduct() {
  194. const { appletOrderProductList } = this.orderData || {}
  195. if (appletOrderProductList?.length == 1 && appletOrderProductList?.[0]?.type == 1) { // type: 产品类型(0营养剂,1预约,2课程)
  196. return appletOrderProductList[0]
  197. }
  198. return null
  199. },
  200. },
  201. onShow() {
  202. console.log('onShow')
  203. if (!this.id) {
  204. return
  205. }
  206. this.getData()
  207. },
  208. onLoad(arg) {
  209. this.id = arg.id
  210. this.getData()
  211. },
  212. onPullDownRefresh() {
  213. this.getData()
  214. },
  215. methods: {
  216. async getData() {
  217. try {
  218. const result = await this.$fetch('detailOrder', { id: this.id })
  219. const {
  220. customerName,
  221. customerPhone,
  222. deliveryAddressDetail,
  223. ...orderData
  224. } = result
  225. this.addressData = {
  226. name: customerName,
  227. phone: customerPhone,
  228. detail: deliveryAddressDetail,
  229. }
  230. this.orderData = orderData
  231. } catch (err) {
  232. }
  233. uni.stopPullDownRefresh()
  234. },
  235. getTypeDesc(type) {
  236. return TYPE_AND_DESC_MAPPING[type]
  237. },
  238. getCoverImg(image) {
  239. return image?.split?.(',')?.[0] || ''
  240. },
  241. onPay() {
  242. const {
  243. id,
  244. title,
  245. orderAmount
  246. } = this.orderData
  247. const obj = {
  248. id,
  249. title,
  250. orderAmount,
  251. }
  252. this.$refs.payPopup.open(obj)
  253. },
  254. async onConfirmReceipt() {
  255. try {
  256. await this.$fetch('confirmOrder', { id: this.orderData.id })
  257. uni.showToast({
  258. icon: 'success',
  259. title: '确认收货成功',
  260. });
  261. this.getData()
  262. } catch (err) {
  263. }
  264. },
  265. onComment() {
  266. this.$utils.navigateTo(`/pages_order/comment/commentWrite?orderId=${this.orderData.id}`)
  267. },
  268. onApplyService() {
  269. console.log('orderData', this.orderData)
  270. const {
  271. id,
  272. appletOrderProductList,
  273. } = this.orderData
  274. const obj = {
  275. id,
  276. appletOrderProductList: appletOrderProductList.map(item => ({ ...item, statusDesc: this.statusDesc })),
  277. }
  278. this.$refs.serviceSelectPopup.open(obj)
  279. },
  280. onDetectModify() {
  281. // todo
  282. },
  283. onDetectSendBack() {
  284. // todo
  285. },
  286. onDetectBook() {
  287. // todo
  288. },
  289. },
  290. }
  291. </script>
  292. <style scoped lang="scss">
  293. .page__view {
  294. width: 100vw;
  295. min-height: 100vh;
  296. background-color: $uni-bg-color;
  297. position: relative;
  298. /deep/ .nav-bar__view {
  299. position: fixed;
  300. top: 0;
  301. left: 0;
  302. }
  303. }
  304. .main {
  305. padding: calc(var(--status-bar-height) + 144rpx) 32rpx 224rpx 32rpx;
  306. }
  307. .address {
  308. padding: 24rpx 32rpx;
  309. background: #FFFFFF;
  310. border-radius: 24rpx;
  311. justify-content: flex-start;
  312. }
  313. .card {
  314. margin-top: 40rpx;
  315. padding: 32rpx;
  316. background: #FAFAFF;
  317. border: 2rpx solid #FFFFFF;
  318. border-radius: 32rpx;
  319. &-top {
  320. margin-bottom: 32rpx;
  321. justify-content: space-between;
  322. .title {
  323. font-family: PingFang SC;
  324. font-weight: 500;
  325. font-size: 36rpx;
  326. line-height: 1.4;
  327. color: #252545;
  328. }
  329. .status {
  330. display: inline-flex;
  331. min-width: 120rpx;
  332. padding: 6rpx 0;
  333. box-sizing: border-box;
  334. font-family: PingFang SC;
  335. font-weight: 400;
  336. font-size: 24rpx;
  337. line-height: 1.4;
  338. color: #252545;
  339. background: #F3F3F3;
  340. border-radius: 12rpx;
  341. &-0 {
  342. color: #FF860E;
  343. background: #FFF4E9;
  344. }
  345. &-1 {
  346. color: #2799E0;
  347. background: #EEF7FD;
  348. }
  349. &-2 {
  350. color: #7D27E0;
  351. background: #F5EEFD;
  352. }
  353. &-5 {
  354. color: #E53C29;
  355. background: #FDE7E5;
  356. }
  357. }
  358. }
  359. .row {
  360. justify-content: space-between;
  361. font-family: PingFang SC;
  362. font-weight: 400;
  363. font-size: 28rpx;
  364. line-height: 1.4;
  365. &-label {
  366. flex: none;
  367. color: #8B8B8B;
  368. }
  369. &-content {
  370. color: #393939;
  371. }
  372. }
  373. &.detail {
  374. .product {
  375. margin-bottom: 32rpx;
  376. column-gap: 24rpx;
  377. .img {
  378. flex: none;
  379. width: 120rpx;
  380. height: 120rpx;
  381. }
  382. .info {
  383. flex: 1;
  384. padding: 24rpx 32rpx;
  385. background: #FFFFFF;
  386. border-radius: 32rpx;
  387. .row {
  388. margin-bottom: 16rpx;
  389. justify-content: flex-start;
  390. column-gap: 4rpx;
  391. }
  392. .price {
  393. justify-content: flex-start;
  394. column-gap: 8rpx;
  395. font-family: PingFang SC;
  396. font-weight: 500;
  397. line-height: 1.4;
  398. &-label {
  399. font-weight: 400;
  400. font-size: 26rpx;
  401. color: #8B8B8B;
  402. }
  403. &-unit {
  404. font-size: 24rpx;
  405. color: #7451DE;
  406. }
  407. &-value {
  408. font-size: 32rpx;
  409. color: #7451DE;
  410. }
  411. }
  412. }
  413. }
  414. .card-bottom {
  415. .price {
  416. column-gap: 8rpx;
  417. font-family: PingFang SC;
  418. font-weight: 500;
  419. font-size: 24rpx;
  420. line-height: 1.4;
  421. color: #7451DE;
  422. &-value {
  423. font-size: 32rpx;
  424. }
  425. }
  426. }
  427. }
  428. &.info {
  429. .row + .row {
  430. margin-top: 32rpx;
  431. }
  432. }
  433. &.service {
  434. .step {
  435. &-header {
  436. justify-content: flex-start;
  437. column-gap: 24rpx;
  438. padding-left: 24rpx;
  439. }
  440. &-title {
  441. font-family: PingFang SC;
  442. font-weight: 400;
  443. font-size: 30rpx;
  444. line-height: 1.4;
  445. color: #000000;
  446. &.highlight {
  447. font-weight: 500;
  448. color: #10A934;
  449. }
  450. }
  451. &-time {
  452. font-family: PingFang SC;
  453. font-weight: 400;
  454. font-size: 24rpx;
  455. line-height: 1.4;
  456. color: #8B8B8B;
  457. }
  458. &-desc {
  459. padding: 16rpx 0 16rpx 24rpx;
  460. font-family: PingFang SC;
  461. font-weight: 400;
  462. font-size: 24rpx;
  463. line-height: 1.4;
  464. color: #777777;
  465. }
  466. }
  467. }
  468. }
  469. .notice {
  470. margin-top: 40rpx;
  471. font-family: PingFang SC;
  472. font-weight: 400;
  473. &-header {
  474. font-size: 28rpx;
  475. line-height: 1.4;
  476. color: #393939;
  477. }
  478. &-content {
  479. margin-top: 24rpx;
  480. font-size: 24rpx;
  481. line-height: 1.4;
  482. color: #BABABA;
  483. }
  484. }
  485. .bottom {
  486. position: fixed;
  487. left: 0;
  488. bottom: 0;
  489. z-index: 2;
  490. width: 100vw;
  491. // height: 200rpx;
  492. padding: 24rpx 40rpx;
  493. padding-bottom: calc(env(safe-area-inset-bottom) + 24rpx);
  494. background: #FFFFFF;
  495. box-sizing: border-box;
  496. align-items: flex-start;
  497. .bar {
  498. width: 100%;
  499. column-gap: 32rpx;
  500. }
  501. .btn {
  502. background: transparent;
  503. border: none;
  504. &-service {
  505. flex: none;
  506. row-gap: 4rpx;
  507. font-family: PingFang SC;
  508. font-weight: 400;
  509. font-size: 22rpx;
  510. line-height: 1.1;
  511. color: #999999;
  512. &-icon {
  513. width: 52rpx;
  514. height: auto;
  515. }
  516. }
  517. }
  518. .cols {
  519. flex: 1;
  520. column-gap: 32rpx;
  521. .col {
  522. flex: 1;
  523. }
  524. .btn {
  525. padding: 14rpx 0;
  526. box-sizing: border-box;
  527. font-family: PingFang SC;
  528. font-weight: 500;
  529. font-size: 36rpx;
  530. line-height: 1.4;
  531. color: #252545;
  532. border: 2rpx solid #252545;
  533. border-radius: 41rpx;
  534. &-primary {
  535. padding: 16rpx 0;
  536. color: #FFFFFF;
  537. background-image: linear-gradient(to right, #4B348F, #845CFA);
  538. border: none;
  539. }
  540. }
  541. .price {
  542. column-gap: 8rpx;
  543. font-family: PingFang SC;
  544. font-weight: 400;
  545. font-size: 24rpx;
  546. line-height: 1.4;
  547. &-label {
  548. color: #626262;
  549. }
  550. &-unit,
  551. &-value {
  552. font-weight: 500;
  553. color: #7451DE;
  554. .highlight {
  555. font-size: 40rpx;
  556. }
  557. }
  558. &-value {
  559. font-size: 40rpx;
  560. }
  561. }
  562. }
  563. }
  564. </style>