| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530 |
- 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 = 16;
- 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)) + "...";
- if (item.Content[1].ContentStr){
- item.Content[1].ContentStr=item.Content[1].ContentStr.replace("[特]","");
- item.Content[1].ContentStr=item.Content[1].ContentStr.replace("[/特]","");
- }
- 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)) + "...";
- if (item.Content[2].ContentStr){
- item.Content[2].ContentStr=item.Content[2].ContentStr.replace("[特]","");
- item.Content[2].ContentStr=item.Content[2].ContentStr.replace("[/特]","");
- }
- 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);
- if (imageUrl.length > 0) {
- item.ImageUrlTemp = main.getTempImage(imageUrl);
- item.ImageUrlServer = imageUrl;
- }
- 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){
- var content=mData.Content.replace("[SelectedCount]",that.data.SelectedCount);
-
- wx.showModal({
- title: '提醒',
- content: content,
- confirmText:mData.ConfirmText,
- complete: (res) => {
- if (res.confirm) {
- that.saveMultipleData(mData,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);
- }
- }
- }
- },
- //保存多选数据
- 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));
- 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链接列表
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|