const api = require('../../utils/api.js'); // const app = getApp(), // { // globalData: { // util: { // regeneratorRuntime, // goLogin, // navigate_auth_native, // getUserInfo // } // } // } = app; Page({ onLoad() { this.setData({ list: [ { title: '个人信息', icon: 'user-icon', url: '/pages/student/user/user', }, { title: '我的投诉建议', icon: 'tousu', url: '/pages/student/proposalList/proposalList', }, { title: '我的设置', icon: 'shezhi', url: 'setting/index', } ] }) }, onShow() { let userInfo = wx.getStorageSync('user') this.setData({ photo: userInfo.headImage ? api.total.split('.if')[0]+userInfo.headImage :'/images/default-urser.png', viewName: userInfo.userName }) // if (!userInfo){ // let { viewName = '', photo = '' } = await getUserInfo() // this.setData({ // photo, // viewName // }) // }else{ // this.setData({ // photo: userInfo.avatarUrl, // viewName: userInfo.nickName // }) // } }, navigate_auth:function(e){ wx.navigateTo({ url: e.currentTarget.dataset.url, }) }, updateimage:function(){ let that=this wx.chooseImage({ count:1, success: function(res) { wx.showLoading({ title: '正在上传', }) wx.uploadFile({ url: api.updateimage, filePath: res.tempFilePaths[0], header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', }, name: 'file', formData: { 'fileType': 'image', 'loginId': wx.getStorageSync('loginId') }, success(res) { wx.hideLoading() if (JSON.parse(res.data).status == true) { let user = wx.getStorageSync('user') user.headImage = JSON.parse(res.data).headImage wx.setStorageSync('user', user) that.setData({ photo: api.total.split('.if')[0]+user.headImage }) wx.showToast({ title: '修改成功', icon:'none' }) } } }) }, }) }, // goLogin, // navigate_auth_native })