import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); var canPress=true;//按钮按下有反应 Page({ data: { IsTempCardNoSaved: false, IsExit: false, DayNumber: 0, TodayTaskNumber: 0, IsStart: 0, IsMaintain: 0, IsIPhoneX: app.globalData.IsIPhoneX, ImagePath: app.globalData.uploadImageUrl, IsShowUserID: false, VersionID: app.globalData.Version, AwardDayNumber: 0, IsShowRemind: false, IsShowHelp: false, IsShowUserFamily: 0, ChildUserID:false, }, onPullDownRefresh: function () { wx.redirectTo({ url: '../main/default', }) wx.stopPullDownRefresh(); }, onLoad: function (options) { var that = this; that.setData({ ChildUserID:false, Containnerheight: main.getWindowHeight(), }); if (app.globalData.IsIPad) { that.setData({ IsIPad: "_iPad", }); } wx.showShareMenu({ withShareTicket: true, menus: ['shareAppMessage', 'shareTimeline'] }); canPress=true; that.getUserFamilyInfo(app.globalData.userInfo.UserID, function (data) {}); }, onHide: function () { wx.hideLoading(); canPress=true; }, onShow: function () { var that = this; //debugger; if (app.globalData.userInfo.IsNewUser && app.globalData.userInfo.IsNewUser == 1 && app.globalData.userInfo.isShow == 1) { if (app.globalData.userInfo.Subscribe == 0 && app.globalData.userInfo.IsApply==0) { wx.navigateTo({ url: '../other/newuser', }); } else{ wx.navigateTo({ url: '../other/userbook', }); app.globalData.GotoUrl = ""; } } else { wx.getSetting({ success(res) { if (app.globalData.userInfo.NickName == "陌生用户" && app.globalData.userInfo.IsMember == 1 && app.globalData.userInfo.isShow == 1) { wx.navigateTo({ url: '../index/accredit', }); } else { if (!app.globalData.userInfo.IsTryOut && app.globalData.userInfo.isShow == 1) { if (app.globalData.userInfo.IsApply==1) { wx.navigateTo({ url: '../other/userbook', }); app.globalData.GotoUrl = ""; } else { wx.redirectTo({ url: '../other/newuser', }); } } else if (app.globalData.userInfo.IsTryOut && app.globalData.userInfo.isShow == 1) { if (app.globalData.GotoUrl.indexOf("../other/pay?PayType=6") >= 0) { wx.navigateTo({ url: app.globalData.GotoUrl, }); app.globalData.GotoUrl = ""; } else { var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime))); var today = common.formatDateCHS(common.formatTime(new Date())); if (productServiceTime < today) { wx.redirectTo({ url: '../other/userbook', }); } else if (app.globalData.GotoUrl) { //console.log(app.globalData.GotoUrl); wx.navigateTo({ url: app.globalData.GotoUrl, }); app.globalData.GotoUrl = ""; } } } else if (app.globalData.userInfo.isShow == 0) { var url = 'SetGrade?UserID=' + app.globalData.userInfo.UserID+'&Grade=1'; main.getData(url, function (data) {}); } that.setData({ IsAccredit: true, }); that.init(); that.getTaskTodayList(); that.isNoSavedCard(); if (res.authSetting['scope.record'] === true) { app.globalData.IsRecorderAccredit = 1; } else if (res.authSetting['scope.record'] === false) { app.globalData.IsRecorderAccredit = -1; } } } }); } app.globalData.TempStr2 = null; wx.setNavigationBarColor({ frontColor: "#ffffff", backgroundColor: "#3157BA", }); if (wx.getStorageSync("IsHelpAddInfomation") == 1) { that.setData({ IsShowHelp: true, }); main.ShowHelp(that, "#btnAdd", "up", "点击下方“添加题卡”按钮"); } else { that.setData({ IsShowHelp: false, }); } //显示提醒练习 var IsNotShowRemindPractice = wx.getStorageSync("IsNotShowRemindPractice"); that.setData({ IsNotShowRemindPractice: IsNotShowRemindPractice, }); }, init: function () { //显示练习模式 var cardType = wx.getStorageSync("CardType"); if (!cardType) cardType = 0; this.setData({ CardType: cardType, }); //题卡主题色 var arrColorIndex = wx.getStorageSync("ColorIndexArr"); if (!arrColorIndex) { app.globalData.ColorIndex = common.random(1, 4); } else { app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)]; } //显示答案操作方式 var clickType = wx.getStorageSync("ClickType"); if (!clickType) clickType = 0; app.globalData.ClickType = clickType; //选择建议 var SecondConfigArray = wx.getStorageSync("SecondConfigArray"); if (SecondConfigArray) app.globalData.SecondConfigArray = SecondConfigArray; //显示命名方式 var MemoryLevel = wx.getStorageSync("MemoryLevel"); if (!MemoryLevel) MemoryLevel = 0; app.globalData.MemoryLevel = MemoryLevel; }, goto: function (e) { //console.log("canPress:"+canPress); if (canPress){ var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url, }); if (url == "../../pages_agent/marketing/index") { this.setData({ IsShowRemind: false, }); wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d", 30, new Date()))); } canPress=false; //console.log("canPress:"+canPress); setTimeout(function(){ canPress=true; //console.log("canPress:"+canPress); },2000); } }, //得到当天任务 getTaskTodayList: function () { var that = this; main.UpdateMiaoguoCardTodayAll(true, function () { main.getTaskTodayList(function (data) { if (data.IsMaintain == 1) { that.setData({ IsMaintain: 1, }); } else { //若基础任务量存在,则重新获得配置数据 if (data.BasicCardLimit) main.getUserConfig(); var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length; that.setData({ DayNumber: data.DayNumber, TodayTaskNumber: TodayTaskNumber, IsStart: data.IsStart, }); //判断是否出现推广广告 common.getStorageValue(that, "IsShowMarketingTime", "2020-01-01 00:00:00", function () { if (that.data.IsShowMarketingTime < common.formatTime(new Date())) { main.getAwardData(function (data) { var award = data.Total - data.AwardDayNumber that.setData({ IsShowRemind: true, AwardDayNumber: award, }); }); } else { if (app.globalData.MemoryLevel == 0 && data.DayNumber >= 30) { var IsShowPatternMenu = wx.getStorageSync("IsShowPatternMenu"); if (!IsShowPatternMenu) { wx.navigateTo({ url: '../other/menu?Type=1', }); wx.setStorageSync('IsShowPatternMenu', 1); } } } }); } }); }); }, isNoSavedCard: function () { var that = this; //判断是否有系统故障 if (app.globalData.userInfo.IsMaintain == 1) { that.setData({ IsMaintain: app.globalData.userInfo.IsMaintain, }); wx.setNavigationBarColor({ frontColor: "#ffffff", backgroundColor: "#0B8457", }) } //判断是否有未保存的卡 else if (wx.getStorageSync("TempCardNoSaved")) { wx.navigateTo({ url: '../other/recover', }); } else { that.setData({ IsTempCardNoSaved: false, }); wx.setNavigationBarColor({ frontColor: "#ffffff", backgroundColor: "#3157BA", }); } }, gotoReLaunch: function (e) { var url = e.currentTarget.dataset.url; wx.reLaunch({ url: url, }); }, showUserID: function () { var that = this; if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 3 || app.globalData.userInfo.UserID == 4) { var userid = 2; if (app.globalData.userInfo.UserID >= 3) userid = app.globalData.userInfo.UserID; that.setData({ IsShowUserID: true, ChangeUserID: userid, }); } }, onKeyInput: function (e) { var id = e.detail.value; var usertype = e.currentTarget.dataset.type; var that = this; if (usertype == "userid") { that.setData({ ChangeUserID: id, }); } else if (usertype == "newuserid") { that.setData({ ChangeNewUserID: id, }); } else if (usertype == "introduceruserid") { that.setData({ ChangeIntroducerUserID: id, }); } else if (usertype == "versionid") { that.setData({ VersoinID: id, }); } else if (usertype == "groupuserid") { that.setData({ ChangeGroupUserID: id, }); } else if (usertype == "refunduserid") { that.setData({ RefundUserID: id, }); } else if (usertype == "refundremark") { that.setData({ RefundRemark: id, }); } }, setSelectUser: function (e) { var that = this; if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 2 || app.globalData.userInfo.UserID == 3 || app.globalData.userInfo.UserID == 4) { var userid = that.data.ChangeUserID; wx.setStorageSync("UserID", userid); app.globalData.userInfo.UserID = userid; var fieldStr = ""; that.getUserInfo(userid, fieldStr, function (data) { wx.setNavigationBarTitle({ title: data.NickName }); main.getUserConfig(); app.globalData.userInfo.ProductServiceTime = data.ProductServiceTime; if (app.globalData.userInfo.UserID != 2) { app.globalData.userInfo.NickName = data.NickName; app.globalData.userInfo.AvatarUrl = data.AvatarUrl; } if (data.IsPromoter > 0) { app.globalData.userInfo.IsPromoter = data.IsPromoter; app.globalData.userInfo.PromotionLimitDays = data.PromotionLimitDays; app.globalData.userInfo.PromotionLimitTime = data.PromotionLimitTime; app.globalData.userInfo.WXServiceCharge = data.WXServiceCharge; app.globalData.userInfo.IndividualIncomeTax = data.IndividualIncomeTax; app.globalData.userInfo.WXAccount = data.WXAccount; app.globalData.userInfo.RealName = data.RealName; app.globalData.userInfo.IntroducerNickName = data.IntroducerNickName; app.globalData.userInfo.IntroducerAvatarUrl = data.IntroducerAvatarUrl; } that.getUserFamilyInfo(app.globalData.userInfo.UserID, function (data) {}); }); that.setData({ IsShowUserID: false, }); that.onShow(); } }, getUserInfoFunction: function (e) { var that = this; var userid = e.currentTarget.dataset.id; var type1 = e.currentTarget.dataset.type; var fieldStr = "&FieldStr=NickName,AvatarUrl"; if (userid) { that.getUserInfo(userid, fieldStr, function (data) { if (type1 == 3) { that.setData({ RefundUserAvatar: data.AvatarUrl, RefundUserNickName: data.NickName, }); var url = "GetUserPayList?UserID=" + userid; main.getData(url, function (data) { if (data) { that.setData({ PayList: data, }); } }); } }); } }, getUserInfo: function (userID, fieldStr, callback) { var url = "GetMiaoguoWXUserInfo?UserID=" + userID + fieldStr; main.getData(url, function (data) { if (data) { callback(data); } }); }, //得到用户关联列表 getUserFamilyInfo: function (userID, callback) { var that = this; var url = "GetUserFamily?UserID=" + userID + "&IsWeb=false"; main.getData(url, function (data) { if (data) { if (data.length > 0) { that.setData({ IsShowUserFamily: 1, UserFamilyNickName: common.getStringMaxLength(app.globalData.userInfo.NickName, 12), UserFamilyAvatar: app.globalData.userInfo.AvatarUrl, UserFamily: data, }); if (app.globalData.userInfo.ChildUserID){ that.setData({ ChildUserID: app.globalData.userInfo.ChildUserID, }); } app.globalData.FamilyUsers = data; } } }); }, selectPayItem: function (e) { var that = this; var id = e.currentTarget.dataset.id; var list = that.data.PayList; for (var i = 0; i < list.length; i++) { if (list[i].TradeNo == id) list[i].IsSelected = "1"; else list[i].IsSelected = ""; } that.setData({ PayList: list, }); }, setRefund: function () { var that = this; var str = "", TradeNo = "", Remark = ""; var list = that.data.PayList; for (var i = 0; i < list.length; i++) { if (list[i].IsSelected == "1") { str = '确认给【' + that.data.RefundUserNickName + "】退款 "; str += list[i].Money + "元,"; str += "交易编号:" + list[i].TradeNo; TradeNo = list[i].TradeNo; Remark = that.data.RefundRemark; break; } } if (!str) { wx.showToast({ title: '请列表中选择', }); } else if (!that.data.RefundRemark) { wx.showToast({ title: '请输入退款备注', }); } else { wx.showModal({ title: '退款确认', showCancel: true, cancelText: "取消", content: str, confirmText: '确认', success(res) { if (res.confirm) { var url = "RefundUser?UserID=" + that.data.RefundUserID + "&TradeNo=" + TradeNo + "&Remark=" + Remark; main.getData(url, function (data) { wx.showToast({ title: '退款完成', }); }); } } }); } }, closeRemind: function () { this.setData({ IsShowRemind: false, }); wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d", 30, new Date()))); //判断每30天是否是完整模式 wx.removeStorageSync('IsShowPatternMenu'); }, closeRemindPractice: function () { this.setData({ IsNotShowRemindPractice: 1, }); wx.setStorageSync("IsNotShowRemindPractice", 1); }, showUserFamily: function () { this.setData({ IsShowUserFamily: 2, }); }, closeUserFamily: function () { this.setData({ IsShowUserFamily: 1, }); }, setVersionStart: function (e) { var flag = e.currentTarget.dataset.flag; var versionid = e.currentTarget.dataset.versionid; var url = "UpdateVersionStatus?ProgramID=166&Version=" + versionid + "&Flag=" + flag; main.getData(url, function (data) { wx.showToast({ title: '修改成功!', }) }); }, onShareTimeline: function () { return this.onShareAppMessage(); }, closeHelp: function () { this.setData({ IsShowHelp: false, }); wx.setStorageSync('IsHelpAddInfomation', 0); }, gotoTaskSetting:function(e){ var taskSetting=wx.getStorageSync("TaskSetting"); if (taskSetting) this.goto({currentTarget:{dataset:{url:"../../pages_plan/plan/taskFull"}}}); else this.goto({currentTarget:{dataset:{url:"../../pages_plan/plan/taskBasic"}}}); }, onShareAppMessage: function () { if (wx.getStorageSync("IsHelpAddInfomation") == 1) { return { title: "题卡制作【加资料】教程", path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID + "&type=helpAddInfomation", imageUrl: app.globalData.uploadImageUrl + "web/program_screenshot_lesson_a0204.png", } } else { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } } }, })