index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. Version:app.globalData.Version,
  7. },
  8. onLoad: function (options) {
  9. var that = this;
  10. that.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. });
  13. that.getUserInfo();
  14. },
  15. //得到用户信息
  16. getUserInfo: function () {
  17. var that = this
  18. //调用登录接口
  19. wx.login({
  20. success: function (res0) {
  21. app.globalData.userInfo = {};
  22. app.globalData.userInfo.Code = res0.code;
  23. console.log("Time2:" + new Date().getTime());
  24. app.globalData.userInfo.nickName = "陌生用户";
  25. app.globalData.userInfo.language = "";
  26. app.globalData.userInfo.gender = "0";
  27. app.globalData.userInfo.city = "";
  28. app.globalData.userInfo.province = "";
  29. app.globalData.userInfo.country = "";
  30. app.globalData.userInfo.avatarUrl = "../../pages/images/universalpic_face_default_blue_120x120.png";
  31. that.login(app.globalData.userInfo);
  32. },
  33. fail: function () {}
  34. });
  35. },
  36. login: function (param) {
  37. var that = this;
  38. main.getLocalHost(function () {
  39. main.postData('MiaoguoLogin?IsPromotion=true', {
  40. Code: param.Code,
  41. NickName: param.nickName,
  42. Language: param.language,
  43. Gender: param.gender,
  44. City: param.city,
  45. Province: param.province,
  46. Country: param.country,
  47. AvatarUrl: param.avatarUrl,
  48. Introducer: app.globalData.introducer,
  49. UserSource: app.globalData.userSource,
  50. SourceID: app.globalData.SourceID,
  51. LastUserSource: app.globalData.userSource,
  52. Brand: app.globalData.systemInfo.brand,
  53. Model: app.globalData.systemInfo.model,
  54. PixelRatio: app.globalData.systemInfo.pixelRatio,
  55. ScreenWidth: app.globalData.systemInfo.screenWidth,
  56. ScreenHeight: app.globalData.systemInfo.screenHeight,
  57. WindowWidth: app.globalData.systemInfo.windowWidth,
  58. WindowHeight: app.globalData.systemInfo.windowHeight,
  59. WXLanguage: app.globalData.systemInfo.language,
  60. WXVersion: app.globalData.systemInfo.version,
  61. System: app.globalData.systemInfo.system,
  62. Platform: app.globalData.systemInfo.platform,
  63. SDKVersion: app.globalData.systemInfo.SDKVersion,
  64. ProgramVersion: app.globalData.Version,
  65. }, function (data) {
  66. console.log("Time4:" + new Date().getTime());
  67. if (!data) {
  68. timeout3 = setTimeout(function () {
  69. that.getUserInfo();
  70. console.log("reboot:" + new Date().getTime());
  71. }, 2000);
  72. } else {
  73. if (!data.IdentityCard)
  74. data.IdentityCard="";
  75. if (!data.Phone)
  76. data.Phone="";
  77. if (!data.WXAccount)
  78. data.WXAccount="";
  79. if (!data.RealName)
  80. data.RealName="";
  81. app.globalData.userInfo = data;
  82. that.setData({
  83. IsPromoter:app.globalData.userInfo.IsPromoter,
  84. });
  85. that.getUserList();
  86. }
  87. });
  88. });
  89. },
  90. getUserList:function(){
  91. var that = this;
  92. var url="GetAgentUserList";
  93. main.getData(url, function (data) {
  94. if (data) {
  95. that.setData({
  96. UserList:data,
  97. });
  98. }
  99. });
  100. },
  101. goto: function (e) {
  102. var url = e.currentTarget.dataset.url;
  103. wx.navigateTo({
  104. url: url,
  105. });
  106. },
  107. setSelectUser: function (e) {
  108. var that = this;
  109. var userid = e.currentTarget.dataset.userid;
  110. wx.setStorageSync("UserID", userid);
  111. app.globalData.userInfo.UserID = userid;
  112. that.getUserInfo2(userid,"",function(data){
  113. wx.setNavigationBarTitle({
  114. title: data.NickName
  115. });
  116. if (!data.WXAccount)
  117. data.WXAccount="";
  118. if (!data.RealName)
  119. data.RealName="";
  120. app.globalData.userInfo=data;
  121. that.setData({
  122. IsPromoter:app.globalData.userInfo.IsPromoter,
  123. });
  124. });
  125. },
  126. getUserInfo2:function(userID,fieldStr,callback){
  127. var url = "GetMiaoguoWXUserInfo?UserID=" + userID + fieldStr;
  128. main.getData(url, function (data) {
  129. if (data) {
  130. callback(data);
  131. }
  132. });
  133. },
  134. onShareAppMessage: function () {
  135. return {
  136. title: app.globalData.ShareTitle,
  137. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  138. imageUrl: app.globalData.ShareImage,
  139. }
  140. },
  141. })