import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); var timeout1 = 0, timeout3=0; var timeoutRedirect=0; Page({ data: { Sentence:1, }, onPullDownRefresh: function () { wx.reLaunch({ url: './index', }) }, onLoad: function (options) { console.log("Time1:" + new Date().getTime()); 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); if (scene.indexOf("type=article")>=0){ app.globalData.SourceID=scene.substr(scene.indexOf("ID=") + 3); this.setData({ gotoType: "other", gotoUrl: '../main/docs?ID=' + app.globalData.SourceID, }); } else if (scene.indexOf("type=web")>=0){ app.globalData.SourceID=scene.substr(scene.indexOf("ID=") + 3); } else{ 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.type == "school") { this.setData({ gotoType: "other", gotoUrl: '../main/school?ID=' + options.ID, }); } else if (options.type == "district") { this.setData({ gotoType: "other", gotoUrl: '../main/district?ID=' + options.ID+'&Name='+options.Name, }); } else if (options.type == "recruitment") { this.setData({ gotoType: "other", gotoUrl: '../main/recruitment?PanelType=' + options.PanelType+'&DistrictID='+options.DistrictID, }); } else if (options.type == "scoreline") { this.setData({ gotoType: "other", gotoUrl: '../main/scoreline?PageType='+options.type+'&ScoreTypeID='+options.ScoreTypeID+'&DistrictID=' + options.ID+"&YearIndex="+options.YearIndex, }); } else if (options.type == "docs") { this.setData({ gotoType: "other", gotoUrl: '../main/docs?ID=' + options.ID, }); } else if (options.type == "wish") { this.setData({ gotoType: "other", gotoUrl: '../main/wishinfo?Share=1&ID=' + options.ID, }); } } this.setData({ IsRefresh: false, Containnerheight: main.getWindowHeight(), Sentence:common.random(1, 9), }); this.updateProgram(); this.getUserInfo(); var that = this; timeout1 = setTimeout(function () { that.setData({ IsRefresh: true, }) }, 15000); }, //得到用户信息 getUserInfo: function (cb) { var that = this //调用登录接口 wx.login({ success: function (res0) { app.globalData.userInfo = {}; app.globalData.userInfo.Code = res0.code; console.log("Time2:" + new Date().getTime()); app.globalData.userInfo.nickName = "陌生用户"; app.globalData.userInfo.language = ""; app.globalData.userInfo.gender = "0"; app.globalData.userInfo.city = ""; app.globalData.userInfo.province = ""; app.globalData.userInfo.country = ""; app.globalData.userInfo.avatarUrl = "../images/icon_sys_14.png"; that.login(app.globalData.userInfo); }, fail: function () {} }); }, login: function (param) { var that = this; main.getLocalHost(function () { main.postData('MPSLogin', { Code: param.Code, NickName: param.nickName, Language: param.language, Gender: param.gender, City: param.city, Province: param.province, Country: param.country, AvatarUrl: param.avatarUrl, 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("Time4:" + new Date().getTime()); if (!data) { timeout3 = setTimeout(function () { that.getUserInfo(); console.log("reboot:" + new Date().getTime()); }, 2000); } else { app.globalData.userInfo = data; 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; if (app.globalData.userInfo.IsMember == 1) app.globalData.IsLocked = 0; wx.removeStorageSync("UserID"); wx.removeStorageSync("UserName"); wx.removeStorageSync("CollectList"); if (that.data.gotoType == "other"){ app.globalData.GotoUrl = that.data.gotoUrl; var url = '../main/default'; wx.redirectTo({ url: url, }); } else{ var url = '../main/default'; timeoutRedirect=setTimeout(function () { console.log("Time5:" + new Date().getTime()); clearTimeout(timeout1); wx.redirectTo({ url: url, }); }, 200); } that.getBaiduToken(); } }); }); }, getBaiduToken: function () { main.getBaiduToken(); }, updateProgram: function () { const updateManager = wx.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 }); updateManager.onUpdateReady(function () { clearTimeout(timeoutRedirect); wx.showModal({ title: '更新提示', content: '新版本已经准备好,重启应用', showCancel:false, success: function (res) { wx.removeStorageSync("UserID"); wx.removeStorageSync("UserName"); updateManager.applyUpdate(); } }); }); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })