You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
popupShow: false,
|
|
|
|
popupType: 'stayTuned',
|
|
|
|
popupParams: {},
|
|
|
|
},
|
|
|
|
onLoad() {
|
|
|
|
app.waitLogin().then(() => {
|
|
|
|
app.mpBehavior({ PageName: 'BTN_MY_NAV' })
|
|
|
|
app.getUserInfo().then((userInfo) => {
|
|
|
|
this.setData({
|
|
|
|
userInfo,
|
|
|
|
// 数字变红
|
|
|
|
Days: userInfo.Days.replace(/(\d+)/g, '<span style="font-size: 20px;color: rgba(242, 58, 47, 1);">$1</span>'),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
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=wtx/user/update-avatar',
|
|
|
|
data: {
|
|
|
|
Avatar: avatarUrl,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
wx.hideLoading()
|
|
|
|
wx.showToast({
|
|
|
|
title: '头像更新成功!',
|
|
|
|
icon: 'none',
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
'userInfo.Avatar': avatarUrl,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
wx.hideLoading()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
fail() {
|
|
|
|
wx.hideLoading()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handlePopupCancel() {
|
|
|
|
this.setData({
|
|
|
|
popupShow: false,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
routerTo(e) {
|
|
|
|
const { url } = e.currentTarget.dataset
|
|
|
|
wx.navigateTo({
|
|
|
|
url,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleNone(e: any) {
|
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
|
const PageName = {
|
|
|
|
1: 'BTN_MY_SWITCHPATIENT',
|
|
|
|
2: 'BTN_MY_SWITCH_DOCTOR',
|
|
|
|
}[index]
|
|
|
|
app.mpBehavior({ PageName })
|
|
|
|
this.setData({
|
|
|
|
popupShow: true,
|
|
|
|
popupType: 'stayTuned',
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
export {}
|