鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
3.9 KiB

2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="page__view">
  3. <!-- 导航栏 -->
  4. <navbar title="搜索结果" leftClick @leftClick="$utils.navigateBack" bgColor="transparent" color="#191919" />
  5. <!-- 搜索栏 -->
  6. <view :class="['flex', 'search', isFocusSearch ? 'is-focus' : '']" >
  7. <uv-search
  8. v-model="keyword"
  9. placeholder="输入关键词搜索"
  10. color="#181818"
  11. bgColor="transparent"
  12. :showAction="isFocusSearch"
  13. @custom="search"
  14. @search="search"
  15. @focus="isFocusSearch = true"
  16. @blur="isFocusSearch = false"
  17. >
  18. <template #prefix>
  19. <image class="search-icon" src="/static/image/icon-search-dark.png" mode="widthFix"></image>
  20. </template>
  21. </uv-search>
  22. </view>
  23. <view class="main">
  24. <sortBar v-model="sort" @change="onSortChange"></sortBar>
  25. <view v-if="list.length" class="list">
  26. <recordsView :list="list"></recordsView>
  27. </view>
  28. <template v-else>
  29. <uv-empty mode="list"></uv-empty>
  30. </template>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import mixinsList from '@/mixins/list.js'
  36. import sortBar from './sortBar.vue'
  37. import recordsView from '@/components/growing/recordsView.vue'
  38. export default {
  39. mixins: [mixinsList],
  40. components: {
  41. sortBar,
  42. recordsView,
  43. },
  44. data() {
  45. return {
  46. keyword: '',
  47. isFocusSearch: false,
  48. sort: 'comprehensive',
  49. queryParams: {
  50. pageNo: 1,
  51. pageSize: 10,
  52. activityTitle: '',
  53. // sort: 'comprehensive',
  54. },
  55. mixinsListApi: 'queryExperienceList',
  56. }
  57. },
  58. onLoad({ search }) {
  59. if (search) {
  60. this.keyword = search
  61. this.queryParams.activityTitle = search
  62. }
  63. this.getData()
  64. },
  65. methods: {
  66. search() {
  67. this.queryParams.pageNo = 1
  68. this.queryParams.pageSize = 10
  69. if (this.keyword) {
  70. this.queryParams.activityTitle = this.keyword
  71. } else {
  72. delete this.queryParams.activityTitle
  73. }
  74. this.getData()
  75. },
  76. onSortChange(sort) {
  77. console.log('onSortChange', sort)
  78. this.getda()
  79. },
  80. beforeGetData() {
  81. console.log('beforeGetData')
  82. let params = {}
  83. switch(this.sort) {
  84. // 时间排序(dateOrder):0-从高到低 1-从低到高
  85. case 'date-desc': // 时间排序 - 降序
  86. params.dateOrder = '0'
  87. break
  88. case 'date-asc': // 时间排序 - 升序
  89. params.dateOrder = '1'
  90. break
  91. default:
  92. break
  93. }
  94. return params
  95. },
  96. getDataThen(records) {
  97. this.list = records.map(item => {
  98. const { id, activityTitle, activityId_dictText, image, createTime } = item
  99. return {
  100. id,
  101. name: activityTitle || activityId_dictText || '',
  102. image: image?.split?.(',') || [],
  103. createTime
  104. }
  105. })
  106. },
  107. },
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .search {
  112. $h: 64rpx;
  113. $radius: 32rpx;
  114. $borderWidth: 4rpx;
  115. margin: 24rpx 32rpx 0 32rpx;
  116. width: calc(100% - 32rpx * 2);
  117. height: $h;
  118. position: relative;
  119. border-radius: $radius;
  120. &-icon {
  121. margin: 0 13rpx 0 26rpx;
  122. width: 30rpx;
  123. height: auto;
  124. }
  125. /deep/ .uv-search__content {
  126. padding: 12rpx 0;
  127. background: #FFFFFF !important;
  128. border-color: #CFEFFF !important;
  129. border: 4rpx solid transparent;
  130. }
  131. &.is-focus {
  132. /deep/ .uv-search__action {
  133. padding: 19rpx 24rpx;
  134. font-size: 26rpx;
  135. font-weight: 500;
  136. line-height: 1;
  137. color: #FFFFFF;
  138. background: #00A9FF;
  139. border-radius: 32rpx;
  140. }
  141. }
  142. }
  143. .main {
  144. margin-top: 24rpx;
  145. padding: 0 32rpx 100rpx 32rpx;
  146. }
  147. .content {
  148. margin-top: 24rpx;
  149. display: grid;
  150. grid-template-columns: repeat(2, 1fr);
  151. gap: 16rpx;
  152. }
  153. </style>