index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. const util = require('../../utils/util.js');
  5. const APIClient = require('../../utils/APIClient.js');
  6. const login = require('../../utils/loginSchedule.js');
  7. Page({
  8. data: {
  9. motto: ['我的','本周推荐','语文','数学','中文','英语','科学','艺术'],
  10. navBtnSelectIdx: 0,
  11. left: 0,
  12. //questionsPreviewing: false,
  13. //questionsShare: false,
  14. data: {},
  15. grade: "",
  16. time: "",
  17. rankData: {},
  18. share: false,
  19. studyLog: [],
  20. height: ''
  21. },
  22. lower: function (e) {
  23. //console.log(e);
  24. //console.log(e.detail.scrollTop)
  25. // if (320 <= e.detail.scrollTop && e.detail.scrollTop <= 1000){
  26. // this.setData({ questionsPreviewing: true, questionsShare: false});
  27. // }else {
  28. // this.setData({ questionsPreviewing: false });
  29. // }
  30. // if (1090 <= e.detail.scrollTop) {
  31. // this.setData({ questionsPreviewing: false, questionsShare: true});
  32. // } else {
  33. // this.setData({ questionsShare: false });
  34. // }
  35. },
  36. onLoad: function (options) {
  37. //获取分享过来的值跳转页面
  38. const ind = options.ind;
  39. const postsId = options.postId || '';
  40. //判断ind的值移动到到艺术
  41. if(ind) {
  42. this.setData({
  43. navBtnSelectIdx: ind
  44. })
  45. //移动nav
  46. if (ind <= 2) {
  47. this.setData({ left: 0 });
  48. }
  49. if(ind > 2){
  50. this.setData({left: 200 });
  51. }
  52. }
  53. },
  54. onShow: function () {
  55. //登录页信息
  56. login.getOpenidSessionKey(res => {
  57. APIClient.getMySchedule({
  58. uid: res.data.data.uid
  59. }).success(res => {
  60. console.log(res)
  61. this.setData({
  62. data: res.data.data,
  63. grade: util.gradeUpper(res.data.data.users.grade),
  64. test:util.day(),
  65. time: util.day(res.data.data.timeSpend),
  66. studyLog: util.studyTime(res.data.data.studyLog)
  67. })
  68. if(res.data.data.studyLog.length > 10) {
  69. this.setData({
  70. height: '700'
  71. })
  72. }
  73. })
  74. //获取排名
  75. APIClient.getFriendSchedule('wx/friendsRank/user', {
  76. uid: res.data.data.uid
  77. }).success(res => {
  78. console.log(res)
  79. this.setData({
  80. rankData: res.data.data,
  81. })
  82. })
  83. }, function() {
  84. wx.showModal({
  85. title: '提示',
  86. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  87. showCancel: false,
  88. success: function (res) {
  89. if (res.confirm) {
  90. console.log('用户点击确定')
  91. } else if (res.cancel) {
  92. console.log('用户点击取消')
  93. }
  94. }
  95. })
  96. });
  97. },
  98. })