144 lines
2.9 KiB
JavaScript
144 lines
2.9 KiB
JavaScript
const DEFAULT_PAGE = 0;
|
|
const baseUrl = getApp();
|
|
const api = require('../../config/api.js');
|
|
const util = require('../../config/util.js');
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
startPageX: 0,
|
|
currentView: DEFAULT_PAGE,
|
|
baseurl:baseUrl.globalData.baseimgurl,
|
|
movies: [],
|
|
active: 1,
|
|
challengeactive: 1,
|
|
toView: `card_${DEFAULT_PAGE}`,
|
|
list: [],
|
|
itemdata: [],
|
|
},
|
|
touchStart(e) {
|
|
this.startPageX = e.changedTouches[0].pageX;
|
|
},
|
|
touchEnd(e) {
|
|
|
|
const moveX = e.changedTouches[0].pageX - this.startPageX;
|
|
const maxPage = this.data.list.length - 1;
|
|
if (Math.abs(moveX) >= 150) {
|
|
if (moveX > 0) {
|
|
this.currentView = this.currentView !== 0 ? this.currentView - 1 : 0;
|
|
} else {
|
|
this.currentView = this.currentView !== maxPage ? this.currentView + 1 : maxPage;
|
|
}
|
|
}
|
|
this.setData({
|
|
toView: `card_${this.currentView}`
|
|
});
|
|
},
|
|
touchecard(e) {
|
|
console.log(e.currentTarget.id);
|
|
this.setData({
|
|
active: e.currentTarget.id
|
|
})
|
|
this.getpaperattrlist(e.currentTarget.id);
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
console.log(options);
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getpapertype();
|
|
this.getpaperattrlist(1);
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
examclicking:function(e){
|
|
|
|
console.log(e);
|
|
wx.navigateTo({
|
|
url: '/pages/indexrespage/indexrespage?id='+e.currentTarget.id,
|
|
})
|
|
},
|
|
getpapertype:function(){
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/paperlist/getpapertypelist';
|
|
var param = {
|
|
id: '123456789'
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.get(url, param).then((res) => {
|
|
console.log(res);
|
|
that.setData({
|
|
list: res.data
|
|
});
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
getpaperattrlist:function(params) {
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/res/reslist';
|
|
var param = {
|
|
papertype_id: params
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.get(url, param).then((res) => {
|
|
console.log(res);
|
|
that.setData({
|
|
itemdata: res.data
|
|
});
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
}
|
|
}) |