zoujiandong b496603f7c 111
2025-06-17 17:58:29 +08:00

149 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/personCenter/personCenter.js
import {getInfo,logout} from "../../api/api"
import {throttle} from "../../utils/util"
import {createStoreBindings} from "mobx-miniprogram-bindings"
import {store} from '../../store/store.js'
const app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
isLogin:false,
userInfo:{
hospitalName:'',
name:'',
photo:'',
passNum:'',
waitNum:'',
refuseNum:'',
},
waitSubmitNum:0,
img_host:app.hostConfig().imghost
},
goLogin:throttle(function(){
app.method.navigateTo({
url:'/case/pages/mobileLogin/mobileLogin'
})
}),
goAgree:throttle(function(){
app.method.navigateTo({
url: '/case/pages/agreement/agreement',
})
}),
goDescription:throttle(function(){
app.method.navigateTo({
url: '/case/pages/agreement/agreement?type=description',
})
}),
handleLogout:throttle(function(){
logout().then(res=>{
// wx.clearStorageSync()
const { envVersion } = wx.getAccountInfoSync().miniProgram;
let token=''
if(envVersion=="develop" || envVersion=="trial"){
token="DEV_CASE_TOKEN"
}else{
token="PROD_CASE_TOKEN"
}
 wx.setStorageSync(token,'');
 wx.setStorageSync('draftTime','');
wx.reLaunch({
url:'/case/pages/mobileLogin/mobileLogin'
})
})
}),
handleGetInfo(){
let {userInfo}=this.data;
getInfo().then(res=>{
this.setData({
isLogin:true
});
for (const key in userInfo) {
this.setData({
['userInfo.'+key]:res[key]
})
}
}).catch(error=>{
if(error.code==30007){
this.setData({
isLogin:false
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.storeBindings = createStoreBindings(this, {
store,
fields: [,"active"],
actions: ["updateActive"],
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow(){
let caseDraft=wx.getStorageSync('caseDraft');
if(caseDraft){
this.setData({
waitSubmitNum:1
})
}else{
this.setData({
waitSubmitNum:0
})
}
this.handleGetInfo();
this.updateActive('center')
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
this.storeBindings.destroyStoreBindings();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
// onShareAppMessage() {
// }
})