questionsList.vue 6.8 KB

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