add.js 49 KB

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