Преглед изворни кода

1.推荐页banner开发年级筛选2.联调官方推荐页面

bayi пре 2 година
родитељ
комит
5dce5bd4bd

+ 1 - 1
api/global.js

@@ -11,7 +11,7 @@ module.exports = {
   // 提交任务
   submitTask: data => request('/v3/task', 'post', data),
   // 获取轮播图列表
-  getBannerList: data => request(`/v3/banner/${data}`, 'get', data),
+  getBannerList: data => request('/v3/banner', 'get', data),
   // 获取官方活动
   getActivities: data => request('/v3/activity', 'get', data),
   // 获取排行榜详情

+ 9 - 8
components/authority/index.wxml

@@ -1,19 +1,20 @@
 <view class="authority">
-  <view class="module">
-    <view class="topic">热门推荐</view>
-    <view class="explain">一句一句话介绍一句话介绍句话介绍</view>
+  <view class="module" wx:for="{{worksList}}" wx:key="index">
+    <view class="topic">{{item.title}}</view>
+    <view class="explain">{{item.intro}}</view>
     <view class="works">
-      <view class="work" wx:for="{{worksList}}" wx:key="index" bindtap="jumpReading" data-id='{{item.userRead.id}}'>
-        <image src="{{item.userRead.coverImg}}" class="cover" wx:if="{{item.userReadExtend.resourcesType==0}}" />
+      <view class="work" wx:for="{{item.userReadList}}" wx:for-item='work' wx:key="index" bindtap="jumpReading"
+        data-id='{{work.userRead.id}}'>
+        <image src="{{work.userRead.coverImg}}" class="cover" wx:if="{{work.userReadExtend.resourcesType==0}}" />
         <view class="audioBox" wx:else>
-          <image src="{{item.userReadExtend.backgroundVirtualImg}}" class="cover" />
+          <image src="{{work.userReadExtend.backgroundVirtualImg}}" class="cover" />
           <view class="audioPlay">
             <image src="/static/audioBg.png" class="audioPlayBg" />
             <image src="/static/zhen.png" class="audioPlayZhen" />
-            <image src="{{item.userRead.coverImg}}" class="cover" />
+            <image src="{{work.userRead.coverImg}}" class="cover" />
           </view>
         </view>
-        <view class="textOver title">{{item.userRead.title}}</view>
+        <view class="textOver title">{{work.userRead.title}}</view>
       </view>
     </view>
   </view>

+ 8 - 16
components/banner/index.js

@@ -1,29 +1,21 @@
-import {
-  getBannerList
-} from '~/api/global'
 Component({
   properties: {
-    // banner的classify是:1:官方推荐;2:作品展播;3:官方活动;4:关注作品;5:我的作品;
-    classify: {
-      type: Number,
-      value: 1,
-      observer(newVal) {
-        this.getBannerList()
+    bannerList: {
+      type: Array,
+      value: [],
+      observer() {
+        this.setData({
+          current: 0
+        })
       }
     }
+    // banner的classify是:1:官方推荐;2:作品展播;3:官方活动;4:关注作品;5:我的作品;
   },
   data: {
     bannerList: [],
     current: 0
   },
   methods: {
-    async getBannerList() {
-      let bannerList = await getBannerList(this.properties.classify)
-      this.setData({
-        bannerList,
-        current: 0
-      })
-    },
     bannelEvent({
       currentTarget
     }) {

+ 0 - 3
components/uploadFile/index.js

@@ -19,9 +19,6 @@ Component({
     fields: {
       readDetail: 'readDetail'
     },
-    actions: {
-      setReadDetail: 'setReadDetail'
-    }
   },
   /**
    * 组件的属性列表

+ 40 - 18
pages/index/index.js

@@ -4,6 +4,9 @@ import {
   getAuthorityList,
   getCategoryList
 } from "~/api/works"
+import {
+  getBannerList
+} from '~/api/global'
 import reachBottom from '~/mixins/reachBottom'
 import share from '~/mixins/share'
 import {
@@ -17,12 +20,13 @@ Page({
   data: {
     navBarHeight: app.globalData.navBarHeight,
     background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
-    currentType: '1',
+    currentType: '2',
     // 控制一级分类是否固定
     isFixed: false,
     desktopTips: app.globalData.desktopTips,
     isIOS: app.globalData.isIOS,
-    categoryList: []
+    categoryList: [],
+    bannerList: []
   },
   /**
    * 生命周期函数--监听页面加载
@@ -35,11 +39,11 @@ 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()
       }
     }
     let {
@@ -72,7 +76,7 @@ Page({
     })
     this.storeBindings.updateStoreBindings()
   },
-  loadMore() {
+  async loadMore() {
     if (!this.data.userInfo.grade) {
       return
     }
@@ -81,11 +85,13 @@ Page({
         grade: this.data.userInfo.grade
       })
     } else if (this.data.currentType == '1') {
-      this.localGetData(getAuthorityList, {
+      let list = await getAuthorityList({
         grade: this.data.userInfo.grade
       })
+      this.setData({
+        list
+      })
     }
-    this.getCategoryList()
   },
   jumpChildClassify({
     currentTarget
@@ -124,28 +130,44 @@ Page({
       categoryList
     })
   },
+  closeDesktop() {
+    this.setData({
+      desktopTips: false
+    })
+    wx.setStorage({
+      key: "preDesktopTime",
+      data: new Date()
+    })
+  },
+  async getBannerList() {
+    let bannerList = await getBannerList({
+      grade: this.data.userInfo.grade,
+      classify: this.data.currentType
+    })
+    this.setData({
+      bannerList,
+    })
+  },
+  requestAgain() {
+    this.resetData()
+    this.getCategoryList()
+    this.getBannerList()
+  },
   selectType({
     target
   }) {
     if (target.dataset.type) {
-      if (target.dataset.type == '7') {
+      if (this.selectComponent('#worksList')) {
         this.selectComponent('#worksList').resetAudio()
       }
       this.setData({
-        currentType: target.dataset.type
+        currentType: target.dataset.type,
+        list: [],
       })
       if (target.dataset.type != '7') {
         this.resetData()
       }
+      this.getBannerList()
     }
   },
-  closeDesktop() {
-    this.setData({
-      desktopTips: false
-    })
-    wx.setStorage({
-      key: "preDesktopTime",
-      data: new Date()
-    })
-  }
 })

+ 3 - 3
pages/index/index.wxml

@@ -1,8 +1,8 @@
-<navigationBar bind:reload='resetData'></navigationBar>
+<navigationBar bind:reload='requestAgain'></navigationBar>
 <view class="recommend">
-  <banner classify='{{currentType}}' />
+  <banner bannerList="{{bannerList}}" />
   <!-- 加桌提示 -->
-  <view class="desktopTips" wx:if="{{desktopTips}}" style="top:{{navBarHeight+3}}px" bindtap="closeDesktop">
+  <view class=" desktopTips" wx:if="{{desktopTips}}" style="top:{{navBarHeight+3}}px" bindtap="closeDesktop">
     <view class="triangle"></view>
     <image
       src="{{isIOS?'http://reader-wx.ai160.com/images/reader/v3/desktop-ios.png':'http://reader-wx.ai160.com/images/reader/v3/desktop-android.png'}}"

+ 5 - 5
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 { */
-baseUrl = 'https://reader-api.ai160.com/wx'
-oldUrl = 'https://reader-api.ai160.com'
-// }
+} else {
+  baseUrl = 'https://reader-api.ai160.com/wx'
+  oldUrl = 'https://reader-api.ai160.com'
+}
 
 function request(url, method, data, oldBaseUrl = false) {
   let header = {