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

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