// pages/mine/mine.js const app = getApp() import Notify from '@vant/weapp/notify/notify'; import { getUserInfo} from "../../api/user" Page({ /** * 页面的初始数据 */ data: { serviceNavList:[ // { // label:'物资情况', // url:'' // }, { label:'入住记录', url:'/subpages/mine/checkInRecord/checkInRecord' }, // { // label:'预约看房', // url:'' // }, // { // label:'我的报修', // url:'/subpages/mine/repairList/repairList' // }, // { // label:'我的报事', // url:'/subpages/mine/eventList/eventList' // }, // { // label:'共享空间', // url:'' // } ], registerFlag:false }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ statusHeight: app.globalData.deviceInfo.statusHeight, navigationHeight: app.globalData.deviceInfo.navigationHeight, }); this.getUserInfo() }, // 跳转到修改信息页 goToEdit() { console.log("点击了修改信息"); wx.navigateTo({ url: "/subpages/mine/editUser/editUser", }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, toInfo(e){ console.log(e); if(e.currentTarget.dataset.url){ wx.navigateTo({ url:e.currentTarget.dataset.url , }) }else{ Notify({ type: 'primary', message: '持续上线中,敬请期待~' }); } }, getUserInfo(){ getUserInfo().then(res=>{ if(res.code ===200 && res.data){ app.globalData.userInfo = res.data; this.setData({ registerFlag:false }) }else{ this.setData({ registerFlag:true }) } }) }, getUserProfile: function(e) { // 推荐使用 getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 console.log(e); if (e.detail.userInfo) { // 用户按了允许授权按钮 this.setData({ userInfo: e.detail.userInfo }) } else { // 用户按了拒绝按钮 wx.showToast({ title: '用户拒绝授权', icon: 'none' }) } } })