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

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