132 lines
2.6 KiB
JavaScript
132 lines
2.6 KiB
JavaScript
// pages/lianxi/index.js
|
|
const api = require("../../utils/request.js");
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
paperData: [
|
|
// {name:'111',id:1},
|
|
// {name:'222',id:2},
|
|
],
|
|
query:{
|
|
page:1,
|
|
limit:10
|
|
},
|
|
workscopeName:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function () {
|
|
|
|
if (getApp().globalData.userinfo.workscope) {
|
|
this.setData({
|
|
workscopeId: getApp().globalData.userinfo.workscope,
|
|
workscopeName:getApp().globalData.userinfo.workscope_name
|
|
})
|
|
} else {
|
|
wx.switchTab({
|
|
url: '/pages/main/main',
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
// this.getList()
|
|
},
|
|
getList: function () {
|
|
var that = this
|
|
if (that.data.workscopeId) {
|
|
that.data.query.workscope = that.data.workscopeId
|
|
api.request('/examtest/paper/', 'GET', that.data.query).then(res => {
|
|
if (that.data.query.page == 1) {
|
|
that.data.paperData = res.data.results
|
|
} else {
|
|
that.data.paperData = that.data.paperData.concat(res.data.results)
|
|
}
|
|
that.setData({
|
|
paperData: that.data.paperData,
|
|
count: res.data.count
|
|
})
|
|
})
|
|
}
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
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()
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
|
|
startYati: function (e) {
|
|
wx.showLoading({
|
|
title: '正在准备考试',
|
|
mask:true
|
|
})
|
|
api.request('/examtest/paper/' + e.currentTarget.id +'/monitest/', 'GET').then(res => {
|
|
wx.hideLoading()
|
|
try {
|
|
wx.setStorageSync('examtest', res.data)
|
|
} catch (e) { }
|
|
wx.navigateTo({
|
|
url: '/pages/moni/note',
|
|
})
|
|
|
|
})
|
|
},
|
|
}) |