普兆健康管家前端代码仓库
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.

217 lines
4.1 KiB

2 months ago
  1. <template>
  2. <view class="flex card">
  3. <view>
  4. <uv-checkbox-group
  5. v-model="checkboxValue"
  6. shape="circle"
  7. @change="onChange"
  8. >
  9. <uv-checkbox
  10. size="36rpx"
  11. icon-size="36rpx"
  12. activeColor="#7451DE"
  13. :name="1"
  14. ></uv-checkbox>
  15. </uv-checkbox-group>
  16. </view>
  17. <view class="img-box">
  18. <image class="img" :src="coverImg" mode="aspectFit"></image>
  19. </view>
  20. <view class="info">
  21. <view class="title">{{ data.name }}</view>
  22. <!-- <view class="desc">{{ data.desc }}</view> -->
  23. <view class="flex price-box">
  24. <view class="flex price">
  25. <text>¥</text>
  26. <text class="highlight">{{ data.currentPrice }}</text>
  27. <text>{{ `/${data.unit}` }}</text>
  28. </view>
  29. <view class="price-origin">
  30. {{ `¥${data.originalPrice}/${data.unit}` }}
  31. </view>
  32. </view>
  33. <view class="flex tool">
  34. <view class="flex count">规格<text class="highlight">{{ data.specName || '' }}</text></view>
  35. <button class="flex btn" @click="jumpToProductDetail">详情</button>
  36. </view>
  37. </view>
  38. <view v-if="data.customized" class="sup customized">
  39. 定制组合
  40. </view>
  41. <view v-else-if="data.free" class="sup free">
  42. 自定组合
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. props: {
  49. data: {
  50. type: Object,
  51. default() {
  52. return {}
  53. }
  54. },
  55. },
  56. data() {
  57. return {
  58. checkboxValue : []
  59. }
  60. },
  61. computed: {
  62. checked: {
  63. set(val) {
  64. this.checkboxValue = val ? [1] : []
  65. if (this.data.selected == val) {
  66. return
  67. }
  68. this.$emit('select', val)
  69. },
  70. get() {
  71. return this.checkboxValue[0] == 1 ? true : false
  72. }
  73. },
  74. coverImg() {
  75. const { image } = this.data
  76. return image?.split(',')?.[0] || ''
  77. },
  78. },
  79. watch: {
  80. data: {
  81. handler(val) {
  82. this.checked = val.selected
  83. },
  84. immediate: true,
  85. deep: true,
  86. }
  87. },
  88. methods: {
  89. onChange(arr) {
  90. this.checked = arr[0] == 1 ? true : false
  91. },
  92. jumpToProductDetail() {
  93. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${this.data.id}`)
  94. },
  95. },
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .card {
  100. position: relative;
  101. height: 272rpx;
  102. padding: 0 32rpx;
  103. background-image: linear-gradient(#FAFAFF, #F3F3F3);
  104. border: 2rpx solid #FFFFFF;
  105. border-radius: 32rpx;
  106. box-sizing: border-box;
  107. column-gap: 24rpx;
  108. overflow: hidden;
  109. /deep/ .uv-checkbox__label-wra {
  110. padding: 0;
  111. }
  112. }
  113. .img {
  114. &-box {
  115. width: 144rpx;
  116. height: 144rpx;
  117. border-radius: 16rpx;
  118. overflow: hidden;
  119. }
  120. width: 100%;
  121. height: 100%;
  122. }
  123. .info {
  124. flex: 1;
  125. font-family: PingFang SC;
  126. font-weight: 400;
  127. line-height: 1.4;
  128. font-size: 26rpx;
  129. color: #8B8B8B;
  130. .title {
  131. font-weight: 600;
  132. font-size: 28rpx;
  133. color: #000000;
  134. }
  135. .desc {
  136. margin-top: 8rpx;
  137. line-height: 1.5;
  138. }
  139. .price {
  140. &-box {
  141. margin-top: 8rpx;
  142. justify-content: flex-start;
  143. column-gap: 20rpx;
  144. }
  145. font-weight: 600;
  146. font-size: 24rpx;
  147. color: #7451DE;
  148. .highlight {
  149. margin: 0 8rpx;
  150. font-size: 32rpx;
  151. }
  152. &-origin {
  153. font-size: 28rpx;
  154. line-height: 1;
  155. text-decoration: line-through;
  156. }
  157. }
  158. .tool {
  159. margin-top: 8rpx;
  160. justify-content: space-between;
  161. .count {
  162. .highlight {
  163. margin-left: 8rpx;
  164. color: #252545;
  165. }
  166. }
  167. .btn {
  168. padding: 8rpx 22rpx;
  169. font-size: 28rpx;
  170. white-space: nowrap;
  171. color: #252545;
  172. border: 2rpx solid #252545;
  173. border-radius: 30rpx;
  174. }
  175. }
  176. }
  177. .sup {
  178. position: absolute;
  179. top: 28rpx;
  180. right: -60rpx;
  181. padding: 5rpx 52rpx;
  182. font-family: PingFang SC;
  183. font-weight: 400;
  184. font-size: 28rpx;
  185. line-height: 1.5;
  186. white-space: nowrap;
  187. transform: rotate(45deg);
  188. &.customized {
  189. color: #FFFFFF;
  190. background: #252545;
  191. }
  192. &.free {
  193. color: #252545;
  194. background: #D7D7FF;
  195. }
  196. }
  197. </style>