haomingming 4f14aad6f3 优化
2023-04-11 18:41:46 +08:00

91 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { API } from './../../../utils/network/api'
let api = new API()
const app = getApp();
Page({
data: {
title: "个人中心",
navHeight: 0,
stateHeight: 0,
user_name: "医师姓名",
iden_auth_status: "0",
idcard_status: "0",
multi_point_status: "0",
avatar: "https://img.applets.igandanyiyuan.com/applet/doctor/static/images/default_photo.png",
balance_account: "0",
estimate_income: "0",
doctor_id: ""
},
onPullDownRefresh(){
console.log("用户下拉动作")
this.onShow();
},
// 获取状态栏信息
getMenuButtonBound() {
let stateHeight = 0; // 接收状态栏高度
const navHeight = wx.getMenuButtonBoundingClientRect().height; // 获取胶囊高度
let top = 0;
wx.getSystemInfo({
success(res) {
stateHeight = res.statusBarHeight;
},
});
top = wx.getMenuButtonBoundingClientRect().top - stateHeight; // 获取top值
// console.log('navHeight', navHeight);
// console.log('top', top);
this.setData({
// navHeight: navHeight + top * 2, // 导航栏高度
navHeight, // 导航栏高度
stateHeight: stateHeight + top, // 状态栏高度
});
},
onLoad(){
console.log("onLoad ");
},
onShow: function () {
// console.log("onshow ");
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
active: 2 //数字是当前页面在tabbar的索引,如我的查询页索引是2因此这边为2同理首页就为0审批页面为1
})
this.getTabBar().startInterval()
}
this.getMenuButtonBound();
// console.log("my onLoad");
//获取个人中心数据
api.getDoctorCenter().then(response => {
this.setData({
user_name: response.data.user_name,
iden_auth_status: response.data.iden_auth_status,
idcard_status: response.data.idcard_status,
multi_point_status: response.data.multi_point_status,
balance_account: response.data.balance_account,
doctor_id: response.data.doctor_id,
estimate_income: response.data.estimate_income
})
let avatar = response.data.avatar;
if(avatar && (avatar.indexOf("http") == -1)){
avatar = api.getStaticHost() + avatar;
}
this.setData({
"avatar": avatar
})
}).then(res => {
wx.stopPullDownRefresh()
}).catch(errors => {
console.error(errors);
})
},
onHide(){
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().stopInterval()
}
},
go(e){
let url = e.currentTarget.dataset.url;
app.go(url)
}
})