吉光研途前端代码仓库
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.

253 lines
6.0 KiB

  1. <template>
  2. <view class="page__view">
  3. <!-- 导航栏 -->
  4. <navbar :title="title" leftClick @leftClick="$utils.navigateBack" bgColor="#4883F9" color="#FFFFFF" />
  5. <view class="top">
  6. <!-- 搜索栏 -->
  7. <view class="search">
  8. <uv-search v-model="keyword" placeholder="输入关键词搜索" bgColor="#FBFBFB" @custom="search" @search="search">
  9. <template #prefix>
  10. <image class="search-icon" src="@/static/image/icon-search.png" mode="widthFix"></image>
  11. </template>
  12. </uv-search>
  13. </view>
  14. </view>
  15. <view class="main">
  16. <view class="flex card" v-for="item in list" :key="item.id">
  17. <view class="left">
  18. <view class="title">{{ item.title }}</view>
  19. <view class="content">{{ item.content }}</view>
  20. </view>
  21. <view class="right">
  22. <image class="img" :src="item.image" mode="aspectFill"></image>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import mixinsList from '@/mixins/list.js'
  30. export default {
  31. mixins: [mixinsList],
  32. data() {
  33. return {
  34. title: '搜索',
  35. keyword: '',
  36. queryParams: {
  37. pageNo: 1,
  38. pageSize: 10,
  39. title: null,
  40. cid: null,
  41. },
  42. // todo
  43. mixinsListApi: '',
  44. }
  45. },
  46. onLoad({ search, cid, title }) {
  47. if (search) {
  48. this.keyword = search
  49. this.queryParams.title = search
  50. }
  51. if (cid) {
  52. this.queryParams.cid = cid
  53. }
  54. if (title) {
  55. this.title = title
  56. }
  57. this.getData()
  58. },
  59. methods: {
  60. search() {
  61. this.queryParams.pageNo = 1
  62. this.queryParams.pageSize = 10
  63. this.queryParams.title = this.keyword
  64. this.getData()
  65. },
  66. // todo: delete
  67. getData() {
  68. this.list = [
  69. {
  70. id: '001',
  71. title: '建筑学',
  72. content: `
  73. <h>建筑学</h>
  74. <p>文字说明</p>
  75. <p>文字说明</p>
  76. <p>文字说明</p>
  77. <p>文字说明</p>
  78. <p>文字说明</p>
  79. <p>文字说明</p>
  80. <p>文字说明</p>
  81. <p>文字说明</p>
  82. <p>文字说明</p>
  83. <p>文字说明</p>
  84. <p>文字说明</p>
  85. <p>文字说明</p>
  86. <p>文字说明</p>
  87. <p>文字说明</p>
  88. <p>文字说明</p>
  89. <p>文字说明</p>
  90. <p>文字说明</p>
  91. <p>文字说明</p>
  92. <p>文字说明</p>
  93. <p>文字说明</p>
  94. <p>文字说明</p>
  95. <p>文字说明</p>
  96. <p>文字说明</p>
  97. <p>文字说明</p>
  98. <p>文字说明</p>
  99. <p>文字说明</p>
  100. <p>文字说明</p>
  101. <p>文字说明</p>
  102. <p>文字说明</p>
  103. <p>文字说明</p>
  104. <p>文字说明</p>
  105. `,
  106. image: '/static/image/temp-1.png',
  107. },
  108. {
  109. id: '002',
  110. title: '建筑学',
  111. content: `
  112. <h>建筑学</h>
  113. <p>文字说明</p>
  114. <p>文字说明</p>
  115. <p>文字说明</p>
  116. <p>文字说明</p>
  117. <p>文字说明</p>
  118. <p>文字说明</p>
  119. <p>文字说明</p>
  120. <p>文字说明</p>
  121. <p>文字说明</p>
  122. <p>文字说明</p>
  123. <p>文字说明</p>
  124. <p>文字说明</p>
  125. <p>文字说明</p>
  126. <p>文字说明</p>
  127. <p>文字说明</p>
  128. <p>文字说明</p>
  129. <p>文字说明</p>
  130. <p>文字说明</p>
  131. <p>文字说明</p>
  132. <p>文字说明</p>
  133. <p>文字说明</p>
  134. <p>文字说明</p>
  135. <p>文字说明</p>
  136. <p>文字说明</p>
  137. <p>文字说明</p>
  138. <p>文字说明</p>
  139. <p>文字说明</p>
  140. <p>文字说明</p>
  141. <p>文字说明</p>
  142. <p>文字说明</p>
  143. <p>文字说明</p>
  144. `,
  145. image: '/static/image/temp-2.png',
  146. },
  147. ]
  148. this.getDataThen(this.list)
  149. },
  150. getDataThen(list) {
  151. const reg = /\<[^>]*\>/g
  152. this.list = list.map(item => {
  153. const content = item.content.replace(reg, '')
  154. return { ...item, content }
  155. })
  156. },
  157. },
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. .page__view {
  162. background: $uni-bg-color-grey;
  163. }
  164. .top {
  165. padding: 49rpx 0 17rpx 0;
  166. box-sizing: border-box;
  167. background: $uni-color;
  168. }
  169. .search {
  170. margin: 0 19rpx;
  171. width: calc(100% - 20rpx * 2);
  172. background-color: #FFFFFF;
  173. border-radius: 37rpx;
  174. padding: 13rpx 0 13rpx 18rpx;
  175. box-sizing: border-box;
  176. display: flex;
  177. align-items: center;
  178. /deep/ .uv-search__action {
  179. color: $uni-color;
  180. padding: 10rpx 18rpx;
  181. }
  182. &-icon {
  183. width: 26rpx;
  184. height: auto;
  185. }
  186. }
  187. .main {
  188. padding: 17rpx;
  189. box-sizing: border-box;
  190. }
  191. .card {
  192. background: #ffffff;
  193. border-radius: 20rpx;
  194. box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  195. & + & {
  196. margin-top: 27rpx;
  197. }
  198. .left {
  199. flex: 1;
  200. padding: 13rpx 32rpx 35rpx 20rpx;
  201. box-sizing: border-box;
  202. .title {
  203. font-size: 32rpx;
  204. font-weight: 700;
  205. color: #000000;
  206. }
  207. .content {
  208. font-size: 28rpx;
  209. font-weight: 400;
  210. color: #0F2248;
  211. overflow: hidden;
  212. text-overflow: ellipsis;
  213. display:-webkit-box; //作为弹性伸缩盒子模型显示。
  214. -webkit-box-orient:vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
  215. -webkit-line-clamp:7; //显示的行
  216. }
  217. }
  218. .right {
  219. padding: 23rpx 17rpx 23rpx 0;
  220. box-sizing: border-box;
  221. .img {
  222. width: 225rpx;
  223. height: 325rpx;
  224. }
  225. }
  226. }
  227. </style>