mainlist.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import constant1 from '../../utils/constant';
  4. const app = getApp();
  5. var intervalRefresh = 0;
  6. var isCollecting = false;
  7. var canPress = true; //按钮按下有反应
  8. var arrOrder=constant1.arrListOrder;
  9. Page({
  10. data: {
  11. ImagePath: app.globalData.uploadImageUrl,
  12. IsShowCardShowDetail: false, //显示题卡显示细节
  13. IsShowSelectContainer:false,//显示多选其它菜单
  14. SelectContainerStyle:0,//多选按钮的样式模版
  15. IsFolderListContainer:0,//卡单列表选择页面
  16. IsHelp: false,
  17. IsFilter:false,
  18. ShowMultiple:0,//显示多选,0为不显示,2为卡单,3为星标,4为归档,5为日常,6为紧急,8为搜索,-1为全部
  19. HasPage: false, //有没有分页
  20. HasPageDelete:false,//有没有回收站的分页
  21. CardTypeStr: "全部",
  22. IsShowSelectCardType: false, //是否显示选择题卡模式
  23. ArrOrder: arrOrder, //可选择的排序数组
  24. OrderType: 2, //选择的排序类型
  25. CardType: 2, //练习模式类型,缺省为日常+紧急
  26. PrintID: 0, //打印ID
  27. CardShowDetail: 0, //0 创建时间 1 修改时间 2到期时间 3练习时间 4练习次数
  28. FolderListCss:"",//卡单时列表样式
  29. HasNullImage:0,//有没有未上传成功的空图
  30. SelectedCount:0,//多选的题卡数
  31. IsIPhoneX: app.globalData.IsIPhoneX,
  32. CanScroll:true,
  33. },
  34. onLoad: function (options) {
  35. var that = this;
  36. var Search = "",
  37. IsToday = 0,
  38. IsCollect = 0;
  39. var count = 0; //列表数
  40. if (options.Count)
  41. count = options.Count;
  42. if (options.source=="health"){
  43. that.setData({
  44. Source:options.source,
  45. });
  46. wx.setNavigationBarTitle({
  47. title: options.dataType
  48. });
  49. if (options.dataType == "最近练完") {
  50. that.gotoList({currentTarget:{dataset:{type:"today"}}});
  51. IsToday = 2;
  52. }
  53. else if (options.dataType == "已到期") {
  54. that.gotoList({currentTarget:{dataset:{type:"limit0"}}});
  55. IsToday = 4;
  56. that.setData({
  57. CardShowDetail: 2,
  58. });
  59. }
  60. else if (options.dataType == "答题时间极短") {
  61. that.gotoList({currentTarget:{dataset:{type:"TimeShort7"}}});
  62. IsToday = 5;
  63. that.setData({
  64. CardShowDetail: 3,
  65. });
  66. }
  67. else if (options.dataType == "多次点蓝") {
  68. that.gotoList({currentTarget:{dataset:{type:"ClickBlue7"}}});
  69. IsToday = 6;
  70. that.setData({
  71. CardShowDetail: 3,
  72. });
  73. }
  74. else if (options.dataType == "多次搁置") {
  75. that.gotoList({currentTarget:{dataset:{type:"ClickShelve7"}}});
  76. IsToday = 7;
  77. that.setData({
  78. CardShowDetail: 3,
  79. });
  80. }
  81. }
  82. //如果是搜索
  83. else if (options.search) {
  84. Search = options.search;
  85. wx.setNavigationBarTitle({
  86. title: "搜索结果"
  87. });
  88. that.setData({
  89. ShowMultiple:8,
  90. });
  91. } else if (options.type == 1) { //未练完的情况
  92. IsToday = 1;
  93. that.setOrderSelect(5);
  94. that.setData({
  95. CardShowDetail: 2,
  96. });
  97. wx.setNavigationBarTitle({
  98. title: "未练完的题卡"
  99. });
  100. } else if (options.type == 2) { //练完的情况
  101. IsToday = 2;
  102. that.setOrderSelect(1);
  103. that.setData({
  104. CardShowDetail: 3,
  105. });
  106. wx.setNavigationBarTitle({
  107. title: "练完的题卡"
  108. });
  109. } else if (options.IsCollect == 1) { //星标的情况(也就是原来的收藏夹)
  110. wx.setNavigationBarTitle({
  111. title: "星标"
  112. });
  113. IsCollect = 1;
  114. that.setData({
  115. IsCollect: IsCollect, //是否是星标
  116. ShowMultiple:3,
  117. });
  118. } else if (options.PrintID) { //打印题卡情况
  119. wx.setNavigationBarTitle({
  120. title: "打印卷题卡清单"
  121. });
  122. that.setData({
  123. PrintID: options.PrintID,
  124. });
  125. //console.log("options.PrintUserID:"+options.PrintUserID);
  126. //console.log("app.globalData.userInfo.UserID:"+app.globalData.userInfo.UserID);
  127. if (options.PrintUserID!=app.globalData.userInfo.UserID){
  128. wx.showModal({
  129. title: '提醒',
  130. showCancel: false,
  131. content: '此打印卷非您微信号生成,请扫描您生成的打印卷查看答案!',
  132. confirmText: '知道了',
  133. success(res) {
  134. if (res.confirm) {
  135. wx.navigateBack({
  136. delta: 1,
  137. });
  138. }
  139. }
  140. });
  141. }
  142. else{
  143. that.getPrintList();
  144. }
  145. } else if (options.FolderID) { //卡单题卡情况
  146. wx.setNavigationBarTitle({
  147. title: "卡单"
  148. });
  149. that.setData({
  150. FolderID: options.FolderID,
  151. FolderName:options.Name,
  152. IconName:options.IconName,
  153. ColorName:options.ColorName,
  154. FolderListCss:"CellHide00",
  155. ShowMultiple:options.FolderID,
  156. });
  157. } else if (options.CardType != 2) { //如果不是日常+紧急
  158. var title = "";
  159. if (options.CardType==0){
  160. title = "日常题卡";
  161. that.setData({
  162. ShowMultiple:5,
  163. });
  164. } else if (options.CardType == 1) {
  165. title = "紧急题卡";
  166. that.setData({
  167. ShowMultiple:6,
  168. });
  169. } else if (options.CardType == -1) {
  170. title = "归档";
  171. that.setData({
  172. ShowMultiple:4,
  173. });
  174. that.setOrderSelect(10);
  175. that.setData({
  176. CardShowDetail: 2,
  177. });
  178. } else if (options.CardType == -2) {
  179. title = "回收";
  180. that.setOrderSelect(10);
  181. var haspage=false;
  182. if (count>app.globalData.CardList.length)
  183. haspage=true;
  184. that.setData({
  185. CardShowDetail: 2,
  186. HasPageDelete:haspage,
  187. });
  188. //debugger;
  189. }
  190. wx.setNavigationBarTitle({
  191. title: title,
  192. });
  193. that.setData({
  194. CardType: options.CardType,
  195. });
  196. }
  197. else if (options.CardType == 2){
  198. that.setData({
  199. CardType: options.CardType,
  200. ShowMultiple:-1,
  201. });
  202. }
  203. that.setData({
  204. Search: Search, //搜索关键词
  205. IsToday: IsToday, //是否是今天任务
  206. Count: count, //列表数
  207. Containnerheight: main.getWindowHeight(),
  208. PageType: options.type, //列表类型,1 今天未练完 2 今天已经练完
  209. IsNew: options.IsNew, //
  210. });
  211. canPress = true;
  212. },
  213. onShow: function () {
  214. var that = this;
  215. if (!that.data.PrintID) {
  216. if (that.data.IsNew) //目前用于年度报告
  217. that.onOrder({
  218. currentTarget: {
  219. dataset: {
  220. value: 4
  221. }
  222. }
  223. });
  224. else
  225. that.getList();
  226. }
  227. //题卡主题色
  228. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  229. if (!arrColorIndex) {
  230. app.globalData.ColorIndex = common.random(1, 4);
  231. } else {
  232. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  233. }
  234. that.getFilter();
  235. if (that.data.FolderID && app.globalData.TempStr){
  236. that.setData({
  237. FolderName:app.globalData.TempStr.Name,
  238. IconName:app.globalData.TempStr.IconName,
  239. ColorName:app.globalData.TempStr.ColorName,
  240. FolderListCss:"CellHide00",
  241. });
  242. app.globalData.TempStr="";
  243. }
  244. if (wx.getStorageSync("TempCardNoSaved")) {
  245. wx.navigateTo({
  246. url: '../other/recover',
  247. });
  248. }
  249. },
  250. getList: function () {
  251. var that = this;
  252. var list = app.globalData.CardList;
  253. var len = 100;
  254. for (var i = 0; i < list.length; i++) {
  255. var item = list[i];
  256. item.ScrollLeft = 0;
  257. item.DeleteType = 0;
  258. item.Content[1].ContentStr = main.replaceCardInfoString(item.Content[1].Content);
  259. if (item.Content[1].ContentStr.length > len)
  260. item.Content[1].ContentStr = main.replaceCardInfoString(item.Content[1].ContentStr.substr(0, len)) + "...";
  261. item.Content[2].ContentStr = main.replaceCardInfoString(item.Content[2].Content);
  262. if (item.Content[2].ContentStr.length > len)
  263. item.Content[2].ContentStr = main.replaceCardInfoString(item.Content[2].ContentStr.substr(0, len)) + "...";
  264. var imageUrl = getImage(item.Content[1].Content);
  265. if (imageUrl.length == 0 && item.Content[2].Content)
  266. imageUrl = getImage(item.Content[2].Content);
  267. if (imageUrl.length == 0 && item.Content[3].Content)
  268. imageUrl = getImage(item.Content[3].Content);
  269. item.Width="650";
  270. if (imageUrl.length > 0) {
  271. item.ImageUrlTemp = main.getTempImage(imageUrl);
  272. item.ImageUrlServer = imageUrl;
  273. item.Width="540";
  274. }
  275. else{
  276. if (item.Content[1].Content.indexOf("[/公式]")>0
  277. || item.Content[2].Content.indexOf("[/公式]")>0
  278. || item.Content[3].Content.indexOf("[/公式]")>0){
  279. item.ImageUrlTemp = "../images/universalpic_dictionary_formula_black_80x80.jpg";
  280. item.ImageUrlServer = item.ImageUrlTemp;
  281. item.Width="540";
  282. }
  283. }
  284. //debugger;
  285. if (item.FirstTime < "1900-01-02")
  286. item.CardCategory = "新题卡";
  287. else
  288. item.CardCategory = "旧题卡";
  289. if (that.data.PrintID){
  290. item.CardShowDetailStr2=item.Number;
  291. }
  292. else if (that.data.CardType == "-2") {
  293. item.CardShowDetailStr2 = common.formatDateCHS(item.DeleteTime);
  294. } else {
  295. switch (Number(that.data.CardShowDetail)) {
  296. case 0:
  297. item.CardShowDetailStr2 = common.formatDateCHS(item.CreateTime);
  298. break;
  299. case 1:
  300. item.CardShowDetailStr2 = common.formatDateCHS(item.UpdateTime);
  301. break;
  302. case 2:
  303. if (that.data.CardType==2 && item.CardType == -1){
  304. item.CardShowDetailStr2 = "不适用";
  305. }
  306. else if (item.CardType == -1)
  307. item.CardShowDetailStr2 = common.formatDateCHS(item.PigeonholeTime);
  308. else
  309. item.CardShowDetailStr2 = common.formatDateCHS(item.LimitTime);
  310. break;
  311. case 3:
  312. if (item.LastTime < "1900-01-02")
  313. item.CardShowDetailStr2 = "不适用";
  314. else
  315. item.CardShowDetailStr2 = common.formatDateCHS(item.LastTime);
  316. break;
  317. case 4:
  318. item.CardShowDetailStr2 = item.LearnNumber + "次";
  319. break;
  320. }
  321. }
  322. item.CardTypeStr = constant1.arrStudyPattern[item.CardType];
  323. }
  324. if (!that.data.IsToday && !that.data.PrintID && !that.data.Search && that.data.CardType != "-2" && !that.data.FolderID && !that.data.Source) {
  325. main.getData("GetUserCardCount?UserID=" + app.globalData.userInfo.UserID + "&CardType=" + that.data.CardType + "&IsCollect=" + that.data.IsCollect+"&OrderType="+that.data.OrderType, function (data) {
  326. if (data) {
  327. that.setData({
  328. Count: data.CardNumber,
  329. });
  330. var hasPage = false;
  331. if (list.length < that.data.Count && list.length >= 20 && that.data.IsToday == 0)
  332. hasPage = true;
  333. that.setData({
  334. List: list,
  335. HasPage: hasPage,
  336. });
  337. if (that.data.PageType === "3") {
  338. wx.redirectTo({
  339. url: './preview?type=show&id=' + list[0].MiaoguoCardID,
  340. })
  341. }
  342. }
  343. });
  344. } else if (that.data.Search || that.data.FolderID > 0 || that.data.Source) {
  345. var hasPage = false;
  346. if (list.length < that.data.Count)
  347. hasPage = true;
  348. that.setData({
  349. List: list,
  350. HasPage: hasPage,
  351. });
  352. } else if (that.data.CardType != -2 && !that.data.Source) {
  353. that.setData({
  354. Count: list.length,
  355. });
  356. var hasPage = false;
  357. if (list.length < that.data.Count && that.data.IsToday == 0)
  358. hasPage = true;
  359. that.setData({
  360. List: list,
  361. HasPage: hasPage,
  362. });
  363. } else {
  364. that.setData({
  365. List: list,
  366. HasNullImage:0,
  367. });
  368. }
  369. var strCardShowDetail = constant1.arrCardShowDetail[that.data.CardShowDetail];
  370. if (that.data.CardShowDetail == 2 && that.data.CardType == -1)
  371. strCardShowDetail = "归档";
  372. else if (that.data.CardType == -2)
  373. strCardShowDetail = "删除";
  374. else if (that.data.PrintID)
  375. strCardShowDetail = "打印卷序号";
  376. that.setData({
  377. CardShowDetailStr: strCardShowDetail,
  378. });
  379. wx.hideLoading();
  380. function getImage(str) {
  381. var result = "";
  382. if (str.indexOf("[图") >= 0) {
  383. result = str.substring(str.indexOf("[图") + 3, str.indexOf("[/图]"));
  384. result = result.substring(result.indexOf("]") + 1);
  385. }
  386. //console.log(result);
  387. return result;
  388. }
  389. },
  390. getNullImageList:function(){
  391. var that=this;
  392. var list=that.data.List;
  393. var arr=[];
  394. var count=0;
  395. for(var i=0;i<list.length;i++){
  396. if (list[i].IsNullImage){
  397. arr.push(list[i]);
  398. count++;
  399. }
  400. }
  401. app.globalData.CardList=arr;
  402. that.setData({
  403. List:arr,
  404. Count:count,
  405. HasPage:false,
  406. HasNullImage:2,
  407. });
  408. wx.setNavigationBarTitle({
  409. title: "遗失图片的题卡"
  410. });
  411. },
  412. onPreview: function (e) {
  413. var id = e.currentTarget.dataset.id;
  414. var url='./preview?type=show&id=' + id;
  415. if (this.data.PrintID)
  416. url+="&PrintID="+this.data.PrintID;
  417. wx.navigateTo({
  418. url: url,
  419. })
  420. },
  421. onBindError: function (e) {
  422. var that = this;
  423. var id = e.currentTarget.dataset.id;
  424. var serverUrl = e.currentTarget.dataset.serverurl;
  425. wx.downloadFile({
  426. url: serverUrl,
  427. success(res) {
  428. if (res.statusCode === 200) {
  429. main.saveTempImage(serverUrl, res.tempFilePath);
  430. }
  431. else{
  432. var list=that.data.List;
  433. for(var i=0;i<list.length;i++){
  434. if (list[i].MiaoguoCardID==id){
  435. list[i].IsNullImage=true;
  436. }
  437. }
  438. that.setData({
  439. HasNullImage:1,
  440. List:list,
  441. });
  442. wx.pageScrollTo({
  443. scrollTop: 0,
  444. });
  445. }
  446. }
  447. });
  448. },
  449. gotoNextPage: function (e) {
  450. wx.showLoading({
  451. title: '请稍候',
  452. });
  453. setTimeout(function () {
  454. wx.hideLoading();
  455. }, 5000);
  456. var that = this;
  457. var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID;
  458. var id = e.currentTarget.dataset.id;
  459. if (id && id > 0)
  460. url += "&PageID=" + id;
  461. if (e.currentTarget.dataset.IsToday)
  462. url += "&IsToday="+e.currentTarget.dataset.IsToday;
  463. var cardtype = e.currentTarget.dataset.cardtype;
  464. if (cardtype || cardtype == "0") {
  465. url += "&CardType=" + cardtype;
  466. var str = constant1.arrStudyPattern[cardtype];
  467. if (cardtype == "2")
  468. str = "全部";
  469. that.setData({
  470. CardType: Number(cardtype),
  471. CardTypeStr: str,
  472. })
  473. } else {
  474. if (that.data.CardType || that.data.CardType==0)
  475. url += "&CardType=" + that.data.CardType;
  476. }
  477. if (that.data.Search)
  478. url += "&Key=" + that.data.Search;
  479. var orderType = that.data.OrderType;
  480. if (orderType)
  481. url += "&OrderType=" + arrOrder[orderType].Value;
  482. if (e.currentTarget.dataset.iscollect == 1)
  483. url += "&IsCollect=1";
  484. if (e.currentTarget.dataset.folderid)
  485. url += "&FolderID="+e.currentTarget.dataset.folderid;
  486. if (e.currentTarget.dataset.dayNumber)
  487. url += "&DayNumber="+e.currentTarget.dataset.dayNumber;
  488. main.getData(url, function (data) {
  489. if (data) {
  490. var list = app.globalData.CardList;
  491. if (id == 0) {
  492. list = [];
  493. that.setData({
  494. Count: data.Count,
  495. });
  496. }
  497. for (var i = 0; i < data.List.length; i++) {
  498. data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
  499. list.push(data.List[i]);
  500. }
  501. app.globalData.CardList = list;
  502. that.getList();
  503. if (data.List.length < 20) {
  504. that.setData({
  505. HasPage: false,
  506. });
  507. }
  508. that.getFilter();
  509. if (that.data.Source=="health"){
  510. setTimeout(function(){
  511. that.setBtnInfo(e.currentTarget.dataset.datatype,data.Count);
  512. },500);
  513. }
  514. }
  515. });
  516. that.setData({
  517. IsOrder: false,
  518. IsHelp: false,
  519. IsShowSelectCardType: false,
  520. });
  521. },
  522. //回收站的下一页
  523. gotoNextPageDelete: function (e) {
  524. wx.showLoading({
  525. title: '请稍候',
  526. });
  527. setTimeout(function () {
  528. wx.hideLoading();
  529. }, 5000);
  530. var that = this;
  531. var url = 'GetMiaoguoCardDeleteList2?UserID=' + app.globalData.userInfo.UserID;
  532. var param={};
  533. var id=e.currentTarget.dataset.id;
  534. param.PageID=id;
  535. param.PageCount=20;
  536. param.Type="app";
  537. main.postData(url,param, function (data) {
  538. if (data) {
  539. var list = app.globalData.CardList;
  540. if (id == 0) {
  541. list = [];
  542. that.setData({
  543. Count: data.Count,
  544. });
  545. }
  546. for (var i = 0; i < data.List.length; i++) {
  547. data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
  548. list.push(data.List[i]);
  549. }
  550. app.globalData.CardList = list;
  551. that.getList();
  552. if (data.List.length < 20) {
  553. that.setData({
  554. HasPageDelete: false,
  555. });
  556. }
  557. that.getFilter();
  558. }
  559. });
  560. that.setData({
  561. IsOrder: false,
  562. IsHelp: false,
  563. IsShowSelectCardType: false,
  564. });
  565. },
  566. getPrintList: function (e) {
  567. wx.showLoading({
  568. title: '请稍候',
  569. });
  570. setTimeout(function () {
  571. wx.hideLoading();
  572. }, 5000);
  573. var that = this;
  574. var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID + '&PrintID=' + that.data.PrintID;
  575. main.getData(url, function (data) {
  576. if (data) {
  577. if (data.List.length > 0) {
  578. var list = [];
  579. for (var i = 0; i < data.List.length; i++) {
  580. data.List[i].Number = i + 1;
  581. list.push(data.List[i]);
  582. }
  583. app.globalData.CardList = list;
  584. that.getList();
  585. wx.setNavigationBarColor({
  586. frontColor: "#000000",
  587. backgroundColor: "#ffffff",
  588. });
  589. } else {
  590. that.onSearch();
  591. }
  592. }
  593. });
  594. },
  595. getFilter:function(){
  596. var that = this;
  597. if (app.globalData.TempStr2){
  598. if (that.data.Count<=1)
  599. isFilter=false;
  600. else{
  601. var arr=[["全部",0,"",2,0],["",0,"",0,0]];
  602. var isFilter=false;
  603. var str=app.globalData.TempStr2;
  604. if (str.indexOf("IsCollect=1")>=0){
  605. arr[1][0]="星标";
  606. arr[1][3]=0;
  607. arr[1][4]=1;
  608. isFilter=true;
  609. }
  610. else if (str.indexOf("CardType=0")>=0){
  611. arr[1][0]="日常";
  612. arr[1][3]=0;
  613. arr[1][4]=0;
  614. isFilter=true;
  615. }
  616. else if (str.indexOf("CardType=1")>=0){
  617. arr[1][0]="紧急";
  618. arr[1][3]=1;
  619. arr[1][4]=0;
  620. isFilter=true;
  621. }
  622. else if (str.indexOf("CardType=-1")>=0){
  623. arr[1][0]="归档";
  624. arr[1][3]=-1;
  625. arr[1][4]=0;
  626. isFilter=true;
  627. }
  628. if (that.data.CardType==2){
  629. arr[0][1]=that.data.Count;
  630. arr[0][2]="panelTop40";
  631. }
  632. else{
  633. arr[1][1]=that.data.Count;
  634. arr[1][2]="panelTop40";
  635. arr[0][2]="";
  636. }
  637. //console.log("CardType:"+that.data.CardType);
  638. that.setData({
  639. FilterArr:arr,
  640. });
  641. }
  642. that.setData({
  643. IsFilter:isFilter,
  644. });
  645. }
  646. },
  647. addCard: function () {
  648. //console.log("canPress:"+canPress);
  649. if (canPress) {
  650. var url='./add?type=add&id=0';
  651. if (this.data.FolderID){
  652. url+="&FolderID="+this.data.FolderID+"&FolderName="+this.data.FolderName;
  653. }
  654. else{
  655. var cardtype=this.data.CardType;
  656. if (cardtype==1 || cardtype==-1){
  657. url+="&CardType="+cardtype;
  658. }
  659. }
  660. wx.redirectTo({
  661. url: url,
  662. });
  663. canPress = false;
  664. //console.log("canPress:"+canPress);
  665. setTimeout(function () {
  666. canPress = true;
  667. //console.log("canPress:"+canPress);
  668. }, 2000);
  669. }
  670. },
  671. onSearch: function (e) {
  672. var id=1;
  673. if (e.currentTarget.dataset.id)
  674. id=Number(e.currentTarget.dataset.id);
  675. wx.navigateBack({
  676. delta: id,
  677. });
  678. },
  679. onOrder: function (e) {
  680. var that = this;
  681. var value = e.currentTarget.dataset.value;
  682. switch (Number(value)) {
  683. case 1:
  684. that.data.CardShowDetail = 3;
  685. break;
  686. case 2:
  687. that.data.CardShowDetail = 1;
  688. break;
  689. case 3:
  690. case 4:
  691. that.data.CardShowDetail = 0;
  692. break;
  693. case 5:
  694. case 6:
  695. that.data.CardShowDetail = 2;
  696. break;
  697. case 7:
  698. case 8:
  699. that.data.CardShowDetail = 4;
  700. break;
  701. case 9:
  702. case 10:
  703. that.data.CardShowDetail = 2;
  704. break;
  705. }
  706. for (var i = 0; i < that.data.ArrOrder.length; i++) {
  707. if (i == value) {
  708. that.data.ArrOrder[i].CSS = "PanelBtnSelect2";
  709. } else
  710. that.data.ArrOrder[i].CSS = "";
  711. }
  712. that.setData({
  713. IsOrder: false,
  714. ArrOrder: that.data.ArrOrder,
  715. OrderType: value,
  716. CardShowDetail: that.data.CardShowDetail,
  717. });
  718. if (that.data.IsToday!=1) {
  719. app.globalData.CardList = [];
  720. that.gotoNextPage({
  721. currentTarget: {
  722. dataset: {
  723. id: 0,
  724. IsToday:that.data.IsToday,
  725. OrderType: value,
  726. cardtype: that.data.CardType,
  727. iscollect: that.data.IsCollect,
  728. folderid: that.data.FolderID,
  729. }
  730. }
  731. });
  732. }
  733. },
  734. gotoList:function(e){
  735. var that=this;
  736. var datatype=e.currentTarget.dataset.type;
  737. var isToday=0,cardType=2,isCollect=0,folderID=0,dayNumber=7;
  738. if (datatype=="today"){
  739. isToday=2;
  740. }
  741. else if (datatype=="yesterday"){
  742. isToday=3;
  743. }
  744. else if (datatype=="limit0"){
  745. cardType=0;
  746. isToday=4;
  747. that.setData({
  748. OrderType:5,
  749. });
  750. }
  751. else if (datatype=="limit1"){
  752. cardType=1;
  753. isToday=4;
  754. that.setData({
  755. OrderType:5,
  756. });
  757. }
  758. else{
  759. if (datatype && datatype.indexOf("7")>0)
  760. dayNumber=7;
  761. else if (datatype && datatype.indexOf("30")>0)
  762. dayNumber=30;
  763. if (datatype.indexOf("TimeShort")>=0)
  764. isToday=5;
  765. else if (datatype.indexOf("ClickBlue")>=0)
  766. isToday=6;
  767. else if (datatype.indexOf("ClickShelve")>=0)
  768. isToday=7;
  769. cardType=2;
  770. that.setData({
  771. OrderType:0,
  772. });
  773. }
  774. app.globalData.CardList = [];
  775. that.gotoNextPage({
  776. currentTarget: {
  777. dataset: {
  778. id: 0,
  779. IsToday:isToday,
  780. cardtype: cardType,
  781. iscollect: isCollect,
  782. folderid: folderID,
  783. datatype:datatype,
  784. dayNumber:dayNumber,
  785. }
  786. }
  787. });
  788. },
  789. setBtnInfo:function(datatype,count){
  790. var that=this;
  791. if (datatype=="today"){
  792. that.setData({
  793. Btn1Name:"今日",
  794. Btn1Type:"today",
  795. Btn2Name:"上次",
  796. Btn2Type:"yesterday",
  797. Btn1Count: count,
  798. Btn2Count: "",
  799. Btn1Class: "btn2",
  800. Btn2Class: "",
  801. CardShowDetail: 3,
  802. HasPage: false,
  803. });
  804. }
  805. else if (datatype=="yesterday"){
  806. that.setData({
  807. Btn1Name:"今日",
  808. Btn1Type:"today",
  809. Btn2Name:"上次",
  810. Btn2Type:"yesterday",
  811. Btn1Count: "",
  812. Btn2Count: count,
  813. Btn1Class: "",
  814. Btn2Class: "btn2",
  815. CardShowDetail: 3,
  816. HasPage: false,
  817. });
  818. }
  819. else if (datatype=="limit0"){
  820. that.setData({
  821. Btn1Name:"日常",
  822. Btn1Type:"limit0",
  823. Btn2Name:"紧急",
  824. Btn2Type:"limit1",
  825. Btn1Count: count,
  826. Btn2Count: "",
  827. Btn1Class: "btn2",
  828. Btn2Class: "",
  829. CardShowDetail: 2,
  830. });
  831. }
  832. else if (datatype=="limit1"){
  833. that.setData({
  834. Btn1Name:"日常",
  835. Btn1Type:"limit0",
  836. Btn2Name:"紧急",
  837. Btn2Type:"limit1",
  838. Btn1Count: "",
  839. Btn2Count: count,
  840. Btn1Class: "",
  841. Btn2Class: "btn2",
  842. CardShowDetail: 2,
  843. });
  844. }
  845. else if (datatype=="TimeShort7"){
  846. that.setData({
  847. Btn1Name:"近7天",
  848. Btn1Type:"TimeShort7",
  849. Btn2Name:"近30天",
  850. Btn2Type:"TimeShort30",
  851. Btn1Count: count,
  852. Btn2Count: "",
  853. Btn1Class: "btn2",
  854. Btn2Class: "",
  855. CardShowDetail: 3,
  856. });
  857. }
  858. else if (datatype=="TimeShort30"){
  859. that.setData({
  860. Btn1Name:"近7天",
  861. Btn1Type:"TimeShort7",
  862. Btn2Name:"近30天",
  863. Btn2Type:"TimeShort30",
  864. Btn1Count: "",
  865. Btn2Count: count,
  866. Btn1Class: "",
  867. Btn2Class: "btn2",
  868. CardShowDetail: 3,
  869. });
  870. }
  871. else if (datatype=="ClickBlue7"){
  872. that.setData({
  873. Btn1Name:"近7天",
  874. Btn1Type:"ClickBlue7",
  875. Btn2Name:"近30天",
  876. Btn2Type:"ClickBlue30",
  877. Btn1Count: count,
  878. Btn2Count: "",
  879. Btn1Class: "btn2",
  880. Btn2Class: "",
  881. CardShowDetail: 3,
  882. });
  883. }
  884. else if (datatype=="ClickBlue30"){
  885. that.setData({
  886. Btn1Name:"近7天",
  887. Btn1Type:"ClickBlue7",
  888. Btn2Name:"近30天",
  889. Btn2Type:"ClickBlue30",
  890. Btn1Count: "",
  891. Btn2Count: count,
  892. Btn1Class: "",
  893. Btn2Class: "btn2",
  894. CardShowDetail: 3,
  895. });
  896. }
  897. else if (datatype=="ClickShelve7"){
  898. that.setData({
  899. Btn1Name:"近7天",
  900. Btn1Type:"ClickShelve7",
  901. Btn2Name:"近30天",
  902. Btn2Type:"ClickShelve30",
  903. Btn1Count: count,
  904. Btn2Count: "",
  905. Btn1Class: "btn2",
  906. Btn2Class: "",
  907. CardShowDetail: 3,
  908. });
  909. }
  910. else if (datatype=="ClickShelve30"){
  911. that.setData({
  912. Btn1Name:"近7天",
  913. Btn1Type:"ClickShelve7",
  914. Btn2Name:"近30天",
  915. Btn2Type:"ClickShelve30",
  916. Btn1Count: "",
  917. Btn2Count: count,
  918. Btn1Class: "",
  919. Btn2Class: "btn2",
  920. CardShowDetail: 3,
  921. });
  922. }
  923. },
  924. showOrder: function () {
  925. this.setData({
  926. IsOrder: true,
  927. });
  928. },
  929. closeHelp: function () {
  930. this.setData({
  931. IsOrder: false,
  932. IsHelp: false,
  933. IsShowSelectCardType: false,
  934. });
  935. },
  936. DeleteItem: function (e) {
  937. var that = this;
  938. var id = e.currentTarget.dataset.id;
  939. var list = this.data.List;
  940. var b = true;
  941. for (var i = 0; i < list.length; i++) {
  942. var item = list[i];
  943. if (id == item.MiaoguoCardID) {
  944. if (item.DeleteType == 0) {
  945. item.ScrollLeft = 440;
  946. item.DeleteType = 1;
  947. } else if (item.DeleteType == 1) {
  948. b = false;
  949. item.DeleteType = 0;
  950. item.ScrollLeft = 0;
  951. var url = 'DeleteMiaoguoCard?UserID=' + app.globalData.userInfo.UserID;
  952. url += "&ID=" + id;
  953. main.getData(url, function (data) {
  954. var list = app.globalData.CardList;
  955. for (var i = 0; i < list.length; i++) {
  956. if (id == list[i].MiaoguoCardID) {
  957. list.splice(i, 1);
  958. break;
  959. }
  960. }
  961. app.globalData.CardList = list;
  962. that.setData({
  963. List: list,
  964. Count: --that.data.Count,
  965. });
  966. });
  967. }
  968. } else {
  969. item.DeleteType = 0;
  970. item.ScrollLeft = 0;
  971. }
  972. }
  973. if (b) {
  974. that.setData({
  975. List: list,
  976. });
  977. }
  978. },
  979. showSelectCardShowDetail: function () {
  980. var that = this;
  981. var arr = [];
  982. for (var i = 0; i < 5; i++) {
  983. var obj = {};
  984. obj.Name = constant1.arrCardShowDetail[i];
  985. if (that.data.CardType == -1 && i == 2)
  986. obj.Name = "归档";
  987. if (i < 4)
  988. obj.Name += "时间";
  989. if (i == that.data.CardShowDetail)
  990. obj.IsSelected = "PanelBtnSelect";
  991. else
  992. obj.IsSelected = "";
  993. arr.push(obj);
  994. }
  995. that.setData({
  996. IsShowCardShowDetail: true,
  997. CardShowDetailArr: arr,
  998. });
  999. },
  1000. hideSelectCardShowDetail: function () {
  1001. var that = this;
  1002. that.setData({
  1003. IsShowCardShowDetail: false,
  1004. });
  1005. },
  1006. selectCardShowDetail: function (e) {
  1007. var that = this;
  1008. that.data.CardShowDetail = e.currentTarget.dataset.id;
  1009. that.setData({
  1010. IsShowCardShowDetail: false,
  1011. CardShowDetail: that.data.CardShowDetail,
  1012. });
  1013. that.getList();
  1014. that.hideSelectCardShowDetail();
  1015. },
  1016. showHelp: function () {
  1017. var that = this;
  1018. that.setData({
  1019. IsHelp: true,
  1020. });
  1021. },
  1022. showSelectCardType: function () {
  1023. var that = this;
  1024. var arr = [
  1025. ["全部", "", 2],
  1026. ["日常", "", 0],
  1027. ["紧急", "", 1],
  1028. ["归档", "", -1]
  1029. ];
  1030. switch (that.data.CardType) {
  1031. case 2:
  1032. arr[0][1] = "PanelBtnSelect";
  1033. break;
  1034. case 0:
  1035. arr[1][1] = "PanelBtnSelect";
  1036. break;
  1037. case 1:
  1038. arr[2][1] = "PanelBtnSelect";
  1039. break;
  1040. case -1:
  1041. arr[3][1] = "PanelBtnSelect";
  1042. break;
  1043. }
  1044. that.setData({
  1045. IsShowSelectCardType: true,
  1046. CardTypeArr: arr,
  1047. });
  1048. },
  1049. recoverItem: function (e) {
  1050. var that = this;
  1051. var id = e.currentTarget.dataset.id;
  1052. var url = "DeleteMiaoguoCardWeb?UserID=" + app.globalData.userInfo.UserID;
  1053. var param = {};
  1054. param.IsRecover = "true";
  1055. param.VisitType = "vtqOSthN7vSwYmhc1gCjfw==";
  1056. param.ID = common.Encrypt(id);
  1057. main.postData(url, param, function () {
  1058. var list = app.globalData.CardList;
  1059. for (var i = 0; i < list.length; i++) {
  1060. if (id == list[i].MiaoguoCardID) {
  1061. list.splice(i, 1);
  1062. break;
  1063. }
  1064. }
  1065. app.globalData.CardList = list;
  1066. that.setData({
  1067. List: list,
  1068. Count: --that.data.Count,
  1069. });
  1070. });
  1071. },
  1072. setCollect: function (e) {
  1073. var that = this;
  1074. if (!isCollecting) {
  1075. isCollecting = true;
  1076. setTimeout(function () {
  1077. isCollecting = false;
  1078. }, 3000);
  1079. var id=e.currentTarget.dataset.id;
  1080. var collect=e.currentTarget.dataset.collect;
  1081. if (collect==0) {
  1082. collect = 1;
  1083. }
  1084. else {
  1085. collect = 0;
  1086. }
  1087. main.setCollect(id, collect, function () {
  1088. var list = app.globalData.CardList;
  1089. for (var i = 0; i < list.length; i++) {
  1090. if (id == list[i].MiaoguoCardID) {
  1091. if (collect==0)
  1092. list.splice(i, 1);
  1093. else
  1094. list[i].IsCollect = collect;
  1095. break;
  1096. }
  1097. }
  1098. app.globalData.CardList = list;
  1099. that.setData({
  1100. List: list,
  1101. });
  1102. });
  1103. }
  1104. },
  1105. editField: function (e) {
  1106. var id=e.currentTarget.dataset.id;
  1107. var that = this;
  1108. wx.navigateTo({
  1109. url: './add?type=edit&id=' + id,
  1110. });
  1111. },
  1112. removeFolder:function(e){
  1113. var that = this;
  1114. var id=e.currentTarget.dataset.id;
  1115. var url = 'RemoveFolder?UserID=' + app.globalData.userInfo.UserID;
  1116. url += "&ID=" + id;
  1117. url += "&FolderID=" + that.data.FolderID;
  1118. main.getData(url, function (data) {
  1119. var list = app.globalData.CardList;
  1120. for (var i = 0; i < list.length; i++) {
  1121. if (id == list[i].MiaoguoCardID) {
  1122. list.splice(i, 1);
  1123. break;
  1124. }
  1125. }
  1126. app.globalData.CardList = list;
  1127. that.setData({
  1128. List: list,
  1129. Count: --that.data.Count,
  1130. });
  1131. });
  1132. },
  1133. setOrderSelect:function(od){
  1134. var that=this;
  1135. for(var k=0;k<arrOrder.length;k++){
  1136. if (k==od)
  1137. arrOrder[k].CSS = "PanelBtnSelect2";
  1138. else
  1139. arrOrder[k].CSS = "";
  1140. }
  1141. that.setData({
  1142. ArrOrder: arrOrder,
  1143. OrderType:od,
  1144. });
  1145. },
  1146. //设置多选状态
  1147. setMultipleOptions:function(event){
  1148. var that=this;
  1149. var IsMultipleOptions=event.currentTarget.dataset.index==1?true:false;
  1150. that.setData({
  1151. IsMultipleOptions:IsMultipleOptions,
  1152. });
  1153. if (!IsMultipleOptions){
  1154. var list=that.data.List;
  1155. for(var i=0;i<list.length;i++){
  1156. list[i].Selected=false;
  1157. }
  1158. that.setData({
  1159. List:list,
  1160. SelectedCount:0,
  1161. CanScroll:true,
  1162. IsShowSelectThisUp: false,
  1163. IsShowSelectThisDown: false
  1164. });
  1165. }
  1166. else{
  1167. that.setData({
  1168. CanScroll:false,
  1169. });
  1170. }
  1171. },
  1172. //选择或反选项
  1173. selectedItem:function(event){
  1174. var that=this;
  1175. var isAll=event.currentTarget.dataset.isall;
  1176. var id=event.currentTarget.dataset.id;
  1177. var list=that.data.List;
  1178. var selectedCount=0;
  1179. var firstSelectedIndex = -1;
  1180. var lastSelectedIndex = -1;
  1181. for(var i=0;i<list.length;i++){
  1182. if (isAll){
  1183. list[i].Selected=true;
  1184. }
  1185. else{
  1186. if (id==list[i].MiaoguoCardID){
  1187. if(!list[i].Selected)
  1188. list[i].Selected=true;
  1189. else
  1190. list[i].Selected=false;
  1191. }
  1192. }
  1193. if (list[i].Selected) {
  1194. selectedCount++;
  1195. if(firstSelectedIndex === -1) firstSelectedIndex = i;
  1196. lastSelectedIndex = i;
  1197. }
  1198. }
  1199. that.setData({
  1200. List:list,
  1201. SelectedCount:selectedCount,
  1202. });
  1203. // 如果有选中的项目,检查它们的位置并决定显示哪个按钮
  1204. if(selectedCount > 0) {
  1205. that.checkSelectedItemsPosition(firstSelectedIndex, lastSelectedIndex);
  1206. } else {
  1207. that.setData({
  1208. IsShowSelectThisUp: false,
  1209. IsShowSelectThisDown: false
  1210. });
  1211. }
  1212. },
  1213. showMultipleOther: function (event) {
  1214. var that = this;
  1215. var index=event.currentTarget.dataset.index;
  1216. var b=false;
  1217. if (index==1)
  1218. b=true;
  1219. if (b && that.data.SelectedCount==0){
  1220. wx.showToast({
  1221. title: '请先选择题卡',
  1222. });
  1223. }
  1224. else{
  1225. that.setData({
  1226. IsShowSelectContainer: b,
  1227. SelectContainerStyle:0,
  1228. });
  1229. }
  1230. },
  1231. //显示多选提醒
  1232. showMultipleNotice:function(event){
  1233. var that = this;
  1234. var index=event.currentTarget.dataset.index;
  1235. var mData = constant1.arrMultipleSaveData[index];
  1236. if (index==1 || index==4 || index==5 || index==6 || index==7 || index==8){
  1237. var content=mData.Content.replace("[SelectedCount]",that.data.SelectedCount);
  1238. wx.showModal({
  1239. title: '提醒',
  1240. content: content,
  1241. confirmText:mData.ConfirmText,
  1242. complete: (res) => {
  1243. if (res.confirm) {
  1244. if (index<8)
  1245. that.saveMultipleData(mData,that.data.List);
  1246. else
  1247. that.gotoYJBDC(that.data.List);
  1248. }
  1249. }
  1250. });
  1251. }
  1252. else if (index==2 || index==3){
  1253. //debugger;
  1254. var menu=event.currentTarget.dataset.menu;
  1255. if (menu==1){
  1256. that.setData({
  1257. SelectContainerStyle: index,
  1258. });
  1259. } else if (menu==2) {
  1260. var id=event.currentTarget.dataset.id;
  1261. that.showFolderListSelect({currentTarget:{dataset:{index:1,readfolder:id}}});
  1262. } else {
  1263. var id=event.currentTarget.dataset.id;
  1264. if (index==3){
  1265. mData.Param.IsCollect=id;
  1266. mData.FinishedText=mData.FinishedTextArr[id];
  1267. that.saveMultipleData(mData,that.data.List);
  1268. }
  1269. else{
  1270. if (id==0){
  1271. mData.Param.FolderID=0;
  1272. }
  1273. else{
  1274. var list=that.data.FolderList;
  1275. for(var i=0;i<list.length;i++){
  1276. if (list[i].Selected==1){
  1277. mData.Param.FolderID=list[i].ID;
  1278. mData.Param.FolderName=list[i].Name;
  1279. break;
  1280. }
  1281. }
  1282. }
  1283. mData.FinishedText=mData.FinishedTextArr[id];
  1284. that.saveMultipleData(mData,that.data.List);
  1285. }
  1286. }
  1287. }
  1288. },
  1289. //保存多选数据
  1290. saveMultipleData:function(mData,list){
  1291. var that=this;
  1292. var arr=[];
  1293. for(var i=0;i<list.length;i++){
  1294. if (list[i].Selected){
  1295. var id=list[i].MiaoguoCardID;
  1296. id=common.Encrypt(id);
  1297. arr.push(id);
  1298. }
  1299. }
  1300. if (arr.length>0){
  1301. var sql=mData.SaveFun+"?UserID="+app.globalData.userInfo.UserID;
  1302. var param=mData.Param;
  1303. param[param.ListStr]=arr;
  1304. //console.log(JSON.stringify(param));
  1305. //debugger;
  1306. main.postData(sql, param, function (data) {
  1307. list=that.updateSavedList(that.data.ShowMultiple,mData,list);
  1308. app.globalData.CardList=list;
  1309. that.setData({
  1310. List:list,
  1311. SelectedCount:0,
  1312. IsShowSelectContainer:false,
  1313. IsMultipleOptions:false,
  1314. IsFolderListContainer:0,
  1315. FolderList:null,
  1316. });
  1317. wx.showToast({
  1318. title: mData.FinishedText,
  1319. duration: 2000,
  1320. });
  1321. });
  1322. }
  1323. },
  1324. //更新保存的列表状态
  1325. updateSavedList:function(source,mData,list){
  1326. var that=this;
  1327. var index=mData.ID;
  1328. //debugger;
  1329. for(var i=list.length-1;i>=0;i--){
  1330. if (list[i].Selected){
  1331. list[i].Selected=0;
  1332. if (index==1){//删除
  1333. list.splice(i,1);
  1334. that.data.Count--;
  1335. }
  1336. else if (index==2){
  1337. list[i].FolderID=mData.Param.FolderID;
  1338. if (list[i].FolderID>0)
  1339. list[i].FolderName=mData.Param.FolderName;
  1340. if (source>0 && index!=source && mData.Param.FolderID!=source){ //不同类型列表删除
  1341. list.splice(i,1);
  1342. that.data.Count--;
  1343. }
  1344. app.globalData.FolderList=[];
  1345. }
  1346. else if (index==3){
  1347. list[i].IsCollect=Number(mData.Param.IsCollect);
  1348. if (source>0 && source<8 && index==source && mData.Param.IsCollect==0) {//不同类型列表删除
  1349. list.splice(i,1);
  1350. that.data.Count--;
  1351. }
  1352. }
  1353. else if (index==4){
  1354. list[i].CardType=-1;
  1355. list[i].CardTypeStr="归档";
  1356. if (source>0 && source<8 && index!=source){ //不同类型列表删除
  1357. list.splice(i,1);
  1358. that.data.Count--;
  1359. }
  1360. }
  1361. else if (index==5){
  1362. list[i].CardType=0;
  1363. list[i].CardTypeStr="日常";
  1364. if (source>0 && source<8 && index!=source){ //不同类型列表删除
  1365. list.splice(i,1);
  1366. that.data.Count--;
  1367. }
  1368. }
  1369. else if (index==6){
  1370. list[i].CardType=1;
  1371. list[i].CardTypeStr="紧急";
  1372. if (source>0 && source<8 && index!=source){ //不同类型列表删除
  1373. list.splice(i,1);
  1374. that.data.Count--;
  1375. }
  1376. }
  1377. else if (index==7){
  1378. list[i].CardType=0;
  1379. list[i].CardTypeStr="日常";
  1380. list[i].FirstTime='1900-01-01 00:00:00';
  1381. list[i].FirstTimeStr='1900-01-01';
  1382. list[i].LastTime='1900-01-01 00:00:00';
  1383. list[i].LastTimeStr='1900-01-01';
  1384. list[i].LimitTime=common.formatTime(new Date(),"-");
  1385. list[i].LimitTimeStr=common.formatTime(new Date(),"-",true);
  1386. list[i].IntervalDay=0;
  1387. list[i].RepetitionCoefficient=2.0;
  1388. list[i].UpdateTime=list[i].LimitTime;
  1389. list[i].UpdateTimeStr="今天";
  1390. list[i].CardCategory="新题卡";
  1391. }
  1392. }
  1393. }
  1394. that.setData({
  1395. Count:that.data.Count,
  1396. });
  1397. return list;
  1398. },
  1399. showFolderListSelect:function(e){
  1400. var that=this;
  1401. var index=Number(e.currentTarget.dataset.index);
  1402. that.setData({
  1403. IsFolderListContainer:index,
  1404. });
  1405. if (index==1){
  1406. var url = 'GetUserFolderList?UserID=' + app.globalData.userInfo.UserID;
  1407. main.getData(url, function (data) {
  1408. that.setData({
  1409. FolderList: data,
  1410. });
  1411. });
  1412. }
  1413. else{
  1414. that.setData({
  1415. FolderList: null,
  1416. });
  1417. }
  1418. },
  1419. selectFolderItem:function(e){
  1420. var that=this;
  1421. var index=Number(e.currentTarget.dataset.index);
  1422. var list=that.data.FolderList;
  1423. for(var i=0;i<list.length;i++){
  1424. list[i].Selected=0;
  1425. if (index==i){
  1426. list[i].Selected=1;
  1427. }
  1428. }
  1429. that.setData({
  1430. FolderList:list,
  1431. });
  1432. },
  1433. goto: function (e) {
  1434. var url = e.currentTarget.dataset.url;
  1435. wx.navigateTo({
  1436. url: './' + url,
  1437. })
  1438. },
  1439. redirect: function (e) {
  1440. var that=this;
  1441. var url = e.currentTarget.dataset.url;
  1442. app.globalData.TempStr2="CardType="+that.data.CardType+"&IsCollect="+that.data.IsCollect;
  1443. wx.redirectTo({
  1444. url: './' + url,
  1445. })
  1446. },
  1447. showHelpImage:function(){
  1448. var url=app.globalData.uploadImageUrl+"web/update_image_mathod.png";
  1449. wx.previewImage({
  1450. current: url, // 当前显示图片的http链接
  1451. urls: [url] // 需要预览的图片http链接列表
  1452. });
  1453. },
  1454. gotoYJBDC:function(list){
  1455. //console.log(list);
  1456. let words=[];
  1457. for(let i=0;i<list.length;i++){
  1458. if (list[i].Selected){
  1459. let str1=main.extractEnglishWords(list[i].Content[1].Content);
  1460. if (str1){
  1461. words.push(str1);
  1462. }
  1463. else{
  1464. let str2=main.extractEnglishWords(list[i].Content[2].Content);
  1465. if (str2){
  1466. words.push(str2);
  1467. }
  1468. }
  1469. }
  1470. }
  1471. //debugger;
  1472. words = [...new Set(words)];
  1473. var appid="wx80059777521b897c";
  1474. var path="pages/index/index?SourceID="+app.globalData.ProgramID+"&goto=selectword&Words="+words.join(",");
  1475. wx.navigateToMiniProgram({
  1476. appId: appid,
  1477. path: path,
  1478. });
  1479. },
  1480. // 检查选中项的位置并决定显示哪个按钮
  1481. checkSelectedItemsPosition: function(firstIndex, lastIndex) {
  1482. var that = this;
  1483. // 使用选择器获取元素位置信息
  1484. var query = wx.createSelectorQuery();
  1485. // 获取第一个选中项的位置
  1486. query.select('#scroll-' + firstIndex).boundingClientRect();
  1487. // 如果有多个选中项,获取最后一个选中项的位置
  1488. if(firstIndex !== lastIndex) {
  1489. query.select('#scroll-' + lastIndex).boundingClientRect();
  1490. }
  1491. // 获取屏幕高度
  1492. query.selectViewport().boundingClientRect();
  1493. query.exec(function(res) {
  1494. if(!res || res.length < 2) return;
  1495. var screenHeight = res[res.length - 1].height;
  1496. var screenMiddle = screenHeight / 2;
  1497. var showUp = false;
  1498. var showDown = false;
  1499. // 获取第一个选中项的位置
  1500. var firstItem = res[0];
  1501. // 如果只有一个选中项
  1502. if(firstIndex === lastIndex) {
  1503. if(!firstItem) return;
  1504. var itemMiddle = firstItem.top + firstItem.height / 2;
  1505. // 如果项目在屏幕中间偏上
  1506. if(itemMiddle < screenMiddle) {
  1507. showUp = true;
  1508. }
  1509. // 如果项目在屏幕中间偏下
  1510. else {
  1511. showDown = true;
  1512. }
  1513. } else {
  1514. // 有多个选中项
  1515. var lastItem = res[1];
  1516. if(!firstItem || !lastItem) return;
  1517. var firstItemMiddle = firstItem.top + firstItem.height / 2;
  1518. var lastItemMiddle = lastItem.top + lastItem.height / 2;
  1519. // 如果第一个选中项在屏幕中间偏下
  1520. if(firstItemMiddle > screenMiddle) {
  1521. showDown = true;
  1522. }
  1523. // 如果最后一个选中项在屏幕中间偏上
  1524. if(lastItemMiddle < screenMiddle) {
  1525. showUp = true;
  1526. }
  1527. }
  1528. that.setData({
  1529. IsShowSelectThisUp: showUp,
  1530. IsShowSelectThisDown: showDown
  1531. });
  1532. });
  1533. },
  1534. onPageScroll:function(e){
  1535. let that=this;
  1536. setTimeout(function() {
  1537. if(that.data.IsMultipleOptions && that.data.SelectedCount > 0) {
  1538. var firstSelectedIndex = -1;
  1539. var lastSelectedIndex = -1;
  1540. var list = that.data.List;
  1541. for(var i = 0; i < list.length; i++) {
  1542. if(list[i].Selected) {
  1543. if(firstSelectedIndex === -1) firstSelectedIndex = i;
  1544. lastSelectedIndex = i;
  1545. }
  1546. }
  1547. if(firstSelectedIndex !== -1) {
  1548. that.checkSelectedItemsPosition(firstSelectedIndex, lastSelectedIndex);
  1549. }
  1550. }
  1551. }, 100);
  1552. },
  1553. onShareAppMessage: function () {
  1554. return {
  1555. title: app.globalData.ShareTitle,
  1556. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  1557. imageUrl: app.globalData.ShareImage,
  1558. }
  1559. },
  1560. selectThisFunc:function(e){
  1561. let upOrDown = e.currentTarget.dataset.selecttype;
  1562. var that = this;
  1563. var list = that.data.List;
  1564. var firstSelectedIndex = -1;
  1565. var lastSelectedIndex = -1;
  1566. // 找出第一个和最后一个已选中的项目索引
  1567. for(var i = 0; i < list.length; i++) {
  1568. if(list[i].Selected) {
  1569. if(firstSelectedIndex === -1) firstSelectedIndex = i;
  1570. lastSelectedIndex = i;
  1571. }
  1572. }
  1573. if(firstSelectedIndex === -1) return; // 没有选中项,不执行操作
  1574. // 创建选择器查询
  1575. var query = wx.createSelectorQuery();
  1576. // 获取所有列表项的位置信息
  1577. for(var i = 0; i < list.length; i++) {
  1578. query.select('#scroll-' + i).boundingClientRect();
  1579. }
  1580. // 获取视口信息
  1581. query.selectViewport().boundingClientRect();
  1582. query.exec(function(res) {
  1583. // 确保我们有足够的结果
  1584. if(!res || res.length < 2) {
  1585. console.error("查询结果不足,无法处理选择操作");
  1586. return;
  1587. }
  1588. var screenHeight = res[res.length - 1].height;
  1589. var visibleItems = [];
  1590. // 找出当前在视口中可见的项
  1591. for(var i = 0; i < list.length; i++) {
  1592. var item = res[i];
  1593. if(item && item.top < screenHeight && item.bottom > 0) {
  1594. visibleItems.push({
  1595. index: i,
  1596. top: item.top,
  1597. bottom: item.bottom
  1598. });
  1599. }
  1600. }
  1601. if(visibleItems.length === 0) {
  1602. console.error("没有找到可见项目");
  1603. return;
  1604. }
  1605. console.log("可见项目数量:", visibleItems.length);
  1606. console.log("第一个可见项目索引:", visibleItems[0].index);
  1607. console.log("最后一个可见项目索引:", visibleItems[visibleItems.length - 1].index);
  1608. console.log("第一个选中项索引:", firstSelectedIndex);
  1609. console.log("最后一个选中项索引:", lastSelectedIndex);
  1610. console.log("按钮类型:", upOrDown);
  1611. // 根据按钮类型决定选择范围
  1612. if(upOrDown === "up") {
  1613. // 上按钮 - 选择从视口中最上面的项到第一个已选项之间的所有项
  1614. var topVisibleIndex = visibleItems[0].index;
  1615. // 如果顶部可见项在第一个已选项之前,选择这个范围内的所有项
  1616. if(topVisibleIndex < firstSelectedIndex) {
  1617. for(var i = topVisibleIndex; i <= firstSelectedIndex; i++) {
  1618. list[i].Selected = true;
  1619. }
  1620. console.log("向上选择范围:", topVisibleIndex, "到", firstSelectedIndex);
  1621. }
  1622. // 否则选择从第一个已选项到顶部可见项之间的所有项
  1623. else {
  1624. for(var i = firstSelectedIndex; i <= topVisibleIndex; i++) {
  1625. list[i].Selected = true;
  1626. }
  1627. console.log("向上选择范围:", firstSelectedIndex, "到", topVisibleIndex);
  1628. }
  1629. } else if(upOrDown === "down") {
  1630. // 下按钮 - 选择从最后一个已选项到视口中最下面的项之间的所有项
  1631. var bottomVisibleIndex = visibleItems[visibleItems.length - 1].index;
  1632. // 如果底部可见项在最后一个已选项之后,选择这个范围内的所有项
  1633. if(bottomVisibleIndex > lastSelectedIndex) {
  1634. for(var i = lastSelectedIndex; i <= bottomVisibleIndex; i++) {
  1635. list[i].Selected = true;
  1636. }
  1637. console.log("向下选择范围:", lastSelectedIndex, "到", bottomVisibleIndex);
  1638. }
  1639. // 否则选择从底部可见项到最后一个已选项之间的所有项
  1640. else {
  1641. for(var i = bottomVisibleIndex; i <= lastSelectedIndex; i++) {
  1642. list[i].Selected = true;
  1643. }
  1644. console.log("向下选择范围:", bottomVisibleIndex, "到", lastSelectedIndex);
  1645. }
  1646. }
  1647. // 计算选中的总数
  1648. var selectedCount = 0;
  1649. for(var i = 0; i < list.length; i++) {
  1650. if(list[i].Selected) {
  1651. selectedCount++;
  1652. }
  1653. }
  1654. console.log("选中总数:", selectedCount);
  1655. // 更新数据
  1656. that.setData({
  1657. List: list,
  1658. SelectedCount: selectedCount
  1659. });
  1660. // 更新按钮显示状态
  1661. that.checkSelectedItemsPosition(firstSelectedIndex, lastSelectedIndex);
  1662. });
  1663. },
  1664. })