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

251 lines
5.0 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
2 months ago
  1. <template>
  2. <view class="card flex product product-card__view" :class="[direction, size]" @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. size: {
  59. type: String,
  60. default: 'small' // small | medium
  61. },
  62. readonly: {
  63. type: Boolean,
  64. default: false,
  65. },
  66. },
  67. data() {
  68. return {
  69. role: 'member-business', // member-personal | member-business
  70. }
  71. },
  72. methods: {
  73. goToPlaceOrder(id) {
  74. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${id}`)
  75. }
  76. },
  77. }
  78. </script>
  79. <style scoped lang="scss">
  80. .product {
  81. margin-top: 20rpx;
  82. background-color: $uni-fg-color;
  83. color: #999999;
  84. font-size: 22rpx;
  85. .img {
  86. width: 164rpx;
  87. height: 164rpx;
  88. box-sizing: border-box;
  89. position: relative;
  90. image {
  91. width: 100%;
  92. height: 100%;
  93. }
  94. &.is-recommend {
  95. border: 3rpx solid $uni-color-light;
  96. .mark {
  97. position: absolute;
  98. top: 0;
  99. left: 0;
  100. width: 68rpx;
  101. height: 68rpx;
  102. }
  103. }
  104. }
  105. .info {
  106. flex: 1;
  107. align-items: flex-start;
  108. }
  109. .title {
  110. color: #000000;
  111. font-size: 28rpx;
  112. font-weight: 700;
  113. margin-bottom: 7rpx;
  114. }
  115. .price {
  116. color: #FF2A2A;
  117. font-size: 30rpx;
  118. margin-top: 7rpx;
  119. align-items: flex-start;
  120. &-unit {
  121. font-size: 18rpx;
  122. margin-right: 3rpx;
  123. }
  124. .tag {
  125. font-size: 18rpx;
  126. font-weight: 700;
  127. padding: 9rpx 12rpx 9rpx 19rpx;
  128. margin-left: 4rpx;
  129. .icon {
  130. width: 27rpx;
  131. height: 19rpx;
  132. margin-right: 3rpx;
  133. }
  134. }
  135. &.member-personal {
  136. color: $uni-color-light;
  137. .tag {
  138. background-color: rgba($color: #D8FF8F, $alpha: 0.72);
  139. }
  140. }
  141. &.member-business {
  142. color: #FFB465;
  143. .tag {
  144. background-color: rgba($color: #FFFBC4, $alpha: 0.72);
  145. }
  146. }
  147. }
  148. .sales {
  149. justify-content: flex-start;
  150. margin-top: 8rpx;
  151. .icon {
  152. width: 19rpx;
  153. height: 23rpx;
  154. margin-right: 4rpx;
  155. }
  156. }
  157. .btn {
  158. display: inline-block;
  159. margin: 0;
  160. border: none !important;
  161. background-color: $uni-color-light;
  162. color: $uni-text-color-inverse;
  163. font-size: 22rpx;
  164. line-height: 1;
  165. padding: 14rpx 28rpx;
  166. box-sizing: border-box;
  167. width: auto;
  168. height: auto;
  169. border-radius: 29rpx;
  170. }
  171. .right {
  172. flex: 1;
  173. padding-left: 14rpx;
  174. }
  175. &.vertical {
  176. padding: 23rpx 22rpx;
  177. .right {
  178. flex-direction: column;
  179. align-items: flex-start;
  180. padding-left: 23rpx;
  181. }
  182. .img {
  183. width: 215rpx;
  184. height: 215rpx;
  185. border-radius: 15rpx;
  186. overflow: hidden;
  187. }
  188. .price {
  189. .tag {
  190. margin-left: 15rpx;
  191. }
  192. }
  193. .btn {
  194. margin-top: 4rpx;
  195. background-image: linear-gradient(#84A73F, #D8FF8F);
  196. padding: 12rpx 28rpx;
  197. border-radius: 10rpx;
  198. }
  199. }
  200. &.medium {
  201. padding: 27rpx 25rpx;
  202. width: 100%;
  203. box-sizing: border-box;
  204. .img {
  205. width: 184rpx;
  206. height: 184rpx;
  207. }
  208. .title {
  209. margin-bottom: 14rpx;
  210. }
  211. .price {
  212. margin-top: 15rpx;
  213. }
  214. .sales {
  215. margin-top: 15rpx;
  216. }
  217. }
  218. }
  219. </style>