Browse Source

feat: 对接首页和个人中心页的部分接口

Moss 1 năm trước cách đây
mục cha
commit
bad8c5008b

+ 34 - 21
src/pages/index/index.vue

@@ -19,9 +19,9 @@
         </view>
 
         <view class="category-container card mt30">
-          <view class="item" v-for="(item, index) in categoryList" :key="index" @tap="$navPage(`/pages/goods/list`)">
-            <image src="@/static/user/icon_2.png"></image>
-            <view class="name">家用空调</view>
+          <view class="item" v-for="(item, index) in categoryList" :key="index" @tap="$navPage(`/pages/goods/list?${item.categoryId}`)">
+            <image :src="imageUrl + item.imgUrl"></image>
+            <view class="name">{{item.categoryName}}</view>
           </view>
         </view>
 
@@ -31,24 +31,22 @@
         </view>
 
         <view class="common-goods-list">
-          <view class="item card" v-for="(item, index) in [1,2,3]" :key="index" @tap="$navPage(`/pages/goods/detail`)">
+          <view class="item card" v-for="(item, index) in dataList" :key="index" @tap="$navPage(`/pages/goods/detail`)">
             <view class="top">
               <image src="@/static/common/logo.png"></image>
               <view class="user">
-                <view class="name">张三</view>
-                <view class="time">23小时前发布</view>
+                <view class="name">{{item.userName}}</view>
+                <view class="time">{{item.createTime}}</view>
               </view>
-              <view class="price">¥1888.00</view>
+              <view class="price">{{item.amount | priceFilter2}}</view>
             </view>
-            <view class="title">商品名称</view>
-            <view class="des">商品描述</view>
+            <view class="title">{{item.title}}</view>
+            <view class="des">{{item.content}}</view>
             <view class="imgs">
-              <image src="@/static/user/other_speech.png"></image>
-              <image src="@/static/user/other_speech.png"></image>
-              <image src="@/static/user/other_speech.png"></image>
+              <image :src="imgUrl + it.imgUrl" v-for="(it, idx) in item.goodsFiles" :key="idx"></image>
             </view>
             <view class="bottom">
-              <view class="left-location">天河区棠下</view>
+              <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
               <view class="right-stats">
                 <view class="it">
                   <text class="iconfont icon-dianzan"></text>
@@ -66,6 +64,8 @@
             </view>
           </view>
         </view>
+        
+        <Loading :loadStatus="loadStatus" :dataList="dataList" />
 
       </view>
 
