普兆健康管家前端代码仓库
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.

326 lines
7.6 KiB

  1. <template>
  2. <view class="card" @click="jumpToProductDetail">
  3. <view class="flex top">
  4. <view class="title">{{ data.title }}</view>
  5. <view :class="['flex', 'status', `status-${flag}`]">{{ flagDesc }}</view>
  6. </view>
  7. <view class="flex main">
  8. <image class="img" :src="coverImg" mode="scaleToFill"></image>
  9. <view class="info">
  10. <view class="flex row">
  11. <view class="row-label">客户姓名</view>
  12. <view class="row-content">{{ data.name }}</view>
  13. </view>
  14. <template v-if="data.status == 0">
  15. <view class="flex row">
  16. <view class="row-label">下单时间</view>
  17. <view class="row-content">{{ data.createTime }}</view>
  18. </view>
  19. </template>
  20. <template v-else>
  21. <view class="flex row">
  22. <view class="row-label">检测类型</view>
  23. <view class="row-content">{{ subscribeTypeDesc }}</view>
  24. </view>
  25. <view class="flex row">
  26. <view class="row-label">预约时间</view>
  27. <view class="row-content">{{ timeDesc }}</view>
  28. </view>
  29. </template>
  30. <view class="flex row">
  31. <view class="row-label">联系电话</view>
  32. <view class="row-content">{{ data.phone }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="flex bottom">
  37. <view class="flex price">
  38. <text class="price-label">总价格</text>
  39. <text class="price-unit">¥</text><text class="price-value">{{ data.price }}</text>
  40. </view>
  41. <view class="flex btns">
  42. <!-- 待预约 -->
  43. <template v-if="data.status == '0'">
  44. <button class="btn" @click.stop="onBook">检测预约</button>
  45. </template>
  46. <!-- 待检测 -->
  47. <template v-else-if="data.status == '1'">
  48. <!-- 自采 -->
  49. <template v-if="data.subscribeType == '0'">
  50. <button class="btn" @click.stop="onSendBackOnline">线上回寄试剂盒</button>
  51. </template>
  52. </template>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. // 状态 0待预约 1待检测 2已完成 3已取消
  59. const STATUS_AND_DESC_MAPPING = {
  60. 0: '待预约',
  61. 1: '待检测',
  62. 2: '已完成',
  63. 3: '已取消',
  64. // todo: check 预约失败
  65. // 0: '待预约',
  66. // 1: '自采',
  67. // 2: '上门',
  68. // 3: '到店',
  69. // 4: '已完成',
  70. // 5: '已取消',
  71. // 6: '预约失败',
  72. }
  73. const FLAG_AND_DESC_MAPPING = {
  74. 0: '待预约',
  75. 1: '自采',
  76. 2: '上门',
  77. 3: '到店',
  78. 4: '已完成',
  79. 5: '已取消',
  80. 6: '预约失败',
  81. }
  82. // 可选预约类型 0自采,1上门,2到店,3已取消
  83. const SUBSCRIBE_TYPE_AND_DESC_MAPPING = {
  84. 0: '自采',
  85. 1: '上门',
  86. 2: '到店',
  87. 3: '已取消',
  88. }
  89. export default {
  90. props: {
  91. data: {
  92. type: Object,
  93. default() {
  94. return {}
  95. }
  96. }
  97. },
  98. computed: {
  99. coverImg() {
  100. const { orderProduct } = this.data || {}
  101. const { image } = orderProduct || {}
  102. return image?.split?.(',')?.[0]
  103. },
  104. subscribeTypeDesc() {
  105. const { subscribeType } = this.data
  106. return SUBSCRIBE_TYPE_AND_DESC_MAPPING[subscribeType]
  107. },
  108. flag() {
  109. const { status, subscribeType } = this.data
  110. // 0: '待预约',
  111. // 1: '自采',
  112. // 2: '上门',
  113. // 3: '到店',
  114. // 4: '已完成',
  115. // 5: '已取消',
  116. // todo: check 预约失败
  117. // 6: '预约失败',
  118. // status 状态 0待预约 1待检测 2已完成 3已取消
  119. if (status == '0') { // 待预约
  120. return 0 // 待预约
  121. }
  122. if (status == '1') { // 待检测
  123. // subscribeType 可选预约类型 0自采,1上门,2到店,3已取消
  124. if (subscribeType == '0') {
  125. return 1 // 自采
  126. } else if (subscribeType == '1') {
  127. return 2 // 上门
  128. } else if (subscribeType == '2') {
  129. return 3 // 到店
  130. }
  131. return
  132. }
  133. if (status == '2') { // 已完成
  134. return 4 // 已完成
  135. }
  136. if (status == '3') { // 已取消
  137. return 5 // 已取消
  138. }
  139. },
  140. flagDesc() {
  141. return FLAG_AND_DESC_MAPPING[this.flag]
  142. },
  143. timeDesc() {
  144. const { subscribeDate, subscribeTime } = this.data || {}
  145. if (!subscribeTime) {
  146. return '--'
  147. }
  148. const timeRange = JSON.parse(subscribeTime).join('~')
  149. return `${subscribeDate} ${timeRange}`
  150. },
  151. },
  152. methods: {
  153. onBook() {
  154. this.$utils.navigateTo(`/pages_order/checkup/checkupBook/apply?id=${this.data.id}&type=${this.data.type}`)
  155. },
  156. onSendBackOnline() {
  157. this.$emit('sendBack')
  158. },
  159. jumpToProductDetail() {
  160. console.log(this.data.id, 'jumpToProductDetail')
  161. // this.$utils.navigateTo(`/pages_order/checkup/checkupBook/detail?id=${this.data.id}`)
  162. // todo: check
  163. if (this.data.status == '0') { // 0-待预约
  164. // this.$utils.navigateTo(`/pages_order/order/orderDetail/index?id=${this.data.id}`)
  165. } else {
  166. this.$utils.navigateTo(`/pages_order/checkup/checkupBook/detail?id=${this.data.id}`)
  167. }
  168. },
  169. },
  170. }
  171. </script>
  172. <style scoped lang="scss">
  173. .card {
  174. width: 100%;
  175. padding: 32rpx;
  176. box-sizing: border-box;
  177. background: #FAFAFF;
  178. border: 2rpx solid #FFFFFF;
  179. border-radius: 32rpx;
  180. }
  181. .top {
  182. justify-content: space-between;
  183. .title {
  184. font-family: PingFang SC;
  185. font-weight: 500;
  186. font-size: 36rpx;
  187. line-height: 1.4;
  188. color: #252545;
  189. }
  190. .status {
  191. display: inline-flex;
  192. min-width: 120rpx;
  193. padding: 6rpx 0;
  194. box-sizing: border-box;
  195. font-family: PingFang SC;
  196. font-weight: 400;
  197. font-size: 24rpx;
  198. line-height: 1.4;
  199. color: #252545;
  200. background: #F3F3F3;
  201. border-radius: 12rpx;
  202. &-0 {
  203. color: #7D27E0;
  204. background: #F5EEFD;
  205. }
  206. &-1 {
  207. color: #2799E0;
  208. background: #EEF7FD;
  209. }
  210. &-2 {
  211. color: #E53C29;
  212. background: #FDE7E5;
  213. }
  214. &-3 {
  215. color: #10A934;
  216. background: #E2FDE9;
  217. }
  218. }
  219. }
  220. .main {
  221. margin: 24rpx 0;
  222. column-gap: 24rpx;
  223. .img {
  224. flex: none;
  225. width: 120rpx;
  226. height: 120rpx;
  227. }
  228. .info {
  229. flex: 1;
  230. padding: 24rpx;
  231. background: #FFFFFF;
  232. border-radius: 32rpx;
  233. }
  234. .row {
  235. align-items: flex-start;
  236. justify-content: flex-start;
  237. column-gap: 4rpx;
  238. font-family: PingFang SC;
  239. font-weight: 400;
  240. font-size: 28rpx;
  241. line-height: 1.4;
  242. &-label {
  243. flex: none;
  244. color: #8B8B8B;
  245. }
  246. &-content {
  247. color: #393939;
  248. }
  249. }
  250. .row + .row {
  251. margin-top: 16rpx;
  252. }
  253. }
  254. .bottom {
  255. justify-content: space-between;
  256. .price {
  257. column-gap: 8rpx;
  258. font-family: PingFang SC;
  259. font-weight: 500;
  260. line-height: 1.4;
  261. &-label {
  262. font-weight: 400;
  263. font-size: 26rpx;
  264. color: #8B8B8B;
  265. }
  266. &-unit {
  267. font-size: 24rpx;
  268. color: #7451DE;
  269. }
  270. &-value {
  271. font-size: 32rpx;
  272. color: #7451DE;
  273. }
  274. }
  275. .btns {
  276. flex: 1;
  277. justify-content: flex-end;
  278. column-gap: 16rpx;
  279. }
  280. .btn {
  281. padding: 10rpx 22rpx;
  282. font-family: PingFang SC;
  283. font-weight: 400;
  284. font-size: 28rpx;
  285. line-height: 1.4;
  286. color: #393939;
  287. border: 2rpx solid #252545;
  288. border-radius: 32rpx;
  289. }
  290. }
  291. </style>