123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //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: '',
- flag: true,
- productionData: {},
- num2: 0,
- productionMore: '',
- canvasHeight: ''
- },
-
- 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 });
- // }
- },
- jurisdiction: function () {
- //隐藏弹框
- this.setData({
- flag: !this.data.flag
- })
- //登录页信息
- this.onShow();
- },
- /*点击获取canvas高度*/
- onGetHeight: function (e) {
- const canvasHeight = this.selectComponent("#chat").data.canvasHeight;
- this.setData({
- canvasHeight,
- })
- },
- /*更改年级*/
- setgrade: function (e) {
- 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 });
- }
- }
- },
- 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: '680'
- })
- }
- })
- //获取排名
- APIClient.getFriendSchedule('wx/friendsRank/user', {
- uid: res.data.data.uid
- }).success(res => {
- console.log(res)
- this.setData({
- rankData: res.data.data,
- })
- })
- }, () => {
- this.setData({
- flag: !this.data.flag
- })
- });
- /* 分享 */
- 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
- })
- }
- }
- }
- });
- },
- /* 区分答疑和分享 */
- 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,
- "pageNo": pageNo,
- "pageSize": pageSize
- }).success(success)
- }, function() {
-
- });
- },
- /*点击加载更多*/
- 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: ''
- })
- }
- }
- });
- },
- /* 转发*/
- onShareAppMessage: function (ops) {
- if (ops.from === 'button') {
- // 来自页面内转发按钮
- console.log(ops.target)
- }
- const postId = ops.target.dataset.postid;
- const imageUrl= ops.target.dataset.imageurl[0];
- return {
- title: '小学王者班',
- path: `pages/transmit/transmit?ind=7&postId=${postId}`,
- imageUrl,
- success: function (res) {
- // 转发成功
- console.log("转发成功:" + JSON.stringify(res));
- },
- fail: function (res) {
- // 转发失败
- console.log("转发失败:" + JSON.stringify(res));
- }
- }
- }
- })
|