s-coupon-select.vue 3.4 KB

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