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

239 lines
4.9 KiB

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