doctorArticleList.vue 7.3 KB

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