red-packet-popup.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <u-popup v-model="show" mode="bottom" border-radius="24">
  3. <view class="red-packet-popup">
  4. <view class="popup-header">
  5. <text>选择红包</text>
  6. <u-icon name="close" size="28" color="#999" class="close-icon" @click="close"></u-icon>
  7. </view>
  8. <scroll-view scroll-y class="packet-list">
  9. <view class="packet-item" v-for="(item, index) in list" :key="index" @click="selectPacket(index)">
  10. <view class="packet-info">
  11. <view class="packet-name">{{ item.name }}</view>
  12. <view class="packet-desc">{{ item.desc }}</view>
  13. <view class="packet-time">{{ item.time }}</view>
  14. </view>
  15. <view class="packet-check">
  16. <u-icon name="checkmark-circle-fill" size="40" :color="selectedIndex === index ? '#ff4500' : '#ccc'"></u-icon>
  17. </view>
  18. </view>
  19. </scroll-view>
  20. <view class="popup-footer">
  21. <u-button type="primary" shape="circle" @click="confirm">确认</u-button>
  22. </view>
  23. </view>
  24. </u-popup>
  25. </template>
  26. <script>
  27. export default {
  28. props: {
  29. value: {
  30. type: Boolean,
  31. default: false
  32. }
  33. },
  34. data() {
  35. return {
  36. show: false,
  37. selectedIndex: 0,
  38. list: [
  39. {
  40. name: '惊喜红包(满15减5)',
  41. desc: '书嗨所有商品(不包含邮费)',
  42. time: '2024-01-01 00:00:00至2024-12-31 23:59:59'
  43. },
  44. {
  45. name: '惊喜红包(满15减5)',
  46. desc: '书嗨所有商品(不包含邮费)',
  47. time: '2024-01-01 00:00:00至2024-12-31 23:59:59'
  48. }
  49. ]
  50. }
  51. },
  52. watch: {
  53. value(val) {
  54. this.show = val;
  55. },
  56. show(val) {
  57. this.$emit('input', val);
  58. }
  59. },
  60. methods: {
  61. close() {
  62. this.show = false;
  63. },
  64. selectPacket(index) {
  65. this.selectedIndex = index;
  66. },
  67. confirm() {
  68. this.$emit('confirm', this.list[this.selectedIndex]);
  69. this.close();
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .red-packet-popup {
  76. height: 100%;
  77. display: flex;
  78. flex-direction: column;
  79. overflow: hidden;
  80. .popup-header {
  81. padding: 30rpx;
  82. text-align: center;
  83. font-size: 32rpx;
  84. font-weight: bold;
  85. position: sticky;
  86. top: 0;
  87. background-color: #fff;
  88. border-bottom: 1rpx solid #eee;
  89. .close-icon {
  90. position: absolute;
  91. right: 30rpx;
  92. top: 40rpx;
  93. }
  94. }
  95. .packet-list {
  96. flex: 1;
  97. padding: 20rpx;
  98. box-sizing: border-box;
  99. max-height: 400px;
  100. overflow-y: auto;
  101. .packet-item {
  102. display: flex;
  103. align-items: center;
  104. padding: 20rpx 30rpx;
  105. .packet-info {
  106. flex: 1;
  107. .packet-name {
  108. font-size: 30rpx;
  109. color: #ff4500;
  110. font-weight: bold;
  111. margin-bottom: 10rpx;
  112. }
  113. .packet-desc {
  114. font-size: 26rpx;
  115. color: #333;
  116. margin-bottom: 6rpx;
  117. }
  118. .packet-time {
  119. font-size: 22rpx;
  120. color: #999;
  121. }
  122. }
  123. }
  124. }
  125. .popup-footer {
  126. padding: 20rpx 40rpx;
  127. padding-bottom: env(safe-area-inset-bottom);
  128. }
  129. }
  130. </style>