推拿小程序前端代码仓库
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.

303 lines
5.9 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="商品详情" leftClick @leftClick="$utils.navigateBack" color="#fff" />
  5. <uv-swiper :list="bannerList" indicator indicatorMode="dot" height="475rpx"></uv-swiper>
  6. <view class="overview">
  7. <view class="flex sale">
  8. <view class="flex price" :class="[role]">
  9. <view>
  10. <text class="price-unit"></text>
  11. <text>{{ productDetail.price }}</text>
  12. </view>
  13. <view class="flex tag" v-if="role === 'member-personal'">
  14. <image class="icon" src="@/static/image/home/icon-member-personal.png"></image>
  15. <text>个人会员价</text>
  16. </view>
  17. <view class="flex tag" v-else-if="role === 'member-business'">
  18. <image class="icon" src="@/static/image/home/icon-member-business.png"></image>
  19. <text>企业会员价</text>
  20. </view>
  21. </view>
  22. <view>
  23. <text>{{ `已售出:${productDetail.sales}` }}</text>
  24. </view>
  25. </view>
  26. <view class="title">
  27. <text>{{ productDetail.title }}</text>
  28. </view>
  29. <view class="flex desc">
  30. <view v-for="tag in tags" :key="tag" class="flex tag">
  31. <view class="dot"></view>
  32. <text>{{ tag }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 商品详情 -->
  37. <view class="detail">
  38. <view class="header">
  39. <cardTitle>商品详情</cardTitle>
  40. </view>
  41. <uv-parse :content="productDetail.details"></uv-parse>
  42. </view>
  43. <!-- 分享和购买按钮 -->
  44. <view class="flex bar">
  45. <button plain class="flex flex-column btn btn-share" open-type="share">
  46. <image class="btn-share-icon" src="../static/productDetail/icon-share.png"></image>
  47. <text>分享</text>
  48. </button>
  49. <view class="flex count">
  50. <text>合计</text>
  51. <view class="price">
  52. <text class="price-unit">¥</text>
  53. <!-- todo: check -->
  54. <text>{{ productDetail.price }}</text>
  55. </view>
  56. </view>
  57. <button plain class="btn btn-pay" @click="submit">立即支付</button>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import { mapGetters } from 'vuex'
  63. import cardTitle from '@/components/base/cardTitle.vue'
  64. export default {
  65. components: {
  66. cardTitle,
  67. },
  68. data() {
  69. return {
  70. productDetail: {
  71. image: '',
  72. details: '',
  73. },
  74. id: 0,
  75. }
  76. },
  77. computed: {
  78. ...mapGetters(['role']),
  79. // todo: check
  80. bannerList() {
  81. const { image } = this.productDetail
  82. if (!image) {
  83. return []
  84. }
  85. return Array.isArray(image) ? image : image.split(',')
  86. },
  87. tags() {
  88. const { tag } = this.productDetail
  89. return tag?.split('、') || []
  90. }
  91. },
  92. onLoad(args) {
  93. this.id = args.id
  94. this.fetchProductDetail(this.id)
  95. },
  96. onShow() {
  97. },
  98. onShareAppMessage(res) {
  99. const {
  100. title,
  101. } = this.productDetail
  102. let o = {
  103. title: title,
  104. // todo: check
  105. imageUrl: bannerList[0],
  106. query: `id=${this.productDetail.id}`,
  107. }
  108. return o
  109. },
  110. methods: {
  111. // 获取商品
  112. async fetchProductDetail(id) {
  113. try {
  114. this.productDetail = await this.$fetch('queryProductDetail', { id })
  115. } catch (err) {
  116. }
  117. },
  118. // 立即下单
  119. submit() {
  120. this.$store.commit('setPayOrderProduct', [
  121. this.productDetail
  122. ])
  123. this.$utils.navigateTo('/pages_order/order/createOrder')
  124. },
  125. }
  126. }
  127. </script>
  128. <style scoped lang="scss">
  129. $bar-height: 132rpx;
  130. .page {
  131. padding-bottom: calc(#{$bar-height} + env(safe-area-inset-bottom));
  132. background-color: #F3F3F3;
  133. /deep/ .nav-bar__view {
  134. background-image: linear-gradient(#84A73F, #D8FF8F);
  135. }
  136. .overview {
  137. padding: 16rpx 31rpx 18rpx 24rpx;
  138. background-color: $uni-fg-color;
  139. .sale {
  140. justify-content: space-between;
  141. color: #949494;
  142. font-size: 20rpx;
  143. .price {
  144. color: #FF2A2A;
  145. font-size: 45rpx;
  146. &-unit {
  147. font-size: 30rpx;
  148. margin-right: 3rpx;
  149. }
  150. .tag {
  151. font-size: 18rpx;
  152. font-weight: 700;
  153. padding: 9rpx 12rpx 9rpx 19rpx;
  154. margin-left: 15rpx;
  155. .icon {
  156. width: 27rpx;
  157. height: 19rpx;
  158. margin-right: 3rpx;
  159. }
  160. }
  161. &.member-personal {
  162. color: $uni-color-light;
  163. .tag {
  164. background-color: rgba($color: #D8FF8F, $alpha: 0.72);
  165. }
  166. }
  167. &.member-business {
  168. color: #FFB465;
  169. .tag {
  170. background-color: rgba($color: #FFFBC4, $alpha: 0.72);
  171. }
  172. }
  173. }
  174. }
  175. .title {
  176. color: #3A3A3A;
  177. font-size: 28rpx;
  178. font-weight: 700;
  179. margin-top: 15rpx;
  180. }
  181. .desc {
  182. justify-content: space-between;
  183. margin-top: 20rpx;
  184. .tag {
  185. color: #949494;
  186. font-size: 22rpx;
  187. .dot {
  188. width: 8rpx;
  189. height: 8rpx;
  190. border-radius: 50%;
  191. background-color: #949494;
  192. margin-right: 16rpx;
  193. }
  194. }
  195. }
  196. }
  197. .detail {
  198. margin-top: 12rpx;
  199. padding: 18rpx 28rpx;
  200. background-color: $uni-fg-color;
  201. .header {
  202. margin-bottom: 30rpx;
  203. }
  204. }
  205. .bar {
  206. position: fixed;
  207. bottom: 0;
  208. left: 0;
  209. width: 100vw;
  210. height: $bar-height;
  211. padding-bottom: env(safe-area-inset-bottom);
  212. background-color: $uni-fg-color;
  213. .count {
  214. flex: 1;
  215. color: #000000;
  216. font-size: 28rpx;
  217. margin-left: 29rpx;
  218. padding-left: 40rpx;
  219. border-left: 1rpx solid #B3997E;
  220. justify-content: flex-start;
  221. .price {
  222. color: #FF2A2A;
  223. font-size: 30rpx;
  224. &-unit {
  225. font-size: 18rpx;
  226. }
  227. }
  228. }
  229. .btn {
  230. border: none;
  231. line-height: 1;
  232. background-color: transparent;
  233. padding: 0;
  234. width: auto;
  235. height: auto;
  236. margin: 0;
  237. &-share {
  238. margin-left: 58rpx;
  239. color: #000000;
  240. font-size: 22rpx;
  241. &-icon {
  242. width: 48rpx;
  243. height: 50rpx;
  244. margin-bottom: 11rpx;
  245. }
  246. }
  247. &-pay {
  248. margin-right: 27rpx;
  249. padding: 24rpx 137rpx;
  250. color: $uni-text-color-inverse;
  251. font-size: 28rpx;
  252. border-radius: 44rpx;
  253. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  254. }
  255. }
  256. }
  257. }
  258. </style>