s-coupon-select.vue 3.2 KB

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