s-coupon-select.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!-- 订单确认的优惠劵选择弹窗 -->
  2. <template>
  3. <su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose backgroundColor="#f2f2f2">
  4. <view class="model-box">
  5. <view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠券</view>
  6. <scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
  7. <!--可使用的优惠券区域-->
  8. <view class="subtitle ss-m-l-20">可使用优惠券</view>
  9. <view v-for="(item, index) in state.couponInfo.filter(coupon => coupon.match)" :key="index">
  10. <s-coupon-list :data="item" type="user" :disabled="false">
  11. <template v-slot:reason>
  12. <view class="ss-flex ss-m-t-24">
  13. <view class="reason-title">可用原因:</view>
  14. <view class="reason-desc">{{ item.description || '已达到使用门槛' }}</view>
  15. </view>
  16. </template>
  17. <template #default>
  18. <label class="ss-flex ss-col-center" @tap="radioChange(item.id)">
  19. <radio
  20. color="var(--ui-BG-Main)"
  21. style="transform: scale(0.8)"
  22. :checked="state.couponId === item.id"
  23. @tap.stop="radioChange(item.id)"
  24. />
  25. </label>
  26. </template>
  27. </s-coupon-list>
  28. </view>
  29. <!--不可使用的优惠券区域-->
  30. <view class="subtitle ss-m-t-40 ss-m-l-20">不可使用优惠券</view>
  31. <view v-for="item in state.couponInfo.filter(coupon => !coupon.match)" :key="item.id">
  32. <s-coupon-list :data="item" type="user" :disabled="true">
  33. <template v-slot:reason>
  34. <view class="ss-flex ss-m-t-24">
  35. <view class="reason-title"> 不可用原因:</view>
  36. <view class="reason-desc">{{ item.description || '未达到使用门槛' }}</view>
  37. </view>
  38. </template>
  39. </s-coupon-list>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. <view class="modal-footer ss-flex">
  44. <button class="confirm-btn ss-reset-button" @tap="onConfirm">确认</button>
  45. </view>
  46. </su-popup>
  47. </template>
  48. <script setup>
  49. import { computed, reactive } from 'vue';
  50. const props = defineProps({
  51. modelValue: { // 优惠劵列表
  52. type: Object,
  53. default() {
  54. },
  55. },
  56. show: {
  57. type: Boolean,
  58. default: false,
  59. },
  60. });
  61. const emits = defineEmits(['confirm', 'close']);
  62. const state = reactive({
  63. couponInfo: computed(() => props.modelValue), // 优惠劵列表
  64. couponId: undefined, // 选中的优惠劵编号
  65. });
  66. // 选中优惠劵
  67. function radioChange(couponId) {
  68. if (state.couponId === couponId) {
  69. state.couponId = undefined;
  70. } else {
  71. state.couponId = couponId;
  72. }
  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>