couponSelectPopup.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <uv-popup ref="popupRef" mode="bottom" round="20rpx" closeable>
  3. <view class="coupon-main">
  4. <view class="coupon-main-title"> 选择优惠卷 </view>
  5. <scroll-view scroll-y class="coupon-list">
  6. <view style="padding: 0 20rpx">
  7. <couponInfo
  8. v-for="(item, index) in list"
  9. :key="index"
  10. :item="item"
  11. :show="checkIndex === index ? true : false"
  12. :isMyCoupon="true"
  13. @useTickets="checkCoupon"
  14. :select="item.id == id ? true : false"
  15. types="select"
  16. />
  17. </view>
  18. </scroll-view>
  19. </view>
  20. </uv-popup>
  21. </template>
  22. <script setup name="couponSelectPopup">
  23. import { ref, watch } from "vue";
  24. const emit = defineEmits(["change"]);
  25. const props = defineProps({
  26. list: {
  27. type: Array,
  28. default: () => [],
  29. },
  30. });
  31. const popupRef = ref(null);
  32. const list = ref(props.list || []);
  33. const id = ref("");
  34. watch(
  35. () => props.list,
  36. (newValue) => {
  37. list.value = newValue;
  38. }
  39. );
  40. const checkCoupon = (item) => {
  41. popupRef.value.close();
  42. emit("change", item);
  43. };
  44. const open = (itemId = "") => {
  45. id.value = itemId || "";
  46. popupRef.value.open();
  47. };
  48. defineExpose({
  49. open,
  50. });
  51. </script>
  52. <style lang="scss" scoped>
  53. .coupon-main-title {
  54. text-align: center;
  55. font-size: 30rpx;
  56. font-weight: 700;
  57. background-color: #fdfdfd;
  58. }
  59. .coupon-main {
  60. background-color: #fdfdfd;
  61. box-sizing: border-box;
  62. padding: 40rpx 0;
  63. }
  64. .coupon-list {
  65. height: 60vh;
  66. }
  67. </style>