| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- 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=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 == "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") {
- 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: '../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 == "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,
- });
- }
- }
- 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,
- 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 = '../other/newuser';
- // 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);
- app.globalData.FolderList=[];
- wx.redirectTo({
- url: url,
- });
- }, 2000);
- }
- main.getUserConfig();
- }
- 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");
- 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,
- }
- },
- })
|