index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. },
  7. onLoad: function (options) {
  8. let that = this;
  9. if (options) {
  10. if (options.UserID) {
  11. console.log("UserID:" + options.UserID);
  12. app.globalData.introducer = options.UserID;
  13. }
  14. if (options.goto) {
  15. console.log("goto:" + options.goto);
  16. app.globalData.goto = options.goto;
  17. }
  18. if (options.SourceID) {
  19. console.log("SourceID:" + options.SourceID);
  20. app.globalData.SourceID = options.SourceID;
  21. }
  22. // 扫码介绍人
  23. if (options.scene) {
  24. var scene = decodeURIComponent(options.scene);
  25. console.log("scene:" + scene);
  26. var introducer = 0;
  27. if (scene.indexOf("UserID") >= 0)
  28. introducer = scene.substr(scene.indexOf("UserID") + 7);
  29. console.log("introducer:" + introducer);
  30. app.globalData.introducer = scene;
  31. }
  32. if (options.ProductID) {
  33. this.setData({
  34. ProductID: options.ProductID,
  35. ProductUserID: options.ProductUserID,
  36. });
  37. }
  38. }
  39. that.setData({
  40. Containnerheight: main.getWindowHeight(),
  41. });
  42. app.globalData.SelectedWords=[];
  43. app.globalData.OCRWords=[];
  44. this.getUserInfo();
  45. },
  46. //得到用户信息
  47. getUserInfo: function (cb) {
  48. let that = this
  49. //调用登录接口
  50. wx.login({
  51. success: function (res0) {
  52. app.globalData.userInfo = {};
  53. app.globalData.userInfo.Code = res0.code;
  54. //console.log("Code:" + res0.code);app.globalData.userInfo.nickName = "陌生用户";
  55. that.login(app.globalData.userInfo);
  56. },
  57. fail: function () {
  58. setTimeout(function () {
  59. that.getUserInfo();
  60. console.log("reboot:" + new Date().getTime());
  61. }, 2000);
  62. }
  63. });
  64. },
  65. login: function (param) {
  66. let that = this;
  67. main.getLocalHost(function () {
  68. main.postData('YJBDCLogin', {
  69. Code: param.Code,
  70. Introducer: app.globalData.introducer,
  71. UserSource: app.globalData.userSource,
  72. SourceID: app.globalData.SourceID,
  73. LastUserSource: app.globalData.userSource,
  74. Brand: app.globalData.systemInfo.brand,
  75. Model: app.globalData.systemInfo.model,
  76. PixelRatio: app.globalData.systemInfo.pixelRatio,
  77. ScreenWidth: app.globalData.systemInfo.screenWidth,
  78. ScreenHeight: app.globalData.systemInfo.screenHeight,
  79. WindowWidth: app.globalData.systemInfo.windowWidth,
  80. WindowHeight: app.globalData.systemInfo.windowHeight,
  81. WXLanguage: app.globalData.systemInfo.language,
  82. WXVersion: app.globalData.systemInfo.version,
  83. System: app.globalData.systemInfo.system,
  84. Platform: app.globalData.systemInfo.platform,
  85. SDKVersion: app.globalData.systemInfo.SDKVersion,
  86. ProgramVersion: app.globalData.Version,
  87. }, function (data) {
  88. //console.log("UserInfo:" + data);
  89. if (!data) {
  90. setTimeout(function () {
  91. that.getUserInfo();
  92. console.log("reboot:" + new Date().getTime());
  93. }, 2000);
  94. }
  95. else {
  96. app.globalData.userInfo = data;
  97. app.globalData.userInfo.IsShow = data.IsShow;
  98. app.globalData.IsLocked = data.IsLocked;
  99. //app.globalData.userInfo.AvatarUrl = param.avatarUrl;
  100. //setTimeout(function () {
  101. wx.redirectTo({
  102. url: '../main/index'
  103. })
  104. //}, 2000);
  105. }
  106. });
  107. });
  108. },
  109. onShareAppMessage: function () {
  110. return {
  111. title: app.globalData.ShareTitle,
  112. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  113. imageUrl: app.globalData.ShareImage,
  114. }
  115. },
  116. })