// pages/specialDiscussion/index.js
|
const app = getApp()
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
barHeight: "",
|
navBarHeight: "",
|
tabList: [{
|
name: '即将直播',
|
amount: ''
|
}, {
|
name: '直播回放',
|
amount: 20
|
}],
|
tabIndex: 0,
|
specialSubjectList: [],
|
|
now: new Date(), // 假设这是当前时间
|
formattedDate: '', // 用于存储格式化后的日期时间字符串
|
batList: [],
|
specialDiscussionList: [],
|
searchValue: '',
|
batListValue: '',
|
loading: false
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad(options) {
|
this.formatDateTime()
|
const systInfo = wx.getSystemInfoSync();
|
const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
|
const navBarHeight =
|
(menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
|
this.setData({
|
barHeight: systInfo.statusBarHeight,
|
navBarHeight: navBarHeight,
|
});
|
this.ceShiList()
|
|
|
this.getCourseTypeListList()
|
|
|
},
|
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload() {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh() {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom() {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage() {
|
|
},
|
goBack() {
|
wx.navigateBack();
|
},
|
onTabsChange(event) {
|
console.log(event.detail.value);
|
const value = event.detail.value
|
|
this.setData({
|
batListValue: value
|
})
|
|
this.specialDiscussionGet(this.data.batList[value])
|
|
|
},
|
onTabsTap(event) {
|
const index = event.currentTarget.dataset.index
|
console.log(index);
|
|
this.setData({
|
tabIndex: index
|
})
|
|
|
this.specialDiscussionGet(this.data.batList[0])
|
|
},
|
// 获取图片文字列表
|
ceShiList() {
|
this.setData({
|
loading: true
|
})
|
let searchObj = {}
|
if (this.data.searchValue) {
|
searchObj = {
|
'Name*': this.data.searchValue.trim()
|
// '||subtitle*': searchInputValue.value.trim()
|
}
|
}
|
|
|
app.MG.store
|
.getProductList({
|
storeInfo: 'jsek_seminar',
|
path: '*',
|
queryType: '*',
|
paging: {
|
start: 0,
|
size: 99
|
},
|
|
fields: {
|
content: [],
|
subtitle: [],
|
backgroundSelection: [],
|
author: [],
|
viewCount: [],
|
startTime: [], //开播时间
|
// "liveTime>=": [formattedDate.value], //直播时间
|
liveTime: [],
|
lecturer: [],
|
position: [],
|
jsek_link: [],
|
...searchObj
|
}
|
})
|
.then((res) => {
|
console.log(res, '000');
|
const specialSubjectList = []
|
res.datas.forEach((item) => {
|
item.price = item.price.toFixed(2)
|
|
|
const date1 = new Date(this.data.formattedDate)
|
const date2 = new Date(item.liveTime)
|
|
// 比较两个日期
|
if (date1 > date2) {
|
// console.log('直播结束,请看回放')
|
} else if (date1 < date2) {
|
// console.log('直播还没开始,请看即将开播')
|
|
specialSubjectList.push(item)
|
|
console.log(specialSubjectList);
|
} else {
|
// console.log('两个时间相同,')
|
}
|
})
|
|
this.setData({
|
specialSubjectList,
|
loading: false,
|
"tabList[0].amount": specialSubjectList.length
|
})
|
})
|
},
|
// 格式化日期时间的方法
|
formatDateTime: function () {
|
let date = new Date();
|
const year = date.getFullYear();
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
const day = date.getDate().toString().padStart(2, '0');
|
const hour = date.getHours().toString().padStart(2, '0');
|
const minute = date.getMinutes().toString().padStart(2, '0');
|
const second = date.getSeconds().toString().padStart(2, '0');
|
const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
this.setData({
|
formattedDate: formattedDate
|
});
|
},
|
onLink(e) {
|
|
const item = e.currentTarget.dataset.item
|
console.log(item.jsek_link);
|
wx.navigateTo({
|
url: '/pages/specialDiscussion/webView/index?link=' + item.jsek_link
|
});
|
},
|
|
async getCourseTypeListList() {
|
|
const quer = {
|
path: '*',
|
filterList: [{
|
value: 'Normal',
|
field: 'state'
|
}],
|
queryType: '\\',
|
searchList: [],
|
size: '20',
|
start: '0',
|
storeRefCode: app.config.seminar,
|
sort: {
|
type: 'Asc',
|
field: 'LinkOrder'
|
},
|
|
}
|
const data = await app.MG.store.getStoreChannelList(quer)
|
let dataList = data.datas
|
|
// data.datas.forEach(item => {
|
// if (item.refCode != "jsek_homepageSeminar") {
|
// console.log(item);
|
// dataList.push(item)
|
// }
|
// })
|
this.setData({
|
batList: dataList
|
})
|
|
|
this.specialDiscussionGet(data.datas[0])
|
|
|
},
|
|
|
specialDiscussionGet(item) {
|
|
let searchObj = {}
|
if (this.data.searchValue) {
|
searchObj = {
|
'Name*': this.data.searchValue.trim()
|
// '||subtitle*': searchInputValue.value.trim()
|
}
|
}
|
const data = []
|
app.MG.store
|
.getProductList({
|
storeInfo: 'jsek_seminar',
|
path: item.refCode,
|
queryType: '*',
|
paging: {
|
start: 0,
|
size: 99
|
},
|
|
fields: {
|
content: [],
|
subtitle: [],
|
backgroundSelection: [],
|
author: [],
|
viewCount: [],
|
startTime: [],
|
liveTime: [],
|
lecturer: [],
|
position: [],
|
jsek_link: [],
|
...searchObj
|
}
|
})
|
.then((res) => {
|
res.datas.forEach((item) => {
|
const date1 = new Date(this.data.formattedDate)
|
const date2 = new Date(item.liveTime)
|
|
// 比较两个日期
|
if (date1 > date2) {
|
// console.log('直播结束,请看回放')
|
data.push(item)
|
} else if (date1 < date2) {
|
// console.log('直播还没开始,请看即将开播')
|
} else {
|
// console.log('两个时间相同,')
|
}
|
})
|
|
this.setData({
|
specialDiscussionList: data,
|
"tabList[1].amount": data.length,
|
|
|
|
})
|
|
console.log(this.data.specialDiscussionList);
|
})
|
},
|
|
searchBook() {
|
console.log(this.data.searchValue);
|
this.ceShiList()
|
this.specialDiscussionGet(this.data.batList[this.data.batListValue])
|
|
|
},
|
|
})
|