帮你贷的小程序

mine.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. userInfo: {},
  7. },
  8. onLoad: function () {
  9. this.initInfo();
  10. },
  11. initInfo () {
  12. var token = wx.getStorageSync('token'), data = {}, that = this;
  13. console.log(token);
  14. if (token) {
  15. that.getInfo(token)
  16. }else{
  17. app.login(that.getInfo);
  18. }
  19. },
  20. getInfo (token) {
  21. var that = this, token = token || wx.getStorageSync('token'), data = null;
  22. wx.request({
  23. url: app.globalData.HOST + '/user/wx/personalCenter',
  24. method: 'POST',
  25. data: {token: token},
  26. success: function (res) {
  27. if (res.data.errno == '0'){
  28. data = res.data.rst
  29. that.setData({userInfo: data})
  30. }else if(res.data.errno == '90001'){
  31. }
  32. }
  33. });
  34. },
  35. goApplication () {
  36. var tel = wx.getStorageSync('tel');
  37. if (tel) {
  38. wx.navigateTo({
  39. url: "/pages/application/application"
  40. })
  41. }else{
  42. wx.navigateTo({
  43. url: "/pages/getPhone/getPhone?from=mine"
  44. })
  45. }
  46. }
  47. })