Parcourir la source

修改用户主页获取相册接口

reghao il y a 2 ans
Parent
commit
ff25a8689d
2 fichiers modifiés avec 17 ajouts et 15 suppressions
  1. 2 2
      src/api/image.js
  2. 15 13
      src/views/user/Home.vue

+ 2 - 2
src/api/image.js

@@ -41,8 +41,8 @@ export function getUserAlbums() {
   return get(imageApi.imageAlbumApi)
 }
 
-export function getUserAlbums1(userId) {
-  return get(imageApi.userAlbumApi + '?userId=' + userId)
+export function getUserAlbums1(page, userId) {
+  return get(imageApi.userAlbumApi + '?page=' + page + '&userId=' + userId)
 }
 
 // 获取相册

+ 15 - 13
src/views/user/Home.vue

@@ -266,19 +266,7 @@ export default {
       if (this.activeName === 'video') {
         this.userVideoListWrapper(this.currentPage, this.userId)
       } else if (this.activeName === 'image') {
-        getUserAlbums1(this.userId).then(resp => {
-          if (resp.code === 0) {
-            const respData = resp.data
-            if (respData.length !== 0) {
-              this.showEmpty = false
-              for (const item of respData) {
-                this.dataList.push(item)
-              }
-            } else {
-              this.showEmpty = true
-            }
-          }
-        })
+        this.userAlbumWrapper(this.currentPage, this.userId)
       } else if (this.activeName === 'audio') {
         getUserAudios(this.userId, this.currentPage).then(resp => {
           if (resp.code === 0) {
@@ -325,6 +313,20 @@ export default {
         }
       })
     },
+    userAlbumWrapper(pageNumber, userId) {
+      getUserAlbums1(pageNumber, userId).then(resp => {
+        if (resp.code === 0) {
+          const respData = resp.data
+          this.dataList = respData.list
+          this.totalSize = respData.totalSize
+          if (this.dataList.length !== 0) {
+            this.showEmpty = false
+          } else {
+            this.showEmpty = true
+          }
+        }
+      })
+    },
     userStatusListWrapper(pageNumber, userId) {
       userStatus(userId, pageNumber).then(resp => {
         if (resp.code === 0) {