accredit.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. this.setData({
  9. Containnerheight: main.getWindowHeight(),
  10. });
  11. var that = this;
  12. var hType=0;
  13. if (options.Type)
  14. hType=options.Type;
  15. main.getData("GetAccreditInfo?Type=" + hType, function (data) {
  16. that.setData({
  17. Info: data,
  18. Htype:hType,
  19. });
  20. });
  21. if (!app.globalData.userInfo)
  22. app.globalData.userInfo = {};
  23. },
  24. //得到用户信息
  25. getUserInfo: function () {
  26. var that = this
  27. wx.getUserProfile({
  28. desc: "登录注册",
  29. success: function (res2) {
  30. that.data.Info.Text3=null;
  31. that.setData({
  32. Info: that.data.Info,
  33. });
  34. app.globalData.userInfo.NickName = res2.userInfo.nickName;
  35. app.globalData.userInfo.AvatarUrl = res2.userInfo.avatarUrl;
  36. //调用登录接口
  37. wx.login({
  38. success: function (res0) {
  39. app.globalData.userInfo.Code = res0.code;
  40. that.login(app.globalData.userInfo, res2.userInfo);
  41. }
  42. });
  43. },
  44. fail: function (res) {
  45. console.log(res);
  46. that.gotoReturn();
  47. }
  48. });
  49. },
  50. login: function (param, param2) {
  51. var that = this;
  52. var url = "MiaoguoLogin";
  53. main.postData(url, {
  54. Code: param.Code,
  55. NickName: param2.nickName,
  56. AvatarUrl: param2.avatarUrl,
  57. Language: param2.language,
  58. Gender: param2.gender,
  59. City: param2.city,
  60. Province: param2.province,
  61. Country: param2.country,
  62. ProgramVersion: app.globalData.Version,
  63. Introducer: app.globalData.introducer,
  64. UserSource: app.globalData.userSource,
  65. SourceID: app.globalData.SourceID,
  66. LastUserSource: app.globalData.userSource,
  67. iv: param.iv,
  68. encryptedData: param.encryptedData,
  69. }, function (data) {
  70. app.globalData.userInfo.NickName = data.NickName;
  71. app.globalData.userInfo.AvatarUrl = data.AvatarUrl;
  72. app.globalData.userInfo.Language = data.Language;
  73. app.globalData.userInfo.Gender = data.Gender;
  74. app.globalData.userInfo.City = data.City;
  75. app.globalData.userInfo.Province = data.Province;
  76. app.globalData.userInfo.Country = data.Country;
  77. app.globalData.userInfo.IsMember = data.IsMember;
  78. if (app.globalData.userInfo.UserID){
  79. if (that.data.Htype==1){
  80. main.buildInitData(function () {
  81. that.gotoReturn();
  82. });
  83. }
  84. else{
  85. that.gotoReturn();
  86. }
  87. }
  88. else {
  89. app.globalData.userInfo.UserID = data.UserID;
  90. that.gotoReturn();
  91. }
  92. wx.setStorageSync("AccreditLimitTime",common.formatTime(new Date(),"-",true)+" 23:59:59");
  93. });
  94. },
  95. gotoReturn: function () {
  96. var that = this;
  97. if (app.globalData.userInfo.IsShow == 1 && that.data.Info.Text3){
  98. wx.showModal({
  99. title: '提醒',
  100. showCancel: false,
  101. content: that.data.Info.Text3,
  102. confirmText: '知道了',
  103. success(res) {
  104. if (res.confirm) {
  105. wx.setStorageSync("IsRemindContinuousNew",1);
  106. }
  107. }
  108. });
  109. }
  110. else{
  111. wx.navigateBack({
  112. delta: 1
  113. });
  114. }
  115. },
  116. onShareAppMessage: function () {
  117. return {
  118. title: app.globalData.ShareTitle,
  119. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  120. imageUrl: app.globalData.ShareImage,
  121. }
  122. },
  123. })