207 lines
4.2 KiB
JavaScript
207 lines
4.2 KiB
JavaScript
// packageA/member/course/VoiceList/VoiceList.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
isAsc: true,
|
|
voiceList: [],
|
|
display_order: '',
|
|
//more
|
|
total: 0,
|
|
isLoadMore: true,
|
|
page: 1,
|
|
total_page: 0,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
this.getData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
if(this.data.page >= this.data.total_page){
|
|
return;
|
|
}else{
|
|
let pages = this.data.page + 1;
|
|
this.data.page = pages;
|
|
this.getMoreData();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
},
|
|
getMoreData(){
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss("plugin.article.api.article.audioArticle");
|
|
urlStr += '&display_order=' + this.data.display_order;
|
|
urlStr += '&page=' + this.data.page;
|
|
that.setData({
|
|
isLoadMore: false,
|
|
page: this.data.page
|
|
});
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success:((resdata)=>{
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
isLoadMore: true,
|
|
total_page: res.data.last_page,
|
|
total: res.data.total
|
|
});
|
|
if (!that.data.total_page) {
|
|
that.setData({
|
|
total_page: 0
|
|
});
|
|
}
|
|
if (!that.data.total) {
|
|
that.setData({
|
|
total: 0
|
|
});
|
|
}
|
|
that.setData({
|
|
voiceList: this.data.voiceList.concat(res.data.data)
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
}
|
|
}),
|
|
fail:((res)=>{
|
|
console.log(res);
|
|
})
|
|
});
|
|
},
|
|
//获取数据
|
|
getData() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss("plugin.article.api.article.audioArticle");
|
|
urlStr += '&display_order=' + this.data.display_order;
|
|
that.setData({
|
|
isLoadMore: false,
|
|
page: 1
|
|
});
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
isLoadMore: true,
|
|
total_page: res.data.last_page,
|
|
total: res.data.total
|
|
});
|
|
if (!that.data.total_page) {
|
|
that.setData({
|
|
total_page: 0
|
|
});
|
|
}
|
|
if (!that.data.total) {
|
|
that.setData({
|
|
total: 0
|
|
});
|
|
}
|
|
that.setData({
|
|
voiceList: res.data.data
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
changeAsc() {
|
|
this.setData({
|
|
isAsc: !this.data.isAsc
|
|
});
|
|
if (this.data.isAsc) {
|
|
this.setData({
|
|
display_order: ''
|
|
});
|
|
} else {
|
|
this.setData({
|
|
display_order: 1
|
|
});
|
|
}
|
|
this.getData();
|
|
},
|
|
toVoice(e) {
|
|
let item = e.currentTarget.dataset.item;
|
|
if (item.has_one_article_pay){
|
|
if (item.has_one_record) {
|
|
wx.navigateTo({
|
|
url: '/packageA/member/course/VoiceDetail/VoiceDetail?article_id=' + item.id
|
|
});
|
|
}else{
|
|
wx.navigateTo({
|
|
url: '/packageD/article/articleList/articleList?article_id=' + item.id
|
|
});
|
|
}
|
|
}else{
|
|
wx.navigateTo({
|
|
url: '/packageA/member/course/VoiceDetail/VoiceDetail?article_id=' + item.id
|
|
});
|
|
}
|
|
// wx.navigateTo({
|
|
// url: '/packageA/member/course/VoiceDetail/VoiceDetail?article_id=' + item.id
|
|
// })
|
|
},
|
|
});
|