index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //index.js
  2. //获取应用实例
  3. var app = getApp();
  4. var APIClient = require('../../utils/APIClient.js');
  5. const login = require('../../utils/loginSchedule.js');
  6. Page({
  7. data: {
  8. scheduleList: [],
  9. flag: true
  10. },
  11. onLoad(options) {
  12. this.getClassSchedule();
  13. let scene = decodeURIComponent(options.scene);
  14. if (scene && scene !== 'undefined') {
  15. let idParam = scene.split('&')[0];
  16. let showIdParam = scene.split('&')[1];
  17. let idKey = idParam.split('=')[0];
  18. let idvalue = idParam.split('=')[1];
  19. let showIdKey = showIdParam.split('=')[0];
  20. let showIdvalue = showIdParam.split('=')[1];
  21. if (idKey === 'id' && idvalue && idvalue !== 'undefined' && showIdKey === 'showId' && showIdvalue && showIdvalue !== 'undefined') {
  22. wx.navigateTo({
  23. url: `/pages/schedule/scheduleSubject/scheduleSubject?id=${idvalue}&showId=${showIdvalue}`
  24. })
  25. }
  26. }
  27. },
  28. onPullDownRefresh: function () {
  29. // 页面相关事件处理函数--监听用户下拉动作
  30. this.getClassSchedule()
  31. wx.stopPullDownRefresh();
  32. },
  33. onShareAppMessage: function() {
  34. // 用户点击右上角分享
  35. return {
  36. title: '课程表列表', // 分享标题
  37. desc: '课程表列表', // 分享描述
  38. path: `pages/index/index`, // 分享路径
  39. success: (res) => {
  40. console.log(res);
  41. }
  42. }
  43. },
  44. getClassSchedule() {
  45. wx.showToast({
  46. title: '加载中...',
  47. icon: 'loading',
  48. duration: 4000
  49. })
  50. login.getOpenidSessionKeyTwo(() => {}, () => {
  51. this.setData({
  52. flag: !this.data.flag
  53. })
  54. })
  55. APIClient.getClassSchedule().success((res) => {
  56. this.setData({
  57. scheduleList: res.data.data.list
  58. })
  59. console.log('课程列表', res.data.data);
  60. wx.hideToast()
  61. }).fail(function (res) {
  62. console.log(res)
  63. })
  64. },
  65. navToSchedule(e) {
  66. let id = e.currentTarget.dataset.id;
  67. let title = e.currentTarget.dataset.title;
  68. wx.navigateTo({
  69. url: `/pages/schedule/scheduleSubject/scheduleSubject?id=${id}&title=${title}`
  70. })
  71. },
  72. /*获取个人信息弹框*/
  73. jurisdiction: function () {
  74. this.setData({
  75. flag: !this.data.flag
  76. })
  77. }
  78. })