index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var util = require('../../../../utils/util.js');
  2. var api = require('../../../../config/api.js');
  3. var user = require('../../../../utils/user.js');
  4. var app = getApp();
  5. Page({
  6. data: {
  7. userInfo: {
  8. nickName: '点击登录',
  9. avatarUrl: '/static/images/my.png',
  10. isDis: false
  11. },
  12. hasLogin: false
  13. },
  14. onLoad: function (options) {
  15. // 页面初始化 options为页面跳转所带来的参数
  16. },
  17. onReady: function () {
  18. },
  19. onShow: function () {
  20. //获取用户的登录信息
  21. if (app.globalData.hasLogin) {
  22. let userInfo = wx.getStorageSync('userInfo');
  23. this.setData({
  24. userInfo: userInfo,
  25. hasLogin: true
  26. });
  27. let that = this;
  28. util.request(api.UserIndex).then(function (res) {
  29. if (res.errno === 0) {
  30. console.log(res);
  31. that.setData({
  32. order: res.data.order,
  33. isdis: res.data.isdis,
  34. isnid: res.data.isnid
  35. });
  36. }
  37. });
  38. }
  39. },
  40. onHide: function () {
  41. // 页面隐藏
  42. },
  43. goExchange(){
  44. wx.showToast({
  45. title: '功能完善中,敬请期待',
  46. icon: 'none',
  47. duration: 2000
  48. });
  49. },
  50. onUnload: function () {
  51. // 页面关闭
  52. },
  53. goLogin() {
  54. if (!this.data.hasLogin) {
  55. wx.navigateTo({
  56. url: "/pages/auth/login/login"
  57. });
  58. }
  59. },
  60. })