Browse Source

feat: 对接我的收益

Moss 1 year ago
parent
commit
c0115b8f42

+ 2 - 2
src/filters/index.js

@@ -4,7 +4,7 @@
  * @param {number} num
  * @return {string}
  */
-export function numToFixed(num) {
+export function priceFilter(num) {
 	if(!num) return '0.00';
 	num = Number(num);
 	return num.toFixed(2);
@@ -52,7 +52,7 @@ export function dateToHHmmss(date) {
 	return date.slice(11, 19);
 }
 
-export function priceFilter(val) {
+export function priceFilter2(val) {
 	if(!val && val != 0) return '-';
   if(val == 0) return '面议';
 	val = Number(val);

+ 12 - 0
src/pages/mine/index.vue

@@ -130,6 +130,7 @@ export default {
     this.$getUserInfo().then(data => {
       this.userInfo = data;
     })
+    this.getStats();
   },
 
   methods: {
@@ -138,6 +139,17 @@ export default {
     	this.refresherTriggered = true;
 
     },
+    
+    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;
+      })
+    },
 
     navToPage(url) {
       if(!this.isLogin) {

+ 27 - 8
src/pages/mine/myCollection.vue

@@ -7,7 +7,7 @@
   	@refresherrefresh="refresherrefresh"
   	@scrolltolower="scrolltolower">
     <view class="common-goods-list">
-      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toGoodsDetail(item.id)">
+      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.id)">
         <view class="top">
           <image src="@/static/common/logo.png"></image>
           <view class="user">
@@ -23,8 +23,8 @@
         </view>
         <view class="bottom">
           <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
-          <view class="right-btn">
-            <u-button text="取消点赞" shape="circle"></u-button>
+          <view class="right-btn" @tap.stop>
+            <u-button text="取消收藏" shape="circle" @click="handelCancel(item.id)"></u-button>
           </view>
         </view>
       </view>
@@ -59,7 +59,7 @@
       //获取列表数据
       async getList() {
         this.$api.get('/likeOrCollect/list', {
-          userId: '',
+          userId: this.$store.state.user.userId,
           type: 2,
           pageNum: this.pageNum,
           pageSize: 10,
@@ -88,17 +88,36 @@
       // 触发下拉刷新
       refresherrefresh(e) {
       	this.refresherTriggered = true;
-      	this.dataList = [];
-      	this.pageNum = 1;
-      	this.getList();
+      	this.refreshList();
       },
 
-      toGoodsDetail(id) {
+      refreshList() {
+        this.dataList = [];
+        this.pageNum = 1;
+        this.getList();
+      },
+
+      toDetail(id) {
         this.$navToPage({
           url: `/pages/goods/detail?id=${id}`
         })
       },
 
+      handelCancel(id) {
+        this.$modal({
+          content: '确定要取消收藏吗?'
+        }).then(() => {
+          this.$api.post('/likeOrCollect/likeOrCollect', {
+            userId: this.$store.state.user.userId,
+            goodsId: id,
+            type: 2,
+            operate: 'NO'
+          }).then(res => {
+            this.refreshList();
+          })
+        }).catch(() => {})
+      },
+
     }
   }
   // #endif

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

@@ -7,56 +7,82 @@
   	@scrolltolower="scrolltolower">
     <view class="total-container">
       <view class="top">
-        <view class="num">¥1008.00</view>
+        <view class="num">¥{{count.total || 0}}</view>
         <view class="text">总收益</view>
       </view>
       <view class="bottom">
         <view class="item">
-          <view class="num">¥1008.00</view>
+          <view class="num">¥{{count.yjs || 0}}</view>
           <view class="text">已结算</view>
         </view>
         <view class="item">
-          <view class="num">¥1008.00</view>
+          <view class="num">¥{{count.wjs || 0}}</view>
           <view class="text">待结算</view>
         </view>
       </view>
     </view>
     <view class="list-container">
       <view class="title">收益明细</view>
-      <view class="item" @tap="$navPage(`/pages/mine/myEarnings/detail`)">
+      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.orderId)">
         <view class="left">
-          <view class="row">订单编号:S123456789</view>
-          <view class="row">订单金额:¥1800.00</view>
-          <view class="row">支付时间:2023-09-11 21:22:33</view>
+          <view class="row">订单编号:{{item.orderId}}</view>
+          <view class="row">订单金额:¥{{item.payment | priceFilter}}</view>
+          <view class="row">支付时间:{{item.createTime}}</view>
         </view>
         <view class="right">
-          <view class="status">已结算</view>
-          <view class="price">+150.00</view>
+          <view class="status">{{item.status | statusFilter}}</view>
+          <view class="price">+{{item.amount | priceFilter}}</view>
         </view>
       </view>
     </view>
+
+    <Loading :loadStatus="loadStatus" :dataList="dataList" />
   </zj-page-layout>
 </template>
 
 <script>
   export default {
+    filters: {
+      statusFilter(val) {
+        const MAP = {
+          ING: '结算中',
+          OVER: '已结算',
+          CANCEL: '已取消',
+          EXCEPTION: '异常结算',
+          OFFLINE: '线下结算',
+        }
+        return MAP[val];
+      }
+    },
+
     data() {
       return {
-        imgUrl: this.$imageUrl,
+        count: {},
         dataList: [],
         pageNum: 1,
+        loadStatus: 0,
         refresherTriggered: false,
       }
     },
 
     async onLoad() {
-      // await this.getList()
+      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;
+        })
+      },
+
       //获取列表数据
       async getList() {
-        this.$api.post('/xxx/xxxlist', {
+        this.$api.postJson('/order/share/list', {
           pageNum: this.pageNum,
           pageSize: 10,
         }).then(res => {
@@ -87,6 +113,13 @@
       	this.dataList = [];
       	this.pageNum = 1;
       	this.getList();
+        this.getStats();
+      },
+
+      toDetail(id) {
+        this.$navToPage({
+          url: `/pages/mine/myEarnings/detail?id=${id}`
+        })
       },
 
     }

+ 27 - 8
src/pages/mine/myLike.vue

@@ -7,7 +7,7 @@
   	@refresherrefresh="refresherrefresh"
   	@scrolltolower="scrolltolower">
     <view class="common-goods-list">
-      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toGoodsDetail(item.id)">
+      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.id)">
         <view class="top">
           <image src="@/static/common/logo.png"></image>
           <view class="user">
@@ -23,8 +23,8 @@
         </view>
         <view class="bottom">
           <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
-          <view class="right-btn">
-            <u-button text="取消点赞" shape="circle"></u-button>
+          <view class="right-btn" @tap.stop>
+            <u-button text="取消点赞" shape="circle" @click="handelCancel(item.id)"></u-button>
           </view>
         </view>
       </view>
@@ -59,7 +59,7 @@
       //获取列表数据
       async getList() {
         this.$api.get('/likeOrCollect/list', {
-          userId: '',
+          userId: this.$store.state.user.userId,
           type: 1,
           pageNum: this.pageNum,
           pageSize: 10,
@@ -88,17 +88,36 @@
       // 触发下拉刷新
       refresherrefresh(e) {
       	this.refresherTriggered = true;
-      	this.dataList = [];
-      	this.pageNum = 1;
-      	this.getList();
+      	this.refreshList();
       },
 
-      toGoodsDetail(id) {
+      refreshList() {
+        this.dataList = [];
+        this.pageNum = 1;
+        this.getList();
+      },
+
+      toDetail(id) {
         this.$navToPage({
           url: `/pages/goods/detail?id=${id}`
         })
       },
 
+      handelCancel(id) {
+        this.$modal({
+          content: '确定要取消点赞吗?'
+        }).then(() => {
+          this.$api.post('/likeOrCollect/likeOrCollect', {
+            userId: this.$store.state.user.userId,
+            goodsId: id,
+            type: 1,
+            operate: 'NO'
+          }).then(res => {
+            this.refreshList();
+          })
+        }).catch(() => {})
+      },
+
     }
   }
   // #endif