| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- import common from '../../utils/util';
- import server from '../../utils/main';
- const app = getApp();
- var timeout2, timeout3;
- Page({
- data: {
- version: app.globalData.Version,
- },
- onLoad: function (options) {
- if (options) {
- if (options.UserID) {
- console.log("UserID:" + options.UserID);
- app.globalData.introducer = options.UserID;
- }
- if (options.SourceID) {
- console.log("SourceID:" + options.SourceID);
- app.globalData.SourceID = options.SourceID;
- }
- // 扫码介绍人
- if (options.scene) {
- var scene = decodeURIComponent(options.scene);
- console.log("scene:" + scene);
- var introducer = 0;
- if (scene.indexOf("UserID") >= 0)
- introducer = scene.substr(scene.indexOf("UserID") + 7);
- console.log("introducer:" + introducer);
- app.globalData.introducer = scene;
- }
- if (options.ProductID) {
- this.setData({
- ProductID: options.ProductID,
- ProductUserID: options.ProductUserID,
- });
- }
- if (options.GiftID) {
- this.setData({
- GiftID: options.GiftID,
- });
- }
- }
- this.setData({
- Containnerheight: server.getWindowHeight(),
- });
- this.getUserInfo();
- this.updateProgram();
- },
- //得到用户信息
- getUserInfo: function (cb) {
- var that = this
- //调用登录接口
- wx.login({
- success: function (res0) {
- app.globalData.userInfo = {};
- app.globalData.userInfo.Code = res0.code;
- //console.log("Code:" + res0.code);app.globalData.userInfo.nickName = "陌生用户";
- that.login(app.globalData.userInfo);
-
- },
- fail: function () {
- setTimeout(function () {
- that.getUserInfo();
- console.log("reboot:" + new Date().getTime());
- }, 2000);
- }
- });
- },
- login: function (param) {
- var that = this;
- server.getLocalHost(function () {
- server.postData('MathLogin', {
- Code: param.Code,
- Introducer: app.globalData.introducer,
- UserSource: app.globalData.userSource,
- SourceID: app.globalData.SourceID,
- LastUserSource: app.globalData.userSource,
- Brand: app.globalData.systemInfo.brand,
- Model: app.globalData.systemInfo.model,
- PixelRatio: app.globalData.systemInfo.pixelRatio,
- ScreenWidth: app.globalData.systemInfo.screenWidth,
- ScreenHeight: app.globalData.systemInfo.screenHeight,
- WindowWidth: app.globalData.systemInfo.windowWidth,
- WindowHeight: app.globalData.systemInfo.windowHeight,
- WXLanguage: app.globalData.systemInfo.language,
- WXVersion: app.globalData.systemInfo.version,
- System: app.globalData.systemInfo.system,
- Platform: app.globalData.systemInfo.platform,
- SDKVersion: app.globalData.systemInfo.SDKVersion,
- ProgramVersion: app.globalData.Version,
- }, function (data) {
- //console.log("UserInfo:" + data);
- if (!data) {
- timeout3 = setTimeout(function () {
- that.getUserInfo();
- console.log("reboot:" + new Date().getTime());
- }, 2000);
- } else {
- app.globalData.userInfo = data;
- //app.globalData.userInfo.AvatarUrl = param.avatarUrl;
- // var isShow = data.IsShow;
- // if (isShow == -1) {
- // isShow = 0;
- // }
- // else {
- // var systemInfo = wx.getSystemInfoSync();
- // if (isShow == 0 && systemInfo.system && systemInfo.system.indexOf("Android") >= 0) {
- // isShow = 1;
- // }
- // }
- // app.globalData.userInfo.IsShow = isShow;
- app.globalData.userInfo.IsShow = data.IsShow;
- app.globalData.IsLocked = data.IsLocked;
- //app.globalData.userInfo.AvatarUrl = param.avatarUrl;
- that.getQuestionType(function () {
- if (that.data.GiftID) {
- var url = "../../package4/main/giftcard?GiftID=" + that.data.GiftID + "&UserID=" + app.globalData.introducer
- wx.redirectTo({
- url: url
- });
- }
- else if (that.data.ProductID) {
- var url = "../../package4/main/activateOK?ProductID=" + that.data.ProductID
- + "&ProductUserID=" + that.data.ProductUserID
- + "&CurrentUserID=" + app.globalData.userInfo.UserID
- + "&CurrentProductID=" + app.globalData.ProgramID;
- wx.redirectTo({
- url: url
- });
- }
- else {
- setTimeout(function () {
- common.getStorageValue(that, "IsStart", false, function () {
- if (that.data.IsStart) {
- wx.redirectTo({
- url: '../main/default'
- })
- }
- else {
- wx.redirectTo({
- url: '../main/help'
- })
- }
- });
- }, 2000);
- }
- that.getPriceList();
- wx.setStorageSync("IsShare", 0);
- });
- }
- });
- });
- },
- getQuestionType: function (callback) {
- var that = this;
- server.getData('GetQuestionTypes?Mode=2', function (data) {
- if (data) {
- //var arr = common.Decrypt(data);
- var arr = data;
- wx.setStorageSync("QuestionTypeList", arr);
- callback();
- }
- });
- //调用登录接口
- wx.login({
- success: function (res0) {
- server.getData('GetBaiduToken20220922?ProgramID='+app.globalData.ProgramID+'&Code='+res0.code, function (data) {
- if (data) {
- app.globalData.BaiduToken = data;
- }
- });
- }});
- },
- getPriceList: function () {
- var that = this;
- server.getData('ProductPayPriceList500', function (data) {
- if (data) {
- var arrProduct = JSON.parse(common.Decrypt(data));
- var programList = server.getProgramList();
- for (var j = 0; j < arrProduct.length; j++) {
- arrProduct[j].ProductList = [];
- var arr = arrProduct[j].ProductNum.split(",");
- for (var k = 0; k < arr.length; k++) {
- for (var i = 0; i < programList.length; i++) {
- if (programList[i].ID == arr[k]) {
- arrProduct[j].ProductList.push(programList[i]);
- }
- }
- }
- }
- wx.setStorageSync("ProductPrice", arrProduct);
- }
- });
- },
- updateProgram: function () {
- const updateManager = wx.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate)
- });
- updateManager.onUpdateReady(function () {
- updateManager.applyUpdate();
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|