userDefined.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar title="自定义筛选项">
  6. <!-- #ifndef MP-WEIXIN -->
  7. <view class="button white-btn" @click="handleSave">
  8. 确定
  9. </view>
  10. <!-- #endif -->
  11. </wk-nav-bar>
  12. <view class="container">
  13. <view
  14. v-if="chooseList.length > 0"
  15. class="section choose-list">
  16. <view class="section-title">
  17. 已选择项
  18. </view>
  19. <view class="section-body">
  20. <view
  21. v-for="(item, index) in chooseList"
  22. :key="index"
  23. class="field-item"
  24. @click="handleRemove(index)">
  25. <view class="field-item_icon choose">
  26. <text class="wk wk-check icon" />
  27. </view>
  28. <view class="field-item_text">
  29. <text class="text">
  30. {{ item.name }}
  31. </text>
  32. <image :src="$static('images/icon/sort.png')" alt="" class="sort-icon" />
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="section other-list">
  38. <view class="section-title">
  39. 其他可选项
  40. </view>
  41. <view class="section-body">
  42. <view
  43. v-for="(item, index) in otherList"
  44. :key="index"
  45. class="field-item"
  46. @click="handleChoose(index)">
  47. <view class="field-item_icon" />
  48. <view class="field-item_text">
  49. {{ item.name }}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- #ifdef MP-WEIXIN -->
  56. <view class="footer-btn-group">
  57. <button class="button" @click="handleSave">
  58. 确定
  59. </button>
  60. </view>
  61. <!-- #endif -->
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. export default {
  67. name: 'UserDefined',
  68. data() {
  69. return {
  70. bridge: {},
  71. chooseList: [],
  72. otherList: []
  73. }
  74. },
  75. onLoad() {
  76. this.bridge = getApp().globalData.filterBridge
  77. this.chooseList = this.bridge.choose || []
  78. this.otherList = this.bridge.other || []
  79. },
  80. methods: {
  81. handleChoose(index) {
  82. const arr = this.otherList.splice(index, 1)
  83. this.chooseList.push(arr[0])
  84. },
  85. handleRemove(index) {
  86. const arr = this.chooseList.splice(index, 1)
  87. this.otherList.push(arr[0])
  88. },
  89. handleSave() {
  90. uni.$emit('select-defined', {
  91. guid: this.bridge.guid,
  92. choose: this.chooseList,
  93. other: this.otherList
  94. })
  95. this.$Router.navigateBack()
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped lang="scss">
  101. .container {
  102. flex: 1;
  103. overflow-y: auto;
  104. .section {
  105. .section-title {
  106. font-size: 24rpx;
  107. padding: 15rpx 30rpx;
  108. }
  109. .section-body {
  110. background-color: white;
  111. padding: 0 30rpx;
  112. .field-item {
  113. width: 100%;
  114. @include left;
  115. .field-item_icon {
  116. width: 38rpx;
  117. height: 38rpx;
  118. border: 1rpx solid #ccc;
  119. border-radius: 50%;
  120. margin-right: 22rpx;
  121. @include center;
  122. .icon {
  123. font-size: 22rpx;
  124. }
  125. &.choose {
  126. background-color: $theme-color;
  127. border-color: $theme-color;
  128. .icon {
  129. color: white;
  130. }
  131. }
  132. }
  133. .field-item_text {
  134. flex: 1;
  135. font-size: 30rpx;
  136. color: $dark;
  137. border-bottom: 1rpx solid $border-color;
  138. padding: 24rpx 0;
  139. @include left;
  140. .text {
  141. flex: 1;
  142. }
  143. .sort-icon {
  144. width: 30rpx;
  145. height: 20rpx;
  146. }
  147. }
  148. }
  149. .field-item:last-child .field-item_text {
  150. border-bottom: 0 none;
  151. }
  152. }
  153. }
  154. }
  155. </style>