Page({ /** * 页面的初始数据 */ data: { userId: "", //用户id phone: "", //用户信息 nickname: "", //用户昵称 cover: "", //用户头像 sex:'', }, besure() { wx.navigateBack({ delta: 0, }) }, /** * 生命周期函数--监听页面加载 */ onLoad() { this.getUserInfo(); }, // 获取用户的基本信息 getUserInfo() { wx.$api.user.getUserInfo().then(res => { this.setData({ phone: res.username, nickname: res.nickname, cover: res.avatar, sex:res.sex }) }) }, // 跳转到修改页面 goUrl() { wx.navigateTo({ url: "../editUserInfo/editUserInfo?nickname=" + this.data.nickname }) }, // 更新头像 upload() { wx.chooseImage({ count: 1, // 默认9 success: res => { const src = res.tempFilePaths[0] wx.navigateTo({ url: '../tailoring/tailoring?src=' + src }) } }) }, logOut() { wx.showModal({ title: "退出提示", content: "是否现在就退出", showCancel: true, confirmColor: "#0b0041", confirmText: "确定", success: (res) => { if (res.confirm) { wx.clearStorage({ success: () => { wx.navigateTo({ url: '/pages/welcome/index', }) } }) } } }) } })