体质测试
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.
tizhiceshi/page/my/my.js

132 lines
2.5 KiB

2 years ago
// pages/my/my.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
lastscore:0,
average:0,
user_id:0,
userInfo: {
id: 0,
avatar: '../img/my.png',
nickname: '未登录',
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getUserId();
this.getdata();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
getUserId(){
var getuser = wx.getStorageSync("userInfo");
if(getuser){
this.data.user_id = getuser.id;
this.data.userInfo= getuser;
}else if(app.globalData.userInfo){
this.data.user_id = app.globalData.userInfo.id;
this.data.userInfo= app.globalData.userInfo;
}else{
wx.navigateTo({
url: '/page/login/login',
});
}
2 years ago
console.log(this.data.userInfo,"iiuu")
2 years ago
this.setData({
userInfo:this.data.userInfo
})
},
2 years ago
sharePage(){
wx.navigateTo({
url: '/page/shareList/shareList',
});
},
2 years ago
//data
getdata:function(){
var that=this;
this.setData({ loading: true });
app.request('/api/mini/usercenter', {
user_id:this.data.user_id,
}, function (data, ret) {
if(ret.code == 1){
that.setData({
loading: false,
lastscore:ret.data.lastscore,
average:ret.data.average,
});
}
typeof cb == 'function' && cb(data);
}, function (data, ret) {
that.setData({
loading: false
});
app.error(ret.msg);
},2);
},
goConstitutionAnalyse:function(){
wx.navigateTo({
url: '/page/constitutionAnalyse/constitutionAnalyse',
});
},
goTestHistory:function(){
wx.navigateTo({
url: '/page/testHistory/testHistory',
});
},
goGradeOrder:function(){
wx.navigateTo({
url: '/page/gradeOrder/gradeOrder',
});
},
})