帮你贷的小程序

mine.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. userInfo: {},
  7. avatar_url: 'http://m.henhaojie.com/images/KX0004.png',
  8. nick_name: '点击授权登录'
  9. },
  10. onLoad: function () {
  11. this.initInfo();
  12. },
  13. initInfo() {
  14. var token = wx.getStorageSync('user').token, data = {}, that = this;
  15. console.log(token);
  16. if (token) {
  17. that.getInfo(token)
  18. } else {
  19. app.login(that, that.getInfo);
  20. }
  21. },
  22. getInfo(token) {
  23. var that = this, token = token || wx.getStorageSync('user').token, data = null;
  24. wx.request({
  25. url: app.globalData.HOST + '/user/wx/personalCenter',
  26. method: 'POST',
  27. data: { token: token },
  28. success: function (res) {
  29. if (res.data.errno == '0') {
  30. data = res.data.rst
  31. that.setData({ userInfo: data, avatar_url: data.user.avatar_url, nick_name: data.user.nick_name})
  32. } else if (res.data.errno == '90001') {
  33. }
  34. }
  35. });
  36. },
  37. goApplication() {
  38. var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0';
  39. console.log(user_id);
  40. console.log(tel);
  41. if (tel != '0' || user_id != '0') {
  42. wx.navigateTo({
  43. url: "/pages/application/application"
  44. })
  45. } else {
  46. wx.navigateTo({
  47. url: "/pages/getPhone/getPhone?from=mine"
  48. })
  49. }
  50. },
  51. goFeedback: function (e) {
  52. var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0';
  53. if (tel != '0' || user_id != '0') {
  54. wx.navigateTo({
  55. url: "/pages/feedback/feedback"
  56. })
  57. } else {
  58. wx.navigateTo({
  59. url: "/pages/getPhone/getPhone?from=mineFeedback"
  60. })
  61. }
  62. },
  63. onShareAppMessage: function () {
  64. return {
  65. title: app.globalData.title,
  66. imageUrl: app.globalData.img,
  67. path: '/pages/index/index',
  68. success: function(res) {
  69. app.noticeModal('分享成功')
  70. },
  71. fail: function(res) {
  72. app.noticeModal('您取消了分享')
  73. }
  74. }
  75. }
  76. })