149 lines
3.3 KiB
JavaScript
149 lines
3.3 KiB
JavaScript
// 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() {
|
||
|
||
// }
|
||
}) |