123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- var APIClient = require('../../../utils/APIClient.js');
- const util = require('../../../utils/util.js');
- Page({
- data: {
- userInfo: wx.getStorageSync('userInfo'),
- swiperList: [],
- currentIndex: 0,
- currentId: '',
- id: '',
- showId: '',
- title: ''
- },
- onLoad(options) {
- if(options.scene) {
-
- // let id = util.convertObject(decodeURIComponent(options.scene)).id;
- this.setData({
- userInfo: wx.getStorageSync('userInfo'),
- // id: id
- id: options.id
- })
- }else {
- 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) {
- 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) {
-
- 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
-
- 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;
- }
- }
- }
- })
|