accredit.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. fileUrl: app.globalData.fileUrl,
  7. },
  8. onLoad: function (options) {
  9. var text0 = "", text1 = "", text2 = "", text3 = "";
  10. text0 = "会员登录";
  11. text1 = "无需注册,微信授权即可登录";
  12. text2 = "去登录";
  13. text3 = "注意:会员登录后可使用付费功能。授权微信用户信息即可一键登录。为保障消费权益,购买后请尽快授权用户信息。登录后才能正常使用统计、排行、我的订单、套装、礼品卡等功能。";
  14. this.setData({
  15. Height: common.getSystemHeight(),
  16. Text0: text0,
  17. Text1: text1,
  18. Text2: text2,
  19. Text3: text3,
  20. OrderType: options.type,
  21. });
  22. //适配ipad
  23. var systemInfo = wx.getSystemInfoSync();
  24. if (systemInfo.model) {
  25. if (systemInfo.model.indexOf("iPad") >= 0) {
  26. this.setData({
  27. ipad: "ipad",
  28. })
  29. }
  30. }
  31. },
  32. goto: function (e) {
  33. var that = this;
  34. wx.getSetting({
  35. success(res) {
  36. if (!res.authSetting['scope.userInfo']) {
  37. wx.authorize({
  38. scope: 'scope.userInfo',
  39. success() {
  40. that.getUserInfo();
  41. },
  42. fail() {
  43. wx.openSetting({
  44. success(res) {
  45. that.getUserInfo();
  46. },
  47. });
  48. }
  49. })
  50. }
  51. else {
  52. that.getUserInfo();
  53. }
  54. }
  55. })
  56. },
  57. //得到用户信息
  58. getUserInfo: function () {
  59. var that = this
  60. //调用登录接口
  61. wx.login({
  62. success: function (res0) {
  63. wx.getUserInfo({
  64. withCredentials: true,
  65. success: function (res) {
  66. app.globalData.userInfo.Code = res0.code;
  67. app.globalData.userInfo.iv = res.iv;
  68. app.globalData.userInfo.encryptedData = res.encryptedData;
  69. app.globalData.userInfo.NickName = res.userInfo.nickName;
  70. app.globalData.userInfo.AvatarUrl = res.userInfo.avatarUrl;
  71. that.login(app.globalData.userInfo, res.userInfo);
  72. },
  73. fail: function (res) {
  74. }
  75. });
  76. },
  77. fail: function () {
  78. }
  79. });
  80. },
  81. login: function (param, param2) {
  82. var that = this;
  83. var url = "Login";
  84. switch (app.globalData.ProgramID) {
  85. case 164:
  86. url = "MathStar" + url;
  87. break;
  88. case 105:
  89. url = "Math" + url;
  90. break;
  91. case 106:
  92. url = "Hanzi" + url;
  93. break;
  94. case 98:
  95. url = "Pinyin" + url;
  96. break;
  97. case 99:
  98. url = "Phonics" + url;
  99. break;
  100. }
  101. server.postData(url, {
  102. Code: param.Code,
  103. NickName: param2.nickName,
  104. AvatarUrl: param2.avatarUrl,
  105. Language: param2.language,
  106. Gender: param2.gender,
  107. City: param2.city,
  108. Province: param2.province,
  109. Country: param2.country,
  110. ProgramVersion: app.globalData.Version,
  111. Introducer: app.globalData.introducer,
  112. UserSource: app.globalData.userSource,
  113. SourceID: app.globalData.SourceID,
  114. LastUserSource: app.globalData.userSource,
  115. iv: param.iv,
  116. encryptedData: param.encryptedData,
  117. }, function (data) {
  118. wx.navigateBack({
  119. delta: 1
  120. });
  121. });
  122. },
  123. onShareAppMessage: function () {
  124. return {
  125. title: app.globalData.ShareTitle,
  126. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  127. imageUrl: app.globalData.ShareImage,
  128. }
  129. },
  130. })