s-coupon-select.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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="radio">
  23. <radio
  24. color="var(--ui-BG-Main)"
  25. style="transform: scale(0.8)"
  26. @tap.stop="radioChange(item.id)"
  27. :checked="state.couponId == 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. </view>
  37. </scroll-view>
  38. </view>
  39. <view class="modal-footer ss-flex">
  40. <button class="confirm-btn ss-reset-button" @tap="onConfirm">确认</button>
  41. </view>
  42. </su-popup>
  43. </template>
  44. <script setup>
  45. import { computed, reactive } from 'vue';
  46. const props = defineProps({
  47. modelValue: {
  48. type: Object,
  49. default() {},
  50. },
  51. show: {
  52. type: Boolean,
  53. default: false,
  54. },
  55. });
  56. const emits = defineEmits(['confirm', 'close']);
  57. const state = reactive({
  58. couponInfo: computed(() => props.modelValue),
  59. couponId: 0,
  60. });
  61. function radioChange(couponId) {
  62. if (state.couponId == couponId) {
  63. state.couponId = 0;
  64. } else {
  65. state.couponId = couponId;
  66. }
  67. }
  68. const onConfirm = () => {
  69. emits('confirm', state.couponId);
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. :deep() {
  74. .uni-checkbox-input {
  75. background-color: var(--ui-BG-Main);
  76. }
  77. }
  78. .model-box {
  79. height: 60vh;
  80. }
  81. .title {
  82. font-size: 36rpx;
  83. height: 80rpx;
  84. font-weight: bold;
  85. color: #333333;
  86. }
  87. .subtitle {
  88. font-size: 26rpx;
  89. font-weight: 500;
  90. color: #333333;
  91. }
  92. .model-content {
  93. height: 54vh;
  94. }
  95. .modal-footer {
  96. width: 100%;
  97. height: 120rpx;
  98. background: #fff;
  99. }
  100. .confirm-btn {
  101. width: 710rpx;
  102. margin-left: 20rpx;
  103. height: 80rpx;
  104. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  105. border-radius: 40rpx;
  106. color: #fff;
  107. }
  108. </style>