s-coupon-select.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <su-popup
  3. :show="show"
  4. type="bottom"
  5. round="20"
  6. @close="emits('close')"
  7. showClose
  8. backgroundColor="#f2f2f2"
  9. >
  10. <view class="model-box">
  11. <view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠券</view>
  12. <scroll-view
  13. class="model-content"
  14. scroll-y
  15. :scroll-with-animation="false"
  16. :enable-back-to-top="true"
  17. >
  18. <view class="subtitle ss-m-l-20">可使用优惠券</view>
  19. <view v-for="(item, index) in state.couponInfo.can_use" :key="index">
  20. <s-coupon-list :data="item" type="user" :disabled="false">
  21. <template #default>
  22. <radio-group @change="radioChange(item.id)" class="ss-flex ss-col-center">
  23. <label class="radio">
  24. <radio
  25. color="var(--ui-BG-Main)"
  26. style="transform: scale(0.8)"
  27. :checked="state.couponId == item.id"
  28. />
  29. </label>
  30. </radio-group>
  31. </template>
  32. </s-coupon-list>
  33. </view>
  34. <view class="subtitle ss-m-t-40 ss-m-l-20">不可使用优惠券</view>
  35. <view v-for="item in state.couponInfo.cannot_use" :key="item.id">
  36. <s-coupon-list :data="item" type="user" :disabled="true">
  37. <template v-slot:reason>
  38. <view class="ss-flex ss-m-t-24">
  39. <view class="reason-title"> 不可用原因:</view>
  40. <view class="reason-desc">{{ item.cannot_use_msg }}</view>
  41. </view>
  42. </template>
  43. </s-coupon-list>
  44. </view>
  45. </scroll-view>
  46. </view>
  47. <view class="modal-footer ss-flex">
  48. <button class="confirm-btn ss-reset-button" @tap="onConfirm">确认</button>
  49. </view>
  50. </su-popup>
  51. </template>
  52. <script setup>
  53. import { computed, reactive } from 'vue';
  54. const props = defineProps({
  55. modelValue: {
  56. type: Object,
  57. default() {},
  58. },
  59. show: {
  60. type: Boolean,
  61. default: false,
  62. },
  63. });
  64. const emits = defineEmits(['confirm', 'close']);
  65. const state = reactive({
  66. couponInfo: computed(() => props.modelValue),
  67. couponId: 0,
  68. });
  69. function radioChange(couponId) {
  70. if (state.couponId == couponId) {
  71. state.couponId = 0;
  72. } else {
  73. state.couponId = couponId;
  74. }
  75. }
  76. const onConfirm = () => {
  77. emits('confirm', state.couponId);
  78. };
  79. </script>
  80. <style lang="scss" scoped>
  81. :deep() {
  82. .uni-checkbox-input {
  83. background-color: var(--ui-BG-Main);
  84. }
  85. }
  86. .model-box {
  87. height: 60vh;
  88. }
  89. .title {
  90. font-size: 36rpx;
  91. height: 80rpx;
  92. font-weight: bold;
  93. color: #333333;
  94. }
  95. .subtitle {
  96. font-size: 26rpx;
  97. font-weight: 500;
  98. color: #333333;
  99. }
  100. .model-content {
  101. height: 54vh;
  102. }
  103. .modal-footer {
  104. width: 100%;
  105. height: 120rpx;
  106. background: #fff;
  107. }
  108. .confirm-btn {
  109. width: 710rpx;
  110. margin-left: 20rpx;
  111. height: 80rpx;
  112. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  113. border-radius: 40rpx;
  114. color: #fff;
  115. }
  116. .reason-title {
  117. font-weight: 600;
  118. font-size: 20rpx;
  119. line-height: 26rpx;
  120. color: #ff0003;
  121. }
  122. .reason-desc {
  123. font-weight: 600;
  124. font-size: 20rpx;
  125. line-height: 26rpx;
  126. color: #434343;
  127. }
  128. </style>