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

229 lines
4.2 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="data.url" mode="aspectFit"></image>
  20. </view>
  21. <view class="info">
  22. <view class="title">{{ data.name }}</view>
  23. <view class="flex price-box">
  24. <view class="flex price">¥<text class="highlight">{{ data.price.toFixed(2) }}</text></view>
  25. </view>
  26. <view class="flex tool">
  27. <view class="flex count">
  28. 规格<text class="highlight">{{ data.countDesc || data.count }}</text>
  29. </view>
  30. <view class="flex status">{{ 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. statusDesc() {
  83. return STATUS_AND_DESC_MAPPING[this.data.status]
  84. },
  85. },
  86. watch: {
  87. data: {
  88. handler(val) {
  89. this.checked = val.selected
  90. },
  91. immediate: true,
  92. deep: true,
  93. }
  94. },
  95. methods: {
  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. }
  186. }
  187. .sup {
  188. position: absolute;
  189. top: 28rpx;
  190. right: -60rpx;
  191. padding: 5rpx 52rpx;
  192. font-family: PingFang SC;
  193. font-weight: 400;
  194. font-size: 28rpx;
  195. line-height: 1.5;
  196. white-space: nowrap;
  197. transform: rotate(45deg);
  198. &.customized {
  199. color: #FFFFFF;
  200. background: #252545;
  201. }
  202. &.free {
  203. color: #252545;
  204. background: #D7D7FF;
  205. }
  206. }
  207. </style>