activate.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. //得到用户信息
  33. getUserInfo: function () {
  34. var that = this
  35. wx.getUserProfile({
  36. desc: "登录注册",
  37. success: function (res2) {
  38. app.globalData.userInfo.NickName = res2.userInfo.nickName;
  39. app.globalData.userInfo.AvatarUrl = res2.userInfo.avatarUrl;
  40. //调用登录接口
  41. wx.login({
  42. success: function (res0) {
  43. app.globalData.userInfo.Code = res0.code;
  44. that.login(app.globalData.userInfo, res2.userInfo);
  45. }
  46. });
  47. },
  48. fail: function (res) {
  49. console.log(res);
  50. }
  51. });
  52. },
  53. login: function (param, param2) {
  54. var that = this;
  55. var url = "Login";
  56. switch (app.globalData.ProgramID) {
  57. case 164:
  58. url = "MathStar" + url;
  59. break;
  60. case 105:
  61. url = "Math" + url;
  62. break;
  63. case 106:
  64. url = "Hanzi" + url;
  65. break;
  66. case 98:
  67. url = "Pinyin" + url;
  68. break;
  69. case 99:
  70. url = "Phonics" + url;
  71. break;
  72. }
  73. server.postData(url, {
  74. Code: param.Code,
  75. NickName: param2.nickName,
  76. AvatarUrl: param2.avatarUrl,
  77. Language: param2.language,
  78. Gender: param2.gender,
  79. City: param2.city,
  80. Province: param2.province,
  81. Country: param2.country,
  82. ProgramVersion: app.globalData.Version,
  83. Introducer: app.globalData.introducer,
  84. UserSource: app.globalData.userSource,
  85. SourceID: app.globalData.SourceID,
  86. LastUserSource: app.globalData.userSource,
  87. iv: param.iv,
  88. encryptedData: param.encryptedData,
  89. }, function (data) {
  90. wx.navigateBack({
  91. delta: 1
  92. });
  93. });
  94. },
  95. onShareAppMessage: function () {
  96. return {
  97. title: app.globalData.ShareTitle,
  98. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  99. imageUrl: app.globalData.ShareImage,
  100. }
  101. },
  102. })