Переглянути джерело

开发资源页面、删除其他页面代码

bayi 1 рік тому
батько
коміт
ee97be2676

+ 1 - 1
app.wxss

@@ -68,7 +68,7 @@ text {
 }
 
 .isFixed2 {
-    width: 100%;
+    width: 100% !important;
     box-sizing: border-box;
     background-color: white;
     box-shadow: 0px 26rpx 24rpx rgba(0, 0, 0, 0.1);

+ 1 - 21
pages/index/index.js

@@ -1,7 +1,6 @@
 const app = getApp()
 import {
     getHotrecommendList,
-    getCategoryList
 } from "~/api/works"
 import {
     getBannerList
@@ -23,7 +22,6 @@ Page({
         // 控制一级分类是否固定
         isFixed: false,
         desktopTips: app.globalData.desktopTips,
-        categoryList: [],
         bannerList: []
     },
     onLoad(options) {
@@ -83,15 +81,6 @@ Page({
             })
         }
     },
-    jumpChildClassify({
-        currentTarget
-    }) {
-        let firstInfo = currentTarget.dataset.item
-        let params = firstInfo.childList.length > 0 ? `list=${encodeURIComponent(JSON.stringify(firstInfo.childList))}` : `id=${firstInfo.id}`
-        wx.navigateTo({
-            url: `/pages/childClassify/index?type=class&title=${firstInfo.title}&${params}`,
-        })
-    },
     jumpSearch() {
         wx.navigateTo({
             url: '/pages/childClassify/index?type=search',
@@ -111,15 +100,7 @@ Page({
             })
         }
     },
-    async getCategoryList() {
-        let grade = this.data.userInfo.grade
-        let categoryList = await getCategoryList({
-            grade
-        })
-        this.setData({
-            categoryList
-        })
-    },
+
     closeDesktop() {
         this.setData({
             desktopTips: false
@@ -139,7 +120,6 @@ Page({
     },
     requestAgain() {
         this.resetData()
-        this.getCategoryList()
         this.getBannerList()
         if (this.data.currentType != 3) {
             this.selectComponent('#activityList').getActivities()

+ 1 - 23
pages/index/index.less

@@ -25,29 +25,7 @@
   .scrollBox {
     width: 100%;
 
-    .firstClassify {
-      padding: 24rpx 0rpx 20rpx;
-      width: 100%;
-      white-space: nowrap;
-      background-color: white;
-      .firstBox {
-        text-align: center;
-        display: inline-block;
-        width: 98rpx;
-        padding: 0rpx 20rpx;
-
-        .icon {
-          width: 60rpx;
-          height: 60rpx;
-        }
-
-        .name {
-          margin-top: 6rpx;
-          font-weight: bold;
-          font-size: 28rpx;
-        }
-      }
-    }
+  
   }
 
   .selectType {

+ 0 - 8
pages/index/index.wxml

@@ -8,14 +8,6 @@
     </view>
     <!-- 滚动定位 -->
     <view class="scrollBox {{isFixed?'isFixed':''}}" style="top:{{navBarHeight}}px;">
-        <!-- 一级分类区域 -->
-        <!-- <scroll-view class="firstClassify" scroll-x="true" enhanced show-scrollbar="{{false}}">
-            <view class="firstBox" wx:for="{{categoryList}}" wx:key="id" data-item='{{item}}'
-                bindtap="jumpChildClassify">
-                <image class="icon" src="{{item.icon}}" />
-                <view class="name">{{item.title}}</view>
-            </view>
-        </scroll-view> -->
         <!-- 展示类型选择 -->
         <view class="selectType {{isFixed?'isFixed2':''}}" bindtap="selectType">
             <view class="type {{currentType=='2'?'currentType':''}}" data-type='2'>排行榜</view>

+ 0 - 21
pages/index/index.wxss

@@ -22,27 +22,6 @@
 .recommend .scrollBox {
   width: 100%;
 }
-.recommend .scrollBox .firstClassify {
-  padding: 24rpx 0rpx 20rpx;
-  width: 100%;
-  white-space: nowrap;
-  background-color: white;
-}
-.recommend .scrollBox .firstClassify .firstBox {
-  text-align: center;
-  display: inline-block;
-  width: 98rpx;
-  padding: 0rpx 20rpx;
-}
-.recommend .scrollBox .firstClassify .firstBox .icon {
-  width: 60rpx;
-  height: 60rpx;
-}
-.recommend .scrollBox .firstClassify .firstBox .name {
-  margin-top: 6rpx;
-  font-weight: bold;
-  font-size: 28rpx;
-}
 .recommend .selectType {
   padding: 30rpx 15rpx 30rpx 26rpx;
   display: flex;

+ 42 - 6
pages/resource/index.js

@@ -2,6 +2,7 @@ import {
     createStoreBindings
 } from 'mobx-miniprogram-bindings'
 import {
+    getCategoryList,
     getAuthorityList,
 } from "~/api/works"
 import share from '~/mixins/share'
@@ -11,8 +12,10 @@ import {
 } from '~/store/index'
 Page({
     behaviors: [reachBottom, share],
-    data: {},
-
+    data: {
+        categoryList: [],
+        isFixed: false
+    },
     onShow() {
         if (typeof this.getTabBar === 'function') {
             this.getTabBar().setData({
@@ -21,14 +24,18 @@ Page({
         }
         this.getLocUserInfo()
         if (Object.keys(this.data.userInfo).length > 0) {
-            this.resetData()
+            this.requestAgain()
         } else {
             getApp().callBack = (res) => {
                 this.getLocUserInfo()
-                this.resetData()
+                this.requestAgain()
             }
         }
     },
+    requestAgain() {
+        this.resetData()
+        this.getCategoryList()
+    },
     async loadMore() {
         if (!this.data.userInfo.grade) {
             return
@@ -40,8 +47,23 @@ Page({
             list
         })
     },
-    onReachBottom() {
-        this.loadMore()
+    async getCategoryList() {
+        let grade = this.data.userInfo.grade
+        let categoryList = await getCategoryList({
+            grade
+        })
+        this.setData({
+            categoryList
+        })
+    },
+    jumpChildClassify({
+        currentTarget
+    }) {
+        let firstInfo = currentTarget.dataset.item
+        let params = firstInfo.childList.length > 0 ? `list=${encodeURIComponent(JSON.stringify(firstInfo.childList))}` : `id=${firstInfo.id}`
+        wx.navigateTo({
+            url: `/pages/childClassify/index?type=class&title=${firstInfo.title}&${params}`,
+        })
     },
     onUnload() {
         this.storeBindings.destroyStoreBindings()
@@ -58,4 +80,18 @@ Page({
     onUnload() {
         this.storeBindings.destroyStoreBindings()
     },
+    /**
+     * 监听页面滚动事件
+     */
+    onPageScroll(e) {
+        if (e.scrollTop >= 6 && !this.data.isFixed) {
+            this.setData({
+                isFixed: true
+            })
+        } else if (e.scrollTop < 6 && this.data.isFixed) {
+            this.setData({
+                isFixed: false
+            })
+        }
+    },
 })

+ 27 - 0
pages/resource/index.less

@@ -0,0 +1,27 @@
+.firstClassify {
+    padding: 24rpx 0rpx 20rpx;
+    width: 710rpx;
+    margin: 0 auto 40rpx;
+    left: 0;
+    right: 0;
+    overflow: hidden;
+    border-radius: 10rpx;
+    white-space: nowrap;
+    background-color: white;
+
+    .firstBox {
+        text-align: center;
+        display: inline-block;
+        width: 98rpx;
+        padding: 0rpx 20rpx;
+        font-size: 0;
+        .icon {
+            width: 84rpx;
+            height: 84rpx;
+        }
+        .name {
+            font-weight: bold;
+            font-size: 28rpx;
+        }
+    }
+}

+ 7 - 0
pages/resource/index.wxml

@@ -1,4 +1,11 @@
 <navigationBar bind:reload='resetData'></navigationBar>
 <view>
+    <scroll-view class="firstClassify {{isFixed?'isFixed isFixed2':''}}" scroll-x="true" enhanced
+        show-scrollbar="{{false}}">
+        <view class="firstBox" wx:for="{{categoryList}}" wx:key="id" data-item='{{item}}' bindtap="jumpChildClassify">
+            <image class="icon" src="{{item.icon}}" />
+            <view class="name">{{item.title}}</view>
+        </view>
+    </scroll-view>
     <authority worksList="{{list}}" />
 </view>

+ 26 - 0
pages/resource/index.wxss

@@ -0,0 +1,26 @@
+.firstClassify {
+  padding: 24rpx 0rpx 20rpx;
+  width: 710rpx;
+  margin: 0 auto 40rpx;
+  left: 0;
+  right: 0;
+  overflow: hidden;
+  border-radius: 10rpx;
+  white-space: nowrap;
+  background-color: white;
+}
+.firstClassify .firstBox {
+  text-align: center;
+  display: inline-block;
+  width: 98rpx;
+  padding: 0rpx 20rpx;
+  font-size: 0;
+}
+.firstClassify .firstBox .icon {
+  width: 84rpx;
+  height: 84rpx;
+}
+.firstClassify .firstBox .name {
+  font-weight: bold;
+  font-size: 28rpx;
+}

+ 0 - 13
pages/works/index.js

@@ -1,7 +1,4 @@
 const app = getApp()
-import {
-  getBannerList
-} from '~/api/global'
 import share from '~/mixins/share'
 import {
   getSelfRead,
@@ -21,7 +18,6 @@ Page({
   behaviors: [reachBottom, share],
   data: {
     navBarHeight: app.globalData.navBarHeight,
-    bannerList: [],
     // 4关注作品,5我的作品,6收藏作品
     currentType: '4',
     isFixed: false
@@ -41,7 +37,6 @@ Page({
         this.requestAgain()
       }
     }
-    this.getBannerList()
   },
   loadMore() {
     if (this.data.currentType == '4') {
@@ -52,14 +47,6 @@ Page({
       this.getData(getFavoritesList, {})
     }
   },
-  async getBannerList() {
-    let bannerList = await getBannerList({
-      grade: this.data.userInfo.grade,
-    })
-    this.setData({
-      bannerList,
-    })
-  },
   changeType({
     target
   }) {

+ 0 - 1
pages/works/index.json

@@ -2,7 +2,6 @@
   "usingComponents": {
     "navigationBar": "/components/navigationBar/index",
     "worksList": "/components/worksList/index",
-    "banner": "/components/banner/index",
     "emptyBg": "/components/empty/index"
   },
   "navigationStyle": "custom"

+ 0 - 2
pages/works/index.wxml

@@ -1,7 +1,5 @@
 <navigationBar bind:reload='requestAgain'></navigationBar>
 <view class="worksBox">
-    <!-- 轮播图 -->
-    <!-- <banner bannerList="{{bannerList}}" /> -->
     <!-- 切换类型 -->
     <view class="selectType {{isFixed?'isFixed isFixed2':''}}" style="top:{{navBarHeight}}px;" bindtap="changeType">
         <view class="type {{currentType=='4'?'currentType':''}}" data-type='4'>关注作品</view>