index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. isRecomClick: 1,
  6. userInfo: app.globalData.userInfo
  7. },
  8. onShow() {
  9. this.setData({ userInfo: app.globalData.userInfo });
  10. this.isRecomCode();
  11. },
  12. isRecomCode() {
  13. let that = this, userInfo = app.globalData.userInfo;
  14. util.ajax({
  15. func: "user/inviter/code",
  16. load: false
  17. }, function (res) {
  18. if (res.code == 0) {
  19. userInfo.recomCode = !util.isEmpty(res.data.inviterCode) ? res.data.inviterCode : userInfo.recomCode;
  20. wx.setStorageSync("WXuserInfo", userInfo);
  21. that.setData({ isRecomClick: (res.data.show == 0 && util.isEmpty(res.data.inviterCode) ? 0 : 1) });
  22. }
  23. });
  24. },
  25. logout() {
  26. let self = this;
  27. wx.showModal({
  28. content: '确定登出吗?',
  29. success: function (res) {
  30. if (res.confirm) {
  31. util.ajax({
  32. func: "login_out"
  33. }, function (res) {
  34. if (res.code == 0) {
  35. wx.removeStorageSync("WXuserInfo");
  36. wx.removeStorageSync("nps");
  37. app.globalData.userInfo = null;
  38. wx.switchTab({
  39. url: '/pages/home/account'
  40. })
  41. } else
  42. util.showTips(res.reason);
  43. });
  44. }
  45. }
  46. });
  47. },
  48. navigatorURl(e) {
  49. util.navigator(e.currentTarget.dataset.url);
  50. },
  51. })