index.js 2.5 KB

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