| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- 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) {
- for(var i=0;i<data.length;i++){
- if (data[i].ID==app.globalData.ProgramID){
- if (that.data.Member=="非会员"){
- data[i].Time = common.formatDateCHS(app.globalData.userInfo.CreateTime);
- }
- }
- }
- that.setData({
- ProductList: data,
- });
- }
- });
- wx.getSetting({
- success(res) {
- if (res.authSetting['scope.userInfo']) {
- that.setData({
- IsAccredit: true,
- });
- }
- }
- });
- },
- gotoPaylist:function(){
- var that=this;
- wx.getSetting({
- success(res) {
- if (res.authSetting['scope.userInfo']) {
- wx.navigateTo({
- url: '../about/paylist',
- });
- }
- else{
- that.getAccredit();
- }
- }
- });
-
- },
- 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) {
- var userID = app.globalData.userInfo.UserID;
- app.globalData.userInfo = res.userInfo;
- app.globalData.userInfo.UserID = userID;
- 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) {
- });
-
- },
- })
|