examtest_mp/pages/workscope/index.js

123 lines
2.3 KiB
JavaScript

// pages/subject/index.js
const api = require("../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
// try {
// var value = wx.getStorageSync('nowSubject')
// if (value.id) {
api.request('/examtest/workscope/', 'GET', {is_public:true}).then(res => {
that.setData({
workData:res.data
})
})
// }else{
// wx.showModal({
// content: '请先选择学科!',
// showCancel:false,
// success(res) {
// if (res.confirm) {
// wx.redirectTo({
// url: '/pages/subject/index',
// })
// }
// }
// })
// }
// } catch (e) {
// }
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
chooseWork: function (e) {
let work = e.currentTarget.dataset
wx.showModal({
title: '提示',
content: '确定修改工作类别吗?',
confirmText: '确定',
cancelText: '取消',
success: function (res) {
if (res.confirm) {
api.request(`/examtest/workscope/${work.id}/chose/`, 'GET').then(res => {
//选择工作类别
// that.setData({
// workData:res.data
// })
wx.showToast({
title: '成功',
icon:'none'
})
getApp().globalData.userinfo.workscope = res.data.workscope
getApp().globalData.userinfo.workscope_name = res.data.workscope_name
wx.navigateBack({
})
})
}
}
})
//wx.setStorageSync('nowWork', work)
},
})