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', studenturl: '/pages/student/user/user', teacherurl:'/pages/student/user/user' }, { title: '我的投诉建议', icon: 'tousu', studenturl: '/pages/student/proposalList/proposalList', teacherurl:'' }, { title: '我的设置', icon: 'shezhi', studenturl: 'setting/index', teacherurl:'setting/index' } ] }) }, onShow() { let userInfo = wx.getStorageSync('user') for(let index in this.data.list){ if (userInfo.roleType == 10001){ if (!this.data.list[index].teacherurl) { this.data.list.splice(index,1) } }else{ if (!this.data.list[index].studenturl) { this.data.list.splice(index, 1) } } } this.setData({ photo: userInfo.headImage ? api.total.split('.if')[0]+userInfo.headImage :'/images/default-urser.png', viewName: userInfo.userName, roleType:wx.getStorageSync('user').roleType, list: this.data.list }) // if (!userInfo){ // let { viewName = '', photo = '' } = await getUserInfo() // this.setData({ // photo, // viewName // }) // }else{ // this.setData({ // photo: userInfo.avatarUrl, // viewName: userInfo.nickName // }) // } }, navigate_auth:function(e){ if (e.currentTarget.dataset.url){ wx.navigateTo({ url: e.currentTarget.dataset.url, }) }else{ wx.showToast({ title: '功能开发中', icon:'none' }) } }, 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 })