|
|
|
// 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',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
userInfo:this.data.userInfo
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
sharePage(){
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/page/shareList/shareList',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
//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',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
})
|