s-coupon-select.vue 3.7 KB

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