123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- // pages/art/art.js
- const app = getApp()
- const util = require('../../utils/util.js');
- const APIClient = require('../../utils/APIClient.js');
- const login = require('../../utils/loginSchedule.js');
- Page({
- data: {
- flag: false,
- productionData: {},
- questionsData: {},
- courseData: {},
- num1: 0,
- num2: 0,
- position: '',
- questionsdian: '',
- list: [],
- lessonListHeight: '',
- previewHeight: '',
- productionMore: '',
- questionsMore: '',
- wxObjectives: []
- },
- /* 区分答疑和分享 */
- distinction: function(type, columnId, pageNo, pageSize, success) {
- login.getOpenidSessionKey(function(res) {
- //console.log(res.data.data.uid);
- APIClient.getProductionSchedule({
- uid: res.data.data.uid
- }, {
- "type": type,
- "columnId": columnId,
- "pageNo": pageNo,
- "pageSize": pageSize
- }).success(success)
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除勋章战士后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- },
- /*点击查看更多*/
- onMyEvent: function(e){
- let type = e.currentTarget.dataset.type;
- const columnId = util.column('5').columnId;
- if(type == 1) {
- this.data.num1++
- this.setData({
- num1: this.data.num1
- })
- this.distinction(type, columnId, 1, 5*this.data.num1, res => {
- if(res.data.success) {
- console.log(res.data.data)
- this.setData({
- questionsData: res.data.data,
- })
- if(res.data.data) {
- this.setData({
- questionsdian: util.replyNo(res.data.data.list)
- })
- if(5*this.data.num1 > res.data.data.totalSize) {
- this.setData({
- questionsMore: ''
- })
- }
- }
- }
- });
- }
-
- if(type == 2) {
- this.data.num2++
- this.setData({
- num: this.data.num2
- })
- this.distinction(type, columnId, 1, 5*this.data.num2, res => {
- if(res.data.success) {
- console.log(res.data.data)
- this.setData({
- productionData: res.data.data,
- })
- if(5*this.data.num2 > res.data.data.totalSize) {
- this.setData({
- productionMore: ''
- })
- }
- }
- });
- }
- },
- /*点击定位*/
- location: function (e) {
- const position = e.currentTarget.dataset.id;
- console.log(position)
- this.setData({
- position: position
- })
- },
- onLoad: function (options) {
- const columnId = util.column('5').columnId;
- /* 分享 */
- this.distinction(2, columnId, 1, 2, res => {
- if(res.data.success) {
- console.log(res.data.data)
- this.setData({
- productionData: res.data.data,
- })
- if(res.data.data) {
- if(res.data.data.totalSize > 2) {
- this.setData({
- productionMore: true
- })
- }
- }
- }
-
- });
- /* 答疑 */
- this.distinction(1, columnId, 1, 2, res => {
- if(res.data.success) {
- console.log(res.data.data)
- this.setData({
- questionsData: res.data.data,
- })
- if(res.data.data) {
- this.setData({
- questionsdian: util.replyNo(res.data.data.list)
- })
- if(res.data.data.totalSize > 2) {
- this.setData({
- questionsMore: true
- })
- }
- }
- }
- });
- /*科目信息*/
- login.getOpenidSessionKey((res) => {
- //console.log(res.data.data.uid);
- APIClient.getEachSchedule({
- uid: res.data.data.uid
- }, {
- "category": 5
- }).success((res) => {
- //console.log('科目信息' + JSON.stringify(res));
- const lessonListLength = res.data.data.lessonPage.list.length;
- const previewLength = util.preview(res.data.data.lessonPage.list).length;
- console.log(res)
- if(lessonListLength > 4) {
- this.setData({
- lessonListHeight: 280
- })
- }
- if(previewLength > 4){
- this.setData({
- previewHeight: 280
- })
- }
- this.setData({
- courseData: res.data.data,
- list: util.studyPageTime(res.data.data.lessonPage.list),
- wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
- })
- })
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除勋章战士后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- //分享按钮
- wx.showShareMenu({
- withShareTicket: true
- })
- },
- onShow: function () {
-
- },
- /* 转发*/
- onShareAppMessage: function (ops) {
- if (ops.from === 'button') {
- // 来自页面内转发按钮
- console.log(ops.target)
- }
- const postId = ops.target.dataset.postid;
- return {
- title: '勋章战士',
- path: `pages/transmit/transmit?ind=6&postId=${postId}`,
- success: function (res) {
- // 转发成功
- console.log("转发成功:" + JSON.stringify(res));
- },
- fail: function (res) {
- // 转发失败
- console.log("转发失败:" + JSON.stringify(res));
- }
- }
- },
- })
|