category-popup.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <u-popup v-model="showPopup" mode="bottom" border-radius="20">
  3. <view class="category-popup">
  4. <view class="popup-header">
  5. <text>分类</text>
  6. <u-icon name="close" size="32" @click="close"></u-icon>
  7. </view>
  8. <view class="category-list">
  9. <view v-for="(item, index) in categories" :key="index" class="category-item"
  10. :class="{ 'active': selectedCategories.includes(item.value), 'disabled': item.disabled }"
  11. @click="toggleSelect(item)">
  12. {{ item.label }}
  13. </view>
  14. </view>
  15. <view class="confirm-btn" @click="confirm">
  16. 确定筛选
  17. </view>
  18. </view>
  19. </u-popup>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'category-popup',
  24. props: {
  25. show: {
  26. type: Boolean,
  27. default: false
  28. }
  29. },
  30. data() {
  31. return {
  32. showPopup: false,
  33. categories: [
  34. { label: '买书', value: 'buy_book' },
  35. { label: '提现', value: 'withdraw' },
  36. { label: '退款', value: 'refund' },
  37. { label: '工单收入', value: 'work_income' },
  38. { label: '自寄运费补贴', value: 'shipping_subsidy' },
  39. { label: '自寄运费补款', value: 'shipping_supplement' },
  40. { label: '分享收入', value: 'share_income' },
  41. { label: '合伙人收入', value: 'partner_income'},
  42. { label: '退回邮费', value: 'return_postage' }
  43. ],
  44. selectedCategories: []
  45. }
  46. },
  47. watch: {
  48. show(newVal) {
  49. this.showPopup = newVal
  50. },
  51. showPopup(newVal) {
  52. if (!newVal) {
  53. this.$emit('update:show', false)
  54. }
  55. }
  56. },
  57. methods: {
  58. toggleSelect(item) {
  59. if (item.disabled) return
  60. const index = this.selectedCategories.indexOf(item.value)
  61. if (index > -1) {
  62. this.selectedCategories.splice(index, 1)
  63. } else {
  64. this.selectedCategories.push(item.value)
  65. }
  66. },
  67. confirm() {
  68. this.$emit('confirm', this.selectedCategories)
  69. this.close()
  70. },
  71. close() {
  72. this.showPopup = false
  73. this.$emit('update:show', false)
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .category-popup {
  80. padding: 30rpx;
  81. padding-bottom: env(safe-area-inset-bottom);
  82. .popup-header {
  83. display: flex;
  84. justify-content: space-between;
  85. align-items: center;
  86. padding-bottom: 30rpx;
  87. font-size: 32rpx;
  88. color: #333;
  89. }
  90. .category-list {
  91. display: flex;
  92. flex-wrap: wrap;
  93. padding: 20rpx 0;
  94. gap: 20rpx;
  95. .category-item {
  96. padding: 0 42rpx;
  97. height: 60rpx;
  98. line-height: 60rpx;
  99. text-align: center;
  100. border-radius: 10rpx;
  101. font-size: 28rpx;
  102. color: #38C148;
  103. border: 1px solid #38C148;
  104. &.active {
  105. color: #ffffff;
  106. border: 1px solid #38C148;
  107. background-color: #38C148;
  108. }
  109. }
  110. }
  111. .confirm-btn {
  112. margin-top: 40rpx;
  113. height: 90rpx;
  114. line-height: 90rpx;
  115. text-align: center;
  116. background: #38C148;
  117. border-radius: 45rpx;
  118. color: #FFFFFF;
  119. font-size: 32rpx;
  120. }
  121. }
  122. </style>