鸿宇研学生前端代码
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.

172 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. },
  54. mixinsListApi: 'queryExperienceList',
  55. }
  56. },
  57. onLoad({ search }) {
  58. if (search) {
  59. this.keyword = search
  60. this.queryParams.activityTitle = search
  61. }
  62. this.getData()
  63. },
  64. methods: {
  65. search() {
  66. this.queryParams.pageNo = 1
  67. this.queryParams.pageSize = 10
  68. if (this.keyword) {
  69. this.queryParams.activityTitle = this.keyword
  70. } else {
  71. delete this.queryParams.activityTitle
  72. }
  73. this.getData()
  74. },
  75. onSortChange(sort) {
  76. console.log('onSortChange', sort)
  77. this.getda()
  78. },
  79. beforeGetData() {
  80. console.log('beforeGetData')
  81. let params = {}
  82. switch(this.sort) {
  83. // 时间排序(dateOrder):0-从高到低 1-从低到高
  84. case 'date-desc': // 时间排序 - 降序
  85. params.dateOrder = '0'
  86. break
  87. case 'date-asc': // 时间排序 - 升序
  88. params.dateOrder = '1'
  89. break
  90. default:
  91. break
  92. }
  93. return params
  94. },
  95. getDataThen(records) {
  96. this.list = records.map(item => {
  97. const { id, activityTitle, activityId_dictText, imageList, createTime } = item
  98. return {
  99. id,
  100. name: activityTitle || activityId_dictText || '',
  101. images: imageList?.split?.(',') || [],
  102. createTime
  103. }
  104. })
  105. },
  106. },
  107. }
  108. </script>
  109. <style scoped lang="scss">
  110. .search {
  111. $h: 64rpx;
  112. $radius: 32rpx;
  113. $borderWidth: 4rpx;
  114. margin: 24rpx 32rpx 0 32rpx;
  115. width: calc(100% - 32rpx * 2);
  116. height: $h;
  117. position: relative;
  118. border-radius: $radius;
  119. &-icon {
  120. margin: 0 13rpx 0 26rpx;
  121. width: 30rpx;
  122. height: auto;
  123. }
  124. /deep/ .uv-search__content {
  125. padding: 12rpx 0;
  126. background: #FFFFFF !important;
  127. border-color: #CFEFFF !important;
  128. border: 4rpx solid transparent;
  129. }
  130. &.is-focus {
  131. /deep/ .uv-search__action {
  132. padding: 19rpx 24rpx;
  133. font-size: 26rpx;
  134. font-weight: 500;
  135. line-height: 1;
  136. color: #FFFFFF;
  137. background: #00A9FF;
  138. border-radius: 32rpx;
  139. }
  140. }
  141. }
  142. .main {
  143. margin-top: 24rpx;
  144. padding: 0 32rpx 100rpx 32rpx;
  145. }
  146. .content {
  147. margin-top: 24rpx;
  148. display: grid;
  149. grid-template-columns: repeat(2, 1fr);
  150. gap: 16rpx;
  151. }
  152. </style>