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

319 lines
6.7 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 productDetail.tags" :key="tag"
  31. class="flex tag"
  32. >
  33. <view class="dot"></view>
  34. <text>{{ tag }}</text>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 商品详情 -->
  39. <view class="detail">
  40. <cardTitle class="header">商品详情</cardTitle>
  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 cardTitle from '../components/cardTitle.vue'
  63. export default {
  64. components: {
  65. cardTitle,
  66. },
  67. data() {
  68. return {
  69. productDetail: {
  70. image: '',
  71. details: '',
  72. },
  73. id: 0,
  74. role: 'member-business', // member-personal | member-business
  75. }
  76. },
  77. computed: {
  78. bannerList() {
  79. const { image } = this.productDetail
  80. if (!image) {
  81. return []
  82. }
  83. return Array.isArray(image) ? image : image.split(',')
  84. }
  85. },
  86. onLoad(args) {
  87. this.id = args.id
  88. },
  89. onShow() {
  90. this.getRiceProductDetail()
  91. },
  92. onShareAppMessage(res) {
  93. const {
  94. title,
  95. } = this.productDetail
  96. // todo: check
  97. let o = {
  98. title: title,
  99. imageUrl: bannerList[0],
  100. query: `id=${this.productDetail.id}`,
  101. }
  102. return o
  103. },
  104. methods: {
  105. // 立即下单
  106. submit() {
  107. this.$store.commit('setPayOrderProduct', [
  108. this.productDetail
  109. ])
  110. this.$utils.navigateTo('/pages_order/order/createOrder')
  111. },
  112. toSend(){
  113. this.$store.commit('setPayOrderProduct', [
  114. this.productDetail
  115. ])
  116. // this.$utils.navigateTo('/pages_order/order/receiveGift?id=1894006757315850241')
  117. this.$utils.navigateTo('/pages_order/order/createOrder?type=give')
  118. },
  119. // 获取商品
  120. getRiceProductDetail() {
  121. // todo: delete test data
  122. const TEMP_BANNER_IMG_URL = 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280'
  123. this.productDetail = {
  124. imgUrl: TEMP_BANNER_IMG_URL,
  125. image: new Array(4).fill(1).map(() => TEMP_BANNER_IMG_URL),
  126. price: 99,
  127. num: 1,
  128. sales: 235,
  129. title: '60分钟肩颈推拿按摩',
  130. desc: '疏通经络 放松肌肉',
  131. tags: ['专业技师', '舒适环境', '深度放松'],
  132. details: '<p>这里是商品详情..............<br/>这里是商品详情..............</p>'
  133. }
  134. return
  135. this.$api('getRiceProductDetail', {
  136. id: this.id
  137. }, res => {
  138. if (res.code == 200) {
  139. res.result.num = 1
  140. this.productDetail = res.result
  141. }
  142. })
  143. },
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. $bar-height: 132rpx;
  149. .page {
  150. padding-bottom: calc(#{$bar-height} + env(safe-area-inset-bottom));
  151. background-color: #F3F3F3;
  152. /deep/ .nav-bar__view {
  153. background-image: linear-gradient(#84A73F, #D8FF8F);
  154. }
  155. .overview {
  156. padding: 16rpx 31rpx 18rpx 24rpx;
  157. background-color: $uni-fg-color;
  158. .sale {
  159. justify-content: space-between;
  160. color: #949494;
  161. font-size: 20rpx;
  162. .price {
  163. color: #FF2A2A;
  164. font-size: 45rpx;
  165. &-unit {
  166. font-size: 30rpx;
  167. margin-right: 3rpx;
  168. }
  169. .tag {
  170. font-size: 18rpx;
  171. font-weight: 700;
  172. padding: 9rpx 12rpx 9rpx 19rpx;
  173. margin-left: 15rpx;
  174. .icon {
  175. width: 27rpx;
  176. height: 19rpx;
  177. margin-right: 3rpx;
  178. }
  179. }
  180. &.member-personal {
  181. color: $uni-color-light;
  182. .tag {
  183. background-color: rgba($color: #D8FF8F, $alpha: 0.72);
  184. }
  185. }
  186. &.member-business {
  187. color: #FFB465;
  188. .tag {
  189. background-color: rgba($color: #FFFBC4, $alpha: 0.72);
  190. }
  191. }
  192. }
  193. }
  194. .title {
  195. color: #3A3A3A;
  196. font-size: 28rpx;
  197. font-weight: 700;
  198. margin-top: 15rpx;
  199. }
  200. .desc {
  201. justify-content: space-between;
  202. margin-top: 20rpx;
  203. .tag {
  204. color: #949494;
  205. font-size: 22rpx;
  206. .dot {
  207. width: 8rpx;
  208. height: 8rpx;
  209. border-radius: 50%;
  210. background-color: #949494;
  211. margin-right: 16rpx;
  212. }
  213. }
  214. }
  215. }
  216. .detail {
  217. margin-top: 12rpx;
  218. padding: 18rpx 28rpx;
  219. background-color: $uni-fg-color;
  220. }
  221. .bar {
  222. position: fixed;
  223. bottom: 0;
  224. left: 0;
  225. width: 100vw;
  226. height: $bar-height;
  227. padding-bottom: env(safe-area-inset-bottom);
  228. background-color: $uni-fg-color;
  229. .count {
  230. flex: 1;
  231. color: #000000;
  232. font-size: 28rpx;
  233. margin-left: 29rpx;
  234. padding-left: 40rpx;
  235. border-left: 1rpx solid #B3997E;
  236. justify-content: flex-start;
  237. .price {
  238. color: #FF2A2A;
  239. font-size: 30rpx;
  240. &-unit {
  241. font-size: 18rpx;
  242. }
  243. }
  244. }
  245. .btn {
  246. border: none;
  247. line-height: 1;
  248. background-color: transparent;
  249. padding: 0;
  250. width: auto;
  251. height: auto;
  252. margin: 0;
  253. &-share {
  254. margin-left: 58rpx;
  255. color: #000000;
  256. font-size: 22rpx;
  257. &-icon {
  258. width: 48rpx;
  259. height: 50rpx;
  260. margin-bottom: 11rpx;
  261. }
  262. }
  263. &-pay {
  264. margin-right: 27rpx;
  265. padding: 24rpx 137rpx;
  266. color: $uni-text-color-inverse;
  267. font-size: 28rpx;
  268. border-radius: 44rpx;
  269. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  270. }
  271. }
  272. }
  273. }
  274. </style>