82 lines
1.9 KiB
JavaScript
82 lines
1.9 KiB
JavaScript
// pages/lianxi/index.js
|
|
const api = require("../../utils/request.js");
|
|
Page({
|
|
data: {
|
|
results: [],
|
|
query: {
|
|
page: 1,
|
|
limit: 10,
|
|
type:'视频'
|
|
},
|
|
isAutoPlay:false
|
|
},
|
|
// onLoad: function () {
|
|
// var that = this
|
|
// that.getList(that.data.query)
|
|
// },
|
|
onShow: function () {
|
|
var that = this
|
|
that.getList(that.data.query)
|
|
},
|
|
getList: function () {
|
|
var that = this
|
|
api.request('/cms/material/', 'GET', that.data.query).then(res => {
|
|
// for(var i=0;i<res.data.results.length;i++){
|
|
// res.data.results[i].showTitle=true
|
|
// }
|
|
if (that.data.query.page == 1) {
|
|
that.data.results = res.data.results
|
|
} else {
|
|
that.data.results = that.data.results.concat(res.data.results)
|
|
}
|
|
that.setData({
|
|
results: that.data.results,
|
|
count: res.data.count
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
var that = this
|
|
that.data.query.page = 1;
|
|
that.getList();
|
|
wx.stopPullDownRefresh();
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
var that = this
|
|
if (that.data.count <= that.data.query.page * that.data.query.limit) {
|
|
wx.showToast({
|
|
title: '没有更多了',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
that.data.query.page = that.data.query.page + 1
|
|
that.getList()
|
|
}
|
|
|
|
},
|
|
play:function(e){
|
|
let index = e.currentTarget.dataset.index
|
|
// this.data.results[index].showTitle=false
|
|
this.setData({
|
|
results:this.data.results
|
|
})
|
|
api.request('/cms/material/'+e.currentTarget.dataset.id+'/down/', 'GET').then(res=>{
|
|
|
|
}).catch(e=>{})
|
|
},
|
|
pause:function(e){
|
|
let index = e.currentTarget.dataset.index
|
|
// this.data.results[index].showTitle=true
|
|
this.setData({
|
|
results:this.data.results
|
|
})
|
|
},
|
|
}) |