index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. wx.showShareMenu({
  41. withShareTicket: true
  42. })
  43. //判断ind的值移动到到艺术
  44. if(ind) {
  45. this.setData({
  46. navBtnSelectIdx: ind
  47. })
  48. //移动nav
  49. if (ind <= 2) {
  50. this.setData({ left: 0 });
  51. }
  52. if(ind > 2){
  53. this.setData({left: 200 });
  54. }
  55. }
  56. },
  57. onShow: function () {
  58. //登录页信息
  59. login.getOpenidSessionKey(res => {
  60. APIClient.getMySchedule({
  61. uid: res.data.data.uid
  62. }).success(res => {
  63. console.log(res)
  64. this.setData({
  65. data: res.data.data,
  66. grade: util.gradeUpper(res.data.data.users.grade),
  67. test:util.day(),
  68. time: util.day(res.data.data.timeSpend),
  69. studyLog: util.studyTime(res.data.data.studyLog)
  70. })
  71. if(res.data.data.studyLog.length > 10) {
  72. this.setData({
  73. height: '700'
  74. })
  75. }
  76. })
  77. //获取排名
  78. APIClient.getFriendSchedule('wx/friendsRank/user', {
  79. uid: res.data.data.uid
  80. }).success(res => {
  81. console.log(res)
  82. this.setData({
  83. rankData: res.data.data,
  84. })
  85. })
  86. }, function() {
  87. wx.showModal({
  88. title: '提示',
  89. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除勋章战士后再次扫码进入,允许授权后可正常使用',
  90. showCancel: false,
  91. success: function (res) {
  92. if (res.confirm) {
  93. console.log('用户点击确定')
  94. } else if (res.cancel) {
  95. console.log('用户点击取消')
  96. }
  97. }
  98. })
  99. });
  100. },
  101. })