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

346 lines
7.2 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. <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. sales: 235,
  136. title: '60分钟肩颈推拿按摩',
  137. desc: '疏通经络 放松肌肉',
  138. tags: ['专业技师', '舒适环境', '深度放松'],
  139. details: '<p>这里是商品详情..............<br/>这里是商品详情..............</p>'
  140. }
  141. return
  142. this.$api('getRiceProductDetail', {
  143. id: this.id
  144. }, res => {
  145. if (res.code == 200) {
  146. res.result.num = 1
  147. this.productDetail = res.result
  148. }
  149. })
  150. },
  151. }
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. $bar-height: 120rpx;
  156. .page {
  157. padding-bottom: $bar-height;
  158. background-color: #F3F3F3;
  159. /deep/ .nav-bar__view {
  160. background-image: linear-gradient(#84A73F, #D8FF8F);
  161. }
  162. .overview {
  163. padding: 16rpx 31rpx 18rpx 24rpx;
  164. background-color: $uni-fg-color;
  165. .sale {
  166. justify-content: space-between;
  167. color: #949494;
  168. font-size: 20rpx;
  169. .price {
  170. color: #FF2A2A;
  171. font-size: 45rpx;
  172. &-unit {
  173. font-size: 30rpx;
  174. margin-right: 3rpx;
  175. }
  176. .tag {
  177. font-size: 18rpx;
  178. font-weight: 700;
  179. padding: 9rpx 12rpx 9rpx 19rpx;
  180. margin-left: 15rpx;
  181. .icon {
  182. width: 27rpx;
  183. height: 19rpx;
  184. margin-right: 3rpx;
  185. }
  186. }
  187. &.member-personal {
  188. color: $uni-color-light;
  189. .tag {
  190. background-color: rgba($color: #D8FF8F, $alpha: 0.72);
  191. }
  192. }
  193. &.member-business {
  194. color: #FFB465;
  195. .tag {
  196. background-color: rgba($color: #FFFBC4, $alpha: 0.72);
  197. }
  198. }
  199. }
  200. }
  201. .title {
  202. color: #3A3A3A;
  203. font-size: 28rpx;
  204. font-weight: 700;
  205. margin-top: 15rpx;
  206. }
  207. .desc {
  208. justify-content: space-between;
  209. margin-top: 20rpx;
  210. .tag {
  211. color: #949494;
  212. font-size: 22rpx;
  213. .dot {
  214. width: 8rpx;
  215. height: 8rpx;
  216. border-radius: 50%;
  217. background-color: #949494;
  218. margin-right: 16rpx;
  219. }
  220. }
  221. }
  222. }
  223. .detail {
  224. margin-top: 12rpx;
  225. padding: 18rpx 28rpx;
  226. background-color: $uni-fg-color;
  227. .header {
  228. position: relative;
  229. margin-bottom: 25rpx;
  230. .underline {
  231. margin-top: 26rpx;
  232. margin-left: 30rpx;
  233. width: 146rpx;
  234. height: 8rpx;
  235. border-radius: 4rpx;
  236. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  237. }
  238. .title {
  239. color: #000000;
  240. font-size: 28rpx;
  241. font-weight: 700;
  242. position: absolute;
  243. top: 0;
  244. }
  245. }
  246. }
  247. .bar {
  248. position: fixed;
  249. bottom: 0;
  250. left: 0;
  251. width: 100vw;
  252. height: $bar-height;
  253. padding: 20rpx 27rpx 20rpx 58rpx;
  254. box-sizing: border-box;
  255. .count {
  256. flex: 1;
  257. color: #000000;
  258. font-size: 28rpx;
  259. margin-left: 29rpx;
  260. padding-left: 40rpx;
  261. border-left: 1rpx solid #B3997E;
  262. justify-content: flex-start;
  263. .price {
  264. color: #FF2A2A;
  265. font-size: 30rpx;
  266. &-unit {
  267. font-size: 18rpx;
  268. }
  269. }
  270. }
  271. .btn {
  272. border: none;
  273. line-height: 1;
  274. background-color: transparent;
  275. padding: 0;
  276. width: auto;
  277. height: auto;
  278. margin: 0;
  279. &-share {
  280. color: #000000;
  281. font-size: 22rpx;
  282. &-icon {
  283. width: 48rpx;
  284. height: 50rpx;
  285. margin-bottom: 11rpx;
  286. }
  287. }
  288. &-pay {
  289. padding: 24rpx 137rpx;
  290. color: $uni-text-color-inverse;
  291. font-size: 28rpx;
  292. border-radius: 44rpx;
  293. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  294. }
  295. }
  296. }
  297. }
  298. </style>