| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- IsTempCardNoSaved: false,
- IsExit: false,
- DayNumber: 0,
- TodayTaskNumber: 0,
- IsStart: 0,
- IsShowMarketing: 1,
- IsMaintain: 0,
- IsIPhoneX: app.globalData.IsIPhoneX,
- ImagePath: app.globalData.uploadImageUrl,
- SelectUserData: app.globalData.SelectUserData,
- IsShowUserID: false,
- },
- onPullDownRefresh: function () {
- wx.redirectTo({
- url: '../main/default',
- })
- wx.stopPullDownRefresh();
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- });
- if (app.globalData.IsIPad) {
- that.setData({
- IsIPad: "_iPad",
- });
- if (app.globalData.systemInfo.windowHeight < app.globalData.systemInfo.windowWidth) {
- that.setData({
- IsExit: true,
- });
- }
- }
- },
- onHide: function () {
- wx.hideLoading();
- },
- 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.redirectTo({
- url: '../other/newuser',
- });
- }
- }
- else {
- wx.getSetting({
- success(res) {
- if (res.authSetting['scope.userInfo'] || app.globalData.userInfo.IsShow == 0) {
- if (!app.globalData.userInfo.IsMember && 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.IsMember && 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.userInfo.ClassDayNumber < 0) {
- 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) {
- main.buildInitData(function () { });
- }
- that.setData({
- IsAccredit: true,
- });
- //判断是否出现推广广告
- common.getStorageValue(that, "IsShowMarketing", app.globalData.userInfo.HasIntroducer, function () {
- if (app.globalData.userInfo.HasIntroducer == 0 && that.data.IsShowMarketing == 3) {
- var isShowMarketingTime = wx.getStorageSync("IsShowMarketingTime");
- if (common.formatTime(new Date()) >= isShowMarketingTime) {
- wx.removeStorageSync("IsShowMarketing");
- wx.removeStorageSync("IsShowMarketingTime");
- that.setData({
- IsShowMarketing: 0,
- });
- }
- }
- });
- that.init();
- that.getTaskTodayList();
- that.isNoSavedCard();
- }
- else {
- wx.navigateTo({
- url: '../index/accredit',
- });
- }
- if (res.authSetting['scope.record'] === true) {
- app.globalData.IsRecorderAccredit = 1;
- }
- else if (res.authSetting['scope.record'] === false) {
- app.globalData.IsRecorderAccredit = -1;
- }
- }
- });
- }
- wx.setNavigationBarColor({
- frontColor: "#ffffff",
- backgroundColor: "#3157BA",
- });
- },
- 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 MemoryLevel = wx.getStorageSync("MemoryLevel");
- if (!MemoryLevel)
- MemoryLevel = 0;
- app.globalData.MemoryLevel = MemoryLevel;
- //选择建议
- var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
- if (SecondConfigArray)
- app.globalData.SecondConfigArray = SecondConfigArray;
- },
- goto: function (e) {
- var url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- if (url == "../marketing/index") {
- this.setData({
- IsShowMarketing: 2,
- });
- wx.setStorageSync("IsShowMarketing", 2);
- }
- },
- //得到当天任务
- 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,
- });
- }
- });
- });
- },
- 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")) {
- that.setData({
- IsTempCardNoSaved: true,
- });
- wx.setNavigationBarColor({
- frontColor: "#ffffff",
- backgroundColor: "#0B8457",
- })
- }
- else {
- that.setData({
- IsTempCardNoSaved: false,
- });
- wx.setNavigationBarColor({
- frontColor: "#ffffff",
- backgroundColor: "#3157BA",
- });
- }
- },
- onOpenTempCard: function () {
- var card = wx.getStorageSync("TempCardNoSaved");
- app.globalData.CardList = [card];
- wx.navigateTo({
- url: './add?type=add2&id=' + card.MiaoguoCardID,
- });
- },
- onGiveupTempCard: function () {
- var that = this;
- wx.removeStorageSync("TempCardNoSaved");
- that.isNoSavedCard();
- },
- gotoSearchCard: function () {
- wx.reLaunch({
- url: './searchCard',
- });
- },
- closeMarketing: function () {
- this.setData({
- IsShowMarketing: 3,
- });
- wx.setStorageSync("IsShowMarketing", 3);
- wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d", 7, new Date())));
- },
- showUserID:function(){
- var that = this;
- if (app.globalData.userInfo.UserID == 1
- || app.globalData.userInfo.UserID == 2
- || app.globalData.userInfo.UserID == 3
- || app.globalData.userInfo.UserID == 4) {
- that.setData({
- IsShowUserID: true,
- ChangeuUserID:2,
- });
- }
- },
- onKeyInput: function (e) {
- var id = e.detail.value;
- var that = this;
- that.setData({
- ChangeuUserID: 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.ChangeuUserID;
- wx.setStorageSync("UserID", userid);
-
- app.globalData.userInfo.UserID = userid;
- var url = "GetMiaoguoWXUserInfo?UserID=" + app.globalData.userInfo.UserID + "&FieldStr=NickName";
- main.getData(url, function (data) {
- if (data) {
- wx.setNavigationBarTitle({
- title: data.NickName
- });
- main.getUserConfig();
- }
- });
- that.setData({
- IsShowUserID: false,
- });
- that.onShow();
- }
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|