153 lines
3.6 KiB
JavaScript
153 lines
3.6 KiB
JavaScript
const baseUrl = getApp();
|
|
const api = require('../../config/api.js');
|
|
const util = require('../../config/util.js');
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
liveswitch: 1,
|
|
hiddenName: false,
|
|
listdata: [],
|
|
baseurl: baseUrl.globalData.baseimgurl,
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
wx.getChannelsLiveInfo({
|
|
finderUserName: 'sph1',// 这里是视频号id
|
|
success: res => {
|
|
console.log('success:', res)
|
|
},
|
|
fail: res => {
|
|
console.log('fail:', res)
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getlivelist();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
getlivelist: function () {
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/lives/liveslist';
|
|
var param = {
|
|
id: '123456789'
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.get(url, param).then((res) => {
|
|
console.log(res);
|
|
that.setData({
|
|
listdata: res.data
|
|
});
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
clicklives: function (e) {
|
|
console.log(e.currentTarget.id);
|
|
console.log(e.currentTarget.dataset.ids);
|
|
const typeid = e.currentTarget.dataset.ids;
|
|
const id = e.currentTarget.id;
|
|
if (typeid == 0) {
|
|
wx.navigateTo({
|
|
url: '/pages/indexlivesvoid/indexlivesvoid?id=' + id,
|
|
})
|
|
} else {
|
|
wx.navigateTo({
|
|
url: '/pages/indexcourselearning/indexcourselearning?id=' + e.currentTarget.id,
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
liveopen(e) {
|
|
let arr = [];
|
|
arr = this.data.listdata;
|
|
console.log(e.currentTarget.dataset.itemid);
|
|
arr.forEach(function (item, index) {
|
|
|
|
if (index == e.currentTarget.dataset.itemid) {
|
|
item['liveclickopen'] = true;
|
|
item['liveclickclose'] = false;
|
|
arr[index] = item;
|
|
} else {
|
|
item['liveclickopen'] = false;
|
|
item['liveclickclose'] = true;
|
|
arr[index] = item
|
|
}
|
|
})
|
|
this.setData({
|
|
listdata: arr
|
|
})
|
|
},
|
|
liveclose(e) {
|
|
|
|
let arr = [];
|
|
arr = this.data.listdata;
|
|
console.log(e.currentTarget.dataset.itemid);
|
|
arr.forEach(function (item, index) {
|
|
|
|
if (index == e.currentTarget.dataset.itemid) {
|
|
item['liveclickopen'] = false;
|
|
item['liveclickclose'] = true;
|
|
arr[index] = item;
|
|
} else {
|
|
item['liveclickopen'] = true;
|
|
item['liveclickclose'] = false;
|
|
arr[index] = item
|
|
}
|
|
})
|
|
this.setData({
|
|
listdata: arr
|
|
})
|
|
}
|
|
}) |