import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); var urlRedirectTo = ""; Page({ data: { }, onLoad: function (options) { urlRedirectTo = options.url; this.setData({ Containnerheight: main.getWindowHeight(), }); wx.hideShareMenu(); }, onUnload: function () { }, goto: function () { var that = this; wx.getSetting({ success(res) { if (!res.authSetting['scope.userInfo']) { wx.authorize({ scope: 'scope.userInfo', success() { that.getUserInfo(); }, fail() { } }) } else { that.getUserInfo(); } } }); }, //得到用户信息 getUserInfo: function () { var that = this //调用登录接口 wx.login({ success: function (res0) { wx.getUserInfo({ withCredentials: true, success: function (res) { app.globalData.userInfo.Code = res0.code; app.globalData.userInfo.iv = res.iv; app.globalData.userInfo.encryptedData = res.encryptedData; app.globalData.userInfo.NickName = res.userInfo.nickName; app.globalData.userInfo.AvatarUrl = res.userInfo.avatarUrl; that.login(app.globalData.userInfo, res.userInfo); }, fail: function (res) { wx.navigateBack({ delta: 1 }); } }); }, fail: function () { } }); }, login: function (param, param2) { var that = this; var url = "MiaoguoLogin"; main.postData(url, { Code: param.Code, NickName: param2.nickName, AvatarUrl: param2.avatarUrl, Language: param2.language, Gender: param2.gender, City: param2.city, Province: param2.province, Country: param2.country, 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) { app.globalData.userInfo.NickName = data.NickName; app.globalData.userInfo.AvatarUrl = data.AvatarUrl; app.globalData.userInfo.Language = data.Language; app.globalData.userInfo.Gender = data.Gender; app.globalData.userInfo.City = data.City; app.globalData.userInfo.Province = data.Province; app.globalData.userInfo.Country = data.Country; that.buildInitData(); }); }, buildInitData: function () { //app.globalData.userInfo.UserID=4; wx.showLoading({ title: '数据初始化', }); main.getData('BuildInitData?UserID=' + app.globalData.userInfo.UserID, function (data) { wx.hideLoading(); if (data) { wx.navigateBack({ delta: 1 }); } }); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })