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

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