1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- var APIClient = require('../../../utils/APIClient.js');
- Page({
- data: {
- userInfo: wx.getStorageSync('userInfo'),
- swiperList: [],
- currentIndex: 0,
- currentId: '',
- id: '',
- showId: '',
- title: ''
- },
- onLoad(options) {
- console.log(wx.getStorageSync('userInfo'));
- this.setData({
- userInfo: wx.getStorageSync('userInfo'),
- id: options.id
- })
- if(options.title) {
- wx.setNavigationBarTitle({
- title: options.title
- })
- }
- if (options.showId) {
- this.getClassScheduleWeeklyQR(this.data.id, this.data.userInfo.id, options.showId);
- } else {
- this.getClassSchedule(this.data.id, this.data.userInfo.id);
- }
- },
- onShareAppMessage: function() {
- // 用户点击右上角分享
- let title = this.data.title
- let id = this.data.id
- let index = this.data.currentIndex
- let showId = this.data.swiperList[index].categoryId
- return {
- title: title, // 分享标题
- desc: title, // 分享描述
- path: `pages/index/index?id=${id}&showId=${showId}` // 分享路径
- }
- },
- switchContent(e) {
- console.log(e.detail.current);
- this.setData({
- currentIndex: e.detail.current
- })
- wx.setNavigationBarTitle({
- title: this.data.swiperList[e.detail.current].mainTitle
- })
- },
- // 获取课程列表
- getClassSchedule(itemId, userId) {
- APIClient.getClassScheduleWeekly(itemId, userId).success(function (res) {
- console.log('轮播图', res);
- if (res.data.success) {
- this.setData({
- swiperList: res.data.data.items,
- currentId: res.data.data.currentId
- })
- this.getCurrentIndex(this.data.currentId, this.data.swiperList)
- }
- }.bind(this))
- },
- // 获取课程列表qr
- getClassScheduleWeeklyQR(itemId, userId, showId) {
- APIClient.getClassScheduleWeeklyQR(itemId, userId, showId).success(function (res) {
- console.log('轮播图', res);
- if (res.data.success) {
- this.setData({
- swiperList: res.data.data.items,
- currentId: res.data.data.currentId
- })
- this.getCurrentIndex(this.data.currentId, this.data.swiperList)
- }
- }.bind(this))
- },
- toScheduleSubjectInner(e) {
- let id = e.currentTarget.dataset.id
- console.log(id);
- wx.navigateTo({
- url: `/pages/schedule/scheduleSubjectInner/scheduleSubjectInner?id=${id}`
- })
- },
- getCurrentIndex(id, arr) {
- let len = arr.length;
- for (let i = 0; i < len; i++) {
- if (arr[i].categoryId === id) {
- this.setData({
- currentIndex: i
- })
- return;
- }
- }
- }
- })
|