index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. time: util.day(res.data.data.timeSpend),
  65. studyLog: util.studyTime(res.data.data.studyLog)
  66. })
  67. if(res.data.data.studyLog.length > 10) {
  68. this.setData({
  69. height: '700'
  70. })
  71. }
  72. })
  73. //获取排名
  74. APIClient.getFriendSchedule('wx/friendsRank/user', {
  75. uid: res.data.data.uid
  76. }).success(res => {
  77. console.log(res)
  78. this.setData({
  79. rankData: res.data.data,
  80. })
  81. })
  82. }, function() {
  83. wx.showModal({
  84. title: '提示',
  85. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除勋章战士后再次扫码进入,允许授权后可正常使用',
  86. showCancel: false,
  87. success: function (res) {
  88. if (res.confirm) {
  89. console.log('用户点击确定')
  90. } else if (res.cancel) {
  91. console.log('用户点击取消')
  92. }
  93. }
  94. })
  95. });
  96. },
  97. })