Parcourir la source

Signed-off-by: zhaobao <528046418@qq.com>

zhaobao il y a 1 an
Parent
commit
b4dbf48557
3 fichiers modifiés avec 42 ajouts et 10 suppressions
  1. 11 0
      api/system/art.js
  2. 27 8
      pages/history/history.vue
  3. 4 2
      pages/index/index.vue

+ 11 - 0
api/system/art.js

@@ -44,3 +44,14 @@ export function getArtByList(data) {
   })
 }
 
+/**
+ * 文章列表
+ * @param data
+ */
+export function getArtByPage(data) {
+  return request({
+    url: '/art/page',
+    method: 'GET',
+    data
+  })
+}

+ 27 - 8
pages/history/history.vue

@@ -28,13 +28,18 @@
 <script>
 	import {getToken}  from '@/libs/auth.js';
 	import {MessageTimeFormat} from '@/libs/index.js';
-	import {getArtCatTop,getArtByList} from '@/api/system/art.js'
+	import {getArtCatTop,getArtByPage} from '@/api/system/art.js'
 	export default {
 		data() {
 			return {
 				artCatId:"",
 				tabs:[],
-				artList:[]
+				artList:[],
+				conditions: {
+					page: 1,
+					limit: 10
+				},
+				total:0
 			}
 		},
 		onShow() {
@@ -44,22 +49,29 @@
 			MessageTimeFormat,
 			changeTab(item){
 				this.artCatId=item.artCatId
-				this.getArtByList()
+				this.conditions={
+					page: 1,
+					limit: 10					
+				}
+				this.getArtByPage()
 			},
 			getArtCatTop(){
 				getArtCatTop().then((res)=>{
 					this.tabs=res.data
 					if(res.data.length>0){
 						this.artCatId=res.data[0].artCatId	
-						this.getArtByList()
+						this.getArtByPage()
 					}
 				})				
 			},
-			getArtByList(){
-				getArtByList({
+			getArtByPage(){
+				let items=JSON.parse(JSON.stringify(this.artList))
+				getArtByPage({
+				  ...this.conditions,
 				  artCatId:this.artCatId
 				}).then((res)=>{
-					this.artList=res.data
+					this.artList=items.concat(res.data)
+					this.total=res.total
 				})  				
 			},
 			showDetail(){
@@ -69,6 +81,12 @@
 				})		
 			}
 		},
+		onReachBottom() {			
+			if(this.total>=this.conditions.page*this.conditions.limit){
+				this.conditions.page++
+				this.getArtByPage()
+			}
+		},
 		onPullDownRefresh() {
 			this.getArtCatTop()
 			uni.stopPullDownRefresh()
@@ -131,8 +149,9 @@
 				display: flex;
 				align-items: center;
 				.tag{
+				  font-size: 20rpx;
 				  display: inline-block;
-				  padding:10rpx 16rpx;
+				  padding:4rpx 6rpx;
 				  border: 1px solid #15CD85;
 				  line-height: 1;
 				  color: #15CD85;

+ 4 - 2
pages/index/index.vue

@@ -42,11 +42,11 @@
 							<image class="icon" src="/static/index/notice.png" mode="widthFix"></image>
 							<text>最近动态</text>
 						</div>
-						<div class="notice-cont">
+						<div class="notice-cont" v-if="showNotice">
 							<uni-notice-bar
 								scrollable :text="notice" 
 								background-color="#fff0"
-								:speed="20"
+								:speed="30"								
 								color="#333" />
 						</div>
 					</div>
@@ -177,6 +177,7 @@
 			return {
 				applist: [],
 				defaultAvatar:"/static/components/avatar.png",
+				showNotice:false,
 				notice:"",
 				user:{
 					groupName: "",
@@ -240,6 +241,7 @@
 						notice+=`${res.data[i].artTitle} 发布时间:${res.data[i].issuedAt};`
 					}
 					this.notice=notice
+					this.showNotice=true
 				})
 				let params={
 					page: 1,