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

218 lines
4.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="card flex product" :class="[direction]" @click="$emit('click')">
  3. <view class="img" :class="[ data.isRecommend ? 'is-recommend' : '']">
  4. <image :src="data.imgUrl" mode="aspectFill"></image>
  5. <image v-if="data.isRecommend" class="mark" src="@/static/image/home/mark-recommend.png"></image>
  6. </view>
  7. <view class="flex right">
  8. <view class="flex flex-column info">
  9. <view class="title">{{ data.title }}</view>
  10. <view>{{ data.desc }}</view>
  11. <view class="flex price" :class="[role]">
  12. <view>
  13. <text class="price-unit">¥</text>
  14. <text>{{ data.price }}</text>
  15. </view>
  16. <view class="flex tag" v-if="role === 'member-personal'">
  17. <image class="icon" src="@/static/image/home/icon-member-personal.png"></image>
  18. <text>个人会员价</text>
  19. </view>
  20. <view class="flex tag" v-else-if="role === 'member-business'">
  21. <image class="icon" src="@/static/image/home/icon-member-business.png"></image>
  22. <text>企业会员价</text>
  23. </view>
  24. </view>
  25. <view class="flex sales">
  26. <image class="icon" src="@/static/image/home/icon-sales.png"></image>
  27. <text>{{ `已售出 ${data.sales}` }}</text>
  28. </view>
  29. </view>
  30. <button plain class="btn" @click="goToPlaceOrder(data.id)">立即下单</button>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. const TEST_DATA = {
  36. imgUrl: '../../static/image/home/temp-product.png',
  37. title: '60分钟肩颈推拿按摩',
  38. desc: '疏通经络 放松肌肉',
  39. price: 264,
  40. sales: 235,
  41. isRecommend: true,
  42. }
  43. export default {
  44. props: {
  45. data: {
  46. type: Object,
  47. default() {
  48. // todo: delete
  49. return TEST_DATA
  50. }
  51. },
  52. direction: {
  53. type: String,
  54. default: 'horizontal' // horizontal | vertical
  55. }
  56. },
  57. data() {
  58. return {
  59. role: 'member-business', // member-personal | member-business
  60. }
  61. },
  62. methods: {
  63. goToPlaceOrder(id) {
  64. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${id}`)
  65. }
  66. },
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. .product {
  71. margin-top: 20rpx;
  72. background-color: $uni-fg-color;
  73. color: #999999;
  74. font-size: 22rpx;
  75. .img {
  76. width: 164rpx;
  77. height: 164rpx;
  78. box-sizing: border-box;
  79. position: relative;
  80. image {
  81. width: 100%;
  82. height: 100%;
  83. }
  84. &.is-recommend {
  85. border: 3rpx solid $uni-color-light;
  86. .mark {
  87. position: absolute;
  88. top: 0;
  89. left: 0;
  90. width: 68rpx;
  91. height: 68rpx;
  92. }
  93. }
  94. }
  95. .info {
  96. flex: 1;
  97. align-items: flex-start;
  98. }
  99. .title {
  100. color: #000000;
  101. font-size: 28rpx;
  102. font-weight: 700;
  103. margin-bottom: 7rpx;
  104. }
  105. .price {
  106. color: #FF2A2A;
  107. font-size: 30rpx;
  108. margin-top: 7rpx;
  109. align-items: flex-start;
  110. &-unit {
  111. font-size: 18rpx;
  112. margin-right: 3rpx;
  113. }
  114. .tag {
  115. font-size: 18rpx;
  116. font-weight: 700;
  117. padding: 9rpx 12rpx 9rpx 19rpx;
  118. margin-left: 4rpx;
  119. .icon {
  120. width: 27rpx;
  121. height: 19rpx;
  122. margin-right: 3rpx;
  123. }
  124. }
  125. &.member-personal {
  126. color: $uni-color-light;
  127. .tag {
  128. background-color: rgba($color: #D8FF8F, $alpha: 0.72);
  129. }
  130. }
  131. &.member-business {
  132. color: #FFB465;
  133. .tag {
  134. background-color: rgba($color: #FFFBC4, $alpha: 0.72);
  135. }
  136. }
  137. }
  138. .sales {
  139. justify-content: flex-start;
  140. margin-top: 8rpx;
  141. .icon {
  142. width: 19rpx;
  143. height: 23rpx;
  144. margin-right: 4rpx;
  145. }
  146. }
  147. .btn {
  148. display: inline-block;
  149. margin: 0;
  150. border: none !important;
  151. background-color: $uni-color-light;
  152. color: $uni-text-color-inverse;
  153. font-size: 22rpx;
  154. line-height: 1;
  155. padding: 14rpx 28rpx;
  156. box-sizing: border-box;
  157. width: auto;
  158. height: auto;
  159. border-radius: 29rpx;
  160. }
  161. .right {
  162. flex: 1;
  163. padding-left: 14rpx;
  164. }
  165. &.vertical {
  166. padding: 23rpx 22rpx;
  167. .right {
  168. flex-direction: column;
  169. align-items: flex-start;
  170. padding-left: 23rpx;
  171. }
  172. .img {
  173. width: 215rpx;
  174. height: 215rpx;
  175. border-radius: 15rpx;
  176. overflow: hidden;
  177. }
  178. .price {
  179. .tag {
  180. margin-left: 15rpx;
  181. }
  182. }
  183. .btn {
  184. margin-top: 4rpx;
  185. background-image: linear-gradient(#84A73F, #D8FF8F);
  186. padding: 12rpx 28rpx;
  187. border-radius: 10rpx;
  188. }
  189. }
  190. }
  191. </style>