index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view>
  3. <view class="top-content">
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <view class="inner">
  7. <image class="icon-search" src="/static/images/search.png" mode=""></image>
  8. <input type="text" v-model="keyword" placeholder="输入服务包搜索" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  9. </view>
  10. </view>
  11. <view class="cate-list">
  12. <!-- 关键字列表 -->
  13. <scroll-view scroll-x="true" >
  14. <view class="inner">
  15. <view v-for="(item,index) in typeOptions" :key="index" :class="questionsType == item.dictValue?'item active':'item'" @click="choseType(item)">
  16. {{ item.dictLabel }}
  17. </view>
  18. </view>
  19. </scroll-view>
  20. </view>
  21. </view>
  22. <mescroll-body top="192rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  23. <view class="article-list">
  24. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  25. <view class="left">
  26. <view class="title ellipsis2">{{ item.title }}</view>
  27. <view class="info-box">
  28. <view class="readers">
  29. <view class="readings">
  30. <image class="eye" src="/static/images/eye.png" ></image>
  31. <text class="num">{{item.views}}</text>
  32. </view>
  33. </view>
  34. <view class="time">{{item.createTime}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </mescroll-body>
  40. <Server/>
  41. </view>
  42. </template>
  43. <script>
  44. import {getDictByKey} from '@/api/common.js'
  45. import {getQuestionsList} from '@/api/index.js'
  46. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  47. import Server from '@/components/Server.vue'
  48. export default {
  49. mixins: [MescrollMixin],
  50. components: {
  51. Server
  52. },
  53. data() {
  54. return {
  55. typeOptions:[],
  56. questionsType:0,
  57. keyword: '',
  58. mescroll:null,
  59. downOption: { //下拉刷新
  60. use:true,
  61. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  62. },
  63. upOption: {
  64. onScroll:false,
  65. use: true, // 是否启用上拉加载; 默认true
  66. page: {
  67. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  68. size: 10 // 每页数据的数量,默认10
  69. },
  70. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  71. textNoMore:"已经到底了",
  72. empty: {
  73. icon:'https://user.test.ylrztop.com/images/empty_icon.png',
  74. tip: '暂无数据'
  75. }
  76. },
  77. dataList: []
  78. };
  79. },
  80. onShow() {
  81. this.getDictByKey("sys_questions_type");
  82. },
  83. methods:{
  84. getDictByKey(key){
  85. var data={key:key}
  86. getDictByKey(data).then(
  87. res => {
  88. if(res.code==200){
  89. if(key=="sys_questions_type"){
  90. this.typeOptions=res.data;
  91. }
  92. }
  93. },
  94. err => {
  95. }
  96. );
  97. },
  98. doSearch(){
  99. this.mescroll.resetUpScroll()
  100. },
  101. mescrollInit(mescroll) {
  102. this.mescroll = mescroll;
  103. },
  104. /*下拉刷新的回调 */
  105. downCallback(mescroll) {
  106. mescroll.resetUpScroll()
  107. },
  108. upCallback(page) {
  109. //联网加载数据
  110. var that = this;
  111. var data = {
  112. keyword:this.keyword,
  113. questionsType:this.questionsType,
  114. pageNum: page.num,
  115. pageSize: page.size
  116. };
  117. getQuestionsList(data).then(res => {
  118. if(res.code==200){
  119. //设置列表数据
  120. if (page.num == 1) {
  121. that.dataList = res.data.list;
  122. } else {
  123. that.dataList = that.dataList.concat(res.data.list);
  124. }
  125. that.mescroll.endBySize(res.data.list.length, res.data.total);
  126. }else{
  127. uni.showToast({
  128. icon:'none',
  129. title: "请求失败",
  130. });
  131. that.dataList = null;
  132. that.mescroll.endErr();
  133. }
  134. });
  135. },
  136. // 关键词选择
  137. choseType(item) {
  138. this.questionsType = item.dictValue;
  139. this.mescroll.resetUpScroll()
  140. },
  141. // 查看详情
  142. showDetail(item) {
  143. uni.navigateTo({
  144. url: './questionsDetails?id=' + item.id
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .top-content{
  152. width: 100%;
  153. position: fixed;
  154. top: 0;
  155. left: 0;
  156. z-index: 10;
  157. }
  158. .top-title{
  159. height: 88upx;
  160. line-height: 88upx;
  161. font-size: 42upx;
  162. font-family: Source Han Sans CN;
  163. font-weight: bold;
  164. color: #222222;
  165. padding-left: 41upx;
  166. background-color: #FFFFFF;
  167. }
  168. .search-cont{
  169. padding: 16upx 30upx;
  170. background-color: #FFFFFF;
  171. .inner{
  172. box-sizing: border-box;
  173. width: 100%;
  174. height: 72upx;
  175. background: #F7F7F7;
  176. border-radius: 36upx;
  177. display: flex;
  178. align-items: center;
  179. padding: 0 30upx;
  180. .icon-search{
  181. width: 28upx;
  182. height: 28upx;
  183. margin-right: 20upx;
  184. }
  185. input{
  186. height: 60upx;
  187. line-height: 60upx;
  188. flex: 1;
  189. }
  190. }
  191. }
  192. .cate-list{
  193. box-sizing: border-box;
  194. background: #fff;
  195. padding: 10upx 27upx;
  196. height: 100upx;
  197. .inner{
  198. display: flex;
  199. }
  200. .item{
  201. flex-shrink: 0;
  202. padding: 0 24upx;
  203. height: 64upx;
  204. line-height: 64upx;
  205. font-size: 28upx;
  206. font-family: PingFang SC;
  207. font-weight: 500;
  208. color: #0bb3f2;
  209. background: #ffffff;
  210. border: 1px solid #66b2ef ;
  211. border-radius: 32upx;
  212. margin: 0 20upx 20upx 0;
  213. &.active{
  214. color: #FFFFFF;
  215. background: #0bb3f2 ;
  216. border: 1px solid #0bb3f2;
  217. }
  218. }
  219. }
  220. .article-list{
  221. margin-top: 20upx;
  222. padding: 0 10upx;
  223. .item{
  224. width: 100%;
  225. box-sizing: border-box;
  226. background: #FFFFFF;
  227. border-radius: 16upx;
  228. padding: 30upx;
  229. display: flex;
  230. align-items: center;
  231. justify-content: space-between;
  232. margin-bottom: 20upx;
  233. .left{
  234. flex: 1;
  235. display: flex;
  236. flex-direction: column;
  237. justify-content: space-between;
  238. .title{
  239. font-size: 32upx;
  240. font-family: PingFang SC;
  241. font-weight: 500;
  242. color: #111111;
  243. line-height: 48upx;
  244. }
  245. .info-box{
  246. margin-top: 20rpx;
  247. width: 100%;
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. .readers{
  252. display: flex;
  253. align-items: center;
  254. .head-box{
  255. margin-right: 27upx;
  256. display: flex;
  257. align-items: center;
  258. .head{
  259. width: 48upx;
  260. height: 48upx;
  261. border-radius: 50%;
  262. overflow: hidden;
  263. box-shadow: 0 0 0 1px #fff;
  264. margin-right: -10upx;
  265. image{
  266. width: 100%;
  267. height: 100%;
  268. }
  269. }
  270. }
  271. .readings{
  272. display: flex;
  273. align-items: center;
  274. .eye{
  275. width: 26upx;
  276. height: 20upx;
  277. margin-right: 9upx;
  278. }
  279. .num{
  280. font-size: 24upx;
  281. font-family: PingFang SC;
  282. font-weight: 500;
  283. color: #999999;
  284. line-height: 1;
  285. }
  286. }
  287. }
  288. .time{
  289. font-size: 24upx;
  290. line-height: 1;
  291. font-family: PingFang SC;
  292. font-weight: 500;
  293. color: #999999;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. </style>