questionsList.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. </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. onLoad(option) {
  76. console.log(option)
  77. if (option.title) {
  78. uni.setNavigationBarTitle({
  79. title: option.title
  80. });
  81. }
  82. },
  83. onShow() {
  84. this.getDictByKey("sys_questions_type");
  85. },
  86. methods:{
  87. getDictByKey(key){
  88. var data={key:key}
  89. getDictByKey(data).then(
  90. res => {
  91. if(res.code==200){
  92. if(key=="sys_questions_type"){
  93. this.typeOptions=res.data;
  94. }
  95. }
  96. },
  97. err => {
  98. }
  99. );
  100. },
  101. doSearch(){
  102. this.mescroll.resetUpScroll()
  103. },
  104. mescrollInit(mescroll) {
  105. this.mescroll = mescroll;
  106. },
  107. /*下拉刷新的回调 */
  108. downCallback(mescroll) {
  109. mescroll.resetUpScroll()
  110. },
  111. upCallback(page) {
  112. //联网加载数据
  113. var that = this;
  114. var data = {
  115. keyword:this.keyword,
  116. questionsType:this.questionsType,
  117. pageNum: page.num,
  118. pageSize: page.size
  119. };
  120. getQuestionsList(data).then(res => {
  121. if(res.code==200){
  122. //设置列表数据
  123. if (page.num == 1) {
  124. that.dataList = res.data.list;
  125. } else {
  126. that.dataList = that.dataList.concat(res.data.list);
  127. }
  128. that.mescroll.endBySize(res.data.list.length, res.data.total);
  129. }else{
  130. uni.showToast({
  131. icon:'none',
  132. title: "请求失败",
  133. });
  134. that.dataList = null;
  135. that.mescroll.endErr();
  136. }
  137. });
  138. },
  139. // 关键词选择
  140. choseType(item) {
  141. this.questionsType = item.dictValue;
  142. this.mescroll.resetUpScroll()
  143. },
  144. // 查看详情
  145. showDetail(item) {
  146. uni.navigateTo({
  147. url: './questionsDetails?id=' + item.id
  148. })
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss">
  154. .top-content{
  155. width: 100%;
  156. position: fixed;
  157. top: 0;
  158. left: 0;
  159. z-index: 10;
  160. }
  161. .top-title{
  162. height: 88upx;
  163. line-height: 88upx;
  164. font-size: 42upx;
  165. font-family: Source Han Sans CN;
  166. font-weight: bold;
  167. color: #222222;
  168. padding-left: 41upx;
  169. background-color: #FFFFFF;
  170. }
  171. .search-cont{
  172. padding: 16upx 30upx;
  173. background-color: #FFFFFF;
  174. .inner{
  175. box-sizing: border-box;
  176. width: 100%;
  177. height: 72upx;
  178. background: #F7F7F7;
  179. border-radius: 36upx;
  180. display: flex;
  181. align-items: center;
  182. padding: 0 30upx;
  183. .icon-search{
  184. width: 28upx;
  185. height: 28upx;
  186. margin-right: 20upx;
  187. }
  188. input{
  189. height: 60upx;
  190. line-height: 60upx;
  191. flex: 1;
  192. }
  193. }
  194. }
  195. .cate-list{
  196. box-sizing: border-box;
  197. background: #fff;
  198. padding: 10upx 27upx;
  199. height: 100upx;
  200. .inner{
  201. display: flex;
  202. }
  203. .item{
  204. flex-shrink: 0;
  205. padding: 0 24upx;
  206. height: 64upx;
  207. line-height: 64upx;
  208. font-size: 28upx;
  209. font-family: PingFang SC;
  210. font-weight: 500;
  211. color: #018C39;
  212. background: #ffffff;
  213. border: 1px solid #00aa00 ;
  214. border-radius: 32upx;
  215. margin: 0 20upx 20upx 0;
  216. &.active{
  217. color: #FFFFFF;
  218. background: #018C39 ;
  219. border: 1px solid #018C39;
  220. }
  221. }
  222. }
  223. .article-list{
  224. margin-top: 20upx;
  225. padding: 0 10upx;
  226. .item{
  227. width: 100%;
  228. box-sizing: border-box;
  229. background: #FFFFFF;
  230. border-radius: 16upx;
  231. padding: 30upx;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. margin-bottom: 20upx;
  236. .left{
  237. flex: 1;
  238. display: flex;
  239. flex-direction: column;
  240. justify-content: space-between;
  241. .title{
  242. font-size: 32upx;
  243. font-family: PingFang SC;
  244. font-weight: 500;
  245. color: #111111;
  246. line-height: 48upx;
  247. }
  248. .info-box{
  249. margin-top: 20rpx;
  250. width: 100%;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. .readers{
  255. display: flex;
  256. align-items: center;
  257. .head-box{
  258. margin-right: 27upx;
  259. display: flex;
  260. align-items: center;
  261. .head{
  262. width: 48upx;
  263. height: 48upx;
  264. border-radius: 50%;
  265. overflow: hidden;
  266. box-shadow: 0 0 0 1px #fff;
  267. margin-right: -10upx;
  268. image{
  269. width: 100%;
  270. height: 100%;
  271. }
  272. }
  273. }
  274. .readings{
  275. display: flex;
  276. align-items: center;
  277. .eye{
  278. width: 26upx;
  279. height: 20upx;
  280. margin-right: 9upx;
  281. }
  282. .num{
  283. font-size: 24upx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #999999;
  287. line-height: 1;
  288. }
  289. }
  290. }
  291. .time{
  292. font-size: 24upx;
  293. line-height: 1;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. color: #999999;
  297. }
  298. }
  299. }
  300. }
  301. }
  302. </style>