152 lines
3.0 KiB
JavaScript
152 lines
3.0 KiB
JavaScript
const baseUrl = getApp();
|
|
const api = require('../../config/api.js');
|
|
const util = require('../../config/util.js');
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
listdata:[],
|
|
baseurl: baseUrl.globalData.baseimgurl,
|
|
liveclickopen: 2,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
baseUrl.islogin();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getcollectioncourse();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
liveopen(e) {
|
|
let arr = [];
|
|
console.log('---------');
|
|
console.log(this.data.listdata);
|
|
arr = Array.from(this.data.listdata);
|
|
// arr = this.data.listdata;
|
|
// console.log(e.currentTarget.dataset.itemid);
|
|
console.log(arr);
|
|
arr.forEach(function(item, index) {
|
|
|
|
if (index == e.currentTarget.dataset.itemid) {
|
|
item['liveclickopen'] = 1;
|
|
arr[index] = item;
|
|
} else {
|
|
item['liveclickopen'] = 2;
|
|
arr[index] = item
|
|
}
|
|
});
|
|
console.log(arr);
|
|
this.setData({
|
|
listdata: arr
|
|
})
|
|
},
|
|
liveclose(e) {
|
|
|
|
let arr = [];
|
|
arr = Array.from(this.data.listdata);
|
|
console.log(e.currentTarget.dataset.itemid);
|
|
arr.forEach(function (item, index) {
|
|
|
|
if (index == e.currentTarget.dataset.itemid) {
|
|
item['liveclickopen'] = 2;
|
|
arr[index] = item;
|
|
} else {
|
|
item['liveclickopen'] = 2;
|
|
arr[index] = item
|
|
}
|
|
});
|
|
console.log(arr);
|
|
this.setData({
|
|
listdata: arr
|
|
})
|
|
},
|
|
communityclick:function(e){
|
|
|
|
console.log(e.currentTarget.id);
|
|
wx.navigateTo({
|
|
url: '/pages/courselearning/courselearning?id='+e.currentTarget.id,
|
|
})
|
|
},
|
|
collectioncourseclick:function(params) {
|
|
wx.navigateTo({
|
|
url: '/pages/collectionsub/collectionsub',
|
|
})
|
|
},
|
|
getcollectioncourse:function () {
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/course/mycollectcourse';
|
|
var param = {
|
|
user_id: wx.getStorageSync('wxuserid')==null?3:wx.getStorageSync('wxuserid'),
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.post(url, param).then((res) => {
|
|
console.log(res.data);
|
|
that.setData({
|
|
listdata: res.data
|
|
});
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
itemclickurl:function(e){
|
|
console.log(e);
|
|
// return;
|
|
let typeid=e.currentTarget.dataset.typeid;
|
|
wx.navigateTo({
|
|
url: '/pages/courselearning/courselearning?id=' + e.currentTarget.id+'&typeid='+typeid,
|
|
})
|
|
}
|
|
|
|
}) |