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

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