doctorArticleList.vue 7.9 KB

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