214 lines
4.0 KiB
JavaScript
214 lines
4.0 KiB
JavaScript
// subpackage/student/my/my.js
|
|
const {
|
|
getTeacherUserInfo,
|
|
getUserInfo,
|
|
getUserAccount,
|
|
deleteOpenId,
|
|
getOpenId,
|
|
postOpenId
|
|
} = require("../../../utils/serve/user");
|
|
const tabService = require("../../../utils/tab-serve");
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
user: {},
|
|
theme: 'user'
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getUserInfoo()
|
|
},
|
|
onChooseAvatar(e) {
|
|
const avatar = e.detail.avatar;
|
|
this.uploadImageToAliyun(avatar.tempFilePath);
|
|
},
|
|
|
|
goJd() {
|
|
wx.navigateToMiniProgram({
|
|
appId: 'wx91d27dbf599dff74',
|
|
path: 'pages/shop/index/index?shopId=43897',
|
|
extraData: {
|
|
foo: 'bar'
|
|
},
|
|
envVersion: 'release',
|
|
success(res) {
|
|
// 打开成功
|
|
}
|
|
})
|
|
},
|
|
|
|
mmm() {
|
|
wx.login({
|
|
success: (loginRes) => {
|
|
if (loginRes.code) {
|
|
console.log(loginRes)
|
|
}
|
|
},
|
|
});
|
|
},
|
|
|
|
goTrainList() {
|
|
wx.navigateTo({
|
|
url: '/subpackage/parent/history-train/history-train',
|
|
})
|
|
},
|
|
|
|
goStautsManger() {
|
|
wx.navigateTo({
|
|
url: '/subpackage/user/check-status/check-status',
|
|
})
|
|
},
|
|
|
|
async getUserInfoo() {
|
|
const theme = wx.getStorageSync('theme')
|
|
let res
|
|
if (theme == 'teacher') {
|
|
res = await getTeacherUserInfo()
|
|
console.log(res)
|
|
} else {
|
|
res = await getUserInfo()
|
|
console.log(res)
|
|
}
|
|
this.setData({
|
|
user: res.data,
|
|
theme: theme
|
|
})
|
|
},
|
|
|
|
goDevice() {
|
|
wx.navigateTo({
|
|
url: '/subpackage/bluebooth/search',
|
|
})
|
|
},
|
|
|
|
goInfo() {
|
|
wx.navigateTo({
|
|
url: '/subpackage/user/info/info',
|
|
})
|
|
},
|
|
|
|
//退出登录
|
|
logout() {
|
|
const that = this
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '确定退出当前登录吗?',
|
|
// cancelColor:"#26A6F6",
|
|
confirmColor: "#ff0000",
|
|
complete: async (res) => {
|
|
if (res.confirm) {
|
|
|
|
wx.showLoading({
|
|
title: '退出登录中',
|
|
})
|
|
|
|
const account = await getUserAccount()
|
|
console.log(account)
|
|
account.data.forEach(item => {
|
|
if (item.roleId == 2) {
|
|
wx.login({
|
|
success: async (loginData) => {
|
|
const opid = await getOpenId(loginData.code)
|
|
const canLogin = await postOpenId(opid.data, item.userId)
|
|
if (canLogin.data) { //当前登录教师,需要退出
|
|
const logout = await deleteOpenId(item.userId)
|
|
that.sure()
|
|
} else {
|
|
that.sure()
|
|
}
|
|
},
|
|
})
|
|
}
|
|
})
|
|
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
sure() {
|
|
app.globalData.isUserLogout = true
|
|
wx.clearStorageSync()
|
|
setTimeout(() => {
|
|
wx.hideLoading()
|
|
wx.reLaunch({
|
|
url: '/pages/login/login',
|
|
})
|
|
}, 500)
|
|
},
|
|
|
|
//修改密码
|
|
changePassword() {
|
|
wx.navigateTo({
|
|
url: '/subpackage/user/change-password/change-password',
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
const info = wx.getStorageSync('theme')
|
|
const update = wx.getStorageSync('updateAvater')
|
|
// console.log('theme==========>',info)
|
|
// console.log('theme==========>',this.data.theme)
|
|
if (this.data.theme != info || update == 1) {
|
|
this.setData({
|
|
theme: info
|
|
}, () => {
|
|
this.getUserInfoo()
|
|
wx.setStorageSync('updateAvater', 0)
|
|
})
|
|
}
|
|
tabService.updateIndex(this, info == 'parent' ? 3 : 4)
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |