doctorArticleList.vue 7.6 KB

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