logistics.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="lg-wrap">
  3. <view class="lg-header">
  4. <text class="lg-title">物流进度</text>
  5. <text class="lg-sub">查看试剂盒寄送与样本回收状态</text>
  6. </view>
  7. <view class="lg-loading" v-if="loading">加载中...</view>
  8. <view class="lg-empty" v-else-if="status === 'none'">
  9. <text class="lg-empty-icon">📦</text>
  10. <text class="lg-empty-text">等待商家发货</text>
  11. <text class="lg-empty-sub">商家正在准备试剂盒,请耐心等待</text>
  12. </view>
  13. <view class="lg-timeline" v-else>
  14. <view class="lg-step" :class="{ 'lg-step-active': stepIndex >= 0 }">
  15. <view class="lg-step-dot"></view>
  16. <view class="lg-step-body">
  17. <text class="lg-step-title">试剂盒已寄出</text>
  18. <text class="lg-step-time" v-if="status === 'kit_shipped'">已发货,请留意查收</text>
  19. <text class="lg-step-tracking" v-if="trackingNo">快递单号:{{ trackingNo }}</text>
  20. </view>
  21. </view>
  22. <view class="lg-step" :class="{ 'lg-step-active': stepIndex >= 1 }">
  23. <view class="lg-step-dot"></view>
  24. <view class="lg-step-body">
  25. <text class="lg-step-title">试剂盒已收到</text>
  26. <text class="lg-step-time" v-if="status === 'kit_received'">已签收</text>
  27. </view>
  28. </view>
  29. <view class="lg-step" :class="{ 'lg-step-active': stepIndex >= 2 }">
  30. <view class="lg-step-dot"></view>
  31. <view class="lg-step-body">
  32. <text class="lg-step-title">样本已寄回</text>
  33. <text class="lg-step-time" v-if="status === 'sample_shipped'">正在返回实验室</text>
  34. </view>
  35. </view>
  36. <view class="lg-step" :class="{ 'lg-step-active': stepIndex >= 3 }">
  37. <view class="lg-step-dot"></view>
  38. <view class="lg-step-body">
  39. <text class="lg-step-title">样本已签收</text>
  40. <text class="lg-step-time" v-if="status === 'sample_received'">实验室已收到样本,等待报告生成</text>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="lg-refresh" @click="refresh">
  45. <text class="lg-refresh-text">刷新状态</text>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { getMyLogistics } from '../../utils/api.js'
  51. import { updateUserIntentStage } from '../../utils/api.js'
  52. var STATUS_ORDER = ['kit_shipped', 'kit_received', 'sample_shipped', 'sample_received']
  53. export default {
  54. data() {
  55. return {
  56. code: '',
  57. status: 'none',
  58. trackingNo: '',
  59. loading: false
  60. }
  61. },
  62. computed: {
  63. stepIndex() {
  64. var idx = STATUS_ORDER.indexOf(this.status)
  65. return idx
  66. }
  67. },
  68. onLoad(options) {
  69. this.code = (options && options.code) || ''
  70. this.loadStatus()
  71. },
  72. onShow() {
  73. this.loadStatus()
  74. },
  75. methods: {
  76. loadStatus() {
  77. var self = this
  78. self.loading = true
  79. uni.showLoading({ title: '加载中...', mask: true })
  80. getMyLogistics().then(function(res) {
  81. uni.hideLoading()
  82. self.loading = false
  83. var data = res && res.data
  84. if (data) {
  85. self.status = data.logisticsStatus || data.logistics_status || 'none'
  86. self.trackingNo = data.trackingNo || data.tracking_no || ''
  87. // 如果已签收样本,推进旅程
  88. if (self.status === 'sample_received') {
  89. updateUserIntentStage(4).then(function() {}).catch(function() {})
  90. }
  91. }
  92. }).catch(function() {
  93. uni.hideLoading()
  94. self.loading = false
  95. self.status = 'none'
  96. })
  97. },
  98. refresh() {
  99. this.loadStatus()
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. .lg-wrap {
  106. min-height: 100vh;
  107. background: #FFF7ED;
  108. padding: 40rpx 32rpx;
  109. box-sizing: border-box;
  110. }
  111. .lg-header {
  112. margin-bottom: 40rpx;
  113. }
  114. .lg-title {
  115. display: block;
  116. font-size: 38rpx;
  117. font-weight: bold;
  118. color: #333;
  119. text-align: center;
  120. }
  121. .lg-sub {
  122. display: block;
  123. font-size: 26rpx;
  124. color: #999;
  125. text-align: center;
  126. margin-top: 10rpx;
  127. }
  128. .lg-loading {
  129. text-align: center;
  130. font-size: 28rpx;
  131. color: #999;
  132. padding: 80rpx 0;
  133. }
  134. .lg-empty {
  135. text-align: center;
  136. padding: 80rpx 0;
  137. }
  138. .lg-empty-icon {
  139. font-size: 80rpx;
  140. display: block;
  141. }
  142. .lg-empty-text {
  143. display: block;
  144. font-size: 32rpx;
  145. font-weight: 600;
  146. color: #333;
  147. margin-top: 20rpx;
  148. }
  149. .lg-empty-sub {
  150. display: block;
  151. font-size: 26rpx;
  152. color: #999;
  153. margin-top: 10rpx;
  154. }
  155. .lg-timeline {
  156. padding-left: 30rpx;
  157. }
  158. .lg-step {
  159. position: relative;
  160. padding-left: 60rpx;
  161. padding-bottom: 40rpx;
  162. opacity: 0.5;
  163. }
  164. .lg-step-active {
  165. opacity: 1;
  166. }
  167. .lg-step:last-child {
  168. padding-bottom: 0;
  169. }
  170. .lg-step-dot {
  171. position: absolute;
  172. left: 0;
  173. top: 4rpx;
  174. width: 32rpx;
  175. height: 32rpx;
  176. border-radius: 50%;
  177. background: #FED7AA;
  178. z-index: 2;
  179. }
  180. .lg-step-active .lg-step-dot {
  181. background: #F97316;
  182. }
  183. .lg-step-body {
  184. background: #fff;
  185. border-radius: 20rpx;
  186. padding: 24rpx 28rpx;
  187. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  188. }
  189. .lg-step-title {
  190. display: block;
  191. font-size: 28rpx;
  192. font-weight: 600;
  193. color: #333;
  194. }
  195. .lg-step-time {
  196. display: block;
  197. font-size: 24rpx;
  198. color: #999;
  199. margin-top: 6rpx;
  200. }
  201. .lg-step-tracking {
  202. display: block;
  203. font-size: 24rpx;
  204. color: #F97316;
  205. margin-top: 6rpx;
  206. }
  207. .lg-refresh {
  208. text-align: center;
  209. margin-top: 40rpx;
  210. padding: 20rpx 0;
  211. }
  212. .lg-refresh-text {
  213. font-size: 28rpx;
  214. color: #F97316;
  215. text-decoration: underline;
  216. }
  217. </style>