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

199 lines
4.3 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="page__view highlight">
  3. <!-- 导航栏 -->
  4. <navbar :title="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="list">
  24. <template v-if="total">
  25. <view class="flex list-item" v-for="item in list" :key="item.id" @click="jumpToDetail(item.id)">
  26. <view class="cover">
  27. <image class="img" :src="item.image" mode="aspectFill"></image>
  28. </view>
  29. <view class="info">
  30. <view class="title">{{ item.title }}</view>
  31. <view class="desc">{{ item.createTime }}</view>
  32. </view>
  33. </view>
  34. </template>
  35. <template v-else>
  36. <uv-empty mode="list"></uv-empty>
  37. </template>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import mixinsList from '@/mixins/list.js'
  43. import recordsView from '@/components/growing/recordsView.vue'
  44. export default {
  45. mixins: [mixinsList],
  46. components: {
  47. recordsView,
  48. },
  49. data() {
  50. return {
  51. title: '搜索',
  52. keyword: '',
  53. isFocusSearch: false,
  54. queryParams: {
  55. pageNo: 1,
  56. pageSize: 10,
  57. title: '',
  58. },
  59. mixinsListApi: '',
  60. }
  61. },
  62. onLoad({ title, api }) {
  63. this.title = title
  64. this.mixinsListApi = api
  65. this.getData()
  66. },
  67. methods: {
  68. search() {
  69. this.queryParams.pageNo = 1
  70. this.queryParams.pageSize = 10
  71. this.queryParams.title = this.keyword
  72. this.getData()
  73. },
  74. jumpToDetail(id) {
  75. let api
  76. let idKey
  77. switch(this.mixinsListApi) {
  78. case 'queryNewsList':
  79. api = 'queryNewsById',
  80. idKey = 'newsId'
  81. break
  82. case 'queryPolicyList':
  83. api = 'queryPolicyById',
  84. idKey = 'policyId'
  85. break
  86. case 'queryJournalList':
  87. api = 'queryJournalById',
  88. idKey = 'journalId'
  89. break
  90. default:
  91. break
  92. }
  93. uni.navigateTo({
  94. url: `/pages_order/article/index?api=${api}&id=${id}&idKey=${idKey}`
  95. })
  96. },
  97. },
  98. }
  99. </script>
  100. <style scoped lang="scss">
  101. .page__view {
  102. background: linear-gradient(#DAF3FF, #FBFEFF 250rpx, #FBFEFF);
  103. }
  104. .search {
  105. $h: 64rpx;
  106. $radius: 32rpx;
  107. $borderWidth: 4rpx;
  108. margin: 24rpx 32rpx 0 32rpx;
  109. width: calc(100% - 32rpx * 2);
  110. height: $h;
  111. position: relative;
  112. border-radius: $radius;
  113. &-icon {
  114. margin: 0 13rpx 0 26rpx;
  115. width: 30rpx;
  116. height: auto;
  117. }
  118. /deep/ .uv-search__content {
  119. padding: 12rpx 0;
  120. background: #FFFFFF !important;
  121. border-color: #CFEFFF !important;
  122. border: 4rpx solid transparent;
  123. }
  124. &.is-focus {
  125. /deep/ .uv-search__action {
  126. padding: 19rpx 24rpx;
  127. font-size: 26rpx;
  128. font-weight: 500;
  129. line-height: 1;
  130. color: #FFFFFF;
  131. background: #00A9FF;
  132. border-radius: 32rpx;
  133. }
  134. }
  135. }
  136. .list {
  137. margin-top: 24rpx;
  138. padding: 12rpx 40rpx;
  139. &-item {
  140. align-items: flex-start;
  141. column-gap: 16rpx;
  142. padding: 24rpx;
  143. background: #F9F9F9;
  144. border: 2rpx solid #FFFFFF;
  145. border-radius: 24rpx;
  146. & + & {
  147. margin-top: 40rpx;
  148. }
  149. .cover {
  150. width: 152rpx;
  151. height: 152rpx;
  152. border-radius: 8rpx;
  153. overflow: hidden;
  154. border: 2rpx solid #E6E6E6;
  155. .img {
  156. width: 100%;
  157. height: 100%;
  158. }
  159. }
  160. .info {
  161. flex: 1;
  162. .title {
  163. font-size: 28rpx;
  164. font-weight: 500;
  165. color: #000000;
  166. }
  167. .desc {
  168. margin-top: 8rpx;
  169. font-size: 24rpx;
  170. color: #8B8B8B;
  171. }
  172. }
  173. }
  174. }
  175. </style>