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

269 lines
5.2 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
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="[ isRecommend ? 'is-recommend' : '']">
  4. <image :src="data.image" mode="aspectFill"></image>
  5. <image v-if="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. <!-- todo: check -->
  11. <view class="text-ellipsis">{{ getDesc(data.details) }}</view>
  12. <view class="flex price" :class="[role]">
  13. <view>
  14. <text class="price-unit">¥</text>
  15. <text>{{ data.price }}</text>
  16. </view>
  17. <view class="flex tag" v-if="role === 'member-personal'">
  18. <image class="icon" src="@/static/image/home/icon-member-personal.png"></image>
  19. <text>个人会员价</text>
  20. </view>
  21. <view class="flex tag" v-else-if="role === 'member-business'">
  22. <image class="icon" src="@/static/image/home/icon-member-business.png"></image>
  23. <text>企业会员价</text>
  24. </view>
  25. </view>
  26. <view class="flex sales">
  27. <image class="icon" src="@/static/image/home/icon-sales.png"></image>
  28. <text>{{ `已售出 ${data.sales}` }}</text>
  29. </view>
  30. </view>
  31. <template v-if="!readonly">
  32. <button plain class="btn" @click="goToPlaceOrder(data.id)">立即下单</button>
  33. </template>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { mapGetters } from 'vuex'
  39. export default {
  40. props: {
  41. data: {
  42. type: Object,
  43. default() {
  44. return {}
  45. }
  46. },
  47. direction: {
  48. type: String,
  49. default: 'horizontal' // horizontal | vertical
  50. },
  51. size: {
  52. type: String,
  53. default: 'small' // small | medium
  54. },
  55. readonly: {
  56. type: Boolean,
  57. default: false,
  58. },
  59. },
  60. data() {
  61. return {
  62. }
  63. },
  64. computed: {
  65. ...mapGetters(['role']),
  66. isRecommend() {
  67. return this.data.isHot === '1'
  68. }
  69. },
  70. methods: {
  71. goToPlaceOrder(id) {
  72. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${id}`)
  73. },
  74. getDesc(str) {
  75. if (!str) {
  76. return ''
  77. }
  78. return str.replace(/<.*?>/g, '')
  79. },
  80. },
  81. }
  82. </script>
  83. <style scoped lang="scss">
  84. .product {
  85. margin-top: 20rpx;
  86. background-color: $uni-fg-color;
  87. color: #999999;
  88. font-size: 22rpx;
  89. box-sizing: border-box;
  90. .img {
  91. width: 164rpx;
  92. height: 164rpx;
  93. box-sizing: border-box;
  94. position: relative;
  95. image {
  96. width: 100%;
  97. height: 100%;
  98. }
  99. &.is-recommend {
  100. border: 3rpx solid $uni-color-light;
  101. .mark {
  102. position: absolute;
  103. top: 0;
  104. left: 0;
  105. width: 68rpx;
  106. height: 68rpx;
  107. }
  108. }
  109. }
  110. .info {
  111. flex: 1;
  112. display: inline-flex;
  113. align-items: flex-start;
  114. box-sizing: border-box;
  115. }
  116. .title {
  117. color: #000000;
  118. font-size: 28rpx;
  119. font-weight: 700;
  120. margin-bottom: 7rpx;
  121. }
  122. .price {
  123. color: #FF2A2A;
  124. font-size: 30rpx;
  125. margin-top: 7rpx;
  126. align-items: flex-start;
  127. &-unit {
  128. font-size: 18rpx;
  129. margin-right: 3rpx;
  130. }
  131. .tag {
  132. font-size: 18rpx;
  133. font-weight: 700;
  134. padding: 9rpx 12rpx 9rpx 19rpx;
  135. margin-left: 4rpx;
  136. .icon {
  137. width: 27rpx;
  138. height: 19rpx;
  139. margin-right: 3rpx;
  140. }
  141. }
  142. &.member-personal {
  143. color: $uni-color-light;
  144. .tag {
  145. background-color: rgba($color: #D8FF8F, $alpha: 0.72);
  146. }
  147. }
  148. &.member-business {
  149. color: #FFB465;
  150. .tag {
  151. background-color: rgba($color: #FFFBC4, $alpha: 0.72);
  152. }
  153. }
  154. }
  155. .sales {
  156. justify-content: flex-start;
  157. margin-top: 8rpx;
  158. .icon {
  159. width: 19rpx;
  160. height: 23rpx;
  161. margin-right: 4rpx;
  162. }
  163. }
  164. .btn {
  165. white-space: nowrap;
  166. display: inline-block;
  167. margin: 0 0 0 10rpx;
  168. border: none !important;
  169. background-color: $uni-color-light;
  170. color: $uni-text-color-inverse;
  171. font-size: 22rpx;
  172. line-height: 1;
  173. padding: 14rpx 28rpx;
  174. box-sizing: border-box;
  175. width: auto;
  176. height: auto;
  177. border-radius: 29rpx;
  178. }
  179. .right {
  180. flex: 1;
  181. padding-left: 14rpx;
  182. }
  183. &.vertical {
  184. padding: 23rpx 22rpx;
  185. .right {
  186. width: calc(100% - 212rpx);
  187. flex-direction: column;
  188. align-items: flex-start;
  189. padding-left: 23rpx;
  190. .text-ellipsis {
  191. width: 100%;
  192. }
  193. }
  194. .info {
  195. width: 100%;
  196. }
  197. .img {
  198. width: 212rpx;
  199. height: 212rpx;
  200. border-radius: 15rpx;
  201. overflow: hidden;
  202. }
  203. .price {
  204. .tag {
  205. margin-left: 15rpx;
  206. }
  207. }
  208. .btn {
  209. margin-top: 4rpx;
  210. background-image: linear-gradient(#84A73F, #D8FF8F);
  211. padding: 12rpx 28rpx;
  212. border-radius: 10rpx;
  213. }
  214. }
  215. &.medium {
  216. padding: 27rpx 25rpx;
  217. width: 100%;
  218. box-sizing: border-box;
  219. .img {
  220. width: 184rpx;
  221. height: 184rpx;
  222. }
  223. .title {
  224. margin-bottom: 14rpx;
  225. }
  226. .price {
  227. margin-top: 15rpx;
  228. }
  229. .sales {
  230. margin-top: 15rpx;
  231. }
  232. }
  233. }
  234. </style>