@@ -81,9 +81,10 @@
   export default {
     data() {
       return {
-        imgUrl: this.$imageUrl,
+        imageUrl: this.$imageUrl,
         dataList: [],
         pageNum: 1,
+        loadStatus: 0,
         refresherTriggered: false,
         keyword: '',
         bannerList: [
@@ -91,7 +92,7 @@
           'https://cdn.uviewui.com/uview/swiper/swiper2.png',
           'https://cdn.uviewui.com/uview/swiper/swiper1.png',
         ],
-        categoryList: [1, 2, 3, 4],
+        categoryList: [],
         tabList: [{
             name: '默认顺序',
             value: 1
@@ -119,13 +120,25 @@
     },
 
     async onLoad() {
-      // await this.getList()
+      await this.getCategory();
+      await this.getList();
     },
 
     methods: {
+      async getCategory() {
+        return new Promise((resolve, reject) => {
+          this.$api.get('/goods/category/list')
+          .then(res => {
+            this.categoryList = res.data || [];
+          }).finally(res => {
+            resolve(1);
+          })
+        })
+      },
+
       //获取列表数据
       async getList() {
-        this.$api.post('/xxx/xxxlist', {
+        this.$api.get('/goods/list', {
           pageNum: this.pageNum,
           pageSize: 10,
         }).then(res => {
@@ -137,8 +150,6 @@
           this.dataList = this.dataList.concat(list);
         }).catch(() => {
           this.loadStatus = 2;
-        }).finally(res => {
-          this.refresherTriggered = false;
         })
       },
 
@@ -151,11 +162,13 @@
       },
 
       // 触发下拉刷新
-      refresherrefresh(e) {
+      async refresherrefresh(e) {
         this.refresherTriggered = true;
         this.dataList = [];
         this.pageNum = 1;
         this.getList();
+        await this.getCategory();
+        this.refresherTriggered = false;
       },
 
     }
@@ -217,4 +230,4 @@
       }
     }
   }
-</style>
+</style>

+ 34 - 11
src/pages/mine/index.vue

@@ -93,7 +93,7 @@ export default {
         { name: '我的收益', num: 0, url: '/pages/mine/myEarnings/list' },
       ],
       issueStats: [
-        { name: '我的发布', icon: 'icon-xiangji', num: 1 },
+        { name: '我的发布', icon: 'icon-xiangji', num: 0 },
         { name: '已卖出', icon: 'icon-xiangji', num: 0 },
         { name: '已下架', icon: 'icon-xiangji', num: 0 },
       ],
@@ -135,19 +135,42 @@ export default {
 
   methods: {
     // 触发下拉刷新
-    refresherrefresh(e) {
+    async refresherrefresh(e) {
     	this.refresherTriggered = true;
+      await this.getStats();
+      await this.getIssueStats();
+      this.refresherTriggered = false;
+    },
 
+    // 获取统计
+    async getStats() {
+      return new Promise((resolve, reject) => {
+        this.$api.get('/likeOrCollect/countLikeCollect', {
+          userId: this.$store.state.user.userId,
+        }).then(res => {
+          if(!res.data) return false;
+          this.userStats[0].num = res.data.dz;
+          this.userStats[1].num = res.data.sc;
+          this.userStats[2].num = res.data.sy;
+        }).finally(res => {
+          resolve(1);
+        })
+      })
     },
-    
-    getStats() {
-      this.$api.get('/likeOrCollect/countLikeCollect', {
-        userId: this.$store.state.user.userId,
-      }).then(res => {
-        if(!res.data) return false;
-        this.userStats[0].num = res.data.dz;
-        this.userStats[1].num = res.data.sc;
-        this.userStats[2].num = res.data.sy;
+
+    // 获取我发布的统计
+    async getIssueStats() {
+      return new Promise((resolve, reject) => {
+        this.$api.get('/goods/count', {
+          userId: this.$store.state.user.userId,
+        }).then(res => {
+          if(!res.data) return false;
+          this.issueStats[0].num = res.data.fb;
+          this.issueStats[1].num = res.data.mc;
+          this.issueStats[2].num = res.data.xj;
+        }).finally(res => {
+          resolve(1);
+        })
       })
     },
 

+ 15 - 12
src/pages/mine/myEarnings/list.vue

@@ -66,17 +66,21 @@
     },
 
     async onLoad() {
-      this.getStats();
-      await this.getList()
+      await this.getStats();
+      await this.getList();
     },
 
     methods: {
       getStats() {
-        this.$api.get('/likeOrCollect/countLikeCollect', {
-          userId: this.$store.state.user.userId,
-        }).then(res => {
-          if(!res.data) return false;
-          this.count = res.data;
+        return new Promise((resolve, reject) => {
+          this.$api.get('/likeOrCollect/countLikeCollect', {
+            userId: this.$store.state.user.userId,
+          }).then(res => {
+            if(!res.data) return false;
+            this.count = res.data;
+          }).finally(res => {
+            resolve(1);
+          })
         })
       },
 
@@ -94,8 +98,6 @@
           this.dataList = this.dataList.concat(list);
         }).catch(() => {
 					this.loadStatus = 2;
-				}).finally(res => {
-					this.refresherTriggered = false;
 				})
       },
 
@@ -108,12 +110,13 @@
       },
 
       // 触发下拉刷新
-      refresherrefresh(e) {
+      async refresherrefresh(e) {
       	this.refresherTriggered = true;
       	this.dataList = [];
       	this.pageNum = 1;
-      	this.getList();
-        this.getStats();
+      	await this.getList();
+        await this.getStats();
+      	this.refresherTriggered = false;
       },
 
       toDetail(id) {

+ 1 - 1
src/pages/mine/myLike.vue

@@ -14,7 +14,7 @@
             <view class="name">{{item.userName}}</view>
             <view class="time">{{item.createTime}}</view>
           </view>
-          <view class="price">{{item.amount | priceFilter}}</view>
+          <view class="price">{{item.amount | priceFilter2}}</view>
         </view>
         <view class="title">{{item.title}}</view>
         <view class="des">{{item.content}}</view>