| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import constant1 from '../../utils/constant';
- const app = getApp();
- var intervalRefresh = 0;
- var isCollecting = false;
- var canPress = true; //按钮按下有反应
- var arrOrder=constant1.arrListOrder;
- Page({
- data: {
- ImagePath: app.globalData.uploadImageUrl,
- IsShowCardShowDetail: false, //显示题卡显示细节
- IsShowSelectContainer:false,//显示多选其它菜单
- SelectContainerStyle:0,//多选按钮的样式模版
- IsFolderListContainer:0,//卡单列表选择页面
- IsHelp: false,
- IsFilter:false,
- ShowMultiple:0,//显示多选,0为不显示,2为卡单,3为星标,4为归档,5为日常,6为紧急,8为搜索,-1为全部
- HasPage: false, //有没有分页
- HasPageDelete:false,//有没有回收站的分页
- CardTypeStr: "全部",
- IsShowSelectCardType: false, //是否显示选择题卡模式
- ArrOrder: arrOrder, //可选择的排序数组
- OrderType: 2, //选择的排序类型
- CardType: 2, //练习模式类型,缺省为日常+紧急
- PrintID: 0, //打印ID
- CardShowDetail: 0, //0 创建时间 1 修改时间 2到期时间 3练习时间 4练习次数
- FolderListCss:"",//卡单时列表样式
- HasNullImage:0,//有没有未上传成功的空图
- SelectedCount:0,//多选的题卡数
- IsIPhoneX: app.globalData.IsIPhoneX,
- CanScroll:true,
- },
- onLoad: function (options) {
- var that = this;
- var Search = "",
- IsToday = 0,
- IsCollect = 0;
- var count = 0; //列表数
- if (options.Count)
- count = options.Count;
-
- if (options.source=="health"){
- that.setData({
- Source:options.source,
- });
- wx.setNavigationBarTitle({
- title: options.dataType
- });
- if (options.dataType == "最近练完") {
- that.gotoList({currentTarget:{dataset:{type:"today"}}});
- IsToday = 2;
- }
- else if (options.dataType == "已到期") {
- that.gotoList({currentTarget:{dataset:{type:"limit0"}}});
- IsToday = 4;
- that.setData({
- CardShowDetail: 2,
- });
- }
- else if (options.dataType == "答题时间极短") {
- that.gotoList({currentTarget:{dataset:{type:"TimeShort7"}}});
- IsToday = 5;
- that.setData({
- CardShowDetail: 3,
- });
- }
- else if (options.dataType == "多次点蓝") {
- that.gotoList({currentTarget:{dataset:{type:"ClickBlue7"}}});
- IsToday = 6;
- that.setData({
- CardShowDetail: 3,
- });
- }
- else if (options.dataType == "多次搁置") {
- that.gotoList({currentTarget:{dataset:{type:"ClickShelve7"}}});
- IsToday = 7;
- that.setData({
- CardShowDetail: 3,
- });
- }
- }
- //如果是搜索
- else if (options.search) {
- Search = options.search;
- wx.setNavigationBarTitle({
- title: "搜索结果"
- });
- that.setData({
- ShowMultiple:8,
- });
- } else if (options.type == 1) { //未练完的情况
- IsToday = 1;
- that.setOrderSelect(5);
- that.setData({
- CardShowDetail: 2,
- });
- wx.setNavigationBarTitle({
- title: "未练完的题卡"
- });
- } else if (options.type == 2) { //练完的情况
- IsToday = 2;
- that.setOrderSelect(1);
- that.setData({
- CardShowDetail: 3,
- });
- wx.setNavigationBarTitle({
- title: "练完的题卡"
- });
- } else if (options.IsCollect == 1) { //星标的情况(也就是原来的收藏夹)
- wx.setNavigationBarTitle({
- title: "星标"
- });
- IsCollect = 1;
- that.setData({
- IsCollect: IsCollect, //是否是星标
- ShowMultiple:3,
- });
- } else if (options.PrintID) { //打印题卡情况
- wx.setNavigationBarTitle({
- title: "打印卷题卡清单"
- });
- that.setData({
- PrintID: options.PrintID,
- });
- //console.log("options.PrintUserID:"+options.PrintUserID);
- //console.log("app.globalData.userInfo.UserID:"+app.globalData.userInfo.UserID);
-
- if (options.PrintUserID!=app.globalData.userInfo.UserID){
- wx.showModal({
- title: '提醒',
- showCancel: false,
- content: '此打印卷非您微信号生成,请扫描您生成的打印卷查看答案!',
- confirmText: '知道了',
- success(res) {
- if (res.confirm) {
- wx.navigateBack({
- delta: 1,
- });
- }
- }
- });
- }
- else{
- that.getPrintList();
- }
- } else if (options.FolderID) { //卡单题卡情况
- wx.setNavigationBarTitle({
- title: "卡单"
- });
- that.setData({
- FolderID: options.FolderID,
- FolderName:options.Name,
- IconName:options.IconName,
- ColorName:options.ColorName,
- FolderListCss:"CellHide00",
- ShowMultiple:options.FolderID,
- });
- } else if (options.CardType != 2) { //如果不是日常+紧急
-
- var title = "";
- if (options.CardType==0){
- title = "日常题卡";
- that.setData({
- ShowMultiple:5,
- });
- } else if (options.CardType == 1) {
- title = "紧急题卡";
- that.setData({
- ShowMultiple:6,
- });
- } else if (options.CardType == -1) {
- title = "归档";
- that.setData({
- ShowMultiple:4,
- });
- that.setOrderSelect(10);
- that.setData({
- CardShowDetail: 2,
- });
- } else if (options.CardType == -2) {
- title = "回收";
- that.setOrderSelect(10);
- var haspage=false;
- if (count>app.globalData.CardList.length)
- haspage=true;
- that.setData({
- CardShowDetail: 2,
- HasPageDelete:haspage,
- });
- //debugger;
- }
- wx.setNavigationBarTitle({
- title: title,
- });
- that.setData({
- CardType: options.CardType,
- });
- }
- else if (options.CardType == 2){
- that.setData({
- CardType: options.CardType,
- ShowMultiple:-1,
- });
- }
- that.setData({
- Search: Search, //搜索关键词
- IsToday: IsToday, //是否是今天任务
- Count: count, //列表数
- Containnerheight: main.getWindowHeight(),
- PageType: options.type, //列表类型,1 今天未练完 2 今天已经练完
- IsNew: options.IsNew, //
- });
- canPress = true;
- },
- onShow: function () {
- var that = this;
- if (!that.data.PrintID) {
- if (that.data.IsNew) //目前用于年度报告
- that.onOrder({
- currentTarget: {
- dataset: {
- value: 4
- }
- }
- });
- else
- that.getList();
- }
- //题卡主题色
- 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)];
- }
-
- that.getFilter();
- if (that.data.FolderID && app.globalData.TempStr){
- that.setData({
- FolderName:app.globalData.TempStr.Name,
- IconName:app.globalData.TempStr.IconName,
- ColorName:app.globalData.TempStr.ColorName,
- FolderListCss:"CellHide00",
- });
- app.globalData.TempStr="";
- }
- if (wx.getStorageSync("TempCardNoSaved")) {
- wx.navigateTo({
- url: '../other/recover',
- });
- }
- },
- getList: function () {
- var that = this;
- var list = app.globalData.CardList;
- var len = 100;
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- item.ScrollLeft = 0;
- item.DeleteType = 0;
- item.Content[1].ContentStr = main.replaceCardInfoString(item.Content[1].Content);
- if (item.Content[1].ContentStr.length > len)
- item.Content[1].ContentStr = main.replaceCardInfoString(item.Content[1].ContentStr.substr(0, len)) + "...";
- item.Content[2].ContentStr = main.replaceCardInfoString(item.Content[2].Content);
- if (item.Content[2].ContentStr.length > len)
- item.Content[2].ContentStr = main.replaceCardInfoString(item.Content[2].ContentStr.substr(0, len)) + "...";
- var imageUrl = getImage(item.Content[1].Content);
- if (imageUrl.length == 0 && item.Content[2].Content)
- imageUrl = getImage(item.Content[2].Content);
- if (imageUrl.length == 0 && item.Content[3].Content)
- imageUrl = getImage(item.Content[3].Content);
- item.Width="650";
- if (imageUrl.length > 0) {
- item.ImageUrlTemp = main.getTempImage(imageUrl);
- item.ImageUrlServer = imageUrl;
- item.Width="540";
- }
- else{
- if (item.Content[1].Content.indexOf("[/公式]")>0
- || item.Content[2].Content.indexOf("[/公式]")>0
- || item.Content[3].Content.indexOf("[/公式]")>0){
- item.ImageUrlTemp = "../images/universalpic_dictionary_formula_black_80x80.jpg";
- item.ImageUrlServer = item.ImageUrlTemp;
- item.Width="540";
- }
- }
- //debugger;
- if (item.FirstTime < "1900-01-02")
- item.CardCategory = "新题卡";
- else
- item.CardCategory = "旧题卡";
- if (that.data.PrintID){
- item.CardShowDetailStr2=item.Number;
- }
- else if (that.data.CardType == "-2") {
- item.CardShowDetailStr2 = common.formatDateCHS(item.DeleteTime);
- } else {
- switch (Number(that.data.CardShowDetail)) {
- case 0:
- item.CardShowDetailStr2 = common.formatDateCHS(item.CreateTime);
- break;
- case 1:
- item.CardShowDetailStr2 = common.formatDateCHS(item.UpdateTime);
- break;
- case 2:
- if (that.data.CardType==2 && item.CardType == -1){
- item.CardShowDetailStr2 = "不适用";
- }
- else if (item.CardType == -1)
- item.CardShowDetailStr2 = common.formatDateCHS(item.PigeonholeTime);
- else
- item.CardShowDetailStr2 = common.formatDateCHS(item.LimitTime);
- break;
- case 3:
- if (item.LastTime < "1900-01-02")
- item.CardShowDetailStr2 = "不适用";
- else
- item.CardShowDetailStr2 = common.formatDateCHS(item.LastTime);
- break;
- case 4:
- item.CardShowDetailStr2 = item.LearnNumber + "次";
- break;
- }
- }
- item.CardTypeStr = constant1.arrStudyPattern[item.CardType];
- }
- if (!that.data.IsToday && !that.data.PrintID && !that.data.Search && that.data.CardType != "-2" && !that.data.FolderID && !that.data.Source) {
- main.getData("GetUserCardCount?UserID=" + app.globalData.userInfo.UserID + "&CardType=" + that.data.CardType + "&IsCollect=" + that.data.IsCollect+"&OrderType="+that.data.OrderType, function (data) {
- if (data) {
- that.setData({
- Count: data.CardNumber,
- });
- var hasPage = false;
- if (list.length < that.data.Count && list.length >= 20 && that.data.IsToday == 0)
- hasPage = true;
- that.setData({
- List: list,
- HasPage: hasPage,
- });
- if (that.data.PageType === "3") {
- wx.redirectTo({
- url: './preview?type=show&id=' + list[0].MiaoguoCardID,
- })
- }
- }
- });
- } else if (that.data.Search || that.data.FolderID > 0 || that.data.Source) {
- var hasPage = false;
- if (list.length < that.data.Count)
- hasPage = true;
- that.setData({
- List: list,
- HasPage: hasPage,
- });
- } else if (that.data.CardType != -2 && !that.data.Source) {
- that.setData({
- Count: list.length,
- });
- var hasPage = false;
- if (list.length < that.data.Count && that.data.IsToday == 0)
- hasPage = true;
- that.setData({
- List: list,
- HasPage: hasPage,
- });
- } else {
- that.setData({
- List: list,
- HasNullImage:0,
- });
- }
- var strCardShowDetail = constant1.arrCardShowDetail[that.data.CardShowDetail];
- if (that.data.CardShowDetail == 2 && that.data.CardType == -1)
- strCardShowDetail = "归档";
- else if (that.data.CardType == -2)
- strCardShowDetail = "删除";
- else if (that.data.PrintID)
- strCardShowDetail = "打印卷序号";
-
- that.setData({
- CardShowDetailStr: strCardShowDetail,
- });
-
- wx.hideLoading();
- function getImage(str) {
- var result = "";
- if (str.indexOf("[图") >= 0) {
- result = str.substring(str.indexOf("[图") + 3, str.indexOf("[/图]"));
- result = result.substring(result.indexOf("]") + 1);
- }
- //console.log(result);
- return result;
- }
-
- },
- getNullImageList:function(){
- var that=this;
- var list=that.data.List;
- var arr=[];
- var count=0;
- for(var i=0;i<list.length;i++){
- if (list[i].IsNullImage){
- arr.push(list[i]);
- count++;
- }
- }
- app.globalData.CardList=arr;
- that.setData({
- List:arr,
- Count:count,
- HasPage:false,
- HasNullImage:2,
- });
- wx.setNavigationBarTitle({
- title: "遗失图片的题卡"
- });
- },
- onPreview: function (e) {
- var id = e.currentTarget.dataset.id;
- var url='./preview?type=show&id=' + id;
- if (this.data.PrintID)
- url+="&PrintID="+this.data.PrintID;
- wx.navigateTo({
- url: url,
- })
- },
- onBindError: function (e) {
- var that = this;
- var id = e.currentTarget.dataset.id;
- var serverUrl = e.currentTarget.dataset.serverurl;
- wx.downloadFile({
- url: serverUrl,
- success(res) {
- if (res.statusCode === 200) {
- main.saveTempImage(serverUrl, res.tempFilePath);
- }
- else{
- var list=that.data.List;
- for(var i=0;i<list.length;i++){
- if (list[i].MiaoguoCardID==id){
- list[i].IsNullImage=true;
- }
- }
- that.setData({
- HasNullImage:1,
- List:list,
- });
- wx.pageScrollTo({
- scrollTop: 0,
- });
- }
- }
- });
- },
- gotoNextPage: function (e) {
- wx.showLoading({
- title: '请稍候',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- var that = this;
- var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID;
- var id = e.currentTarget.dataset.id;
- if (id && id > 0)
- url += "&PageID=" + id;
- if (e.currentTarget.dataset.IsToday)
- url += "&IsToday="+e.currentTarget.dataset.IsToday;
- var cardtype = e.currentTarget.dataset.cardtype;
- if (cardtype || cardtype == "0") {
- url += "&CardType=" + cardtype;
- var str = constant1.arrStudyPattern[cardtype];
- if (cardtype == "2")
- str = "全部";
- that.setData({
- CardType: Number(cardtype),
- CardTypeStr: str,
- })
- } else {
- if (that.data.CardType || that.data.CardType==0)
- url += "&CardType=" + that.data.CardType;
- }
- if (that.data.Search)
- url += "&Key=" + that.data.Search;
- var orderType = that.data.OrderType;
- if (orderType)
- url += "&OrderType=" + arrOrder[orderType].Value;
- if (e.currentTarget.dataset.iscollect == 1)
- url += "&IsCollect=1";
-
- if (e.currentTarget.dataset.folderid)
- url += "&FolderID="+e.currentTarget.dataset.folderid;
-
- if (e.currentTarget.dataset.dayNumber)
- url += "&DayNumber="+e.currentTarget.dataset.dayNumber;
-
-
- main.getData(url, function (data) {
- if (data) {
- var list = app.globalData.CardList;
- if (id == 0) {
- list = [];
- that.setData({
- Count: data.Count,
- });
- }
- for (var i = 0; i < data.List.length; i++) {
- data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
- list.push(data.List[i]);
- }
- app.globalData.CardList = list;
- that.getList();
- if (data.List.length < 20) {
- that.setData({
- HasPage: false,
- });
- }
- that.getFilter();
- if (that.data.Source=="health"){
- setTimeout(function(){
- that.setBtnInfo(e.currentTarget.dataset.datatype,data.Count);
- },500);
- }
- }
- });
- that.setData({
- IsOrder: false,
- IsHelp: false,
- IsShowSelectCardType: false,
- });
- },
- //回收站的下一页
- gotoNextPageDelete: function (e) {
- wx.showLoading({
- title: '请稍候',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- var that = this;
- var url = 'GetMiaoguoCardDeleteList2?UserID=' + app.globalData.userInfo.UserID;
- var param={};
- var id=e.currentTarget.dataset.id;
- param.PageID=id;
- param.PageCount=20;
- param.Type="app";
- main.postData(url,param, function (data) {
- if (data) {
- var list = app.globalData.CardList;
- if (id == 0) {
- list = [];
- that.setData({
- Count: data.Count,
- });
- }
- for (var i = 0; i < data.List.length; i++) {
- data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
- list.push(data.List[i]);
- }
- app.globalData.CardList = list;
- that.getList();
-
- if (data.List.length < 20) {
- that.setData({
- HasPageDelete: false,
- });
- }
- that.getFilter();
- }
- });
- that.setData({
- IsOrder: false,
- IsHelp: false,
- IsShowSelectCardType: false,
- });
- },
- getPrintList: function (e) {
- wx.showLoading({
- title: '请稍候',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- var that = this;
- var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID + '&PrintID=' + that.data.PrintID;
- main.getData(url, function (data) {
- if (data) {
- if (data.List.length > 0) {
- var list = [];
- for (var i = 0; i < data.List.length; i++) {
- data.List[i].Number = i + 1;
- list.push(data.List[i]);
- }
- app.globalData.CardList = list;
- that.getList();
- wx.setNavigationBarColor({
- frontColor: "#000000",
- backgroundColor: "#ffffff",
- });
- } else {
- that.onSearch();
- }
- }
- });
- },
- getFilter:function(){
- var that = this;
- if (app.globalData.TempStr2){
- if (that.data.Count<=1)
- isFilter=false;
- else{
- var arr=[["全部",0,"",2,0],["",0,"",0,0]];
- var isFilter=false;
- var str=app.globalData.TempStr2;
- if (str.indexOf("IsCollect=1")>=0){
- arr[1][0]="星标";
- arr[1][3]=0;
- arr[1][4]=1;
- isFilter=true;
- }
- else if (str.indexOf("CardType=0")>=0){
- arr[1][0]="日常";
- arr[1][3]=0;
- arr[1][4]=0;
- isFilter=true;
- }
- else if (str.indexOf("CardType=1")>=0){
- arr[1][0]="紧急";
- arr[1][3]=1;
- arr[1][4]=0;
- isFilter=true;
- }
- else if (str.indexOf("CardType=-1")>=0){
- arr[1][0]="归档";
- arr[1][3]=-1;
- arr[1][4]=0;
- isFilter=true;
- }
-
- if (that.data.CardType==2){
- arr[0][1]=that.data.Count;
- arr[0][2]="panelTop40";
- }
- else{
- arr[1][1]=that.data.Count;
- arr[1][2]="panelTop40";
- arr[0][2]="";
- }
- //console.log("CardType:"+that.data.CardType);
- that.setData({
- FilterArr:arr,
- });
- }
- that.setData({
- IsFilter:isFilter,
- });
- }
- },
- addCard: function () {
- //console.log("canPress:"+canPress);
- if (canPress) {
- var url='./add?type=add&id=0';
- if (this.data.FolderID){
- url+="&FolderID="+this.data.FolderID+"&FolderName="+this.data.FolderName;
- }
- else{
- var cardtype=this.data.CardType;
- if (cardtype==1 || cardtype==-1){
- url+="&CardType="+cardtype;
- }
- }
-
- wx.redirectTo({
- url: url,
- });
- canPress = false;
- //console.log("canPress:"+canPress);
- setTimeout(function () {
- canPress = true;
- //console.log("canPress:"+canPress);
- }, 2000);
- }
- },
- onSearch: function (e) {
- var id=1;
- if (e.currentTarget.dataset.id)
- id=Number(e.currentTarget.dataset.id);
- wx.navigateBack({
- delta: id,
- });
- },
- onOrder: function (e) {
- var that = this;
- var value = e.currentTarget.dataset.value;
- switch (Number(value)) {
- case 1:
- that.data.CardShowDetail = 3;
- break;
- case 2:
- that.data.CardShowDetail = 1;
- break;
- case 3:
- case 4:
- that.data.CardShowDetail = 0;
- break;
- case 5:
- case 6:
- that.data.CardShowDetail = 2;
- break;
- case 7:
- case 8:
- that.data.CardShowDetail = 4;
- break;
- case 9:
- case 10:
- that.data.CardShowDetail = 2;
- break;
- }
- for (var i = 0; i < that.data.ArrOrder.length; i++) {
- if (i == value) {
- that.data.ArrOrder[i].CSS = "PanelBtnSelect2";
- } else
- that.data.ArrOrder[i].CSS = "";
- }
- that.setData({
- IsOrder: false,
- ArrOrder: that.data.ArrOrder,
- OrderType: value,
- CardShowDetail: that.data.CardShowDetail,
- });
- if (that.data.IsToday!=1) {
- app.globalData.CardList = [];
- that.gotoNextPage({
- currentTarget: {
- dataset: {
- id: 0,
- IsToday:that.data.IsToday,
- OrderType: value,
- cardtype: that.data.CardType,
- iscollect: that.data.IsCollect,
- folderid: that.data.FolderID,
- }
- }
- });
- }
- },
- gotoList:function(e){
- var that=this;
- var datatype=e.currentTarget.dataset.type;
- var isToday=0,cardType=2,isCollect=0,folderID=0,dayNumber=7;
-
- if (datatype=="today"){
- isToday=2;
- }
- else if (datatype=="yesterday"){
- isToday=3;
- }
- else if (datatype=="limit0"){
- cardType=0;
- isToday=4;
- that.setData({
- OrderType:5,
- });
- }
- else if (datatype=="limit1"){
- cardType=1;
- isToday=4;
- that.setData({
- OrderType:5,
- });
- }
- else{
- if (datatype && datatype.indexOf("7")>0)
- dayNumber=7;
- else if (datatype && datatype.indexOf("30")>0)
- dayNumber=30;
-
- if (datatype.indexOf("TimeShort")>=0)
- isToday=5;
- else if (datatype.indexOf("ClickBlue")>=0)
- isToday=6;
- else if (datatype.indexOf("ClickShelve")>=0)
- isToday=7;
-
- cardType=2;
- that.setData({
- OrderType:0,
- });
- }
-
- app.globalData.CardList = [];
- that.gotoNextPage({
- currentTarget: {
- dataset: {
- id: 0,
- IsToday:isToday,
- cardtype: cardType,
- iscollect: isCollect,
- folderid: folderID,
- datatype:datatype,
- dayNumber:dayNumber,
- }
- }
- });
- },
- setBtnInfo:function(datatype,count){
- var that=this;
- if (datatype=="today"){
- that.setData({
- Btn1Name:"今日",
- Btn1Type:"today",
- Btn2Name:"上次",
- Btn2Type:"yesterday",
- Btn1Count: count,
- Btn2Count: "",
- Btn1Class: "btn2",
- Btn2Class: "",
- CardShowDetail: 3,
- HasPage: false,
- });
- }
- else if (datatype=="yesterday"){
- that.setData({
- Btn1Name:"今日",
- Btn1Type:"today",
- Btn2Name:"上次",
- Btn2Type:"yesterday",
- Btn1Count: "",
- Btn2Count: count,
- Btn1Class: "",
- Btn2Class: "btn2",
- CardShowDetail: 3,
- HasPage: false,
- });
- }
- else if (datatype=="limit0"){
- that.setData({
- Btn1Name:"日常",
- Btn1Type:"limit0",
- Btn2Name:"紧急",
- Btn2Type:"limit1",
- Btn1Count: count,
- Btn2Count: "",
- Btn1Class: "btn2",
- Btn2Class: "",
- CardShowDetail: 2,
- });
- }
- else if (datatype=="limit1"){
- that.setData({
- Btn1Name:"日常",
- Btn1Type:"limit0",
- Btn2Name:"紧急",
- Btn2Type:"limit1",
- Btn1Count: "",
- Btn2Count: count,
- Btn1Class: "",
- Btn2Class: "btn2",
- CardShowDetail: 2,
- });
- }
- else if (datatype=="TimeShort7"){
- that.setData({
- Btn1Name:"近7天",
- Btn1Type:"TimeShort7",
- Btn2Name:"近30天",
- Btn2Type:"TimeShort30",
- Btn1Count: count,
- Btn2Count: "",
- Btn1Class: "btn2",
- Btn2Class: "",
- CardShowDetail: 3,
- });
- }
- else if (datatype=="TimeShort30"){
- that.setData({
- Btn1Name:"近7天",
- Btn1Type:"TimeShort7",
- Btn2Name:"近30天",
- Btn2Type:"TimeShort30",
- Btn1Count: "",
- Btn2Count: count,
- Btn1Class: "",
- Btn2Class: "btn2",
- CardShowDetail: 3,
- });
- }
- else if (datatype=="ClickBlue7"){
- that.setData({
- Btn1Name:"近7天",
- Btn1Type:"ClickBlue7",
- Btn2Name:"近30天",
- Btn2Type:"ClickBlue30",
- Btn1Count: count,
- Btn2Count: "",
- Btn1Class: "btn2",
- Btn2Class: "",
- CardShowDetail: 3,
- });
- }
- else if (datatype=="ClickBlue30"){
- that.setData({
- Btn1Name:"近7天",
- Btn1Type:"ClickBlue7",
- Btn2Name:"近30天",
- Btn2Type:"ClickBlue30",
- Btn1Count: "",
- Btn2Count: count,
- Btn1Class: "",
- Btn2Class: "btn2",
- CardShowDetail: 3,
- });
- }
- else if (datatype=="ClickShelve7"){
- that.setData({
- Btn1Name:"近7天",
- Btn1Type:"ClickShelve7",
- Btn2Name:"近30天",
- Btn2Type:"ClickShelve30",
- Btn1Count: count,
- Btn2Count: "",
- Btn1Class: "btn2",
- Btn2Class: "",
- CardShowDetail: 3,
- });
- }
- else if (datatype=="ClickShelve30"){
- that.setData({
- Btn1Name:"近7天",
- Btn1Type:"ClickShelve7",
- Btn2Name:"近30天",
- Btn2Type:"ClickShelve30",
- Btn1Count: "",
- Btn2Count: count,
- Btn1Class: "",
- Btn2Class: "btn2",
- CardShowDetail: 3,
- });
- }
- },
- showOrder: function () {
- this.setData({
- IsOrder: true,
- });
- },
- closeHelp: function () {
- this.setData({
- IsOrder: false,
- IsHelp: false,
- IsShowSelectCardType: false,
- });
- },
- DeleteItem: function (e) {
- var that = this;
- var id = e.currentTarget.dataset.id;
- var list = this.data.List;
- var b = true;
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- if (id == item.MiaoguoCardID) {
- if (item.DeleteType == 0) {
- item.ScrollLeft = 440;
- item.DeleteType = 1;
- } else if (item.DeleteType == 1) {
- b = false;
- item.DeleteType = 0;
- item.ScrollLeft = 0;
- var url = 'DeleteMiaoguoCard?UserID=' + app.globalData.userInfo.UserID;
- url += "&ID=" + id;
- main.getData(url, function (data) {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (id == list[i].MiaoguoCardID) {
- list.splice(i, 1);
- break;
- }
- }
- app.globalData.CardList = list;
- that.setData({
- List: list,
- Count: --that.data.Count,
- });
- });
- }
- } else {
- item.DeleteType = 0;
- item.ScrollLeft = 0;
- }
- }
- if (b) {
- that.setData({
- List: list,
- });
- }
- },
- showSelectCardShowDetail: function () {
- var that = this;
- var arr = [];
- for (var i = 0; i < 5; i++) {
- var obj = {};
- obj.Name = constant1.arrCardShowDetail[i];
- if (that.data.CardType == -1 && i == 2)
- obj.Name = "归档";
- if (i < 4)
- obj.Name += "时间";
- if (i == that.data.CardShowDetail)
- obj.IsSelected = "PanelBtnSelect";
- else
- obj.IsSelected = "";
- arr.push(obj);
- }
- that.setData({
- IsShowCardShowDetail: true,
- CardShowDetailArr: arr,
- });
- },
- hideSelectCardShowDetail: function () {
- var that = this;
- that.setData({
- IsShowCardShowDetail: false,
- });
- },
- selectCardShowDetail: function (e) {
- var that = this;
- that.data.CardShowDetail = e.currentTarget.dataset.id;
- that.setData({
- IsShowCardShowDetail: false,
- CardShowDetail: that.data.CardShowDetail,
- });
- that.getList();
- that.hideSelectCardShowDetail();
- },
- showHelp: function () {
- var that = this;
- that.setData({
- IsHelp: true,
- });
- },
- showSelectCardType: function () {
- var that = this;
- var arr = [
- ["全部", "", 2],
- ["日常", "", 0],
- ["紧急", "", 1],
- ["归档", "", -1]
- ];
- switch (that.data.CardType) {
- case 2:
- arr[0][1] = "PanelBtnSelect";
- break;
- case 0:
- arr[1][1] = "PanelBtnSelect";
- break;
- case 1:
- arr[2][1] = "PanelBtnSelect";
- break;
- case -1:
- arr[3][1] = "PanelBtnSelect";
- break;
- }
- that.setData({
- IsShowSelectCardType: true,
- CardTypeArr: arr,
- });
- },
- recoverItem: function (e) {
- var that = this;
- var id = e.currentTarget.dataset.id;
- var url = "DeleteMiaoguoCardWeb?UserID=" + app.globalData.userInfo.UserID;
- var param = {};
- param.IsRecover = "true";
- param.VisitType = "vtqOSthN7vSwYmhc1gCjfw==";
- param.ID = common.Encrypt(id);
- main.postData(url, param, function () {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (id == list[i].MiaoguoCardID) {
- list.splice(i, 1);
- break;
- }
- }
- app.globalData.CardList = list;
- that.setData({
- List: list,
- Count: --that.data.Count,
- });
- });
- },
- setCollect: function (e) {
- var that = this;
- if (!isCollecting) {
- isCollecting = true;
- setTimeout(function () {
- isCollecting = false;
- }, 3000);
- var id=e.currentTarget.dataset.id;
- var collect=e.currentTarget.dataset.collect;
- if (collect==0) {
- collect = 1;
- }
- else {
- collect = 0;
- }
- main.setCollect(id, collect, function () {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (id == list[i].MiaoguoCardID) {
- if (collect==0)
- list.splice(i, 1);
- else
- list[i].IsCollect = collect;
- break;
- }
- }
- app.globalData.CardList = list;
- that.setData({
- List: list,
- });
- });
- }
- },
- editField: function (e) {
- var id=e.currentTarget.dataset.id;
- var that = this;
- wx.navigateTo({
- url: './add?type=edit&id=' + id,
- });
- },
- removeFolder:function(e){
- var that = this;
- var id=e.currentTarget.dataset.id;
- var url = 'RemoveFolder?UserID=' + app.globalData.userInfo.UserID;
- url += "&ID=" + id;
- url += "&FolderID=" + that.data.FolderID;
- main.getData(url, function (data) {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (id == list[i].MiaoguoCardID) {
- list.splice(i, 1);
- break;
- }
- }
- app.globalData.CardList = list;
- that.setData({
- List: list,
- Count: --that.data.Count,
- });
- });
- },
- setOrderSelect:function(od){
- var that=this;
- for(var k=0;k<arrOrder.length;k++){
- if (k==od)
- arrOrder[k].CSS = "PanelBtnSelect2";
- else
- arrOrder[k].CSS = "";
- }
- that.setData({
- ArrOrder: arrOrder,
- OrderType:od,
- });
- },
- //设置多选状态
- setMultipleOptions:function(event){
- var that=this;
- //debugger;
- var IsMultipleOptions=event.currentTarget.dataset.index==1?true:false;
- that.setData({
- IsMultipleOptions:IsMultipleOptions,
- });
- if (!IsMultipleOptions){
- var list=that.data.List;
- for(var i=0;i<list.length;i++){
- list[i].Selected=false;
- }
- that.setData({
- List:list,
- SelectedCount:0,
- CanScroll:true,
- });
- }
- else{
- that.setData({
- CanScroll:false,
- });
- }
- },
- //选择或反选项
- selectedItem:function(event){
- var that=this;
- var isAll=event.currentTarget.dataset.isall;
-
- var id=event.currentTarget.dataset.id;
- var list=that.data.List;
- var selectedCount=0;
- //debugger;
- for(var i=0;i<list.length;i++){
- if (isAll){
- list[i].Selected=true;
- }
- else{
- if (id==list[i].MiaoguoCardID){
- if(!list[i].Selected)
- list[i].Selected=true;
- else
- list[i].Selected=false;
- }
- }
- if (list[i].Selected)
- selectedCount++;
- }
- that.setData({
- List:list,
- SelectedCount:selectedCount,
- });
- },
- showMultipleOther: function (event) {
- var that = this;
- var index=event.currentTarget.dataset.index;
- var b=false;
- if (index==1)
- b=true;
- if (b && that.data.SelectedCount==0){
- wx.showToast({
- title: '请先选择题卡',
- });
- }
- else{
- that.setData({
- IsShowSelectContainer: b,
- SelectContainerStyle:0,
- });
- }
- },
- //显示多选提醒
- showMultipleNotice:function(event){
- var that = this;
- var index=event.currentTarget.dataset.index;
- var mData = constant1.arrMultipleSaveData[index];
- if (index==1 || index==4 || index==5 || index==6 || index==7 || index==8){
- var content=mData.Content.replace("[SelectedCount]",that.data.SelectedCount);
- wx.showModal({
- title: '提醒',
- content: content,
- confirmText:mData.ConfirmText,
- complete: (res) => {
- if (res.confirm) {
- if (index<8)
- that.saveMultipleData(mData,that.data.List);
- else
- that.gotoYJBDC(that.data.List);
- }
- }
- });
- }
- else if (index==2 || index==3){
- //debugger;
- var menu=event.currentTarget.dataset.menu;
- if (menu==1){
- that.setData({
- SelectContainerStyle: index,
- });
- } else if (menu==2) {
- var id=event.currentTarget.dataset.id;
- that.showFolderListSelect({currentTarget:{dataset:{index:1,readfolder:id}}});
- } else {
- var id=event.currentTarget.dataset.id;
-
- if (index==3){
- mData.Param.IsCollect=id;
- mData.FinishedText=mData.FinishedTextArr[id];
- that.saveMultipleData(mData,that.data.List);
- }
- else{
- if (id==0){
- mData.Param.FolderID=0;
- }
- else{
- var list=that.data.FolderList;
- for(var i=0;i<list.length;i++){
- if (list[i].Selected==1){
- mData.Param.FolderID=list[i].ID;
- mData.Param.FolderName=list[i].Name;
- break;
- }
- }
- }
- mData.FinishedText=mData.FinishedTextArr[id];
- that.saveMultipleData(mData,that.data.List);
- }
- }
- }
- },
- selectThisFunc:function(){
- },
- //保存多选数据
- saveMultipleData:function(mData,list){
- var that=this;
- var arr=[];
- for(var i=0;i<list.length;i++){
- if (list[i].Selected){
- var id=list[i].MiaoguoCardID;
- id=common.Encrypt(id);
- arr.push(id);
- }
- }
- if (arr.length>0){
- var sql=mData.SaveFun+"?UserID="+app.globalData.userInfo.UserID;
- var param=mData.Param;
- param[param.ListStr]=arr;
- //console.log(JSON.stringify(param));
- //debugger;
- main.postData(sql, param, function (data) {
-
- list=that.updateSavedList(that.data.ShowMultiple,mData,list);
- app.globalData.CardList=list;
- that.setData({
- List:list,
- SelectedCount:0,
- IsShowSelectContainer:false,
- IsMultipleOptions:false,
- IsFolderListContainer:0,
- FolderList:null,
- });
- wx.showToast({
- title: mData.FinishedText,
- duration: 2000,
- });
- });
- }
- },
- //更新保存的列表状态
- updateSavedList:function(source,mData,list){
- var that=this;
- var index=mData.ID;
- //debugger;
- for(var i=list.length-1;i>=0;i--){
- if (list[i].Selected){
- list[i].Selected=0;
- if (index==1){//删除
- list.splice(i,1);
- that.data.Count--;
- }
- else if (index==2){
- list[i].FolderID=mData.Param.FolderID;
- if (list[i].FolderID>0)
- list[i].FolderName=mData.Param.FolderName;
-
- if (source>0 && index!=source && mData.Param.FolderID!=source){ //不同类型列表删除
- list.splice(i,1);
- that.data.Count--;
- }
- app.globalData.FolderList=[];
- }
- else if (index==3){
- list[i].IsCollect=Number(mData.Param.IsCollect);
-
- if (source>0 && source<8 && index==source && mData.Param.IsCollect==0) {//不同类型列表删除
- list.splice(i,1);
- that.data.Count--;
- }
- }
- else if (index==4){
- list[i].CardType=-1;
- list[i].CardTypeStr="归档";
-
- if (source>0 && source<8 && index!=source){ //不同类型列表删除
- list.splice(i,1);
- that.data.Count--;
- }
- }
- else if (index==5){
- list[i].CardType=0;
- list[i].CardTypeStr="日常";
- if (source>0 && source<8 && index!=source){ //不同类型列表删除
- list.splice(i,1);
- that.data.Count--;
- }
- }
- else if (index==6){
- list[i].CardType=1;
- list[i].CardTypeStr="紧急";
- if (source>0 && source<8 && index!=source){ //不同类型列表删除
- list.splice(i,1);
- that.data.Count--;
- }
- }
- else if (index==7){
- list[i].CardType=0;
- list[i].CardTypeStr="日常";
- list[i].FirstTime='1900-01-01 00:00:00';
- list[i].FirstTimeStr='1900-01-01';
- list[i].LastTime='1900-01-01 00:00:00';
- list[i].LastTimeStr='1900-01-01';
- list[i].LimitTime=common.formatTime(new Date(),"-");
- list[i].LimitTimeStr=common.formatTime(new Date(),"-",true);
- list[i].IntervalDay=0;
- list[i].RepetitionCoefficient=2.0;
- list[i].UpdateTime=list[i].LimitTime;
- list[i].UpdateTimeStr="今天";
- list[i].CardCategory="新题卡";
- }
- }
- }
- that.setData({
- Count:that.data.Count,
- });
- return list;
- },
- showFolderListSelect:function(e){
- var that=this;
- var index=Number(e.currentTarget.dataset.index);
- that.setData({
- IsFolderListContainer:index,
- });
- if (index==1){
- var url = 'GetUserFolderList?UserID=' + app.globalData.userInfo.UserID;
- main.getData(url, function (data) {
- that.setData({
- FolderList: data,
- });
- });
- }
- else{
- that.setData({
- FolderList: null,
- });
- }
- },
- selectFolderItem:function(e){
- var that=this;
- var index=Number(e.currentTarget.dataset.index);
- var list=that.data.FolderList;
- for(var i=0;i<list.length;i++){
- list[i].Selected=0;
- if (index==i){
- list[i].Selected=1;
- }
- }
- that.setData({
- FolderList:list,
- });
- },
- goto: function (e) {
- var url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: './' + url,
- })
- },
- redirect: function (e) {
- var that=this;
- var url = e.currentTarget.dataset.url;
- app.globalData.TempStr2="CardType="+that.data.CardType+"&IsCollect="+that.data.IsCollect;
- wx.redirectTo({
- url: './' + url,
- })
- },
- showHelpImage:function(){
- var url=app.globalData.uploadImageUrl+"web/update_image_mathod.png";
- wx.previewImage({
- current: url, // 当前显示图片的http链接
- urls: [url] // 需要预览的图片http链接列表
- });
- },
- gotoYJBDC:function(list){
- //console.log(list);
- let words=[];
- for(let i=0;i<list.length;i++){
- if (list[i].Selected){
- let str1=main.extractEnglishWords(list[i].Content[1].Content);
- if (str1){
- words.push(str1);
- }
- else{
- let str2=main.extractEnglishWords(list[i].Content[2].Content);
- if (str2){
- words.push(str2);
- }
- }
- }
- }
- //debugger;
- words = [...new Set(words)];
- var appid="wx80059777521b897c";
- var path="pages/index/index?SourceID="+app.globalData.ProgramID+"&goto=selectword&Words="+words.join(",");
- wx.navigateToMiniProgram({
- appId: appid,
- path: path,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|