doctorArticleList.vue 7.7 KB

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