import common from '../../utils/util'; import server from '../../utils/main'; const app = getApp(); Page({ data: { IsAccredit:false, }, onLoad: function (options) { var member="非会员"; if (app.globalData.userInfo.IsMember==1) member = "付费会员"; this.setData({ Height: common.getSystemHeight(), Member:member, }); this.init(); }, init:function(){ var that = this; server.getData('GetWXUsersAllTime?ProductID=' + app.globalData.ProgramID+'&UserID=' + app.globalData.userInfo.UserID, function (data) { if (data) { that.setData({ ProductList: data, }); } }); wx.getSetting({ success(res) { if (res.authSetting['scope.userInfo']) { that.setData({ IsAccredit: true, }); } } }); }, gotoPaylist:function(){ wx.navigateTo({ url: '../about/paylist', }); }, getAccredit: function () { if (!this.data.IsAccredit) { var that = this; wx.getSetting({ success(res) { if (!res.authSetting['scope.userInfo']) { wx.authorize({ scope: 'scope.userInfo', success() { that.getUserInfo(); }, fail() { wx.openSetting({ success(res) { that.getUserInfo(); } }); } }) } } }) } }, //得到用户信息 getUserInfo: function () { var that = this //调用登录接口 wx.login({ success: function (res0) { wx.getUserInfo({ withCredentials: true, success: function (res) { app.globalData.userInfo = res.userInfo; app.globalData.userInfo.NickName = app.globalData.userInfo.nickName; app.globalData.userInfo.AvatarUrl = app.globalData.userInfo.avatarUrl; // that.hasGetShareInfo(app.globalData.userInfo); that.setData({ IsAccredit: true, NickName: app.globalData.userInfo.NickName, AvatarUrl: app.globalData.userInfo.AvatarUrl }); app.globalData.userInfo.Code = res0.code; app.globalData.userInfo.iv = res.iv; app.globalData.userInfo.encryptedData = res.encryptedData; that.login(app.globalData.userInfo); }, fail: function (res) { } }); }, fail: function () { } }); }, login: function (param) { var that = this; server.postData('HanziLogin', { Code: param.Code, NickName: param.nickName, Language: param.language, Gender: param.gender, City: param.city, Province: param.province, Country: param.country, AvatarUrl: param.avatarUrl, ProgramVersion: app.globalData.Version, Introducer: app.globalData.introducer, UserSource: app.globalData.userSource, SourceID: app.globalData.SourceID, LastUserSource: app.globalData.userSource, iv: param.iv, encryptedData: param.encryptedData, }, function (data) { }); }, })