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

178 lines
3.7 KiB

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