add.js 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import constant1 from '../../utils/constant';
  4. const app = getApp();
  5. var arrTag = [];
  6. var tempCursor = undefined,
  7. btnName = "";
  8. var arrSoundMark = [];
  9. var isUnload = true;
  10. var isEdit = true;
  11. var isSave = true;
  12. var interval;
  13. var timeoutUploadImage = 0;
  14. var intervalRecorder = 0; //录音计时器
  15. var recorderManager;
  16. var tempRecorderFile = "";
  17. var innerAudioContext;
  18. var isViolate = false; //是否是违禁词
  19. var isFirstAdd = true;//是第一个填加
  20. Page({
  21. data: {
  22. ImagePath: app.globalData.uploadImageUrl,
  23. HiddenFieldEdit: true,
  24. FieldContent: "",
  25. SoundSign: "[读]",
  26. LineSign: "[线]",
  27. HighlighterSign: "[光]",
  28. IsPracticeTime: false,
  29. IsRecorder: false,
  30. IsIPhoneX: app.globalData.IsIPhoneX,
  31. IsTagShow:false,
  32. IsEditCardType:"",
  33. PageTitle:"新建题卡",
  34. InputHeight:315,
  35. IsShowMenu:false,
  36. IsHelp:false,
  37. HelpArr:["help_board_tips_jiaziliao","help_board_tips_gengduo","help_board_tips_qingchu","help_board_tips_meihua","help_board_tips_geshi"],
  38. IsFontsize:false,
  39. IsCollect:0,
  40. },
  41. onReady: function () {
  42. recorderManager = wx.getRecorderManager();
  43. recorderManager.onStart(() => {
  44. console.log('recorder start')
  45. });
  46. recorderManager.onStop((res) => {
  47. console.log('recorder stop', res);
  48. tempRecorderFile = res.tempFilePath;
  49. });
  50. recorderManager.onError((err) => {});
  51. },
  52. //获取导航栏高度
  53. getBarInfo(e) {
  54. var h=e.detail.topBarHeight;
  55. h=h*2;
  56. this.setData({
  57. topBarHeight: h,
  58. })
  59. },
  60. onLoad: function (options) {
  61. var that = this;
  62. var fieldNumber = 0;
  63. if (options.fieldid)
  64. fieldNumber = options.fieldid;
  65. that.setData({
  66. Containnerheight: main.getWindowHeight(),
  67. UpdateType: options.type,
  68. MiaoguoCardID: options.id,
  69. FieldNumber: fieldNumber,
  70. IsShow: app.globalData.userInfo.IsShow,
  71. });
  72. var list = app.globalData.CardList;
  73. for (var i = 0; i < list.length; i++) {
  74. if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  75. wx.setStorageSync("TempCardInfo", list[i]);
  76. break;
  77. }
  78. }
  79. app.globalData.TempFieldNumber = 0;
  80. app.globalData.TempMiaoguoCardID = that.data.MiaoguoCardID;
  81. isViolate = false;
  82. isFirstAdd = true;
  83. if (app.globalData.IsIPhoneX){
  84. that.setData({
  85. InputHeight: 480,
  86. });
  87. }
  88. if (options.type=="add3"){
  89. that.gotoAddInfomationDetail(options);
  90. }
  91. },
  92. onShow: function () {
  93. var that = this;
  94. if (that.data.UpdateType == "add" || that.data.UpdateType == "add3") {
  95. that.initAddCard();
  96. if (!that.data.PracticeCardType && !that.data.PracticeTimeStr){
  97. that.setData({
  98. PracticeCardType: "日常"+"题卡",
  99. PracticeTimeStr: "",
  100. });
  101. }
  102. } else {
  103. var card = {},
  104. content = "";
  105. var list = app.globalData.CardList;
  106. for (var i = 0; i < list.length; i++) {
  107. if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  108. card = main.changeStringToView(list[i].Content);
  109. card.MiaoguoCardID = list[i].MiaoguoCardID;
  110. if (list[i].CardType==0 || list[i].CardType==1 || list[i].CardType==-1)
  111. card.CardType=list[i].CardType;
  112. else if (that.data.CardType)
  113. card.CardType=that.data.CardType;
  114. else
  115. card.CardType=0;
  116. card.IsCollect=list[i].IsCollect;
  117. if (list[i].LimitTime)
  118. card.LimitTime=list[i].LimitTime;
  119. else if (that.data.LimitTime)
  120. card.LimitTime=that.data.LimitTime;
  121. if (that.data.FieldNumber && that.data.FieldNumber > 0)
  122. content = main.encryptUrl(list[i].Content[that.data.FieldNumber].Content);
  123. break;
  124. }
  125. }
  126. switch(Number(card.CardType)){
  127. case 0:
  128. card.CardTypeStr="日常";
  129. break;
  130. case 1:
  131. card.CardTypeStr="紧急";
  132. break;
  133. case -1:
  134. card.CardTypeStr="留白";
  135. break;
  136. }
  137. if (app.globalData.TempIsEditCardType==1 && that.data.IsEditCardType==""){
  138. app.globalData.TempIsEditCardType=0;
  139. that.setData({
  140. IsEditCardType:"_IsEditCardType",
  141. });
  142. }
  143. var arrTagTemp=[];
  144. for(var j=0;j<card.Tags.length;j++){
  145. if (card.Tags[j])
  146. arrTagTemp.push(card.Tags[j]);
  147. }
  148. card.Tags=arrTagTemp;
  149. that.setData({
  150. MiaoguoCardID: card.MiaoguoCardID,
  151. LimitTime: common.formatTime(card.LimitTime),
  152. PracticeCardType: card.CardTypeStr+"题卡",
  153. PracticeTimeStr: common.formatDateCHS(common.formatTime(card.LimitTime)),
  154. Field: card.Field,
  155. Tags: card.Tags,
  156. TagsStr: card.Tags.join("、"),
  157. FieldContent: content,
  158. CardType:card.CardType,
  159. IsCollect:card.IsCollect,
  160. });
  161. if (that.data.UpdateType != "add2") {
  162. that.setData({
  163. PageTitle: '编辑题卡',
  164. });
  165. }
  166. if (that.data.UpdateType == "edit3") {
  167. that.gotoAddItem({
  168. currentTarget: {
  169. dataset: {
  170. fieldid: that.data.FieldNumber
  171. }
  172. }
  173. });
  174. }
  175. }
  176. if (that.data.IsFolder){
  177. that.getFolderList();
  178. }
  179. common.getStorageValue(that, "SymbolMain", app.globalData.SymbolMain, function () { });
  180. },
  181. onHide: function () {
  182. //用于恢复未保存的新题卡
  183. //console.log("onHide");
  184. var that = this;
  185. if (!that.data.HiddenFieldEdit) {
  186. that.updateField();
  187. }
  188. if (!(that.data && that.data.Field && that.data.Field[1].length == 0 &&
  189. that.data.Field[2].length == 0 &&
  190. that.data.Field[3].length == 0)) {
  191. if (!isViolate && (that.data.UpdateType == "add" || that.data.UpdateType == "add2")) {
  192. var card = {};
  193. card.MiaoguoCardID = that.data.MiaoguoCardID;
  194. card.Content = [];
  195. var param1 = {};
  196. param1 = that.formatField(that.data.Field);
  197. for (var i = 0; i < 4; i++) {
  198. var obj = {};
  199. obj.ContentType = i;
  200. if (i == 0)
  201. obj.Content = that.data.Tags;
  202. else
  203. obj.Content = param1["Field" + i];
  204. card.Content.push(obj);
  205. }
  206. wx.setStorageSync("TempCardNoSaved", card);
  207. }
  208. }
  209. },
  210. onUnload: function () {
  211. this.onHide();
  212. var card = wx.getStorageSync("TempCardInfo");
  213. if (card) {
  214. var list = app.globalData.CardList;
  215. for (var i = 0; i < list.length; i++) {
  216. if (this.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  217. list[i] = card;
  218. break;
  219. }
  220. }
  221. app.globalData.CardList = list;
  222. wx.removeStorageSync("TempCardInfo");
  223. }
  224. clearInterval(interval);
  225. clearTimeout(timeoutUploadImage);
  226. clearInterval(intervalRecorder);
  227. if (this.data.IsRecorder)
  228. this.closeRecorder();
  229. if (wx.getStorageSync("IsRemindContinuousNew")==1){
  230. wx.removeStorageSync('IsRemindContinuousNew');
  231. }
  232. },
  233. onClose: function () {
  234. wx.navigateBack({
  235. delta: 1,
  236. });
  237. clearInterval(intervalRecorder);
  238. },
  239. gotoAddItem: function (e) {
  240. var that = this;
  241. var fieldid = e.currentTarget.dataset.fieldid;
  242. var content;
  243. var list = app.globalData.CardList;
  244. for (var i = 0; i < list.length; i++) {
  245. if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  246. content = main.encryptUrl(list[i].Content[fieldid].Content);
  247. break;
  248. }
  249. }
  250. wx.setStorageSync("TempCardInfoAddItem", content);
  251. that.setData({
  252. HiddenFieldEdit: false,
  253. Focus: true,
  254. FieldNumber: fieldid,
  255. FieldContent: content,
  256. });
  257. that.setData({
  258. PageTitle: '编辑 段落' + fieldid,
  259. });
  260. },
  261. onSearch: function (e) {
  262. app.globalData.TempFieldNumber = 0;
  263. wx.navigateTo({
  264. url: './addInfomation',
  265. })
  266. },
  267. onPreview: function (e) {
  268. var that = this;
  269. if (that.data.Field[1] == "") {
  270. wx.showToast({
  271. title: '填写段落1',
  272. image: "../images/universalpic_exclamation_white_120x120.png",
  273. });
  274. } else {
  275. wx.navigateTo({
  276. url: './preview?type=preview&id=' + this.data.MiaoguoCardID,
  277. });
  278. }
  279. },
  280. saveCard: function () {
  281. var that = this;
  282. if (that.data.Field[1] == "") {
  283. wx.showToast({
  284. title: '填写段落1',
  285. image: "../images/universalpic_exclamation_white_120x120.png",
  286. });
  287. } else {
  288. if (isSave) {
  289. isSave = false;
  290. setTimeout(function () {
  291. isSave = true;
  292. }, 5000);
  293. if (that.checkImageCount(that.data.Field)) {
  294. that.uploadImageAll(that.data.Field, function (success, field) {
  295. if (success) {
  296. that.data.Field = field;
  297. var userid = app.globalData.userInfo.UserID;
  298. var tags = [];
  299. for (var i = 0; i < that.data.Tags.length; i++) {
  300. if (that.data.Tags[i])
  301. tags.push(that.data.Tags[i]);
  302. }
  303. var param1 = {};
  304. param1 = that.formatField(that.data.Field);
  305. param1.Tags = tags;
  306. param1.IsCollect=that.data.IsCollect;
  307. param1.LimitTime = that.data.LimitTime;
  308. if (!param1.LimitTime)
  309. param1.LimitTime=common.formatTime(new Date(),"-",true);
  310. param1.CardType = that.data.CardType;
  311. if (!param1.CardType)
  312. param1.CardType=0;
  313. param1.ID = that.data.MiaoguoCardID;
  314. that.saveLocalCardList(param1);
  315. wx.hideLoading();
  316. wx.showLoading({
  317. title: '保存中',
  318. mask: true,
  319. });
  320. timeoutUploadImage = setTimeout(function () {
  321. wx.hideLoading();
  322. }, 15000);
  323. main.postData('AddMiaoguoCard?Type=' + that.data.UpdateType + '&UserID=' + userid, param1, function (data) {
  324. wx.removeStorageSync("TempCardNoSaved");
  325. if (that.data.UpdateType == "edit" || that.data.UpdateType == "edit2" || that.data.UpdateType == "edit3") {
  326. var list = app.globalData.CardList;
  327. for (var i = 0; i < list.length; i++) {
  328. if (list[i].MiaoguoCardID == that.data.MiaoguoCardID){
  329. list[i].CardType = that.data.CardType;
  330. list[i].IsCollect = that.data.IsCollect;
  331. list[i].LimitTime=that.data.LimitTime;
  332. list[i].LimitTimeStr=common.formatDateCHS(that.data.LimitTime);
  333. }
  334. }
  335. app.globalData.CardList = list;
  336. app.globalData.IsUpdateStudyPlan = 1;
  337. if (that.data.CardType==1){
  338. app.globalData.TaskToday.CardNumberUrgent++;
  339. }
  340. app.globalData.TempIsEditCardType=1;
  341. that.onClose();
  342. } else {
  343. wx.hideLoading();
  344. if (that.data.UpdateType == "add2") {
  345. if (!wx.getStorageSync("IsRemindContinuousNew") && that.data.IsEditCardType){
  346. wx.showModal({
  347. title: '提醒',
  348. showCancel: true,
  349. cancelText: "不再提醒",
  350. content: '连续新建会保留上一张题卡的练习模式、到期时间等设置,以便减少设置次数,新建一批相同属性的题卡。以蓝色标明。点恢复按键可立即恢复成默认设置。',
  351. confirmText: '好的',
  352. success(res) {
  353. if (res.confirm) {
  354. wx.setStorageSync("IsRemindContinuousNew",1);
  355. }
  356. else{
  357. wx.setStorageSync("IsRemindContinuousNew",2);
  358. }
  359. changePattern(that);
  360. }
  361. });
  362. }
  363. else{
  364. wx.showToast({
  365. title: '已保存',
  366. image: "../images/universalpic_save_white_120x120.png",
  367. });
  368. changePattern(that);
  369. }
  370. isFirstAdd = false;
  371. that.initAddCard();
  372. }
  373. else{
  374. wx.showToast({
  375. title: '已保存',
  376. image: "../images/universalpic_save_white_120x120.png",
  377. });
  378. changePattern(that);
  379. }
  380. }
  381. wx.removeStorageSync("TempCardInfo");
  382. });
  383. } else {
  384. wx.showToast({
  385. title: '图片上传失败1',
  386. image: "../images/universalpic_exclamation_white_120x120.png",
  387. mask: true,
  388. });
  389. }
  390. });
  391. }
  392. } else {
  393. wx.showToast({
  394. title: '点击太频繁',
  395. image: "../images/universalpic_exclamation_white_120x120.png",
  396. mask: true,
  397. });
  398. }
  399. }
  400. function changePattern(obj){
  401. if (obj.data.CardType==1){
  402. var cardType=wx.getStorageSync('CardType');
  403. if (cardType==0 && app.globalData.TaskToday.CardNumberUrgent==1){
  404. wx.navigateTo({
  405. url: "../other/menu?Type=0",
  406. });
  407. }
  408. }
  409. }
  410. },
  411. formatField: function (field) {
  412. var result = {};
  413. for (var i = 1; i <= 3; i++) {
  414. result["Field" + i] = "";
  415. if (field.length>0 && field[i]) {
  416. for (var key in field[i]) {
  417. var item = field[i][key];
  418. var str = "";
  419. if (item.Type == "image") {
  420. str = "[图 w='" + item.Width + "' h='" + item.Height + "']" + item.Content + "[/图]";
  421. } else if (item.Type == "line") {
  422. for (var j = 0; j < item.Content.length; j++) {
  423. if (item.Content[j].key == "normal")
  424. str += item.Content[j].value;
  425. if (item.Content[j].key == "line") {
  426. str += "[线]" + item.Content[j].value + "[/线]";
  427. }
  428. if (item.Content[j].key == "highlighter") {
  429. str += "[光]" + item.Content[j].value + "[/光]";
  430. }
  431. }
  432. } else if (item.Type == "sound") {
  433. if (item.SoundMark)
  434. str = "[读 src='" + item.SoundMark + "']" + item.Content + "[/读]";
  435. else
  436. str = "[读]" + item.Content + "[/读]";
  437. } else if (item.Type == "recorder") {
  438. if (item.SoundMark)
  439. str = "[音 url='" + item.SoundMark + "'][/音]";
  440. } else if (item.Type == "normal") {
  441. str = item.Content;
  442. } else if (item.Type == "return") {
  443. str = "\n";
  444. }
  445. result["Field" + i] += str;
  446. }
  447. }
  448. result["Field" + i] = main.changeViewToString(result["Field" + i]);
  449. }
  450. return result;
  451. },
  452. checkImageCount: function (arr) {
  453. var count = 0;
  454. for (var i = 0; i < arr.length; i++) {
  455. for (var j = 0; j < arr[i].length; j++) {
  456. if (arr[i][j].Type == "image" && arr[i][j].Content) {
  457. count++;
  458. }
  459. }
  460. }
  461. if (count > 3) {
  462. wx.showToast({
  463. title: '只能上传三张图片',
  464. image: "../images/universalpic_exclamation_white_120x120.png",
  465. });
  466. return false;
  467. } else
  468. return true;
  469. },
  470. uploadImageAll: function (arr, callback) {
  471. var that = this;
  472. var b = false;
  473. var arrSource = [],
  474. arrResult = [];
  475. for (var i = 0; i < arr.length; i++) {
  476. for (var j = 0; j < arr[i].length; j++) {
  477. if (arr[i][j].Type == "image" && arr[i][j].Content) {
  478. arrSource.push(arr[i][j].Content);
  479. if (arr[i][j].ContentServer.indexOf(app.globalData.uploadImageUrl) >= 0 ||
  480. arr[i][j].ContentServer.indexOf("baidu.com") >= 0 ||
  481. arr[i][j].ContentServer.indexOf("bcebos.com") >= 0) {
  482. var result = {};
  483. result.Source = arr[i][j].ContentServer;
  484. result.Target = arr[i][j].ContentServer;
  485. arrResult.push(result);
  486. } else {
  487. var source = arr[i][j].Content;
  488. that.uploadFileToServer(source, function (data) {
  489. if (data) {
  490. data = JSON.parse(data);
  491. var result = data.result;
  492. result.Target = app.globalData.uploadImageUrl + result.Target;
  493. arrResult.push(result);
  494. }
  495. });
  496. }
  497. b = true;
  498. }
  499. }
  500. }
  501. if (b) {
  502. wx.showLoading({
  503. title: '正在上传',
  504. mask: true,
  505. });
  506. timeoutUploadImage = setTimeout(function () {
  507. wx.hideLoading();
  508. }, 30000);
  509. }
  510. interval = setInterval(function () {
  511. //console.log(arrResult.length);
  512. if (arrResult.length >= arrSource.length) {
  513. wx.hideLoading();
  514. //console.log("arrResult:" + JSON.stringify(arrResult));
  515. clearInterval(interval);
  516. var success = true;
  517. var ari = 0;
  518. for (var i = 0; i < arr.length; i++) {
  519. for (var j = 0; j < arr[i].length; j++) {
  520. if (arr[i][j].Type == "image" && arr[i][j].Content) {
  521. var tempUrl = arr[i][j].Content;
  522. var serverUrl = "";
  523. for (var k = 0; k < arrResult.length; k++) {
  524. if (tempUrl.indexOf(arrResult[k].Source) >= 0) {
  525. serverUrl = arrResult[k].Target;
  526. break;
  527. }
  528. }
  529. //console.log("serverUrl:" + serverUrl);
  530. //console.log("tempUrl:" + tempUrl);
  531. if (serverUrl == "")
  532. serverUrl = main.getServerImage(tempUrl);
  533. main.saveTempImage(serverUrl, tempUrl);
  534. arr[i][j].Content = serverUrl;
  535. arr[i][j].ContentServer = serverUrl;
  536. if (serverUrl == "") {
  537. success = false;
  538. break;
  539. }
  540. }
  541. }
  542. }
  543. //console.log(JSON.stringify(arr));
  544. callback(success, arr);
  545. }
  546. }, 500);
  547. },
  548. uploadFileToServer: function (file, callback) {
  549. var url = common.Encrypt("MiaoguoUploadFile2");
  550. wx.uploadFile({
  551. url: app.globalData.serverUrl + url,
  552. filePath: file,
  553. name: 'file',
  554. success(res) {
  555. callback(res.data);
  556. },
  557. fail: function (err) {
  558. wx.hideLoading();
  559. wx.showModal({
  560. title: '上传文件失败',
  561. showCancel: false,
  562. content: JSON.stringify(err),
  563. });
  564. }
  565. });
  566. },
  567. saveLocalCardList: function (param1) {
  568. var that = this;
  569. var list = app.globalData.CardList;
  570. for (var i = 0; i < list.length; i++) {
  571. if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  572. for (var j = 0; j < 4; j++) {
  573. if (j == 0) {
  574. if (param1.tags && param1.tags.length > 0)
  575. list[i].Content[j].Content = param1.tags.join(",");
  576. } else
  577. list[i].Content[j].Content = param1["Field" + j];
  578. }
  579. if (param1.LimitTime)
  580. list[i].LimitTime = common.formatTime(param1.LimitTime);
  581. app.globalData.CardList = list;
  582. break;
  583. }
  584. }
  585. },
  586. initAddCard: function () {
  587. var card = {};
  588. card.MiaoguoCardID = 0;
  589. card.Content = [];
  590. for (var i = 0; i < 4; i++) {
  591. var obj = {};
  592. obj.ContentType = i;
  593. obj.Content = [];
  594. card.Content.push(obj);
  595. }
  596. app.globalData.CardList = [card];
  597. this.setData({
  598. MiaoguoCardID: 0,
  599. Field: [
  600. [],
  601. [],
  602. [],
  603. []
  604. ],
  605. Tags: [],
  606. UpdateType: "add2",
  607. });
  608. },
  609. onBindError: function (e) {
  610. for (var i = 1; i < this.data.Field.length; i++) {
  611. for (var j = 0; j < this.data.Field[i].length; j++) {
  612. if (this.data.Field[i][j].Type == "image") {
  613. this.data.Field[i][j].Url = this.data.Field[i][j].Content;
  614. }
  615. }
  616. }
  617. this.setData({
  618. Field: this.data.Field,
  619. });
  620. },
  621. deleteItem: function (e) {
  622. var that = this;
  623. var index = e.currentTarget.dataset.id;
  624. if (e.currentTarget.dataset.type==1){
  625. that.setData({
  626. TagIndex: index,
  627. });
  628. }
  629. else if (e.currentTarget.dataset.type==2){
  630. that.data.TagTemp.splice(index, 1);
  631. that.setData({
  632. TagTemp: that.data.TagTemp,
  633. TagIndex: -1,
  634. });
  635. }
  636. else if (e.currentTarget.dataset.type==3){
  637. that.setData({
  638. Tags: that.data.TagTemp,
  639. TagsStr:that.data.TagTemp.join("、"),
  640. TagIndex: -1,
  641. });
  642. var list = app.globalData.CardList;
  643. for (var i = 0; i < list.length; i++) {
  644. if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  645. list[i].Content[0].Content = that.data.Tags;
  646. break;
  647. }
  648. }
  649. app.globalData.CardList = list;
  650. that.closeTagShow();
  651. }
  652. },
  653. onGotoList: function () {
  654. var that = this;
  655. if (isFirstAdd == true || !that.data.Field) {
  656. wx.showModal({
  657. title: '提醒',
  658. content: '无法复查,因为没有上一张。从连续新建第二张题卡起可一键查看上一张题卡。',
  659. confirmText: '知道了',
  660. showCancel: false,
  661. });
  662. }
  663. else if (that.data.Field[1].length > 0 || that.data.Field[2].length > 0 || that.data.Field[2].length > 0) {
  664. wx.showModal({
  665. title: '提醒',
  666. content: '将离开编辑状态,请先保存题卡。',
  667. confirmText: '不保存',
  668. success(res) {
  669. if (res.confirm) {
  670. goto();
  671. setTimeout(function () {
  672. wx.removeStorageSync("TempCardNoSaved");
  673. }, 1000);
  674. }
  675. }
  676. });
  677. }
  678. else {
  679. goto();
  680. }
  681. function goto() {
  682. wx.showLoading({
  683. title: '请稍候',
  684. });
  685. setTimeout(function () {
  686. wx.hideLoading();
  687. }, 5000);
  688. var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID;
  689. main.getData(url, function (data) {
  690. wx.hideLoading();
  691. if (data) {
  692. app.globalData.CardList = data.List;
  693. that.setData({
  694. UpdateType: "add",
  695. });
  696. wx.navigateTo({
  697. url: './mainlist?type=3&Count=' + data.Count,
  698. })
  699. }
  700. });
  701. }
  702. },
  703. //段落编辑**************************
  704. //字段输入
  705. bindinputField: function (e) {
  706. //console.log("bindinputField:" + e.detail.value + " isEdit:" + isEdit);
  707. var that = this;
  708. if (app.globalData.IsAndroid && !isEdit) {
  709. return;
  710. }
  711. this.setData({
  712. FieldContent: e.detail.value,
  713. });
  714. },
  715. //加符号
  716. addSymbol: function (e) {
  717. //console.log("addSymbol");
  718. isEdit = true;
  719. var that = this;
  720. btnName = e.currentTarget.dataset.id;
  721. if (btnName == "[读]") {
  722. this.setData({
  723. SoundSign: "[/读]",
  724. });
  725. } else if (btnName == "[/读]") {
  726. this.setData({
  727. SoundSign: "[读]",
  728. });
  729. } else if (btnName == "[线]") {
  730. this.setData({
  731. LineSign: "[/线]",
  732. });
  733. } else if (btnName == "[/线]") {
  734. this.setData({
  735. LineSign: "[线]",
  736. });
  737. } else if (btnName == "[光]") {
  738. this.setData({
  739. HighlighterSign: "[/光]",
  740. });
  741. } else if (btnName == "[/光]") {
  742. this.setData({
  743. HighlighterSign: "[光]",
  744. });
  745. }
  746. if (btnName == "( )")
  747. btnName = "( )";
  748. else if (btnName == "_")
  749. btnName = "_____";
  750. //console.log("addSymbol_btnName:" + btnName);
  751. if (!this.data.Focus) {
  752. var obj = { detail: { cursor: tempCursor } };
  753. this.onBindblur(obj);
  754. }
  755. //console.log("addSymbol:" + this.data.FieldContent);
  756. setTimeout(function () {
  757. that.setData({
  758. Focus: true,
  759. });
  760. }, 300);
  761. },
  762. //焦点聚焦
  763. onBindFocus: function () {
  764. //console.log("onBindFocus");
  765. btnName = "";
  766. this.setData({
  767. Focus: true,
  768. });
  769. },
  770. //失焦
  771. onBindblur: function (e) {
  772. var that = this;
  773. //console.log("onBindblur:" + isEdit + " Filed:" + this.data.FieldContent);
  774. if (app.globalData.IsAndroid && !isEdit) {
  775. setTimeout(function () {
  776. isEdit = true;
  777. //console.log("onBindblur2:" + isEdit);
  778. }, 500);
  779. return;
  780. }
  781. isEdit = false;
  782. if (app.globalData.IsAndroid && !isEdit) {
  783. setTimeout(function () {
  784. isEdit = true;
  785. //console.log("onBindblur2:" + isEdit);
  786. }, 500);
  787. }
  788. //console.log("onBindblur:"+isEdit);
  789. this.updateField();
  790. tempCursor = e.detail.cursor;
  791. //console.log("tempCursor:" + tempCursor);
  792. if (tempCursor == undefined)
  793. tempCursor = this.data["FieldContent"].length;
  794. var str1 = "",
  795. str2 = "";
  796. if (this.data.FieldContent.length > 0) {
  797. str1 = this.data.FieldContent.substr(0, tempCursor);
  798. str2 = this.data.FieldContent.substring(tempCursor, this.data.FieldContent.length);
  799. }
  800. //console.log("str1:" + str1);
  801. //console.log("btnName:" + btnName);
  802. //console.log("str2:" + str2);
  803. var cur = 0;
  804. if (btnName) {
  805. cur = 1;
  806. if (btnName == "[读]" || btnName == "[线]" || btnName == "[光]") {
  807. cur = 3;
  808. } else if (btnName == "[/读]" || btnName == "[/线]" || btnName == "[/光]") {
  809. cur = 4;
  810. } else if (btnName === "( )") {
  811. cur = 7;
  812. } else if (btnName === "_____") {
  813. cur = 5;
  814. }
  815. }
  816. this.data.FieldContent = str1 + btnName + str2;
  817. this.setData({
  818. FieldContent: this.data.FieldContent,
  819. Focus: false,
  820. Cursor: tempCursor + cur,
  821. });
  822. btnName = "";
  823. },
  824. bindscrollHandler: function () {
  825. //console.log("bindscrollHandler");
  826. btnName = "";
  827. },
  828. onSearchField: function (e) {
  829. app.globalData.TempFieldNumber = this.data.FieldNumber;
  830. wx.navigateTo({
  831. url: './addInfomation',
  832. });
  833. this.updateField();
  834. setTimeout(function () {
  835. isEdit = true;
  836. //console.log("onSearchEnd");
  837. }, 1000);
  838. },
  839. clear: function () {
  840. var that = this;
  841. //console.log("clear");
  842. this.setData({
  843. FieldContent: "",
  844. Focus: true,
  845. Cursor: 0,
  846. });
  847. btnName = "";
  848. isEdit = false;
  849. this.updateField();
  850. },
  851. closeAddItem: function (e) {
  852. var that = this;
  853. var isSave = e.currentTarget.dataset.idsave;
  854. if (isSave == "true") {
  855. isUnload = false;
  856. if (that.data.FieldContent) {
  857. var content = that.data.FieldContent;
  858. main.postData("MsgSecCheck2",
  859. { Content: content, },
  860. function (data) {
  861. if (data && data.errcode == 0) {
  862. next(that);
  863. } else {
  864. if (data.errmsg) {
  865. wx.showToast({
  866. title: data.errmsg,
  867. duration: 2000,
  868. image: "../images/universalpic_wrong_white_120x120.png",
  869. });
  870. isViolate = true;
  871. }
  872. }
  873. });
  874. } else {
  875. next(that);
  876. }
  877. } else if (isSave == "false") {
  878. var content = wx.getStorageSync("TempCardInfoAddItem");
  879. this.setData({
  880. FieldContent: content,
  881. });
  882. next(that);
  883. }
  884. function next(obj) {
  885. isViolate = false;
  886. obj.updateField();
  887. obj.setData({
  888. HiddenFieldEdit: true,
  889. });
  890. var title = "编辑题卡";
  891. if (obj.data.UpdateType == "add2") {
  892. title = "新建题卡";
  893. }
  894. that.setData({
  895. PageTitle: title,
  896. });
  897. }
  898. },
  899. updateField: function () {
  900. var str = this.data.FieldContent;
  901. var list = app.globalData.CardList;
  902. var card = {};
  903. for (var i = 0; i < list.length; i++) {
  904. if (this.data.MiaoguoCardID == list[i].MiaoguoCardID) {
  905. list[i].Content[this.data.FieldNumber].Content = str;
  906. card = main.changeStringToView(list[i].Content);
  907. break;
  908. }
  909. }
  910. app.globalData.CardList = list;
  911. this.setData({
  912. Field: card.Field,
  913. Tags: card.Tags,
  914. });
  915. },
  916. //选择图片上传
  917. uploadImageField: function () {
  918. //console.log("uploadImageStart");
  919. var that = this;
  920. //若是安卓机
  921. if (app.globalData.IsAndroid) {
  922. selectImage(that);
  923. } else {
  924. wx.showActionSheet({
  925. itemList: ['拍照', '从手机相册选择'],
  926. success(res) {
  927. if (res.tapIndex == 0) {
  928. wx.chooseImage({
  929. count: 1,
  930. sizeType: ['compressed'],
  931. sourceType: ['camera'],
  932. success(res2) {
  933. wx.showLoading({
  934. title: '请稍候',
  935. mask: true,
  936. });
  937. setTimeout(function () {
  938. wx.hideLoading();
  939. selectImage(that);
  940. }, 2000);
  941. },
  942. });
  943. } else if (res.tapIndex == 1) {
  944. selectImage(that);
  945. }
  946. },
  947. fail(res) {
  948. console.log(res.errMsg)
  949. }
  950. });
  951. }
  952. function selectImage(that) {
  953. var sizeType = ['album'];
  954. //若是安卓机
  955. if (app.globalData.IsAndroid)
  956. sizeType = ['album', 'camera'];
  957. wx.chooseImage({
  958. count: 1,
  959. sizeType: ['compressed'],
  960. sourceType: sizeType,
  961. success(res) {
  962. // tempFilePath可以作为img标签的src属性显示图片
  963. const tempFilePaths = res.tempFilePaths;
  964. //console.log(tempFilePaths[0]);
  965. //that.data.FieldContent = that.data.FieldContent + "[图 url='" + tempFilePaths[0] + "']" + tempFilePaths[0] + "[/图]";
  966. wx.getImageInfo({
  967. src: res.tempFilePaths[0],
  968. success(res) {
  969. //console.log(res.width)
  970. //console.log(res.height)
  971. if (tempCursor == undefined)
  972. tempCursor = that.data.FieldContent.length;
  973. var str1 = "",
  974. str2 = "";
  975. if (that.data.FieldContent.length > 0) {
  976. str1 = that.data.FieldContent.substr(0, tempCursor);
  977. str2 = that.data.FieldContent.substring(tempCursor, that.data.FieldContent.length);
  978. }
  979. var width = res.width;
  980. if (isNaN(width))
  981. width = 650;
  982. var height = res.height;
  983. if (isNaN(height))
  984. height = 650;
  985. var str0 = "[图 w='" + width + "' h='" + height + "']" + tempFilePaths[0] + "[/图]";
  986. that.data.FieldContent = str1 + str0 + str2;
  987. tempCursor = that.data.FieldContent.length;
  988. //console.log("uploadImageEnd:" + that.data.FieldContent);
  989. that.setData({
  990. FieldContent: that.data.FieldContent,
  991. Focus: false,
  992. });
  993. that.updateField();
  994. if (!wx.getStorageSync("NoRemindImage")) {
  995. wx.showModal({
  996. title: '提醒',
  997. showCancel: true,
  998. content: "“图片记号”以符号[图]开始…以符号[/图]结尾。如要剪切请确保完整性。",
  999. confirmText: "好的",
  1000. cancelText: "不再提醒",
  1001. success(res) {
  1002. if (res.confirm) { } else {
  1003. wx.setStorageSync("NoRemindImage", true);
  1004. }
  1005. },
  1006. });
  1007. }
  1008. }
  1009. });
  1010. },
  1011. fail: function () {
  1012. }
  1013. });
  1014. }
  1015. },
  1016. showPracticeTime: function () {
  1017. if (this.data.MiaoguoCardID){
  1018. wx.navigateTo({
  1019. url: './previewMenu?IsSave=0&ID='+this.data.MiaoguoCardID+'&CardType='+this.data.CardType+"&LimitTime="+this.data.LimitTime,
  1020. });
  1021. }
  1022. else{
  1023. var limitTime=common.formatTime(new Date(),"-",true);
  1024. if (this.data.LimitTime)
  1025. limitTime=this.data.LimitTime;
  1026. var cardType=0;
  1027. if (this.data.CardType)
  1028. cardType=this.data.CardType;
  1029. wx.navigateTo({
  1030. url: './previewMenu?IsSave=0&ID=0&CardType='+cardType+'&LimitTime='+limitTime,
  1031. });
  1032. }
  1033. },
  1034. //录音授权
  1035. recorderAccredit: function () {
  1036. var that = this;
  1037. if (app.globalData.IsRecorderAccredit == 1)
  1038. that.showRecorder();
  1039. else if (app.globalData.IsRecorderAccredit == 0) {
  1040. recorderManager.stop();
  1041. app.globalData.IsRecorderAccredit = 1;
  1042. that.showRecorder();
  1043. } else if (app.globalData.IsRecorderAccredit == -1) {
  1044. wx.getSetting({
  1045. success(res) {
  1046. if (res.authSetting['scope.record'] === true) {
  1047. app.globalData.IsRecorderAccredit = 1;
  1048. that.showRecorder();
  1049. } else if (res.authSetting['scope.record'] === false) {
  1050. wx.navigateTo({
  1051. url: '../index/openSetting',
  1052. });
  1053. }
  1054. }
  1055. });
  1056. }
  1057. },
  1058. showRecorder: function () {
  1059. var that = this;
  1060. if (that.checkRecorderCount()) {
  1061. that.recorderInit();
  1062. tempRecorderFile = "";
  1063. that.setData({
  1064. PageTitle: '录音',
  1065. });
  1066. that.setData({
  1067. IsRecorder: true,
  1068. IsRecorderFinished: false,
  1069. BtnRecorderName: "按住录音1分钟",
  1070. RecorderTime: "00:00",
  1071. RecorderTimeCss: "",
  1072. RecorderPlayName: "播放",
  1073. });
  1074. innerAudioContext = wx.createInnerAudioContext();
  1075. innerAudioContext.onPlay(() => {
  1076. console.log('开始播放');
  1077. that.setData({
  1078. RecorderTimeCss: "RecorderPanel1121",
  1079. RecorderTime: "00:00",
  1080. RecorderPlayName: "停止",
  1081. });
  1082. });
  1083. innerAudioContext.onEnded(() => {
  1084. console.log('结束播放');
  1085. clearInterval(intervalRecorder);
  1086. that.setData({
  1087. RecorderTime: "00:00",
  1088. RecorderTimeCss: "",
  1089. RecorderPlayName: "播放",
  1090. });
  1091. });
  1092. }
  1093. },
  1094. closeRecorder: function () {
  1095. var that = this;
  1096. this.recorderInit();
  1097. if (tempRecorderFile) {
  1098. wx.showModal({
  1099. title: '提醒',
  1100. content: '这段录音还没有上传,要放弃录音吗?',
  1101. showCancel: true,
  1102. confirmText: "取消",
  1103. cancelText: "不上传",
  1104. success(res) {
  1105. if (res.cancel) {
  1106. closeRecorder2();
  1107. }
  1108. },
  1109. })
  1110. } else {
  1111. closeRecorder2();
  1112. }
  1113. function closeRecorder2() {
  1114. that.setData({
  1115. PageTitle: '编辑 段落' + that.data.FieldNumber,
  1116. });
  1117. that.setData({
  1118. IsRecorder: false,
  1119. IsRecorderFinished: false,
  1120. });
  1121. tempRecorderFile = "";
  1122. }
  1123. },
  1124. //录音初始化
  1125. recorderInit: function () {
  1126. if (innerAudioContext)
  1127. innerAudioContext.stop();
  1128. if (recorderManager)
  1129. recorderManager.stop();
  1130. clearInterval(intervalRecorder);
  1131. },
  1132. checkRecorderCount: function (arr) {
  1133. var that = this;
  1134. var count = 0;
  1135. if (that.data.FieldContent.indexOf("[音 url=") >= 0 ||
  1136. that.data.FieldContent.indexOf("[/音]") >= 0) {
  1137. count = 1;
  1138. }
  1139. if (count > 0) {
  1140. wx.showToast({
  1141. title: '仅能上传一段',
  1142. image: "../images/universalpic_exclamation_white_120x120.png",
  1143. });
  1144. return false;
  1145. } else
  1146. return true;
  1147. },
  1148. btnRecorderStart: function () {
  1149. var that = this;
  1150. if (app.globalData.IsRecorderAccredit == 1) {
  1151. that.setData({
  1152. BtnRecorderName: "松手结束",
  1153. RecorderTimeCss: "RecorderPanel1121",
  1154. });
  1155. that.showRecorderTime();
  1156. recorderManager.start();
  1157. }
  1158. },
  1159. btnRecorderEnd: function () {
  1160. var that = this;
  1161. if (app.globalData.IsRecorderAccredit == 1) {
  1162. if (that.data.RecorderTime == "00:00") {
  1163. //小于1秒处理
  1164. wx.showToast({
  1165. title: '时间过短',
  1166. image: "../images/universalpic_exclamation_white_120x120.png",
  1167. });
  1168. that.showRecorder();
  1169. } else {
  1170. that.setData({
  1171. IsRecorderFinished: true,
  1172. RecorderTimeCss: "",
  1173. });
  1174. that.recorderInit();
  1175. }
  1176. } else {
  1177. that.recorderAccredit();
  1178. }
  1179. },
  1180. showRecorderTime: function () {
  1181. var that = this;
  1182. var second = 0;
  1183. clearInterval(intervalRecorder);
  1184. intervalRecorder = setInterval(function () {
  1185. second++;
  1186. var secondStr = second.toString();
  1187. if (second < 10)
  1188. secondStr = "0" + secondStr;
  1189. that.setData({
  1190. RecorderTime: "00:" + secondStr,
  1191. });
  1192. if (second >= 59) {
  1193. that.setData({
  1194. IsRecorderFinished: true,
  1195. RecorderTimeCss: "",
  1196. });
  1197. that.recorderInit();
  1198. if (that.data.RecorderPlayName == "播放") {
  1199. wx.showToast({
  1200. title: '录音超时',
  1201. image: "../images/universalpic_exclamation_white_120x120.png",
  1202. });
  1203. }
  1204. }
  1205. }, 1000);
  1206. },
  1207. btnRecorderPlay: function () {
  1208. var that = this;
  1209. if (tempRecorderFile && this.data.RecorderPlayName == "播放") {
  1210. innerAudioContext.src = tempRecorderFile;
  1211. innerAudioContext.play();
  1212. this.showRecorderTime();
  1213. } else if (this.data.RecorderPlayName == "停止") {
  1214. if (innerAudioContext)
  1215. innerAudioContext.stop();
  1216. clearInterval(intervalRecorder);
  1217. that.setData({
  1218. RecorderTime: "00:00",
  1219. RecorderTimeCss: "",
  1220. RecorderPlayName: "播放",
  1221. });
  1222. }
  1223. },
  1224. btnRecorderSave: function () {
  1225. var that = this;
  1226. this.recorderInit();
  1227. wx.showLoading({
  1228. title: '正在上传',
  1229. });
  1230. setTimeout(function () {
  1231. wx.hideLoading();
  1232. }, 60000);
  1233. that.uploadFileToServer(tempRecorderFile, function (data) {
  1234. if (data) {
  1235. data = JSON.parse(data);
  1236. //console.log(data);
  1237. wx.hideLoading();
  1238. var result = data.result;
  1239. result.Target = app.globalData.uploadImageUrl + result.Target;
  1240. that.data.FieldContent = that.data.FieldContent + "[音 url='" + result.Target + "'][/音]";
  1241. that.data.FieldContent = main.encryptUrl(that.data.FieldContent);
  1242. that.setData({
  1243. FieldContent: that.data.FieldContent,
  1244. });
  1245. tempRecorderFile = "";
  1246. that.closeRecorder();
  1247. if (!wx.getStorageSync("NoRemindRecorder")) {
  1248. wx.showModal({
  1249. title: '提醒',
  1250. showCancel: true,
  1251. content: "“录音记号”以符号[录]开始…以符号[/录]结尾。如要剪切请确保完整性。",
  1252. confirmText: "好的",
  1253. cancelText: "不再提醒",
  1254. success(res) {
  1255. if (res.confirm) { } else {
  1256. wx.setStorageSync("NoRemindRecorder", true);
  1257. }
  1258. },
  1259. });
  1260. }
  1261. }
  1262. });
  1263. },
  1264. goto: function (e) {
  1265. var url=e.currentTarget.dataset.url;
  1266. wx.navigateTo({
  1267. url: url,
  1268. });
  1269. },
  1270. showTagShow:function(){
  1271. var tagTemp=this.data.Tags.join(",");
  1272. this.setData({
  1273. IsTagShow:true,
  1274. TagTemp:tagTemp.split(","),
  1275. TagIndex:-1,
  1276. });
  1277. this.setData({
  1278. PageTitle: '自动记号',
  1279. });
  1280. },
  1281. closeTagShow:function(){
  1282. this.setData({
  1283. IsTagShow:false,
  1284. });
  1285. this.setData({
  1286. PageTitle: '编辑题卡',
  1287. });
  1288. },
  1289. setCardTypeInit:function(){
  1290. this.setData({
  1291. CardType:0,
  1292. PracticeCardType:"日常"+"题卡",
  1293. PracticeTimeStr:"",
  1294. LimitTime:common.formatTime(new Date(),"-",true),
  1295. IsEditCardType:"",
  1296. });
  1297. wx.showToast({
  1298. title: '已恢复默认',
  1299. image: "../images/universalpic_restore_white_120x120.png",
  1300. });
  1301. },
  1302. gotoAddInfomationDetail:function(param){
  1303. var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
  1304. url += "&Word=" + param.Word;
  1305. if (param.SearchType)
  1306. url += "&SearchType=" + param.SearchType;
  1307. if (param.Author)
  1308. url += "&Author=" + param.Author;
  1309. if (app.globalData.TempStr){
  1310. url += "&ShiciUrl=" + app.globalData.TempStr;
  1311. app.globalData.TempStr="";
  1312. }
  1313. main.getData(url, function (data) {
  1314. if (data){
  1315. var obj={};
  1316. obj.Value=data;
  1317. main.updateSearchList(obj);
  1318. app.globalData.TempSearchBackNumber=1;
  1319. wx.navigateTo({
  1320. url: './addInfomationDetail',
  1321. });
  1322. }
  1323. });
  1324. },
  1325. showPanel: function (e) {
  1326. var that = this;
  1327. that.hiddenPanel();
  1328. switch(e.currentTarget.dataset.type){
  1329. case "help":
  1330. that.setData({
  1331. IsHelp: true,
  1332. });
  1333. break;
  1334. case "menu":
  1335. that.setData({
  1336. IsShowMenu: true,
  1337. });
  1338. break;
  1339. case "folder":
  1340. that.setData({
  1341. IsFolder: true,
  1342. });
  1343. that.getFolderList();
  1344. break;
  1345. case "limittime":
  1346. var arrLimitTime=constant1.arrLimitTime;
  1347. for(var i=0;i<arrLimitTime.length;i++){
  1348. arrLimitTime[i].Selected="";
  1349. }
  1350. that.setData({
  1351. IsLimitTime: true,
  1352. LimitTimeArr:arrLimitTime,
  1353. });
  1354. break;
  1355. case "fontsize":
  1356. if (!that.data.FontSize)
  1357. that.data.FontSize=48;
  1358. var fontSize=constant1.arrFontSize;
  1359. var fontSizeName="";
  1360. for(var i=0;i<fontSize.length;i++){
  1361. fontSize[i].Selected="";
  1362. if (fontSize[i].Value==that.data.FontSize){
  1363. fontSize[i].Selected="MenuBtnSelect";
  1364. fontSizeName=fontSize[i].Name;
  1365. }
  1366. }
  1367. that.setData({
  1368. IsFontsize: true,
  1369. FontSizeArr:fontSize,
  1370. FontSizeTemp:that.data.FontSize,
  1371. FontSizeName:fontSizeName,
  1372. });
  1373. break;
  1374. case "cardtype":
  1375. var obj={};
  1376. if (!that.data.CardType)
  1377. that.data.CardType=0;
  1378. if (that.data.CardType==0){
  1379. obj.NormalCss="MenuBtnSelect";
  1380. obj.UrgentCss="";
  1381. }
  1382. else if (that.data.CardType==1){
  1383. obj.NormalCss="";
  1384. obj.UrgentCss="MenuBtnSelect";
  1385. }
  1386. else if (that.data.CardType==-1){
  1387. obj.NormalCss="";
  1388. obj.UrgentCss="";
  1389. }
  1390. if (app.globalData.TaskToday.CardNumberUrgent>200){
  1391. obj.UrgentCss="MenuBtnDisabled";
  1392. }
  1393. that.setData({
  1394. IsCardType: true,
  1395. CardTypeCss:obj,
  1396. });
  1397. break;
  1398. }
  1399. },
  1400. hiddenPanel:function(){
  1401. this.setData({
  1402. IsShowMenu:false,
  1403. IsHelp: false,
  1404. IsFontsize:false,
  1405. IsFolder:false,
  1406. IsLimitTime:false,
  1407. IsCardType:false,
  1408. });
  1409. },
  1410. setFontSize:function(e){
  1411. var that=this;
  1412. var fontSize=constant1.arrFontSize;
  1413. var fontSizeName;
  1414. for(var i=0;i<fontSize.length;i++){
  1415. fontSize[i].Selected="";
  1416. if (fontSize[i].Value==e.currentTarget.dataset.fontsize){
  1417. fontSize[i].Selected="MenuBtnSelect";
  1418. fontSizeName=fontSize[i].Name;
  1419. }
  1420. }
  1421. that.setData({
  1422. FontSizeTemp:e.currentTarget.dataset.fontsize,
  1423. FontSizeArr:fontSize,
  1424. FontSizeName:fontSizeName,
  1425. });
  1426. },
  1427. saveFontSize:function(){
  1428. this.setData({
  1429. FontSize:this.data.FontSizeTemp,
  1430. });
  1431. this.hiddenPanel();
  1432. },
  1433. getFolderList:function(e){
  1434. var that=this;
  1435. if (app.globalData.FolderList.length==0){
  1436. var url="GetUserFolderList?UserID="+app.globalData.userInfo.UserID;
  1437. main.getData(url, function (data) {
  1438. if (data) {
  1439. that.setData({
  1440. FolderArr:data,
  1441. });
  1442. app.globalData.FolderList=data;
  1443. }
  1444. });
  1445. }
  1446. else{
  1447. that.setData({
  1448. FolderArr:app.globalData.FolderList,
  1449. });
  1450. }
  1451. },
  1452. selectFolder:function(e){
  1453. var that=this;
  1454. var id=e.currentTarget.dataset.id;
  1455. for(var i=0;i<that.data.FolderArr.length;i++){
  1456. if (id==that.data.FolderArr[i].ID)
  1457. that.data.FolderArr[i].Selected="MenuBtnSelect";
  1458. else
  1459. that.data.FolderArr[i].Selected="";
  1460. }
  1461. var nullFolder="";
  1462. if (id==0){
  1463. nullFolder="MenuBtnSelect";
  1464. }
  1465. that.setData({
  1466. FolderArr:that.data.FolderArr,
  1467. NullFolder:nullFolder,
  1468. });
  1469. },
  1470. setContinute:function(){
  1471. var that=this;
  1472. if (!that.data.IsContinute)
  1473. that.data.IsContinute="CircleSelected";
  1474. else
  1475. that.data.IsContinute="";
  1476. that.setData({
  1477. IsContinute:that.data.IsContinute,
  1478. });
  1479. },
  1480. setFolder:function(){
  1481. var that=this;
  1482. var id=0;
  1483. var FolderName="";
  1484. for(var i=0;i<that.data.FolderArr.length;i++){
  1485. if (that.data.FolderArr[i].Selected=="MenuBtnSelect"){
  1486. id=that.data.FolderArr[i].ID;
  1487. FolderName=that.data.FolderArr[i].Name;
  1488. }
  1489. }
  1490. that.setData({
  1491. FolderID:id,
  1492. FolderName:FolderName,
  1493. });
  1494. that.hiddenPanel();
  1495. },
  1496. selectLimitTime:function(e){
  1497. var that=this;
  1498. var limitTime="";
  1499. var daynumber=e.currentTarget.dataset.daynumber;
  1500. for(var i=0;i<that.data.LimitTimeArr.length;i++){
  1501. if (daynumber==that.data.LimitTimeArr[i].DayNumber){
  1502. that.data.LimitTimeArr[i].Selected="MenuBtnSelect";
  1503. limitTime=common.formatTime(common.addDate("d",daynumber,new Date()),"-",true);
  1504. }
  1505. else
  1506. that.data.LimitTimeArr[i].Selected="";
  1507. }
  1508. that.setData({
  1509. LimitTimeTemp: limitTime,
  1510. PracticeTimeStr: common.formatDateCHS(limitTime),
  1511. LimitTimeArr:that.data.LimitTimeArr,
  1512. });
  1513. },
  1514. selectLimitTime2:function(e){
  1515. var that=this;
  1516. var limitTime=e.detail.value;
  1517. for(var i=0;i<that.data.LimitTimeArr.length;i++){
  1518. that.data.LimitTimeArr[i].Selected="";
  1519. }
  1520. that.setData({
  1521. LimitTimeTemp: limitTime,
  1522. PracticeTimeStr: common.formatDateCHS(limitTime),
  1523. LimitTimeArr:that.data.LimitTimeArr,
  1524. });
  1525. },
  1526. setLimitTime:function(e){
  1527. var that=this;
  1528. that.setData({
  1529. LimitTime: that.data.LimitTimeTemp,
  1530. PracticeTimeStr: common.formatDateCHS(that.data.LimitTimeTemp),
  1531. });
  1532. that.hiddenPanel();
  1533. },
  1534. setCollect:function(){
  1535. var that=this;
  1536. var IsCollectStr="";
  1537. if (that.data.IsCollect==1){
  1538. that.data.IsCollect=0;
  1539. }
  1540. else{
  1541. that.data.IsCollect=1;
  1542. }
  1543. that.setData({
  1544. IsCollect: that.data.IsCollect,
  1545. });
  1546. that.hiddenPanel();
  1547. },
  1548. setLimitTime:function(e){
  1549. var that=this;
  1550. that.setData({
  1551. LimitTime: that.data.LimitTimeTemp,
  1552. PracticeTimeStr: common.formatDateCHS(that.data.LimitTimeTemp),
  1553. });
  1554. that.hiddenPanel();
  1555. },
  1556. selectCardType:function(e){
  1557. var that=this;
  1558. var cardtype=0;
  1559. if (!e.currentTarget.dataset.disabled){
  1560. if (e.currentTarget.dataset.cardtype){
  1561. cardtype=e.currentTarget.dataset.cardtype;
  1562. }
  1563. if (e.detail.value===true)
  1564. cardtype=-1;
  1565. else if (e.detail.value===false)
  1566. cardtype=0;
  1567. var obj={};
  1568. if (cardtype==0){
  1569. obj.NormalCss="MenuBtnSelect";
  1570. }
  1571. if (cardtype==1){
  1572. obj.UrgentCss="MenuBtnSelect";
  1573. }
  1574. if (cardtype==-1){
  1575. obj.NormalCss="";
  1576. obj.UrgentCss="";
  1577. }
  1578. if (that.data.CardType==1 && (cardtype==0 || cardtype==-1))
  1579. app.globalData.TaskToday.CardNumberUrgent--;
  1580. if (app.globalData.TaskToday.CardNumberUrgent+1>200){
  1581. obj.UrgentCss="MenuBtnDisabled";
  1582. }
  1583. that.setData({
  1584. CardTypeTemp: cardtype,
  1585. CardTypeCss:obj,
  1586. });
  1587. }
  1588. },
  1589. setCardType:function(e){
  1590. var that=this;
  1591. that.setData({
  1592. CardType: Number(that.data.CardTypeTemp),
  1593. PracticeCardType: constant1.arrStudyPattern[that.data.CardTypeTemp]+"题卡",
  1594. });
  1595. that.hiddenPanel();
  1596. },
  1597. onShareAppMessage: function () {
  1598. return {
  1599. title: app.globalData.ShareTitle,
  1600. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  1601. imageUrl: app.globalData.ShareImage,
  1602. }
  1603. },
  1604. })