accredit.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. IsIPad:"",
  7. AgeList:[{Name:"学龄前",Grade:0},{Name:"一年级",Grade:1},{Name:"二年级",Grade:2},{Name:"三年级",Grade:3},{Name:"四年级",Grade:4},{Name:"五年级",Grade:5},{Name:"六年级",Grade:6},{Name:"初中及以上",Grade:100}],
  8. },
  9. onLoad: function (options) {
  10. this.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. IsAccredit:true,
  13. });
  14. var that = this;
  15. var hType=0;
  16. if (options.Type)
  17. hType=options.Type;
  18. main.getData("GetAccreditInfo?Type=" + hType, function (data) {
  19. that.setData({
  20. Info: data,
  21. Htype:hType,
  22. });
  23. });
  24. if (!app.globalData.userInfo)
  25. app.globalData.userInfo = {};
  26. if (app.globalData.IsIPad) {
  27. that.setData({
  28. IsIPad: "_iPad",
  29. });
  30. }
  31. },
  32. //得到用户信息
  33. getUserInfo: function () {
  34. var that = this
  35. wx.getUserProfile({
  36. desc: "登录注册",
  37. success: function (res2) {
  38. that.data.Info.Text3=null;
  39. that.setData({
  40. Info: that.data.Info,
  41. });
  42. app.globalData.userInfo.NickName = res2.userInfo.nickName;
  43. app.globalData.userInfo.AvatarUrl = res2.userInfo.avatarUrl;
  44. //调用登录接口
  45. wx.login({
  46. success: function (res0) {
  47. app.globalData.userInfo.Code = res0.code;
  48. that.login(app.globalData.userInfo, res2.userInfo);
  49. }
  50. });
  51. },
  52. fail: function (res) {
  53. console.log(res);
  54. that.gotoReturn();
  55. }
  56. });
  57. },
  58. login: function (param, param2) {
  59. var that = this;
  60. var url = "MiaoguoLogin";
  61. main.postData(url, {
  62. Code: param.Code,
  63. NickName: param2.nickName,
  64. AvatarUrl: param2.avatarUrl,
  65. Language: param2.language,
  66. Gender: param2.gender,
  67. City: param2.city,
  68. Province: param2.province,
  69. Country: param2.country,
  70. ProgramVersion: app.globalData.Version,
  71. Introducer: app.globalData.introducer,
  72. UserSource: app.globalData.userSource,
  73. SourceID: app.globalData.SourceID,
  74. LastUserSource: app.globalData.userSource,
  75. iv: param.iv,
  76. encryptedData: param.encryptedData,
  77. }, function (data) {
  78. app.globalData.userInfo.NickName = data.NickName;
  79. app.globalData.userInfo.AvatarUrl = data.AvatarUrl;
  80. app.globalData.userInfo.Language = data.Language;
  81. app.globalData.userInfo.Gender = data.Gender;
  82. app.globalData.userInfo.City = data.City;
  83. app.globalData.userInfo.Province = data.Province;
  84. app.globalData.userInfo.Country = data.Country;
  85. app.globalData.userInfo.IsMember = data.IsMember;
  86. if (app.globalData.userInfo.UserID){
  87. if (that.data.Htype==1){
  88. that.setData({
  89. IsAccredit:false,
  90. });
  91. }
  92. else{
  93. that.gotoReturn();
  94. }
  95. }
  96. else {
  97. app.globalData.userInfo.UserID = data.UserID;
  98. that.gotoReturn();
  99. }
  100. wx.setStorageSync("AccreditLimitTime",common.formatTime(new Date(),"-",true)+" 23:59:59");
  101. });
  102. },
  103. gotoReturn: function () {
  104. var that = this;
  105. if (app.globalData.userInfo.IsShow == 1 && that.data.Info.Text3){
  106. wx.showModal({
  107. title: '提醒',
  108. showCancel: false,
  109. content: that.data.Info.Text3,
  110. confirmText: '知道了',
  111. success(res) {
  112. if (res.confirm) {
  113. wx.setStorageSync("IsRemindContinuousNew",1);
  114. }
  115. }
  116. });
  117. }
  118. else{
  119. wx.navigateBack({
  120. delta: 1
  121. });
  122. }
  123. },
  124. setGrade:function(e){
  125. var that=this;
  126. var grade=e.currentTarget.dataset.grade;
  127. console.log(grade);
  128. var url = 'SetGrade?UserID=' + app.globalData.userInfo.UserID+'&Grade='+grade;
  129. main.getData(url, function (data) {
  130. wx.navigateBack({
  131. delta: 1
  132. });
  133. });
  134. },
  135. onShareAppMessage: function () {
  136. return {
  137. title: app.globalData.ShareTitle,
  138. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  139. imageUrl: app.globalData.ShareImage,
  140. }
  141. },
  142. })