// pages/person/person.js import { LogOut } from '../../utils/network' // import Dialog from '../../miniprogram_npm/vant-weapp/dialog/index'; const app = getApp() Page({ /** * 页面的初始数据 */ data: { username: '', part: '', show: false, phone:'', imgHeader: '/images/heard.png' }, openDialog() { this.setData({ show: true }) }, goPersonSet(){ console.log(1); // wx.navigateTo({ // url: '/pages/personSet/personSet', // }) wx.navigateTo({ url: '/pages/personSet/personSet', }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, toFixpwd() { wx.navigateTo({ url: '/pages/fixpwd/fixpwd', }) }, onClose() { this.setData({ show: false }); }, // 退出登录 logout() { console.log(111); LogOut().then((res) => { wx.removeStorage({ key: 'user', success() { // console.log(111); wx.setStorageSync('token', '') wx.redirectTo({ url: '/pages/login/login', }) } }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getUser() }, getUser() { wx.request({ url: `https://puyue.yhupai.com/prod-api/system/user/profile`, method: 'GET', header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, dataType: 'json', success: (res, header) => { console.log(res); if (res.data.code != 200) { } else { console.log(res.data.data); this.setData({ username: res.data.data.nickName, phone:res.data.data.phonenumber }) if(res.data.data.avatar){ this.setData({ imgHeader:'https://puyue.yhupai.com/prod-api/'+res.data.data.avatar }) } } }, }); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })