index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. flag: true
  22. },
  23. lower: function (e) {
  24. //console.log(e);
  25. //console.log(e.detail.scrollTop)
  26. // if (320 <= e.detail.scrollTop && e.detail.scrollTop <= 1000){
  27. // this.setData({ questionsPreviewing: true, questionsShare: false});
  28. // }else {
  29. // this.setData({ questionsPreviewing: false });
  30. // }
  31. // if (1090 <= e.detail.scrollTop) {
  32. // this.setData({ questionsPreviewing: false, questionsShare: true});
  33. // } else {
  34. // this.setData({ questionsShare: false });
  35. // }
  36. },
  37. jurisdiction: function () {
  38. //登录页信息
  39. login.getOpenidSessionKey(res => {
  40. //隐藏弹框
  41. this.setData({
  42. flag: !this.data.flag
  43. })
  44. APIClient.getMySchedule({
  45. uid: res.data.data.uid
  46. }).success(res => {
  47. console.log(res)
  48. this.setData({
  49. data: res.data.data,
  50. grade: util.gradeUpper(res.data.data.users.grade),
  51. test:util.day(),
  52. time: util.day(res.data.data.timeSpend),
  53. studyLog: util.studyTime(res.data.data.studyLog)
  54. })
  55. if(res.data.data.studyLog.length > 10) {
  56. this.setData({
  57. height: '700'
  58. })
  59. }
  60. })
  61. //获取排名
  62. APIClient.getFriendSchedule('wx/friendsRank/user', {
  63. uid: res.data.data.uid
  64. }).success(res => {
  65. console.log(res)
  66. this.setData({
  67. rankData: res.data.data,
  68. })
  69. })
  70. }, function() {
  71. wx.showModal({
  72. title: '提示',
  73. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  74. showCancel: false,
  75. success: function (res) {
  76. if (res.confirm) {
  77. console.log('用户点击确定')
  78. } else if (res.cancel) {
  79. console.log('用户点击取消')
  80. }
  81. }
  82. })
  83. });
  84. },
  85. onLoad: function (options) {
  86. //获取分享过来的值跳转页面
  87. const ind = options.ind;
  88. const postsId = options.postId || '';
  89. //判断ind的值移动到到艺术
  90. if(ind) {
  91. this.setData({
  92. navBtnSelectIdx: ind
  93. })
  94. //移动nav
  95. if (ind <= 2) {
  96. this.setData({ left: 0 });
  97. }
  98. if(ind > 2){
  99. this.setData({left: 200 });
  100. }
  101. }
  102. },
  103. onShow: function () {
  104. //登录页信息
  105. login.getOpenidSessionKey(res => {
  106. APIClient.getMySchedule({
  107. uid: res.data.data.uid
  108. }).success(res => {
  109. console.log(res)
  110. this.setData({
  111. data: res.data.data,
  112. grade: util.gradeUpper(res.data.data.users.grade),
  113. test:util.day(),
  114. time: util.day(res.data.data.timeSpend),
  115. studyLog: util.studyTime(res.data.data.studyLog)
  116. })
  117. if(res.data.data.studyLog.length > 10) {
  118. this.setData({
  119. height: '700'
  120. })
  121. }
  122. })
  123. //获取排名
  124. APIClient.getFriendSchedule('wx/friendsRank/user', {
  125. uid: res.data.data.uid
  126. }).success(res => {
  127. console.log(res)
  128. this.setData({
  129. rankData: res.data.data,
  130. })
  131. })
  132. }, () => {
  133. this.setData({
  134. flag: !this.data.flag
  135. })
  136. });
  137. },
  138. })