const app = getApp(); Page({ data: { popupShow: false, // popupType: 'popup1', // 绑定医生弹窗 // popupType: 'popup2', // 去关注弹窗 // popupType: 'popup3', // 问题反馈弹窗 popupType: 'popup4', // 登录失败弹窗 popupParams: { close: true, } as any, userInfo: {} as any, }, onShow() { app.waitLogin().then(() => { this.getUserInfo(); }); }, getUserInfo() { app.getUserInfo(2).then((userInfo) => { this.setData({ userInfo, }); }); }, handleLogin() { wx.navigateTo({ url: '/pages/login/index', }); }, handleLoginOut() { wx.showModal({ title: '是否确认退出登录?', success: (res) => { if (res.confirm) { wx.ajax({ method: 'POST', url: '?r=xd/user/reg-logout', data: {}, }).then((res) => { app.globalData.isLogin = res.isLogin; app.globalData.loginType = res.loginType; wx.reLaunch({ url: '/pages/start/index', }); }); } }, }); }, handleEditUser() { wx.navigateTo({ url: '/pages/userInfo/index', }); }, onChooseAvatar(e) { const { avatarUrl } = e.detail; const url = `${app.globalData.upFileUrl}?r=file-service/upload-img`; wx.showLoading({ title: '上传中', }); wx.uploadFile({ url, filePath: avatarUrl, name: 'file', success: (res) => { const data = JSON.parse(res.data); const avatarUrl = data.data.Url; wx.ajax({ method: 'POST', url: '?r=xd/doctor/index/update-doctor-img', data: { UserImg: avatarUrl, }, }) .then(() => { wx.hideLoading(); wx.showToast({ title: '头像更新成功!', icon: 'none', }); this.setData({ 'userInfo.Img': avatarUrl, }); }) .catch(() => { wx.hideLoading(); }); }, fail() { wx.hideLoading(); }, }); }, handleDoc() { wx.navigateTo({ url: '/doc/pages/doc1/index', }); }, handlePublic() { this.setData({ popupShow: true, popupType: 'popup2', popupParams: { close: true, }, }); }, handleQuestion() { this.setData({ popupShow: true, popupType: 'popup3', popupParams: { close: true, }, }); }, handlePopupCancel() { this.setData({ popupShow: false, }); }, });