me.js 535 B

1234567891011121314151617181920212223242526272829
  1. // pages/me/me.js
  2. import * as requestAPI from '../../models/dataModel'
  3. Page({
  4. data: {
  5. isLogin: false,
  6. userName: ''
  7. },
  8. onLoad: function (options) {
  9. },
  10. onShow() {
  11. if(wx.getStorageSync('token') && !this.data.userName) {
  12. requestAPI.getUserInfo().then(res => {
  13. this.setData({
  14. userName: res.data.data.sysUser.username,
  15. isLogin: true
  16. })
  17. })
  18. }
  19. },
  20. login() {
  21. if(!this.data.isLogin) {
  22. wx.navigateTo({
  23. url: '/pages/login/login',
  24. })
  25. }
  26. }
  27. })