couponModel.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="card_box" :class="isWidth ? 'card_box_max' : ''">
  3. <up-collapse :border="false" :value="[]">
  4. <up-collapse-item name="1" :border="false">
  5. <template #title>
  6. <view class="collapse_title">
  7. <trans _t="优惠券" />
  8. </view>
  9. </template>
  10. <template #value>
  11. <view class="collapse_value" v-if="checkDate">
  12. -<view class="item_num">{{ symbol.symbol }}</view
  13. >{{ Moneyhtml(checkDate.money) }}
  14. </view>
  15. </template>
  16. <view class="card_box_item" v-for="(items, index) in item" :key="index">
  17. <up-checkbox-group
  18. v-model="radioValue"
  19. activeColor="var(--black)"
  20. iconPlacement="right"
  21. class="card_box_item_check"
  22. :class="!items.can_use ? 'is-disabled' : ''"
  23. @change="handleRadioChange"
  24. >
  25. <up-checkbox
  26. :name="items.id"
  27. shape="circle"
  28. :disabled="!items.can_use"
  29. >
  30. <template #label>
  31. <view class="card_box_item_left">
  32. <view class="amount"
  33. >{{ symbol.symbol }}&nbsp;{{ Moneyhtml(items.money) }}</view
  34. >
  35. <view class="title">{{ items.title }}</view>
  36. </view>
  37. </template>
  38. </up-checkbox>
  39. </up-checkbox-group>
  40. </view>
  41. <trans _t="暂无优惠券" class="none" v-if="!item.length" />
  42. </up-collapse-item>
  43. </up-collapse>
  44. </view>
  45. </template>
  46. <script setup>
  47. import { ref, computed } from "vue";
  48. import { useSystemStore } from "@/store";
  49. import { Toast, Moneyhtml } from "@/utils";
  50. const useSystem = useSystemStore();
  51. const symbol = computed(() => useSystem.getSymbol);
  52. const props = defineProps({
  53. item: {
  54. type: Array,
  55. default: () => [],
  56. },
  57. isWidth: {
  58. type: Boolean,
  59. default: false,
  60. },
  61. });
  62. const radioValue = ref([]);
  63. const checkDate = ref(null);
  64. const emit = defineEmits(["change"]);
  65. const handleRadioChange = (id) => {
  66. radioValue.value = id;
  67. checkDate.value = id ? props.item.find((item) => item.id === id[0]) : null;
  68. emit("change", radioValue.value[0], checkDate.value);
  69. };
  70. </script>
  71. <style lang="less" scoped>
  72. @import url("@/style.less");
  73. .card_box {
  74. width: calc(100% - 60rpx);
  75. border: 1rpx solid var(--borderColor);
  76. border-radius: 16rpx;
  77. box-sizing: border-box;
  78. &.card_box_max {
  79. width: 100%;
  80. }
  81. .collapse_value {
  82. color: var(--red);
  83. font-weight: 700;
  84. .size();
  85. .item_num {
  86. display: inline-block;
  87. margin-left: 8rpx;
  88. }
  89. }
  90. .card_box_item {
  91. width: 100%;
  92. margin-bottom: 22rpx;
  93. &:last-child {
  94. margin-bottom: 0;
  95. }
  96. .card_box_item_check {
  97. .hor(space-between);
  98. width: 100%;
  99. padding: 16rpx 26rpx;
  100. // background-color: var(--bg-primary);
  101. background: radial-gradient(
  102. circle at 14rpx,
  103. transparent 14rpx,
  104. var(--bg-primary) 0
  105. ) -14rpx;
  106. border-radius: 12rpx;
  107. &.is-disabled {
  108. opacity: 0.5;
  109. }
  110. ::v-deep .u-checkbox {
  111. width: 100%;
  112. }
  113. .card_box_item_left {
  114. height: 80rpx;
  115. display: flex;
  116. flex-direction: column;
  117. justify-content: space-between;
  118. .amount {
  119. .size(32rpx);
  120. color: var(--red);
  121. font-weight: 700;
  122. }
  123. .title {
  124. .size(28rpx);
  125. }
  126. }
  127. }
  128. }
  129. .none {
  130. width: 100%;
  131. color: var(--red);
  132. text-align: center;
  133. font-size: 26rpx;
  134. }
  135. }
  136. </style>