import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); var timeout1 = 0, timeout3=0; var timeoutRedirect=0; var UserFamilyID=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.UserFamilyID) UserFamilyID=options.UserFamilyID; 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=print")>=0){ options.type="print"; options.PUserID=scene.substr(scene.indexOf("U") + 2); options.PrintID=scene.substring(scene.indexOf("P") + 2,scene.indexOf("&U")); } 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 == "share") { if (options.ColorIndex) app.globalData.ColorIndex = options.ColorIndex; this.setData({ gotoType: "share", gotoUrl: '../main/preview?type=share&id=' + options.MiaoguoCardID, }); } else if (options.type == "bebound") { this.setData({ gotoType: "bebound", gotoUrl: "../other/binding?type=bebound&ParentUserID=" + options.ParentUserID + "&NickName=" + options.NickName + "&AvatarUrl=" + options.AvatarUrl + "&BindTime=" + options.BindTime, }); } else if (options.type == "family") { var url="../other/family"; if (options.PanelType==1) url="../other/family?PanelType=1&Time="+options.Time+"&MainUserID="+options.MainUserID+ "&NickName=" + options.NickName + "&AvatarUrl=" + options.AvatarUrl; this.setData({ gotoType: "other", gotoUrl: url, }); } else if (options.type == "lesson" || options.type == "video") { app.globalData.LessonID = options.LessonID; if (options.LessonPage) app.globalData.LessonPage = options.LessonPage; else app.globalData.LessonPage = 1; var url=""; if (options.type == "video"){ url = '../other/video?LessonID=' + app.globalData.LessonID + '&LessonPage=' + app.globalData.LessonPage } else{ if (app.globalData.LessonID === "all") { if (!options.ListType) url = '../other/lessonlistselect'; else url = '../other/lessonlist?listtype='+options.ListType; } else if (app.globalData.LessonID > 0) { url = '../other/lesson?LessonID=' + app.globalData.LessonID + '&LessonPage=' + app.globalData.LessonPage } } this.setData({ gotoType: "other", gotoUrl: url, }); } else if (options.type == "marketing") { this.setData({ gotoType: "other", gotoUrl: '../../pages_agent/marketing/index', }); } else if (options.type == "homework") { this.setData({ gotoType: "other", gotoUrl: "../other/homework", }); } else if (options.type == "userbook") { this.setData({ gotoType: "other", gotoUrl: "../other/userbook", }); } else if (options.type == "activity") { this.setData({ gotoType: "other", gotoUrl: "../other/activity?ActivityID=" + options.ActivityID + "&EarlyBirdTimeStart=" + options.EarlyBirdTimeStart + "&EarlyBirdTimeEnd=" + options.EarlyBirdTimeEnd + "&EndTime=" + options.EndTime, }); } else if (options.type == "webview") { this.setData({ gotoType: "other", gotoUrl: "../other/webview?PageID=" + options.PageID, }); } else if (options.type == "shareIndex") { this.setData({ gotoType: "other", gotoUrl: "../share/shareindex", }); } else if (options.type == "help") { this.setData({ gotoType: "other", gotoUrl: "../other/help?IsShare=1&id=" + options.ID+"&idchild="+options.IDChild, }); } else if (options.type == "paycustom") { this.setData({ gotoType: "other", gotoUrl: "../other/pay?PayType=6&PayUserID="+options.PayUserID+"&DayNumber="+options.DayNumber+"&Price="+options.Price+"&Remark="+options.Remark, }); } else if (options.type == "print") { var pid=options.PrintID; if (!pid) pid=options.P; var puid=options.PUserID; this.setData({ gotoType: "other", gotoUrl: "../main/mainlist?PrintID="+pid+"&PrintUserID="+puid, }); } else if (options.type == "paycontinue") { this.setData({ gotoType: "other", gotoUrl: "../other/pay?PayType=7&EndDate="+options.EndDate, }); } else if (options.type == "helpAddInfomation") { wx.setStorageSync('IsHelpAddInfomation', 1); } } 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/universalpic_face_default_blue_120x120.png"; that.login(app.globalData.userInfo); }, fail: function () {} }); }, login: function (param) { var that = this; main.getLocalHost(function () { main.postData('MiaoguoLogin', { Code: param.Code, UserFamilyID:UserFamilyID, 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"); // //测试**************** // var url = '../share/shareindex'; // wx.redirectTo({ // url: url, // }); // return; // //测试**************** if (that.data.gotoType == "share") { wx.reLaunch({ url: that.data.gotoUrl, }); } else if (that.data.gotoType == "bebound") { wx.reLaunch({ url: that.data.gotoUrl, }); } else { 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); clearTimeout(timeout3); app.globalData.FolderList=[]; wx.redirectTo({ url: url, }); }, 2000); } main.getUserConfig(); } main.getServerSoundErrorArr(); 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"); wx.removeStorageSync("SearchWord3"); wx.removeStorageSync("HanziUpdateTime"); wx.removeStorageSync("HanziAll"); wx.removeStorageSync("EnglishAll"); updateManager.applyUpdate(); } }); }); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })