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

235 lines
4.7 KiB

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