accredit.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. var urlRedirectTo = "";
  5. Page({
  6. data: {
  7. ShowNotice:false,
  8. },
  9. onLoad: function (options) {
  10. urlRedirectTo = options.url;
  11. this.setData({
  12. Containnerheight: main.getWindowHeight(),
  13. });
  14. wx.hideShareMenu();
  15. },
  16. onUnload: function () {
  17. },
  18. goto: function () {
  19. var that = this;
  20. wx.getSetting({
  21. success(res) {
  22. if (!res.authSetting['scope.userInfo']) {
  23. wx.authorize({
  24. scope: 'scope.userInfo',
  25. success() {
  26. that.getUserInfo();
  27. },
  28. fail() {
  29. }
  30. })
  31. }
  32. else {
  33. that.getUserInfo();
  34. }
  35. }
  36. });
  37. },
  38. //得到用户信息
  39. getUserInfo: function () {
  40. var that = this
  41. //调用登录接口
  42. wx.login({
  43. success: function (res0) {
  44. wx.getUserInfo({
  45. withCredentials: true,
  46. success: function (res) {
  47. app.globalData.userInfo.Code = res0.code;
  48. app.globalData.userInfo.iv = res.iv;
  49. app.globalData.userInfo.encryptedData = res.encryptedData;
  50. app.globalData.userInfo.NickName = res.userInfo.nickName;
  51. app.globalData.userInfo.AvatarUrl = res.userInfo.avatarUrl;
  52. that.login(app.globalData.userInfo, res.userInfo);
  53. },
  54. fail: function (res) {
  55. wx.navigateBack({
  56. delta: 1
  57. });
  58. }
  59. });
  60. },
  61. fail: function () {
  62. }
  63. });
  64. },
  65. login: function (param, param2) {
  66. var that = this;
  67. var url = "MiaoguoLogin";
  68. main.postData(url, {
  69. Code: param.Code,
  70. NickName: param2.nickName,
  71. AvatarUrl: param2.avatarUrl,
  72. Language: param2.language,
  73. Gender: param2.gender,
  74. City: param2.city,
  75. Province: param2.province,
  76. Country: param2.country,
  77. ProgramVersion: app.globalData.Version,
  78. Introducer: app.globalData.introducer,
  79. UserSource: app.globalData.userSource,
  80. SourceID: app.globalData.SourceID,
  81. LastUserSource: app.globalData.userSource,
  82. iv: param.iv,
  83. encryptedData: param.encryptedData,
  84. }, function (data) {
  85. app.globalData.userInfo.NickName = data.NickName;
  86. app.globalData.userInfo.AvatarUrl = data.AvatarUrl;
  87. app.globalData.userInfo.Language = data.Language;
  88. app.globalData.userInfo.Gender = data.Gender;
  89. app.globalData.userInfo.City = data.City;
  90. app.globalData.userInfo.Province = data.Province;
  91. app.globalData.userInfo.Country = data.Country;
  92. app.globalData.userInfo.IsMember=data.IsMember;
  93. that.buildInitData();
  94. });
  95. },
  96. buildInitData: function () {
  97. //app.globalData.userInfo.UserID=4;
  98. wx.showLoading({
  99. title: '数据初始化',
  100. });
  101. main.getData('BuildInitData?UserID=' + app.globalData.userInfo.UserID, function (data) {
  102. wx.hideLoading();
  103. if (data) {
  104. wx.navigateBack({
  105. delta: 1
  106. });
  107. }
  108. });
  109. },
  110. onShareAppMessage: function () {
  111. return {
  112. title: app.globalData.ShareTitle,
  113. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  114. imageUrl: app.globalData.ShareImage,
  115. }
  116. },
  117. })