index.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. var that = this;
  9. that.setData({
  10. Containnerheight: main.getWindowHeight(),
  11. });
  12. that.getUserInfo();
  13. },
  14. //得到用户信息
  15. getUserInfo: function () {
  16. var that = this
  17. //调用登录接口
  18. wx.login({
  19. success: function (res0) {
  20. app.globalData.userInfo = {};
  21. app.globalData.userInfo.Code = res0.code;
  22. console.log("Time2:" + new Date().getTime());
  23. app.globalData.userInfo.nickName = "陌生用户";
  24. app.globalData.userInfo.language = "";
  25. app.globalData.userInfo.gender = "0";
  26. app.globalData.userInfo.city = "";
  27. app.globalData.userInfo.province = "";
  28. app.globalData.userInfo.country = "";
  29. app.globalData.userInfo.avatarUrl = "../../pages/images/universalpic_face_default_blue_120x120.png";
  30. that.login(app.globalData.userInfo);
  31. },
  32. fail: function () {}
  33. });
  34. },
  35. login: function (param) {
  36. var that = this;
  37. main.getLocalHost(function () {
  38. main.postData('MiaoguoLogin?IsPromotion=true', {
  39. Code: param.Code,
  40. NickName: param.nickName,
  41. Language: param.language,
  42. Gender: param.gender,
  43. City: param.city,
  44. Province: param.province,
  45. Country: param.country,
  46. AvatarUrl: param.avatarUrl,
  47. Introducer: app.globalData.introducer,
  48. UserSource: app.globalData.userSource,
  49. SourceID: app.globalData.SourceID,
  50. LastUserSource: app.globalData.userSource,
  51. Brand: app.globalData.systemInfo.brand,
  52. Model: app.globalData.systemInfo.model,
  53. PixelRatio: app.globalData.systemInfo.pixelRatio,
  54. ScreenWidth: app.globalData.systemInfo.screenWidth,
  55. ScreenHeight: app.globalData.systemInfo.screenHeight,
  56. WindowWidth: app.globalData.systemInfo.windowWidth,
  57. WindowHeight: app.globalData.systemInfo.windowHeight,
  58. WXLanguage: app.globalData.systemInfo.language,
  59. WXVersion: app.globalData.systemInfo.version,
  60. System: app.globalData.systemInfo.system,
  61. Platform: app.globalData.systemInfo.platform,
  62. SDKVersion: app.globalData.systemInfo.SDKVersion,
  63. ProgramVersion: app.globalData.Version,
  64. }, function (data) {
  65. console.log("Time4:" + new Date().getTime());
  66. if (!data) {
  67. timeout3 = setTimeout(function () {
  68. that.getUserInfo();
  69. console.log("reboot:" + new Date().getTime());
  70. }, 2000);
  71. } else {
  72. app.globalData.userInfo = data;
  73. //console.log(data);
  74. }
  75. });
  76. });
  77. },
  78. goto: function (e) {
  79. var url = e.currentTarget.dataset.url;
  80. wx.navigateTo({
  81. url: url,
  82. });
  83. },
  84. onShareAppMessage: function () {
  85. return {
  86. title: app.globalData.ShareTitle,
  87. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  88. imageUrl: app.globalData.ShareImage,
  89. }
  90. },
  91. })