169 lines
4.3 KiB
JavaScript
169 lines
4.3 KiB
JavaScript
const baseUrl = getApp();
|
|
const api = require('../../config/api.js');
|
|
const util = require('../../config/util.js');
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据---练习题查看交卷
|
|
*/
|
|
data: {
|
|
coursetypefour_id: 1,
|
|
grouppaper_id: 1,
|
|
listdata: [],
|
|
list: [],
|
|
typeid:1
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
console.log('===============');
|
|
console.log(options);
|
|
this.setData({
|
|
coursetypefour_id: options.id,
|
|
grouppaper_id: options.grouppaper_id,
|
|
typeid:options.typeid
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getexamright();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
jumpitem:function(e){
|
|
|
|
console.log(e.currentTarget.dataset.id);
|
|
const id=e.currentTarget.dataset.id;
|
|
|
|
//得到练习题目
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/exam/getexamasitem';
|
|
var param = {
|
|
id: id
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.post(url, param).then((res) => {
|
|
console.log(res.data);
|
|
wx.navigateTo({
|
|
url: '/pages/examing/examing?examid='+res.data.coursetypefour_id+'&index='+res.data.index+'&now='+res.data.now,
|
|
})
|
|
|
|
|
|
// that.setData({
|
|
// list: res.data.itemdata,
|
|
// listdata: res.data
|
|
// });
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
getexamright: function () {
|
|
//得到练习题目
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/exam/examuseransweras';
|
|
let user_id = wx.getStorageSync('wxuserid') == '' ? 3 : wx.getStorageSync('wxuserid');
|
|
var param = {
|
|
coursetypefour_id: that.data.coursetypefour_id,
|
|
user_id: user_id
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.post(url, param).then((res) => {
|
|
console.log(res.data);
|
|
that.setData({
|
|
list: res.data.itemdata,
|
|
listdata: res.data
|
|
});
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
viewallexplain: function (params) {
|
|
console.log(params);
|
|
console.log(this.data.coursetypefour_id);
|
|
let typeid = this.data.typeid;
|
|
let coursetypefour_id = this.data.coursetypefour_id;
|
|
let grouppaper_id = this.data.grouppaper_id;
|
|
console.log(this.data.list);
|
|
let arr=[];
|
|
arr=this.data.list;
|
|
const arrstr=[];
|
|
arr.forEach(element => {
|
|
arrstr.push(element.id);
|
|
});
|
|
console.log(arrstr);
|
|
let jsonstr=JSON.stringify(arr);
|
|
this.examaddinnerdata(jsonstr);
|
|
|
|
if (typeid == 1) {
|
|
wx.navigateTo({
|
|
url: '/pages/exampaper/exampaper?id=' + coursetypefour_id + '&grouppaper_id=' + grouppaper_id,
|
|
})
|
|
} else {
|
|
wx.navigateTo({
|
|
url: '/pages/exampaper2/exampaper2?id=' + coursetypefour_id + '&grouppaper_id=' + grouppaper_id,
|
|
})
|
|
}
|
|
},examaddinnerdata:function(listdata){
|
|
//传送数组参数,批量添加数据
|
|
//得到练习题目
|
|
const that = this;
|
|
let url = baseUrl.globalData.baseUrl + '/exam/foreachexaminner';
|
|
var param = {
|
|
listdata: listdata
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.post(url, param).then((res) => {
|
|
console.log(res.data);
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
}
|
|
|
|
}) |