bayi 1 year ago
parent
commit
9acaefe1c9
6 changed files with 45 additions and 7 deletions
  1. 2 0
      api/works.js
  2. 9 2
      pages/works/index.js
  3. 16 2
      pages/works/index.less
  4. 3 0
      pages/works/index.wxml
  5. 12 0
      pages/works/index.wxss
  6. 3 3
      utils/request.js

+ 2 - 0
api/works.js

@@ -10,6 +10,8 @@ module.exports = {
     getCategoryWorks: data => request('/v3/column/opus', 'get', data),
     // 作品查询
     searchWorks: data => request('/v3/recommend/query', 'get', data),
+    // 获取我的、关注、收藏作品数量
+    getWorksNum: data => request('/v3/user/myCount', 'get', data),
     // 获取优秀作品展播列表
     getHotrecommendList: data => request('/userRead/recommend', 'get', data),
     //   获取资源页面接口

+ 9 - 2
pages/works/index.js

@@ -1,6 +1,7 @@
 import share from '~/mixins/share'
 import {
     getHotrecommendList,
+    getWorksNum
 } from "~/api/works"
 import event from '~/mixins/event'
 import reachBottom from '~/mixins/reachBottom'
@@ -13,7 +14,8 @@ import {
 Page({
     behaviors: [reachBottom, share, event],
     data: {
-        isFixed: false
+        isFixed: false,
+        count:{}
     },
     onShow() {
         if (typeof this.getTabBar === 'function') {
@@ -39,8 +41,13 @@ Page({
             grade: this.data.userInfo.grade
         })
     },
-    requestAgain() {
+    async requestAgain() {
         this.resetData()
+        let count = await getWorksNum()
+        console.log(count);
+        this.setData({
+            count
+        })
     },
     async getLocUserInfo() {
         this.storeBindings = createStoreBindings(this, {

+ 16 - 2
pages/works/index.less

@@ -4,19 +4,32 @@
 
     .itemize {
         margin-bottom: 90rpx;
-        padding:0 60rpx;
+        padding: 0 60rpx;
         display: flex;
         align-items: center;
         justify-content: space-between;
 
         .box {
+            position: relative;
             text-align: center;
             font-size: 28rpx;
 
+            .count {
+                position: absolute;
+                top: 0;
+                right: 0;
+                padding: 4rpx 11rpx;
+                background: #FED806;
+                border-radius: 20rpx 20rpx 20rpx 2rpx;
+                font-size: 18rpx;
+                font-weight: 500;
+                color: #F01515;
+            }
+
             .img {
                 margin-bottom: 10rpx;
                 width: 156rpx;
-                height: 111rpx;
+                height: 111rpx; 
             }
         }
     }
@@ -27,6 +40,7 @@
         align-items: center;
         font-size: 36rpx;
         color: #000000;
+
         .icon {
             width: 50rpx;
             height: 50rpx;

+ 3 - 0
pages/works/index.wxml

@@ -3,14 +3,17 @@
     <view class="itemize">
         <view class="box" bindtap="jump" data-type='my'>
             <image src="/static/works-1.png" class="img" />
+            <view class="count">{{count.myReadCount}}</view>
             <view>我的作品</view>
         </view>
         <view class="box" bindtap="jump" data-type='follow'>
             <image src="/static/works-2.png" class="img" />
+            <view class="count">{{count.myFansReadCount}}</view>
             <view>关注作品</view>
         </view>
         <view class="box" bindtap="jump" data-type='collect'>
             <image src="/static/works-3.png" class="img" />
+            <view class="count">{{count.myFavoritesCount}}</view>
             <view>收藏作品</view>
         </view>
     </view>

+ 12 - 0
pages/works/index.wxss

@@ -10,9 +10,21 @@
   justify-content: space-between;
 }
 .worksBox .itemize .box {
+  position: relative;
   text-align: center;
   font-size: 28rpx;
 }
+.worksBox .itemize .box .count {
+  position: absolute;
+  top: 0;
+  right: 0;
+  padding: 4rpx 11rpx;
+  background: #FED806;
+  border-radius: 20rpx 20rpx 20rpx 2rpx;
+  font-size: 18rpx;
+  font-weight: 500;
+  color: #F01515;
+}
 .worksBox .itemize .box .img {
   margin-bottom: 10rpx;
   width: 156rpx;

+ 3 - 3
utils/request.js

@@ -6,13 +6,13 @@ const {
         envVersion
     }
 } = wx.getAccountInfoSync();
-if (envVersion == 'develop') {
+// if (envVersion == 'develop') {
     baseUrl = 'https://reader-api.efunbox.cn/wx'
     oldUrl = 'https://reader-api.efunbox.cn'
-} else {
+/* } else {
     baseUrl = 'https://reader-api.ai160.com/wx'
     oldUrl = 'https://reader-api.ai160.com'
-}
+} */
 
 function request(url, method, data, oldBaseUrl = false, intercept = true) {
     let header = {