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

240 lines
4.4 KiB

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