doctorArticleList.vue 7.8 KB

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