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

195 lines
4.2 KiB

  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. default:
  87. break
  88. }
  89. uni.navigateTo({
  90. url: `/pages_order/article/index?api=${api}&id=${id}&idKey=${idKey}`
  91. })
  92. },
  93. },
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. .page__view {
  98. background: linear-gradient(#DAF3FF, #FBFEFF 250rpx, #FBFEFF);
  99. }
  100. .search {
  101. $h: 64rpx;
  102. $radius: 32rpx;
  103. $borderWidth: 4rpx;
  104. margin: 24rpx 32rpx 0 32rpx;
  105. width: calc(100% - 32rpx * 2);
  106. height: $h;
  107. position: relative;
  108. border-radius: $radius;
  109. &-icon {
  110. margin: 0 13rpx 0 26rpx;
  111. width: 30rpx;
  112. height: auto;
  113. }
  114. /deep/ .uv-search__content {
  115. padding: 12rpx 0;
  116. background: #FFFFFF !important;
  117. border-color: #CFEFFF !important;
  118. border: 4rpx solid transparent;
  119. }
  120. &.is-focus {
  121. /deep/ .uv-search__action {
  122. padding: 19rpx 24rpx;
  123. font-size: 26rpx;
  124. font-weight: 500;
  125. line-height: 1;
  126. color: #FFFFFF;
  127. background: #00A9FF;
  128. border-radius: 32rpx;
  129. }
  130. }
  131. }
  132. .list {
  133. margin-top: 24rpx;
  134. padding: 12rpx 40rpx;
  135. &-item {
  136. align-items: flex-start;
  137. column-gap: 16rpx;
  138. padding: 24rpx;
  139. background: #F9F9F9;
  140. border: 2rpx solid #FFFFFF;
  141. border-radius: 24rpx;
  142. & + & {
  143. margin-top: 40rpx;
  144. }
  145. .cover {
  146. width: 152rpx;
  147. height: 152rpx;
  148. border-radius: 8rpx;
  149. overflow: hidden;
  150. border: 2rpx solid #E6E6E6;
  151. .img {
  152. width: 100%;
  153. height: 100%;
  154. }
  155. }
  156. .info {
  157. flex: 1;
  158. .title {
  159. font-size: 28rpx;
  160. font-weight: 500;
  161. color: #000000;
  162. }
  163. .desc {
  164. margin-top: 8rpx;
  165. font-size: 24rpx;
  166. color: #8B8B8B;
  167. }
  168. }
  169. }
  170. }
  171. </style>