doctorArticleList.vue 7.8 KB

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