membercenter.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. IsAccredit:false,
  7. },
  8. onLoad: function (options) {
  9. var member="非会员";
  10. if (app.globalData.userInfo.IsMember==1)
  11. member = "付费会员";
  12. this.setData({
  13. Height: common.getSystemHeight(),
  14. Member:member,
  15. });
  16. this.init();
  17. },
  18. init:function(){
  19. var that = this;
  20. server.getData('GetWXUsersAllTime?ProductID=' + app.globalData.ProgramID+'&UserID=' + app.globalData.userInfo.UserID, function (data) {
  21. if (data) {
  22. that.setData({
  23. ProductList: data,
  24. });
  25. }
  26. });
  27. wx.getSetting({
  28. success(res) {
  29. if (res.authSetting['scope.userInfo']) {
  30. that.setData({
  31. IsAccredit: true,
  32. });
  33. }
  34. }
  35. });
  36. },
  37. gotoPaylist:function(){
  38. wx.navigateTo({
  39. url: '../about/paylist',
  40. });
  41. },
  42. getAccredit: function () {
  43. if (!this.data.IsAccredit) {
  44. var that = this;
  45. wx.getSetting({
  46. success(res) {
  47. if (!res.authSetting['scope.userInfo']) {
  48. wx.authorize({
  49. scope: 'scope.userInfo',
  50. success() {
  51. that.getUserInfo();
  52. },
  53. fail() {
  54. wx.openSetting({
  55. success(res) {
  56. that.getUserInfo();
  57. }
  58. });
  59. }
  60. })
  61. }
  62. }
  63. })
  64. }
  65. },
  66. //得到用户信息
  67. getUserInfo: function () {
  68. var that = this
  69. //调用登录接口
  70. wx.login({
  71. success: function (res0) {
  72. wx.getUserInfo({
  73. withCredentials: true,
  74. success: function (res) {
  75. app.globalData.userInfo = res.userInfo;
  76. app.globalData.userInfo.NickName = app.globalData.userInfo.nickName;
  77. app.globalData.userInfo.AvatarUrl = app.globalData.userInfo.avatarUrl;
  78. // that.hasGetShareInfo(app.globalData.userInfo);
  79. that.setData({
  80. IsAccredit: true,
  81. NickName: app.globalData.userInfo.NickName,
  82. AvatarUrl: app.globalData.userInfo.AvatarUrl
  83. });
  84. app.globalData.userInfo.Code = res0.code;
  85. app.globalData.userInfo.iv = res.iv;
  86. app.globalData.userInfo.encryptedData = res.encryptedData;
  87. that.login(app.globalData.userInfo);
  88. },
  89. fail: function (res) {
  90. }
  91. });
  92. },
  93. fail: function () {
  94. }
  95. });
  96. },
  97. login: function (param) {
  98. var that = this;
  99. server.postData('HanziLogin', {
  100. Code: param.Code,
  101. NickName: param.nickName,
  102. Language: param.language,
  103. Gender: param.gender,
  104. City: param.city,
  105. Province: param.province,
  106. Country: param.country,
  107. AvatarUrl: param.avatarUrl,
  108. ProgramVersion: app.globalData.Version,
  109. Introducer: app.globalData.introducer,
  110. UserSource: app.globalData.userSource,
  111. SourceID: app.globalData.SourceID,
  112. LastUserSource: app.globalData.userSource,
  113. iv: param.iv,
  114. encryptedData: param.encryptedData,
  115. }, function (data) {
  116. });
  117. },
  118. })