index.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. },
  21. lower: function (e) {
  22. //console.log(e);
  23. //console.log(e.detail.scrollTop)
  24. // if (320 <= e.detail.scrollTop && e.detail.scrollTop <= 1000){
  25. // this.setData({ questionsPreviewing: true, questionsShare: false});
  26. // }else {
  27. // this.setData({ questionsPreviewing: false });
  28. // }
  29. // if (1090 <= e.detail.scrollTop) {
  30. // this.setData({ questionsPreviewing: false, questionsShare: true});
  31. // } else {
  32. // this.setData({ questionsShare: false });
  33. // }
  34. },
  35. onLoad: function (options) {
  36. //获取分享过来的值跳转页面
  37. const ind = options.ind;
  38. const postsId = options.postId || '';
  39. //判断ind的值移动到到艺术
  40. if(ind) {
  41. this.setData({
  42. navBtnSelectIdx: ind
  43. })
  44. //移动nav
  45. if (ind <= 2) {
  46. this.setData({ left: 0 });
  47. }
  48. if(ind > 2){
  49. this.setData({left: 200 });
  50. }
  51. }
  52. },
  53. onShow: function () {
  54. //登录页信息
  55. login.getOpenidSessionKey(res => {
  56. APIClient.getMySchedule({
  57. uid: res.data.data.uid
  58. }).success(res => {
  59. console.log(res)
  60. this.setData({
  61. data: res.data.data,
  62. grade: util.gradeUpper(res.data.data.users.grade),
  63. time: util.day(res.data.data.timeSpend),
  64. studyLog: util.studyTime(res.data.data.studyLog)
  65. })
  66. })
  67. //获取排名
  68. APIClient.getFriendSchedule('wx/friendsRank/user', {
  69. uid: res.data.data.uid
  70. }).success(res => {
  71. console.log(res)
  72. this.setData({
  73. rankData: res.data.data,
  74. })
  75. })
  76. }, function() {
  77. wx.showModal({
  78. title: '提示',
  79. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  80. showCancel: false,
  81. success: function (res) {
  82. if (res.confirm) {
  83. console.log('用户点击确定')
  84. } else if (res.cancel) {
  85. console.log('用户点击取消')
  86. }
  87. }
  88. })
  89. });
  90. },
  91. })