123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //index.js
- //获取应用实例
- const app = getApp()
- const util = require('../../utils/util.js');
- const APIClient = require('../../utils/APIClient.js');
- const login = require('../../utils/loginSchedule.js');
- Page({
- data: {
- motto: ['我的','本周推荐','语文','数学','中文','英语','科学','艺术'],
- navBtnSelectIdx: 0,
- left: 0,
- //questionsPreviewing: false,
- //questionsShare: false,
- data: {},
- grade: "",
- time: "",
- rankData: {},
- share: false,
- studyLog: [],
- height: '',
- productionData: {},
- num2: 0,
- productionMore: ''
- },
-
- lower: function (e) {
- //console.log(e);
- //console.log(e.detail.scrollTop)
- // if (320 <= e.detail.scrollTop && e.detail.scrollTop <= 1000){
- // this.setData({ questionsPreviewing: true, questionsShare: false});
- // }else {
- // this.setData({ questionsPreviewing: false });
- // }
- // if (1090 <= e.detail.scrollTop) {
- // this.setData({ questionsPreviewing: false, questionsShare: true});
- // } else {
- // this.setData({ questionsShare: false });
- // }
- },
- setgrade: function (e) {
- //console.log(this.setGrade)
- this.setGrade.showPopup()
- },
- onLoad: function (options) {
- //获取更改年级组件
- this.setGrade = this.selectComponent("#set-grade");
- console.log(this.setGrade)
- //获取分享过来的值跳转页面
- const ind = options.ind;
- const postsId = options.postId || '';
- //判断ind的值移动到到艺术
- if(ind) {
- this.setData({
- navBtnSelectIdx: ind
- })
- //移动nav
- if (ind <= 2) {
- this.setData({ left: 0 });
- }
- if(ind > 2){
- this.setData({left: 200 });
- }
- }
- /* 分享 */
- const columnId = util.column('6').columnId;
- this.distinction(2, columnId, 1, 2, res => {
- if(res.data.success) {
- console.log(res.data.data)
- this.setData({
- productionData: res.data.data
- })
- if(res.data.data) {
- if(res.data.data.totalSize > 2) {
- this.setData({
- productionMore: true
- })
- }
- }
- }
- });
- },
- onShow: function () {
- //登录页信息
- login.getOpenidSessionKey(res => {
- APIClient.getMySchedule({
- uid: res.data.data.uid
- }).success(res => {
- console.log(res)
- this.setData({
- data: res.data.data,
- grade: util.gradeUpper(res.data.data.users.grade),
- test:util.day(),
- time: util.day(res.data.data.timeSpend),
- studyLog: util.studyTime(res.data.data.studyLog)
- })
-
- if(res.data.data.studyLog.length > 10) {
- this.setData({
- height: '700'
- })
- }
- })
- //获取排名
- APIClient.getFriendSchedule('wx/friendsRank/user', {
- uid: res.data.data.uid
- }).success(res => {
- console.log(res)
- this.setData({
- rankData: res.data.data,
- })
- })
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- },
- /* 区分答疑和分享 */
- distinction: function(type, columnId, pageNo, pageSize, success) {
- login.getOpenidSessionKey(function(res) {
- //console.log(res.data.data.uid);
- APIClient.getProductionSchedule({
- uid: res.data.data.uid
- }, {
- "type": type,
- "category": columnId,
- "pageNo": pageNo,
- "pageSize": pageSize
- }).success(success)
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- },
- /*点击加载更多*/
- onMyEvent: function(e){
- const columnId = util.column('6').columnId;
- this.data.num2++
- this.setData({
- num: this.data.num2
- })
- this.distinction(2, columnId, 1, 5*this.data.num2, res => {
- if(res.data.success) {
- console.log(res.data.data)
- this.setData({
- productionData: res.data.data,
- })
- if(5*this.data.num2 > res.data.data.totalSize) {
- this.setData({
- productionMore: ''
- })
- }
- }
- });
- },
- })
|