//index.js //获取应用实例 var app = getApp(); var APIClient = require('../../utils/APIClient.js'); const login = require('../../utils/loginSchedule.js'); Page({ data: { scheduleList: [], flag: true, idvalue:"", goto: false }, onLoad(options) { this.getClassSchedule(); let scene = decodeURIComponent(options.scene); console.log(scene); if (scene && scene !== 'undefined') { let idParam = scene.split('&')[0]; let showIdParam = scene.split('&')[1]; let idKey = idParam.split('=')[0]; let idvalue = idParam.split('=')[1]; this.setData({ goto:true, idvalue:idvalue }) let showIdKey = showIdParam.split('=')[0]; let showIdvalue = showIdParam.split('=')[1]; if (idKey === 'id' && idvalue && idvalue !== 'undefined' && showIdKey === 'showId' && showIdvalue && showIdvalue !== 'undefined') { wx.navigateTo({ url: `/pages/schedule/scheduleSubject/scheduleSubject?id=${idvalue}&showId=${showIdvalue}` }) } if (idKey === 'id' && idvalue && idvalue !== 'undefined') { console.log(idvalue); wx.navigateTo({ url: `/pages/schedule/scheduleSubject/scheduleSubject?id=${idvalue}` }) } } }, onPullDownRefresh: function () { // 页面相关事件处理函数--监听用户下拉动作 this.getClassSchedule() wx.stopPullDownRefresh(); }, onShareAppMessage: function() { // 用户点击右上角分享 return { title: '课程表列表', // 分享标题 desc: '课程表列表', // 分享描述 path: `pages/index/index`, // 分享路径 success: (res) => { console.log(res); } } }, getClassSchedule() { wx.showToast({ title: '加载中...', icon: 'loading', duration: 4000 }) login.getOpenidSessionKeyTwo(() => {}, () => { this.setData({ flag: !this.data.flag }) }) APIClient.getClassSchedule().success((res) => { this.setData({ scheduleList: res.data.data.list }) console.log('课程列表', res.data.data); wx.hideToast() }).fail(function (res) { console.log(res) }) }, navToSchedule(e) { let id = e.currentTarget.dataset.id; let title = e.currentTarget.dataset.title; wx.navigateTo({ url: `/pages/schedule/scheduleSubject/scheduleSubject?id=${id}&title=${title}` }) }, /*获取个人信息弹框*/ jurisdiction: function () { this.setData({ flag: !this.data.flag }) if(this.data.goto){ wx.navigateTo({ url: `/pages/schedule/scheduleSubject/scheduleSubject?id=${this.data.idvalue}` }) } } })