bayi пре 2 година
родитељ
комит
7b23e27e32
8 измењених фајлова са 129 додато и 13 уклоњено
  1. 2 0
      api/works.js
  2. 1 1
      app.json
  3. 8 7
      pages/index/index.js
  4. 40 5
      pages/works/index.js
  5. 36 0
      pages/works/index.less
  6. 7 0
      pages/works/index.wxml
  7. 32 0
      pages/works/index.wxss
  8. 3 0
      store/index.js

+ 2 - 0
api/works.js

@@ -6,4 +6,6 @@ module.exports = {
   getHotrecommendList: data => request('/userRead/recommend', 'get', data),
   // 发布作品
   publishWorks: data => request('/userRead', 'post', data),
+  // 获取关注的人的作品
+  getFollowWorks: data => request('/fans/interest', 'get', data),
 }

+ 1 - 1
app.json

@@ -1,7 +1,7 @@
 {
   "pages": [
-    "pages/index/index",
     "pages/works/index",
+    "pages/index/index",
     "pages/collection/index",
     "pages/personal/index",
     "pages/childClassify/index",

+ 8 - 7
pages/index/index.js

@@ -2,9 +2,6 @@ const app = getApp()
 import {
   getHotrecommendList
 } from "~/api/works"
-import {
-  getBannerList
-} from '~/api/global'
 import reachBottom from '~/mixins/reachBottom'
 import {
   createStoreBindings
@@ -33,9 +30,15 @@ Page({
         selected: 1
       })
     }
-    getApp().callBack = (res) => {
+    let uid = wx.getStorageSync('uid')
+    if (uid) {
       this.getLocUserInfo()
-      this.loadMore()
+      this.resetData()
+    } else {
+      getApp().callBack = (res) => {
+        this.getLocUserInfo()
+        this.resetData()
+      }
     }
   },
   onUnload() {
@@ -49,8 +52,6 @@ Page({
       },
     })
     this.storeBindings.updateStoreBindings()
-    /*  let res = await getBannerList(1)
-     console.log(res); */
   },
   loadMore() {
     if (this.data.currentType == '1') {

+ 40 - 5
pages/works/index.js

@@ -2,9 +2,19 @@ const app = getApp()
 import {
   getBannerList
 } from '~/api/global'
+import {
+  getSelfRead
+} from '~/api/user'
+import {
+  getFollowWorks
+} from '~/api/works'
+import reachBottom from '~/mixins/reachBottom'
 Page({
+  behaviors: [reachBottom],
   data: {
-    bannerList: []
+    bannerList: [],
+    // 1关注的人的作品,2是自己的作品
+    currentType: '1',
   },
   onShow() {
     if (typeof this.getTabBar === 'function') {
@@ -12,17 +22,42 @@ Page({
         selected: 2
       })
     }
-    getApp().callBack = (res) => {
+    let uid = wx.getStorageSync('uid')
+    if (uid) {
+      this.resetData()
+    } else {
+      getApp().callBack = (res) => {
+        this.resetData()
+      }
+    }
+  },
+  loadMore() {
+    if (this.data.currentType == '1') {
+      this.getData(getFollowWorks, {})
+    } else if (this.data.currentType == '2') {
+      this.getData(getSelfRead, {})
+    }
+  },
+  async getFollowWorks() {
+    let res = await getFollowWorks()
+    console.log(res);
+  },
+  changeType({
+    target
+  }) {
+    if (target.dataset.type) {
+      this.setData({
+        currentType: target.dataset.type
+      })
+      this.resetData()
     }
   },
-
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom() {
-
+    this.loadMore()
   },
-
   /**
    * 用户点击右上角分享
    */

+ 36 - 0
pages/works/index.less

@@ -1,3 +1,39 @@
 .worksBox {
 
+  .selectType {
+    padding: 30rpx 15rpx 30rpx 26rpx;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+
+    .type {
+      padding: 14rpx 0rpx;
+      width: 200rpx;
+      box-sizing: border-box;
+      text-align: center;
+      border: 1rpx solid #9f9f9fa4;
+      border-radius: 50rpx;
+      color: #1A1A1A;
+      font-size: 24rpx;
+    }
+
+    .currentType {
+      border: none;
+      box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
+      background-color: white;
+      font-weight: bold;
+    }
+
+    .search {
+      padding: 8rpx 20rpx;
+      text-align: center;
+      border: 1rpx solid #9f9f9fa4;
+      border-radius: 50rpx;
+
+      .searchImg {
+        width: 26rpx;
+        height: 26rpx;
+      }
+    }
+  }
 }

+ 7 - 0
pages/works/index.wxml

@@ -2,4 +2,11 @@
 <view class="worksBox">
   <!-- 轮播图 -->
   <banner classify='1' />
+  <!-- 切换类型 -->
+  <view class="selectType" bindtap="changeType">
+    <view class="type {{currentType=='1'?'currentType':''}}" data-type='1'>关注作品</view>
+    <view class="type {{currentType=='2'?'currentType':''}}" data-type='2'>我的作品</view>
+  </view>
+  <!-- 优秀作品展播及官方推荐列表组件 -->
+  <worksList id="worksList" worksList="{{list}}" />
 </view>

+ 32 - 0
pages/works/index.wxss

@@ -0,0 +1,32 @@
+.worksBox .selectType {
+  padding: 30rpx 15rpx 30rpx 26rpx;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.worksBox .selectType .type {
+  padding: 14rpx 0rpx;
+  width: 200rpx;
+  box-sizing: border-box;
+  text-align: center;
+  border: 1rpx solid #9f9f9fa4;
+  border-radius: 50rpx;
+  color: #1A1A1A;
+  font-size: 24rpx;
+}
+.worksBox .selectType .currentType {
+  border: none;
+  box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
+  background-color: white;
+  font-weight: bold;
+}
+.worksBox .selectType .search {
+  padding: 8rpx 20rpx;
+  text-align: center;
+  border: 1rpx solid #9f9f9fa4;
+  border-radius: 50rpx;
+}
+.worksBox .selectType .search .searchImg {
+  width: 26rpx;
+  height: 26rpx;
+}

+ 3 - 0
store/index.js

@@ -23,10 +23,13 @@ export const store = observable({
       "PRIMARY_SECOND_GRADE": "二年级",
       "PRIMARY_THREE_GRADE": "三年级",
       "PRIMARY_SENIOR_GRADE": "四年级",
+      "PRIMARY_FIVE_GRADE":"五年级",
+      "PRIMARY_SIX_GRADE":"五年级",
       "PRESCHOOL": "学前班",
     }
     step.gradeName = grade ? gradeObj[grade] : '请选择'
     this.userInfo = step
+    console.log(this.userInfo);
   }, ),
   setReadDetail: action(function (detail) {
     this.readDetail = detail