| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575 |
- 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;
- if (app.globalData.userInfo.IsNewUser && app.globalData.userInfo.IsNewUser == 1 && app.globalData.userInfo.isShow == 1) {
- if (app.globalData.userInfo.Subscribe == 0) {
- wx.navigateTo({
- url: '../other/newuser',
- });
- }
- } 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.Subscribe == 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,
- });
- }
- },
- 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())));
- }
- if (url == "../plan/studyplan" && this.data.DayNumber <= app.globalData.IsShowSettingRemind) {
- wx.setStorageSync('IsShowSettingRemind', this.data.DayNumber);
- }
- 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 {
- var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
- that.setData({
- DayNumber: data.DayNumber,
- TodayTaskNumber: TodayTaskNumber,
- IsStart: data.IsStart,
- });
- //是否显示提示任务量设置
- if (that.data.DayNumber <= app.globalData.IsShowSettingRemind) {
- var IsShowSettingRemind = wx.getStorageSync("IsShowSettingRemind");
- if (!IsShowSettingRemind || IsShowSettingRemind < that.data.DayNumber) {
- that.setData({
- IsShowSettingRemind: 1,
- });
- } else {
- that.setData({
- IsShowSettingRemind: 0,
- });
- }
- }
- //判断是否出现推广广告
- 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 >= 8) {
- 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');
- },
- 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);
- },
- 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,
- }
- }
- },
- })
|