const app = getApp() import { setUserInfo } from '~/api/user' Component({ properties: { title: { type: String, value: '朗读小咖秀', } }, data: { navBarHeight: app.globalData.navBarHeight, menuRight: app.globalData.menuRight, menuTop: app.globalData.menuTop, menuHeight: app.globalData.menuHeight, grade: null, isGradeShow: false }, attached: function () { // console.log(wx.getStorage(user)); }, methods: { // 选择年级 selectGrade({ target }) { let code = target.dataset.code if (!code) { return } this.setData({ grade: code }) }, // 修改年级 async changeGrade(e) { const grade = this.data.grade if (!grade) { return wx.showToast({ title: '请选择年级', icon: 'none', duration: 2000 }) } this.setData({ isGradeShow: false, }) await setUserInfo({ grade }, 'put') }, } })