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

443 lines
12 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="商品详情页" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />
  4. <view class="main">
  5. <uv-swiper :list="bannerList" indicator indicatorMode="dot" height="680rpx" keyName="image"></uv-swiper>
  6. <view class="summary">
  7. <view class="card info">
  8. <view class="name">{{ detail.fullName }}</view>
  9. <view class="flex tags">
  10. <view class="tag" v-for="(tag, tIdx) in detail.tags" :key="tIdx">
  11. {{ tag }}
  12. </view>
  13. </view>
  14. <view class="flex price">
  15. <view class="flex price-val">¥<text class="highlight">{{ (detail.price || 0).toFixed(2) }}</text>/</view>
  16. <view class="price-bef">¥<text>{{ detail.originalPrice }}</text>/</view>
  17. </view>
  18. </view>
  19. <view class="card bar">
  20. <view class="flex row">
  21. <view class="flex row-content">
  22. <view class="label">品类</view>
  23. <view class="value">{{ detail.category }}</view>
  24. </view>
  25. </view>
  26. <view class="flex row" @click="openPicker">
  27. <view class="flex row-content">
  28. <view class="label">规格</view>
  29. <view class="value">{{ detail.countDesc || '请选择规格' }}</view>
  30. </view>
  31. <uv-picker ref="picker" :columns="[detail.options]" keyName="label" confirmColor="#7451DE" @confirm="onChange"></uv-picker>
  32. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  33. </view>
  34. <view class="flex row">
  35. <view class="flex row-content">
  36. <view class="label">服务</view>
  37. <view class="value">{{ detail.deliverService }}</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="detail">
  43. <uv-parse :content="detail.details"></uv-parse>
  44. </view>
  45. <view class="comment">
  46. <view class="header">
  47. <view class="highlight">用户评价</view>
  48. <view>User reviews</view>
  49. </view>
  50. <view class="comment-item" v-for="item in commentList" :key="item.id">
  51. <commentCard :data="item"></commentCard>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="flex bottom">
  56. <button class="flex flex-column btn btn-simple" @click="jumpToComment">
  57. <image class="icon" src="@/pages_order/static/product/comment.png" mode="widthFix"></image>
  58. <view>评价</view>
  59. </button>
  60. <button class="flex btn btn-palin">加入购物车</button>
  61. <button class="flex btn btn-primary" @click="onBuy">立即购买</button>
  62. </view>
  63. <countSelectPopup ref="countSelectPopup" :data="detail" @confirm="onSelectCount"></countSelectPopup>
  64. <agreementPopup ref="agreementPopup" @confirm="jumpToCreateOrder"></agreementPopup>
  65. </view>
  66. </template>
  67. <script>
  68. import commentCard from '@/pages_order/comment/commentCard.vue'
  69. import agreementPopup from './agreementPopup.vue'
  70. import countSelectPopup from './countSelectPopup.vue'
  71. export default {
  72. components: {
  73. commentCard,
  74. agreementPopup,
  75. countSelectPopup,
  76. },
  77. data() {
  78. return {
  79. id: null,
  80. detail: {},
  81. commentList: [],
  82. }
  83. },
  84. computed: {
  85. bannerList() {
  86. const { image } = this.detail
  87. if (!image) {
  88. return []
  89. }
  90. return Array.isArray(image) ? image : image.split(',')
  91. },
  92. },
  93. onLoad(arg) {
  94. console.log('onLoad', arg)
  95. this.id = arg.id
  96. // todo: fetch detail data
  97. this.detail = {
  98. id: '001',
  99. image: new Array(4).fill('/pages_order/static/product/product-detail.png'),
  100. name: 'NMN',
  101. fullName: 'NMN 是 NAD* 的前体,在细胞能量代谢、DNA 修复和抗衰老等方面发挥重要作用。提高 NAD*水平能改善代谢健康1-8。',
  102. tags: ['专业设备', '科学流程', '质量保证'],
  103. sales: 24770,
  104. price: 688.00,
  105. originalPrice: 1664,
  106. category: '逆龄抗衰',
  107. count: null,
  108. countDesc: null,
  109. options: [
  110. { id: '001', label: '每天1颗', count: 1, value: 688, originValue: 1664 },
  111. { id: '002', label: '每天2颗', count: 2, value: 688*2, originValue: 1664*2 },
  112. { id: '003', label: '每天3颗', count: 3, value: 688*3, originValue: 1664*3 },
  113. { id: '004', label: '每天4颗', count: 4, value: 688*4, originValue: 1664*4 },
  114. ],
  115. deliverService: '上门取件·送货上门',
  116. details: `<p>商品详情↓<br/><br/><br/><br/>商品详情↑</p>`
  117. }
  118. this.commentList = [
  119. {
  120. id: '001',
  121. userName: '战斗世界',
  122. avatar: '/pages_order/static/report/avatar.png',
  123. countDesc: '三月装',
  124. createTime: '2023-04-18',
  125. content: '包装很精致,性价比非常高,终于收到啦,期待效果,每日一包,超级方便,真的能坚持服用',
  126. images: [
  127. '/pages_order/static/index/medicine-1.png',
  128. '/pages_order/static/index/medicine-2.png',
  129. '/pages_order/static/index/medicine-3.png',
  130. ],
  131. productServeScore: 5,
  132. questionExperienceScore: 4,
  133. deliverySpeedScore: 4.5,
  134. },
  135. {
  136. id: '002',
  137. userName: '战斗世界',
  138. avatar: '/pages_order/static/report/avatar.png',
  139. countDesc: '三月装',
  140. createTime: '2023-04-18',
  141. content: '包装很精致,性价比非常高,终于收到啦,期待效果,每日一包,超级方便,真的能坚持服用',
  142. images: [
  143. '/pages_order/static/index/medicine-1.png',
  144. '/pages_order/static/index/medicine-2.png',
  145. '/pages_order/static/index/medicine-3.png',
  146. ],
  147. productServeScore: 5,
  148. questionExperienceScore: 4,
  149. deliverySpeedScore: 4.5,
  150. },
  151. {
  152. id: '003',
  153. userName: '战斗世界',
  154. avatar: '/pages_order/static/report/avatar.png',
  155. countDesc: '三月装',
  156. createTime: '2023-04-18',
  157. content: '包装很精致,性价比非常高,终于收到啦,期待效果,每日一包,超级方便,真的能坚持服用',
  158. images: [
  159. '/pages_order/static/index/medicine-1.png',
  160. '/pages_order/static/index/medicine-2.png',
  161. '/pages_order/static/index/medicine-3.png',
  162. ],
  163. productServeScore: 5,
  164. questionExperienceScore: 4,
  165. deliverySpeedScore: 4.5,
  166. },
  167. ]
  168. },
  169. methods: {
  170. openPicker() {
  171. this.$refs.picker.open();
  172. },
  173. onChange(e) {
  174. const target = e.value[0]
  175. console.log('onChange', target)
  176. this.detail.price = target.value
  177. this.detail.count = target.count
  178. this.detail.countDesc = target.label
  179. },
  180. jumpToComment() {
  181. this.$utils.navigateTo('/pages_order/comment/commentRecords')
  182. },
  183. jumpToCreateOrder() {
  184. // todo
  185. },
  186. onSelectCount(optionId) {
  187. const { options } = this.detail
  188. let target = options.find(item => item.id === optionId)
  189. this.detail.price = target.value
  190. this.detail.count = target.count
  191. this.detail.countDesc = target.label
  192. this.onBuy()
  193. },
  194. onBuy() {
  195. const { count, options } = this.detail
  196. if (!count && options?.length) {
  197. this.$refs.countSelectPopup.open()
  198. return
  199. }
  200. // todo
  201. this.$refs.agreementPopup.open()
  202. // this.jumpToCreateOrder()
  203. },
  204. },
  205. }
  206. </script>
  207. <style scoped lang="scss">
  208. .page__view {
  209. width: 100vw;
  210. min-height: 100vh;
  211. background-color: $uni-bg-color;
  212. position: relative;
  213. /deep/ .nav-bar__view {
  214. position: fixed;
  215. top: 0;
  216. left: 0;
  217. }
  218. }
  219. .main {
  220. width: 100vw;
  221. padding: calc(var(--status-bar-height) + 120rpx) 0 198rpx 0;
  222. box-sizing: border-box;
  223. }
  224. .summary {
  225. width: 100%;
  226. padding: 40rpx 32rpx;
  227. box-sizing: border-box;
  228. }
  229. .card {
  230. border-radius: 24rpx;
  231. & + & {
  232. margin-top: 40rpx;
  233. }
  234. &.info {
  235. width: 100%;
  236. padding: 32rpx;
  237. box-sizing: border-box;
  238. background: #FFFFFF;
  239. .name {
  240. font-family: PingFang SC;
  241. font-weight: 400;
  242. font-size: 32rpx;
  243. line-height: 1.4;
  244. color: #181818;
  245. }
  246. .tags {
  247. margin-top: 16rpx;
  248. justify-content: flex-start;
  249. flex-wrap: wrap;
  250. gap: 16rpx;
  251. .tag {
  252. padding: 2rpx 14rpx;
  253. font-family: PingFang SC;
  254. font-weight: 400;
  255. font-size: 24rpx;
  256. line-height: 1.4;
  257. color: #7451DE;
  258. background: #EFEAFF;
  259. border: 2rpx solid #7451DE;
  260. border-radius: 8rpx;
  261. }
  262. }
  263. .price {
  264. margin-top: 32rpx;
  265. justify-content: flex-start;
  266. column-gap: 20rpx;
  267. &-val {
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. font-size: 24rpx;
  271. line-height: 1.4;
  272. color: #7451DE;
  273. .highlight {
  274. margin: 0 8rpx;
  275. font-size: 48rpx;
  276. }
  277. }
  278. &-bef {
  279. font-family: PingFang SC;
  280. text-decoration: line-through;
  281. font-weight: 400;
  282. font-size: 28rpx;
  283. line-height: 1;
  284. color: #8B8B8B;
  285. }
  286. }
  287. }
  288. &.bar {
  289. width: 100%;
  290. padding: 20rpx 32rpx;
  291. box-sizing: border-box;
  292. background: #FAFAFF;
  293. box-shadow: -4rpx -4rpx 20rpx 0 #FFFFFFC4,
  294. 4rpx 4rpx 20rpx 0 #AAAACC1F,
  295. 2rpx 2rpx 4rpx 0 #AAAACC40,
  296. -2rpx -2rpx 4rpx 0 #FFFFFF;
  297. .row {
  298. padding: 8rpx 0;
  299. &-content {
  300. flex: 1;
  301. justify-content: flex-start;
  302. column-gap: 4rpx;
  303. font-family: PingFang SC;
  304. font-weight: 400;
  305. font-size: 28rpx;
  306. line-height: 1.4;
  307. .label {
  308. color: #8B8B8B;
  309. }
  310. .value {
  311. color: #393939;
  312. }
  313. }
  314. }
  315. .row + .row {
  316. margin-top: 24rpx;
  317. }
  318. }
  319. }
  320. .comment {
  321. padding: 40rpx 32rpx;
  322. .header {
  323. margin-bottom: 24rpx;
  324. font-family: PingFang SC;
  325. font-weight: 400;
  326. font-size: 26rpx;
  327. line-height: 1.4;
  328. color: #252545;
  329. .highlight {
  330. font-weight: 600;
  331. font-size: 48rpx;
  332. }
  333. }
  334. &-item {
  335. & + & {
  336. margin-top: 32rpx;
  337. }
  338. }
  339. }
  340. .bottom {
  341. position: fixed;
  342. left: 0;
  343. bottom: 0;
  344. align-items: flex-start;
  345. column-gap: 32rpx;
  346. width: 100vw;
  347. height: 198rpx;
  348. padding: 24rpx 40rpx 0 40rpx;
  349. background: #FFFFFF;
  350. box-sizing: border-box;
  351. .btn {
  352. font-family: PingFang SC;
  353. &-simple {
  354. font-weight: 400;
  355. font-size: 22rpx;
  356. line-height: 1.1;
  357. color: #999999;
  358. .icon {
  359. width: 52rpx;
  360. height: auto;
  361. }
  362. }
  363. &-palin {
  364. flex: 1;
  365. padding: 14rpx 0;
  366. font-weight: 500;
  367. font-size: 36rpx;
  368. line-height: 1.4;
  369. color: #252545;
  370. border: 2rpx solid #252545;
  371. border-radius: 41rpx;
  372. }
  373. &-primary {
  374. flex: 1;
  375. padding: 16rpx 0;
  376. font-weight: 500;
  377. font-size: 36rpx;
  378. line-height: 1.4;
  379. color: #FFFFFF;
  380. background-image: linear-gradient(to right, #4B348F, #845CFA);
  381. border-radius: 41rpx;
  382. }
  383. }
  384. }
  385. </style>