index.js 4.2 KB

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