227 lines
4.6 KiB
JavaScript
227 lines
4.6 KiB
JavaScript
// pages/wode/wode.js
|
|
const MyApi = require('../../Api/api.js');
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
value: '',
|
|
show: false,
|
|
showCode: false,
|
|
passwordcode: null,
|
|
intervalId: null,
|
|
headiconurl: '/static/image/user.png',
|
|
urlstring: getApp().globalData.BaseURL + "/Images/ToolsIcon/toolsicon",
|
|
CodeURL:getApp().globalData.BaseURL + "/Images/WXCode/Yeomai.png",
|
|
LoginBtnText: '登录注册',
|
|
UserNameText: '未登录',
|
|
user_openid: null,
|
|
YelayMaths_ID: null,
|
|
IsLogin: null,
|
|
IsAdministor: null,
|
|
LastLoginDate: null,
|
|
UserName: null,
|
|
NewUser: null
|
|
},
|
|
showdialog() {
|
|
if (wx.getStorageSync('UserInfoCache').IsLogin ) {
|
|
this.setData({
|
|
show: true,
|
|
value: ''
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
mask:true,
|
|
icon: 'error',
|
|
title: '请登录后操作!',
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
ChangeUserInfo() {
|
|
wx.navigateTo({
|
|
url: '/pages/ChangeUserInfo/ChangeUserInfo',
|
|
});
|
|
},
|
|
|
|
onChange(e) {
|
|
this.setData({
|
|
passwordcode: e.detail
|
|
});
|
|
},
|
|
|
|
onClose() {
|
|
this.setData({
|
|
show: false,
|
|
passwordcode: null,
|
|
});
|
|
},
|
|
|
|
showCode() {
|
|
this.setData({
|
|
showCode: true,
|
|
});
|
|
},
|
|
|
|
OnClickCodeImage() {
|
|
console.log("点击了二维码");
|
|
},
|
|
|
|
onCodeClose() {
|
|
this.setData({
|
|
showCode: false,
|
|
});
|
|
},
|
|
|
|
GetCourse() {
|
|
//点击确定后的课程获取
|
|
if (this.data.passwordcode) {
|
|
wx.showToast({
|
|
title: '请稍后...',
|
|
icon: 'loading',
|
|
mask:true,
|
|
duration: 10000
|
|
});
|
|
|
|
MyApi.ApiPasswordCodeValidate(wx.getStorageSync('UserInfoCache').user_openid, this.data.passwordcode)
|
|
.then(result => {
|
|
// 成功后执行的代码
|
|
try {
|
|
wx.hideToast();
|
|
} catch (error) {}
|
|
|
|
wx.showToast({
|
|
title: result.Data,
|
|
icon: 'error',
|
|
mask:true,
|
|
duration: 2000
|
|
});
|
|
|
|
//修改缓存已拥有课程
|
|
if (result.ReturnData) {
|
|
var tempcourse = wx.getStorageSync('UserInfoCache');
|
|
tempcourse.OwnedCourse=result.ReturnData;
|
|
wx.setStorageSync('UserInfoCache', tempcourse);
|
|
};
|
|
})
|
|
.catch(err => {
|
|
// 失败后执行的代码
|
|
console.error("请求失败:" + err);
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: '请输入课程码!',
|
|
icon: 'error',
|
|
mask:true,
|
|
duration: 2000
|
|
});
|
|
}
|
|
|
|
this.setData({
|
|
show: false,
|
|
});
|
|
},
|
|
|
|
redirectToTargetLoginout: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/LoginOrOutDetails/LoginOrOutDetails?IsLogin=' + this.IsLogin,
|
|
})
|
|
},
|
|
|
|
NGT_SetPasswordCode: function () {
|
|
this.setData({
|
|
show: false,
|
|
});
|
|
wx.navigateTo({
|
|
url: '/pages/SetPasswordCode/SetPasswordCode',
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
var Storage = wx.getStorageSync('UserInfoCache');
|
|
if (Storage.IsLogin === "1") {
|
|
this.setData({
|
|
IsLogin: Storage.IsLogin,
|
|
headiconurl: getApp().globalData.BaseURL + "/Images/Headicons/Headicon" + Storage.HeadiconID + ".png",
|
|
LoginBtnText: "退出登录",
|
|
UserNameText: Storage.UserName,
|
|
IsAdministor: Storage.IsAdministor,
|
|
});
|
|
} else {
|
|
this.setData({
|
|
IsLogin: null,
|
|
headiconurl: "/static/image/user.png",
|
|
LoginBtnText: "登录注册",
|
|
UserNameText: "未登录",
|
|
IsAdministor: null,
|
|
});
|
|
}
|
|
},
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
this.onLoad();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
function2_01() {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '功能安排中。。。',
|
|
success(res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定');
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消');
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
|
|
|
|
}) |