| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- 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,
- 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,
- });
- }
- }
- wx.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- },
- 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 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) {
- 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,
- });
- 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")) {
- 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 == 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,
- });
- }
- },
- 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="&FieldStr=NickName,ProductServiceTime,AvatarUrl";
- 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;
- }
- });
-
- 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==1){
- that.setData({
- IntroducerAvatar: data.AvatarUrl,
- IntroducerNickName: data.NickName,
- });
- }
- else{
- that.setData({
- NewUserAvatar: data.AvatarUrl,
- NewUserNickName: data.NickName,
- });
- }
- });
- }
- },
- getUserInfo:function(userID,fieldStr,callback){
- var url = "GetMiaoguoWXUserInfo?UserID=" + userID + fieldStr;
- main.getData(url, function (data) {
- if (data) {
- callback(data);
- }
- });
- },
- setUserIntroducer: function (e) {
- var that = this;
- if (that.data.ChangeNewUserID && that.data.ChangeIntroducerUserID){
- if (app.globalData.userInfo.UserID == 1
- || app.globalData.userInfo.UserID == 2
- || app.globalData.userInfo.UserID == 3
- || app.globalData.userInfo.UserID == 4) {
- var url = "UpdateIntroducer?UserID=" + that.data.ChangeNewUserID + "&Introducer="+that.data.ChangeIntroducerUserID;
- main.getData(url, function (data) {
- that.setData({
- ChangeNewUserID: null,
- ChangeIntroducerUserID: null,
- });
- wx.showToast({
- title: '介绍人更改成功',
- })
- });
- }
- }
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- onShareTimeline: function () {
- return this.onShareAppMessage();
- },
- })
|