main.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395
  1. import common from '../utils/util';
  2. import constant from '../utils/constant';
  3. var app = getApp();
  4. var dataSendTimeout = 0;
  5. function getData(url, callback) {
  6. if (!app.globalData.IsProduction)
  7. console.log("加密前的结果为===", url);
  8. var url = common.Encrypt(url);
  9. //console.log("加密后的结果为===",url);
  10. wx.request({
  11. url: app.globalData.serverUrl + url,
  12. success: function (res) {
  13. if (res.statusCode)
  14. common.checkError(res.statusCode);
  15. var data = res.data.result;
  16. callback(data);
  17. },
  18. fail: function () {
  19. wx.showToast({
  20. title: '系统忙请稍候',
  21. // image: "../images/universalpic_warning_white_126x120.png",
  22. duration: 3000
  23. });
  24. },
  25. });
  26. }
  27. function postData(url, postData, callback) {
  28. var url = common.Encrypt(url);
  29. //console.log("加密后的结果为===",url);
  30. wx.request({
  31. url: app.globalData.serverUrl + url,
  32. method: "POST",
  33. data: postData,
  34. success: function (res) {
  35. if (res.statusCode)
  36. common.checkError(res.statusCode);
  37. var data = res.data.result;
  38. callback(data);
  39. },
  40. fail: function () {
  41. wx.showToast({
  42. title: '系统忙请稍候',
  43. duration: 3000
  44. });
  45. },
  46. });
  47. }
  48. function getLocalHost(callback) {
  49. if (!app.globalData.IsProduction) {
  50. var url = common.Encrypt("Ping");
  51. wx.request({
  52. url: app.globalData.serverUrlLocalhost + url,
  53. success: function (res) {
  54. app.globalData.serverUrl = app.globalData.serverUrlLocalhost;
  55. callback();
  56. },
  57. fail: function () {
  58. app.globalData.serverUrl = app.globalData.serverUrlServer;
  59. callback();
  60. },
  61. });
  62. } else {
  63. app.globalData.serverUrl = app.globalData.serverUrlServer;
  64. callback();
  65. }
  66. }
  67. function getBaiduToken() {
  68. getData('GetBaiduToken', function (data) {
  69. if (data) {
  70. app.globalData.BaiduToken = data;
  71. //console.log(app.globalData.BaiduToken);
  72. }
  73. });
  74. }
  75. function payMoney(payType, remark, money, detail, callback) {
  76. console.log(money);
  77. if (app.globalData.userInfo.UserID < 8 ||
  78. app.globalData.userInfo.UserID == 3089)
  79. money = 0.01;
  80. //登录认证
  81. wx.login({
  82. success: function (res) {
  83. if (res.code) {
  84. console.log('获取用户登录态成功!' + res.code);
  85. //预支付
  86. getData('ProductPayLogin500?code=' + res.code + '&payType=' + payType + '&money=' + money + '&detail=' + detail + '&productID=' + app.globalData.ProgramID + '&Remark=' + remark, function (data) {
  87. if (data && data.timeStamp) {
  88. //微信支付
  89. wx.requestPayment({
  90. 'timeStamp': data.timeStamp.toString(),
  91. 'nonceStr': data.nonceStr,
  92. 'package': data.package,
  93. 'signType': 'MD5',
  94. 'paySign': data.paySign,
  95. 'success': function (res3) {
  96. console.log("success:" + res3);
  97. callback(data);
  98. },
  99. 'fail': function (err) {
  100. if (err && err.errMsg && err.errMsg.indexOf("fail cancel")) {
  101. } else {
  102. wx.showToast({
  103. title: '系统忙请稍候',
  104. duration: 3000
  105. });
  106. }
  107. }
  108. });
  109. }
  110. });
  111. } else {
  112. console.log('获取用户登录态失败!' + res.errMsg);
  113. wx.showToast({
  114. title: '系统忙请稍候',
  115. duration: 3000
  116. });
  117. }
  118. }
  119. });
  120. }
  121. function getTimeFormat(duration) {
  122. //console.log("duration:" + duration);
  123. var arr = ['', '', '']
  124. if (duration.indexOf("'") > 0)
  125. arr[0] = duration.substring(0, duration.indexOf("'"));
  126. if (duration.indexOf(".") > 0) {
  127. arr[1] = duration.substring(duration.indexOf("'") + 1, duration.indexOf(".") + 1);
  128. arr[2] = duration.substring(duration.indexOf(".") + 1, duration.indexOf('"'));
  129. } else {
  130. arr[1] = duration.substring(duration.indexOf("'") + 1, duration.indexOf('"'));
  131. }
  132. return arr;
  133. }
  134. function getWindowHeight() {
  135. var height = app.globalData.systemInfo.windowHeight;
  136. //console.log("app.globalData.systemInfo.windowHeight:" + app.globalData.systemInfo.windowHeight * 2);
  137. if (app.globalData.systemInfo.model) {
  138. if (height == 504 && (
  139. app.globalData.systemInfo.model.indexOf("iPhone 6<") >= 0 ||
  140. app.globalData.systemInfo.model.indexOf("iPhone 7<") >= 0 ||
  141. app.globalData.systemInfo.model.indexOf("iPhone 6s<") >= 0 ||
  142. app.globalData.systemInfo.model.indexOf("iPhone 5") >= 0 ||
  143. app.globalData.systemInfo.model.indexOf("iPhone SE") >= 0
  144. )) {
  145. height = 596;
  146. } else if (app.globalData.systemInfo.model.indexOf("iPad") >= 0) {
  147. height = 470;
  148. }
  149. }
  150. height = height * 2;
  151. if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0) {
  152. height = height + 168;
  153. } else {
  154. height = height + 50;
  155. }
  156. //console.log("height:" + height);
  157. //var height = app.globalData.systemInfo.screenHeight * 2;
  158. return height;
  159. }
  160. //获取存储数据,若不存在,则获得缺省值。
  161. function getStorageValue(obj, name, defaultStatus, callback) {
  162. wx.getStorage({
  163. key: name,
  164. success: function (res) {
  165. obj.data[name] = res.data;
  166. obj.setData(obj.data);
  167. callback();
  168. },
  169. fail: function (res) {
  170. obj.data[name] = defaultStatus;
  171. obj.setData(obj.data);
  172. callback();
  173. },
  174. });
  175. }
  176. function getProgramList() {
  177. return [{
  178. id: 89,
  179. appId: 'wx46a7b4c420e6d38f',
  180. path: 'pages/index/start?SourceID=' + app.globalData.ProgramID,
  181. },
  182. {
  183. id: 98,
  184. appId: 'wx331e8dd070f01d0e',
  185. path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
  186. },
  187. {
  188. id: 99,
  189. appId: 'wxb54a6d5aff836ee3',
  190. path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
  191. },
  192. {
  193. id: 106,
  194. appId: 'wx313a8f2c0741efe1',
  195. path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
  196. },
  197. ];
  198. }
  199. function gotoFeedback() {
  200. wx.navigateToMiniProgram({
  201. appId: "wx80059777521b897c",
  202. path: "pages/index/feedback",
  203. extraData: {},
  204. success(res) {
  205. // 打开成功
  206. }
  207. });
  208. }
  209. function changeViewToString(content) {
  210. var str = content;
  211. if (str.constructor == Array) {
  212. if (str.length > 0)
  213. str = str.join(",");
  214. else
  215. str = "";
  216. }
  217. if (!str)
  218. str = ""
  219. else {
  220. str = str.replace(/\n\n\n/g, "\n\n");
  221. if (str.indexOf("\n") == 0 && str.indexOf("[") == 1) {
  222. str = str.substr(1);
  223. }
  224. if (str.lastIndexOf("\n") == str.length - 1) {
  225. str = str.substr(0, str.length - 1);
  226. }
  227. }
  228. return str;
  229. }
  230. function EncryptUrl(str) {
  231. if (str.constructor == Array) {
  232. if (str.length > 0)
  233. str = str.join(",");
  234. else
  235. str = "";
  236. }
  237. if (str) {
  238. str = str.replace(/baidu.com/g, "#####1#####");
  239. str = str.replace(/iciba.com/g, "#####2#####");
  240. str = str.replace(/https:\/\/pinyin.kylx365.com\/sounds/g, "#####3#####");
  241. str = str.replace(/https:\/\/miaguo-1253256735.file.myqcloud.com/g, "#####4#####");
  242. }
  243. if (str.substr(0, 1) == "\n")
  244. str = str.substr(1);
  245. return str;
  246. }
  247. function DecryptUrl(str) {
  248. if (str.constructor == Array) {
  249. if (str.length > 0)
  250. str = str.join(",");
  251. else
  252. str = "";
  253. }
  254. if (str) {
  255. str = str.replace(/#####1#####/g, "baidu.com");
  256. str = str.replace(/#####2#####/g, "iciba.com");
  257. str = str.replace(/#####3#####/g, "https://pinyin.kylx365.com/sounds");
  258. str = str.replace(/#####4#####/g, "https://miaguo-1253256735.file.myqcloud.com");
  259. }
  260. return str;
  261. }
  262. function changeStringToView(field) {
  263. var result = {};
  264. result.Field = [
  265. []
  266. ];
  267. result.Images = [];
  268. for (var j = 0; j < field.length; j++) {
  269. if (j == 0) {
  270. if (field[j].ContentType == 0 && field[j].Content && field[j].Content.length > 0) {
  271. result.Tags = field[j].Content.toString().split(",");
  272. } else {
  273. result.Tags = [];
  274. }
  275. } else {
  276. if (field[j].ContentType == j && field[j].Content && field[j].Content.length > 0) {
  277. var arrResult = [],
  278. arrSoundMark = [];
  279. var str = field[j].Content.toString();
  280. str = DecryptUrl(str);
  281. if (str.indexOf("[读") > 0)
  282. str = str.replace(/\[读/g, "\n[读");
  283. str = str.replace(/\[图/g, "\n[图");
  284. if (str.indexOf("[音") > 0)
  285. str = str.replace(/\[音/g, "\n[音");
  286. str = str.replace(/\[\/读\]/g, "[\/读]\n");
  287. str = str.replace(/\[\/图\]/g, "[\/图]\n");
  288. str = str.replace(/\[\/音\]/g, "[\/音]\n");
  289. str = str.replace(/\n\n\n/g, "\n\n");
  290. var arr = str.split("\n");
  291. for (var k = 0; k < arr.length; k++) {
  292. if (arr[k].indexOf("[图") >= 0 && arr[k].indexOf("[/图]") > 0) {
  293. var obj = {};
  294. obj.Type = "image";
  295. if (arr[k].indexOf("[图") >= 0) {
  296. obj.ContentServer = arr[k].substring(arr[k].indexOf("[图") + 3, arr[k].indexOf("[/图]"));
  297. const w = 650;
  298. if (obj.ContentServer.indexOf("w='") >= 0 && obj.ContentServer.indexOf("h='") >= 0) {
  299. obj.Width = obj.ContentServer.substring(obj.ContentServer.indexOf("w='") + 3, obj.ContentServer.indexOf("h='") - 2);
  300. obj.Height = obj.ContentServer.substring(obj.ContentServer.indexOf("h='") + 3, obj.ContentServer.indexOf("']"));
  301. obj.Height = Math.round((w * Number(obj.Height)) / Number(obj.Width));
  302. obj.Width = w;
  303. } else {
  304. obj.Width = "";
  305. obj.Height = "";
  306. }
  307. obj.ContentServer = obj.ContentServer.substring(obj.ContentServer.indexOf("]") + 1);
  308. obj.Content = getTempImage(obj.ContentServer);
  309. result.Images.push(obj.Content);
  310. }
  311. arrResult.push(obj);
  312. } else if ((arr[k].indexOf("[线]") >= 0 && arr[k].indexOf("[/线]") > 0) || (arr[k].indexOf("[光]") >= 0 && arr[k].indexOf("[/光]") > 0)) {
  313. var obj;
  314. var content = [],
  315. temp = arr[k];
  316. do {
  317. var num1 = temp.indexOf("[线]");
  318. var num2 = temp.indexOf("[光]");
  319. if (num1 >= 0 || num2 >= 0) {
  320. if ((num1 < num2 && num1 >= 0 && num2 >= 0) || (num1 >= 0 && num2 < 0)) {
  321. var temp1 = temp.substring(0, temp.indexOf("[线]"));
  322. if (temp1) {
  323. content.push({
  324. key: "normal",
  325. value: temp1,
  326. });
  327. } else {
  328. if (temp && temp.indexOf("[线]") < 0) {
  329. content.push({
  330. key: "normal",
  331. value: temp,
  332. });
  333. temp = "";
  334. }
  335. }
  336. } else if ((num1 > num2 && num1 >= 0 && num2 >= 0) || (num1 < 0 && num2 >= 0)) {
  337. var temp1 = temp.substring(0, temp.indexOf("[光]"));
  338. if (temp1) {
  339. content.push({
  340. key: "normal",
  341. value: temp1,
  342. });
  343. } else {
  344. if (temp && temp.indexOf("[光]") < 0) {
  345. content.push({
  346. key: "normal",
  347. value: temp,
  348. });
  349. temp = "";
  350. }
  351. }
  352. } else {
  353. content.push({
  354. key: "normal",
  355. value: temp,
  356. });
  357. temp = "";
  358. }
  359. } else {
  360. content.push({
  361. key: "normal",
  362. value: temp,
  363. });
  364. temp = "";
  365. }
  366. if (temp.length > 0 && (num1 >= 0 || num2 >= 0)) {
  367. if ((num1 < num2 && num1 >= 0 && num2 >= 0) || (num1 >= 0 && num2 < 0)) {
  368. temp = temp.substr(temp.indexOf("[线]") + 3);
  369. temp1 = temp.substring(0, temp.indexOf("[/线]"));
  370. if (temp1) {
  371. content.push({
  372. key: "line",
  373. value: temp1,
  374. });
  375. }
  376. temp = temp.substr(temp.indexOf("[/线]") + 4);
  377. } else if ((num1 > num2 && num1 >= 0 && num2 >= 0) || (num1 < 0 && num2 >= 0)) {
  378. temp = temp.substr(temp.indexOf("[光]") + 3);
  379. temp1 = temp.substring(0, temp.indexOf("[/光]"));
  380. if (temp1) {
  381. content.push({
  382. key: "highlighter",
  383. value: temp1,
  384. });
  385. }
  386. temp = temp.substr(temp.indexOf("[/光]") + 4);
  387. } else
  388. temp = "";
  389. } else
  390. temp = "";
  391. }
  392. while (temp.length > 0);
  393. obj = {};
  394. obj.Type = "line";
  395. obj.Content = content;
  396. arrResult.push(obj);
  397. } else if (arr[k].indexOf("[读") >= 0 && arr[k].indexOf("[/读]") > 0) {
  398. var obj = {};
  399. obj.Type = "sound";
  400. if (arr[k].indexOf("[读]") >= 0) {
  401. obj.Content = arr[k].substring(arr[k].indexOf("[读]") + 3, arr[k].indexOf("[/读]"));
  402. } else {
  403. var tempIndex = arr[k].indexOf("\']") + 2;
  404. obj.Content = arr[k].substring(tempIndex, arr[k].indexOf("[/读]"));
  405. obj.SoundMark = arr[k].substring(arr[k].indexOf("src='") + 5, arr[k].indexOf("']"));;
  406. }
  407. arrResult.push(obj);
  408. } else if (arr[k].indexOf("[音") >= 0 && arr[k].indexOf("[/音]") > 0) {
  409. var obj = {};
  410. obj.Type = "recorder";
  411. var tempIndex = arr[k].indexOf("\']") + 2;
  412. //obj.Content = arr[k].substring(tempIndex, arr[k].indexOf("[/音]"));
  413. obj.SoundMark = arr[k].substring(arr[k].indexOf("url='") + 5, arr[k].indexOf("']"));;
  414. arrResult.push(obj);
  415. } else if (arr[k] != "") {
  416. var obj = {};
  417. obj.Type = "normal";
  418. obj.Content = arr[k];
  419. arrResult.push(obj);
  420. } else if (k > 0 && arr[k] == "") {
  421. var obj = {};
  422. obj.Type = "br";
  423. obj.Content = "";
  424. arrResult.push(obj);
  425. }
  426. var obj = {};
  427. obj.Type = "return";
  428. arrResult.push(obj);
  429. }
  430. //去掉前回车换行
  431. // while (arrResult[0].Type == "return" ||
  432. // arrResult[0].Type == "br") {
  433. // arrResult.shift();
  434. // if (arrResult.length == 0)
  435. // break;
  436. // }
  437. //去掉后回车换行
  438. for (var i = arrResult.length - 1; i >= 0; i--) {
  439. if (arrResult[i].Type == "return" ||
  440. arrResult[i].Type == "br")
  441. arrResult.pop();
  442. else {
  443. break;
  444. }
  445. }
  446. result.Field.push(arrResult);
  447. } else {
  448. result.Field.push([]);
  449. }
  450. }
  451. }
  452. return result;
  453. }
  454. //得到当天任务
  455. function getTaskTodayList(callback) {
  456. var isNotData = true;
  457. var intervalTask = setTimeout(function () {
  458. if (isNotData) {
  459. wx.showLoading({
  460. title: '请稍候',
  461. mask: true,
  462. });
  463. setTimeout(function () {
  464. wx.hideLoading();
  465. }, 60000);
  466. }
  467. }, 2000);
  468. var that = this;
  469. var url = 'GetMiaoguoCardToday2?UserID=' + app.globalData.userInfo.UserID;
  470. getData(url, function (data) {
  471. clearTimeout(intervalTask);
  472. if (isNotData) {
  473. wx.hideLoading();
  474. }
  475. isNotData = false;
  476. if (data) {
  477. app.globalData.TaskToday = data;
  478. callback(data);
  479. }
  480. });
  481. }
  482. function getTempImage(serverUrl) {
  483. if (serverUrl.indexOf("miaguo-1253256735") >= 0) {
  484. var list = wx.getStorageSync("TempImageList");
  485. if (!list)
  486. list = [];
  487. for (var i = 0; i < list.length; i++) {
  488. if (list[i].ServerUrl == serverUrl) {
  489. return list[i].TempUrl;
  490. break;
  491. }
  492. }
  493. }
  494. return serverUrl;
  495. }
  496. function getServerImage(tempUrl) {
  497. if (tempUrl.indexOf("http") < 0) {
  498. var list = wx.getStorageSync("TempImageList");
  499. if (!list)
  500. list = [];
  501. for (var i = 0; i < list.length; i++) {
  502. if (list[i].TempUrl == tempUrl) {
  503. return list[i].ServerUrl;
  504. break;
  505. }
  506. }
  507. return ""
  508. }
  509. }
  510. function saveTempImage(serverUrl, tempUrl) {
  511. if (tempUrl.indexOf("http") < 0) {
  512. var list = wx.getStorageSync("TempImageList");
  513. if (!list)
  514. list = [];
  515. var b = false;
  516. for (var i = 0; i < list.length; i++) {
  517. if (list[i].ServerUrl == serverUrl) {
  518. list[i].TempUrl = tempUrl;
  519. b = true;
  520. break;
  521. }
  522. }
  523. if (!b) {
  524. list.push({
  525. "ServerUrl": serverUrl,
  526. "TempUrl": tempUrl
  527. });
  528. }
  529. if (list.length > 200) {
  530. list.pop();
  531. }
  532. wx.setStorageSync("TempImageList", list);
  533. }
  534. }
  535. function UpdateMiaoguoCardTodayAll(isShowLoading, callback) {
  536. var that = this;
  537. if (isShowLoading) {
  538. wx.showLoading({
  539. title: '请稍候',
  540. mask: true,
  541. });
  542. clearTimeout(dataSendTimeout);
  543. dataSendTimeout = setTimeout(function () {
  544. wx.hideLoading();
  545. wx.reLaunch({
  546. url: '../index/index',
  547. })
  548. }, 60000);
  549. }
  550. var list = wx.getStorageSync("ListTaskFinished");
  551. if (list && list.length > 0) {
  552. var arr = [];
  553. for (var i = 0; i < list.length; i++) {
  554. var obj = {};
  555. obj.MiaoguoCardID = list[i].Card.MiaoguoCardID;
  556. obj.IntervalTime = list[i].IntervalTime;
  557. obj.BtnNumber = list[i].BtnNumber;
  558. obj.FontSize = list[i].Card.FontSize;
  559. obj.Duration = list[i].Duration;
  560. obj.LearningType = list[i].LearningType;
  561. obj.IsCollect = list[i].Card.IsCollect;
  562. obj.LastTime = list[i].LastTime;
  563. arr.push(obj);
  564. }
  565. that.postData('UpdateMiaoguoCardTodayAll?UserID=' + app.globalData.userInfo.UserID, {
  566. List: arr,
  567. }, function (data) {
  568. if (isShowLoading) {
  569. wx.hideLoading();
  570. clearTimeout(dataSendTimeout);
  571. }
  572. if (data) {
  573. wx.removeStorageSync("ListTaskFinished");
  574. }
  575. if (callback) {
  576. callback();
  577. }
  578. });
  579. } else {
  580. wx.hideLoading();
  581. clearTimeout(dataSendTimeout);
  582. if (callback) {
  583. callback();
  584. }
  585. }
  586. }
  587. function updateSearchList(obj,callback) {
  588. var arr = wx.getStorageSync("SearchWord3");
  589. if (!arr)
  590. arr = [];
  591. if (obj.Type == "shici") {
  592. if (obj.Value.CHN.ShiciTitle)
  593. obj.Key = obj.Value.CHN.ShiciTitle;
  594. if (obj.Key.indexOf("《") == 0)
  595. obj.Key = obj.Key.substring(1, obj.Key.length - 1);
  596. }
  597. for (var i = 0; i < arr.length; i++) {
  598. if (arr[i].Key == obj.Key
  599. ) {
  600. if (obj.Type == "shici") {
  601. if (arr[i].ShiciUrl == obj.ShiciUrl) {
  602. obj.Value = arr[i].Value;
  603. arr.splice(i, 1);
  604. break;
  605. }
  606. } else {
  607. var b=true;
  608. if (obj.Type && arr[i].Type && arr[i].Type != obj.Type)
  609. b=false;
  610. if (obj.Author && arr[i].Author && arr[i].Author != obj.Author)
  611. b=false;
  612. if (b){
  613. obj.Value = arr[i].Value;
  614. arr.splice(i, 1);
  615. break;
  616. }
  617. }
  618. }
  619. }
  620. if (obj.Key)
  621. arr.unshift(obj);
  622. if (arr.length > 30) {
  623. arr.pop();
  624. }
  625. wx.setStorageSync("SearchWord3", arr);
  626. app.globalData.SearchItem = obj.Value;
  627. if (obj.TypeName)
  628. app.globalData.SearchItem.TypeName = obj.TypeName;
  629. if (callback)
  630. callback();
  631. }
  632. function checkIsIPhoneX() {
  633. var isIphoneX = false;
  634. if (app.globalData.systemInfo.model.indexOf("iPhone X") >= 0 ||
  635. app.globalData.systemInfo.model.indexOf("iPhone X") >= 0) {
  636. isIphoneX = true;
  637. }
  638. return isIphoneX;
  639. }
  640. //设置收藏
  641. function setCollect(id, collect, callback) {
  642. var that = this;
  643. if (collect) {
  644. wx.showToast({
  645. title: '加注成功',
  646. image: '../images/universalpic_star_white_120x120.png',
  647. });
  648. } else {
  649. wx.showToast({
  650. title: '清除成功',
  651. image: '../images/universalpic_star_whiteline_120x120.png',
  652. });
  653. }
  654. getData("UpdateMiaoguoCardInfo?UserID=" + app.globalData.userInfo.UserID + "&MiaoguoCardID=" + id + "&IsCollect=" + collect, function (data) {
  655. if (callback)
  656. callback();
  657. });
  658. }
  659. function buildInitData(callback) {
  660. var that = this;
  661. wx.showLoading({
  662. title: '数据初始化',
  663. });
  664. setTimeout(function () {
  665. wx.hideLoading();
  666. }, 5000);
  667. getData('BuildInitData?UserID=' + app.globalData.userInfo.UserID, function (data) {
  668. wx.hideLoading();
  669. if (data) {
  670. if (callback)
  671. callback();
  672. }
  673. });
  674. }
  675. function getMemoryLevelAll() {
  676. return constant.arrMemoryLevelAll;
  677. }
  678. function getMemoryLevel(index, number, time) {
  679. var arr = getMemoryLevelAll();
  680. if (index < 1)
  681. return arr[index].Value[number].Name;
  682. else
  683. return replaceStr(time);
  684. function replaceStr(data) {
  685. var result = "";
  686. if (data.indexOf("d") > 0) {
  687. var dayNum = Number(data.replace("d", ""));
  688. if (dayNum >= 365) {
  689. var year1 = Math.floor(dayNum / 365);
  690. var year = year1 + Math.round(10 * (dayNum - year1 * 365) / 365) / 10;
  691. result = year + "年后";
  692. } else {
  693. if (dayNum > 31) {
  694. var month1 = Math.floor(dayNum / 30);
  695. var month = month1 + Math.round(10 * (dayNum - month1 * 30) / 30) / 10;
  696. result = month + "月后";
  697. } else {
  698. result = Number(data.replace("d", ""));
  699. if (result == 1)
  700. result = "明天";
  701. else if (result == 2)
  702. result = "后天";
  703. else
  704. result = (result - 1) + "天后";
  705. }
  706. }
  707. } else if (data.indexOf("m") > 0)
  708. result = data.replace("m", "分钟内");
  709. return result;
  710. }
  711. }
  712. //得到要检验的汉字列表
  713. function GetHanziUnitWords(unitsID, testType, callback) {
  714. getData('GetHanziUnitWords?UnitID=' + unitsID, function (data) {
  715. if (data) {
  716. var TaskList = [];
  717. var words = data;
  718. for (var k = 0; k < words.length; k++) {
  719. var taskInfo = {
  720. FontSize: 144,
  721. TagWidth: 136,
  722. Content: [{
  723. ContentType: 0,
  724. Content: []
  725. },
  726. {
  727. ContentType: 1,
  728. Content: []
  729. },
  730. {
  731. ContentType: 2,
  732. Content: []
  733. },
  734. ]
  735. };
  736. taskInfo.Word = words[k].Name;
  737. var pinyinNormal = "(" + getPinyinNormal(words[k].Pinyin) + ")";
  738. var combineWords = common.ReplaceAllString(words[k].CombineWords, words[k].Name, words[k].Name + pinyinNormal);
  739. taskInfo.ReadString = words[k].Name + pinyinNormal + "," + combineWords + "的" + words[k].Name + pinyinNormal;
  740. if (testType == "read") {
  741. taskInfo.Content[0].Content = ["怎么念"];
  742. var question = words[k].CombineWords;
  743. question = common.ReplaceAllString(question, words[k].Name, "(" + words[k].Name + ")");
  744. taskInfo.Content[1].Content = question;
  745. var answer = "[读 src='" + taskInfo.ReadString + "']" + words[k].Pinyin + "[/读]";
  746. taskInfo.Content[2].Content = answer;
  747. if (words[k].CombineWords.length > 6) {
  748. taskInfo.FontSize = 108;
  749. if (words[k].CombineWords.length > 10) {
  750. taskInfo.FontSize = 68;
  751. }
  752. }
  753. } else if (testType == "write") {
  754. taskInfo.Content[0].Content = ["怎么写"];
  755. var question = words[k].CombineWords;
  756. var question2 = common.ReplaceAllString(question, words[k].Name, words[k].Pinyin);
  757. question = "[读 src='" + taskInfo.ReadString + "']" + question2 + "[/读]"
  758. taskInfo.Content[1].Content = question;
  759. var answer = words[k].Name;
  760. answer += "[图 w='650' h='650']" + words[k].BiShunUrl + "[/图]";
  761. taskInfo.Content[2].Content = answer;
  762. if (question2.length > 6) {
  763. taskInfo.FontSize = 108;
  764. if (question2.length > 10) {
  765. taskInfo.FontSize = 68;
  766. if (question2.length > 14) {
  767. taskInfo.FontSize = 48;
  768. }
  769. }
  770. }
  771. }
  772. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  773. TaskList.push(taskInfo);
  774. }
  775. callback(TaskList);
  776. } else {
  777. callback([]);
  778. }
  779. });
  780. }
  781. function GetTestReportInfo(reportid, callback) {
  782. var UserTestReport = wx.getStorageSync('UserTestReport');
  783. for (var n = 0; n < UserTestReport.length; n++) {
  784. if (UserTestReport[n].ID == reportid) {
  785. var name1 = UserTestReport[n].Name[0].split(" ");
  786. var name2 = UserTestReport[n].Name[1];
  787. if (name1[0].indexOf("英语") >= 0) {
  788. //console.log("英语");
  789. var arrEnglist = wx.getStorageSync("EnglishAll");
  790. if (arrEnglist)
  791. arrEnglist = JSON.parse(arrEnglist);
  792. else
  793. arrEnglist = [];
  794. var userTestReportInfo = UserTestReport[n];
  795. var bookid = userTestReportInfo.BookID;
  796. var wordStr = "";
  797. if (name1[1]=="英文字母"){
  798. bookid=100;
  799. wordStr="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
  800. }
  801. else{
  802. for (var i = 0; i < arrEnglist.length; i++) {
  803. if (arrEnglist[i].Name == name1[1]) {
  804. for (var j = 0; j < arrEnglist[i].Units.length; j++) {
  805. if (arrEnglist[i].Units[j].Name == name2) {
  806. wordStr = arrEnglist[i].Units[j].Words.join(",");
  807. break;
  808. }
  809. }
  810. }
  811. }
  812. }
  813. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  814. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  815. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  816. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  817. var unitsid="";
  818. if (bookid>120 && bookid<=124){
  819. unitsid=Number(name2.replace("Lesson ",""));
  820. }
  821. getData('GetTestEnglishWords?UserID=' + app.globalData.userInfo.UserID+'&BookID='+bookid+'&LessonID='+unitsid+ '&Words=' + wordStr+"&TestType="+userTestReportInfo.TestType, function (data) {
  822. if (data) {
  823. var result = {};
  824. result.ID = userTestReportInfo.ID;
  825. result.IsFinished = userTestReportInfo.IsFinished;
  826. result.Name = userTestReportInfo.Name.join("#");
  827. result.TestType = userTestReportInfo.TestType;
  828. result.BookID = bookid;
  829. var TaskList = [];
  830. var words = data;
  831. for (var k = 0; k < words.length; k++) {
  832. var taskInfo = words[k];
  833. if (userTestReportInfo.TestType=="read"){
  834. taskInfo.TagWidth=212;
  835. taskInfo.FontSize=108;
  836. }
  837. else{
  838. taskInfo.TagWidth=186;
  839. taskInfo.FontSize=36;
  840. }
  841. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  842. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  843. taskInfo.Result = 1;
  844. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  845. taskInfo.Result = -1;
  846. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  847. taskInfo.Result = 0;
  848. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  849. taskInfo.Css = "Select2";
  850. TaskList.push(taskInfo);
  851. }
  852. result.TestRightStr = "";
  853. result.TestWrongStr = "";
  854. result.TestSkipStr = "";
  855. result.TestExistStr = "";
  856. if (userTestReportInfo.TestRightStr)
  857. result.TestRightStr = userTestReportInfo.TestRightStr;
  858. if (userTestReportInfo.TestWrongStr)
  859. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  860. if (userTestReportInfo.TestSkipStr)
  861. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  862. if (userTestReportInfo.TestExistStr)
  863. result.TestExistStr = userTestReportInfo.TestExistStr;
  864. result.List = TaskList;
  865. callback(result);
  866. } else {
  867. callback({});
  868. }
  869. });
  870. }
  871. else if (name2=="古诗文") {
  872. //todo
  873. //console.log("古诗文");
  874. var userTestReportInfo = UserTestReport[n];
  875. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  876. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  877. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  878. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  879. getData('GetTestAncientPoetryList?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + userTestReportInfo.BookID, function (data) {
  880. if (data) {
  881. var result = {};
  882. result.ID = userTestReportInfo.ID;
  883. result.IsFinished = userTestReportInfo.IsFinished;
  884. result.Name = userTestReportInfo.Name.join("#");
  885. result.TestType = userTestReportInfo.TestType;
  886. result.BookID = userTestReportInfo.BookID;
  887. var TaskList = [];
  888. for (var k = 0; k < data.length; k++) {
  889. var taskInfo = data[k];
  890. taskInfo.TagWidth=336;
  891. if (taskInfo.Word.length>9)
  892. taskInfo.FontSize=48;
  893. else
  894. taskInfo.FontSize=64;
  895. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  896. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  897. taskInfo.Result = 1;
  898. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  899. taskInfo.Result = -1;
  900. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  901. taskInfo.Result = 0;
  902. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  903. taskInfo.Css = "Select2";
  904. TaskList.push(taskInfo);
  905. }
  906. result.TestRightStr = "";
  907. result.TestWrongStr = "";
  908. result.TestSkipStr = "";
  909. result.TestExistStr = "";
  910. if (userTestReportInfo.TestRightStr)
  911. result.TestRightStr = userTestReportInfo.TestRightStr;
  912. if (userTestReportInfo.TestWrongStr)
  913. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  914. if (userTestReportInfo.TestSkipStr)
  915. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  916. if (userTestReportInfo.TestExistStr)
  917. result.TestExistStr = userTestReportInfo.TestExistStr;
  918. result.List = TaskList;
  919. callback(result);
  920. } else {
  921. callback({});
  922. }
  923. });
  924. }
  925. else {
  926. name1 = name1[0] + name1[1].substr(2, 2) + "能力" + name1[2].substr(0, 1);
  927. var HanziAll = wx.getStorageSync('HanziAll');
  928. HanziAll = JSON.parse(HanziAll);
  929. for (var i = 0; i < HanziAll.length; i++) {
  930. if (name1 == HanziAll[i].Name) {
  931. for (var j = 0; j < HanziAll[i].Units.length; j++) {
  932. if (name2 == HanziAll[i].Units[j].Name) {
  933. var obj = UserTestReport[n];
  934. GetHanziUnitWords(HanziAll[i].Units[j].ID, obj.TestType, function (list) {
  935. if (list) {
  936. for (var k = 0; k < list.length; k++) {
  937. if (obj.TestRightStr && obj.TestRightStr.indexOf(list[k].Word) >= 0)
  938. list[k].Result = 1;
  939. else if (obj.TestWrongStr && obj.TestWrongStr.indexOf(list[k].Word) >= 0)
  940. list[k].Result = -1;
  941. else if (obj.TestSkipStr && obj.TestSkipStr.indexOf(list[k].Word) >= 0)
  942. list[k].Result = 0;
  943. if (obj.TestExistStr && obj.TestExistStr.indexOf(list[k].Word) >= 0)
  944. list[k].Css = "Select2";
  945. }
  946. var result = {};
  947. result.ID = reportid;
  948. result.TestType = obj.TestType;
  949. result.Name = obj.Name.join("#");
  950. result.IsFinished = obj.IsFinished;
  951. result.TestRightStr = obj.TestRightStr;
  952. result.TestWrongStr = obj.TestWrongStr;
  953. result.TestSkipStr = obj.TestSkipStr;
  954. result.TestExistStr = obj.TestExistStr;
  955. result.List = list;
  956. callback(result);
  957. } else
  958. callback({});
  959. });
  960. }
  961. }
  962. }
  963. }
  964. }
  965. }
  966. }
  967. }
  968. function getDetailColor(index) {
  969. var arrDetailColor = constant.arrDetailColor;
  970. if (index > 0)
  971. return arrDetailColor[index];
  972. else if (index == 0)
  973. return arrDetailColor[common.random(1, arr.length - 1)];
  974. else if (index == -1)
  975. return arrDetailColor;
  976. }
  977. function getShareImageBackColor() {
  978. var arr = constant.arrShareImageBackColor;
  979. return arr[common.random(0, arr.length - 1)];
  980. }
  981. function getPinyinNormal(pinyin) {
  982. var result = "";
  983. var arr = constant.arrPinyin;
  984. for (var i = 0; i < arr.length; i++) {
  985. if (arr[i][1] == pinyin) {
  986. result = arr[i][0];
  987. break;
  988. }
  989. }
  990. return result;
  991. }
  992. function getHanzi(callback) {
  993. var that = this;
  994. wx.showLoading({
  995. title: '请稍候',
  996. mask: true,
  997. });
  998. var time = wx.getStorageSync("HanziUpdateTime");
  999. getData('GetHanziAll2?HasEnglish=true&HasHanziWrite=true&UpdateTime=' + time, function (data) {
  1000. wx.hideLoading();
  1001. if (data) {
  1002. var arr = [];
  1003. if (data.List) {
  1004. arr = common.Decrypt(data.List);
  1005. wx.setStorageSync("HanziAll", arr);
  1006. var arrEng = common.Decrypt(data.EngList);
  1007. var arrNewConceptEngList = common.Decrypt(data.NewConceptEngList);
  1008. wx.setStorageSync("EnglishAll", arrEng);
  1009. wx.setStorageSync("NewConceptEngList", arrNewConceptEngList);
  1010. wx.setStorageSync("HanziUpdateTime", data.UpdateTime);
  1011. } else {
  1012. arr = wx.getStorageSync("HanziAll");
  1013. if (arr)
  1014. arr = JSON.parse(arr);
  1015. }
  1016. callback(arr);
  1017. }
  1018. });
  1019. }
  1020. function UploadUserConfig(callback) {
  1021. var that = this;
  1022. var param1 = {};
  1023. param1.CardType = wx.getStorageSync("CardType");
  1024. param1.CardMaxNumberNew = wx.getStorageSync("CardMaxNumberNew");
  1025. param1.CardMaxNumberHistory = wx.getStorageSync("CardMaxNumberHistory");
  1026. param1.CardMaxNumberNewUrgent = wx.getStorageSync("CardMaxNumberNewUrgent");
  1027. param1.CardMaxNumberHistoryUrgent = wx.getStorageSync("CardMaxNumberHistoryUrgent");
  1028. param1.SortTypeIndex = wx.getStorageSync("SortTypeIndex");
  1029. param1.MemoryLevel = wx.getStorageSync("MemoryLevel");
  1030. param1.ClickType = wx.getStorageSync("ClickType");
  1031. param1.SecondConfigArray = wx.getStorageSync("SecondConfigArray").join(",");
  1032. param1.ColorIndexArr = wx.getStorageSync("ColorIndexArr").join(",");
  1033. var symboMain = wx.getStorageSync("SymbolMain");
  1034. var symbol1 = [];
  1035. for (var i = 0; i < symboMain.length; i++) {
  1036. symbol1.push(symboMain[i].Name);
  1037. }
  1038. symbol1 = JSON.stringify(symbol1);
  1039. param1.SymbolList = symbol1;
  1040. that.postData('UploadUserConfig?Type=update&UserID=' + app.globalData.userInfo.UserID, param1, function (data) {
  1041. if (callback) {
  1042. callback();
  1043. }
  1044. });
  1045. }
  1046. function getAwardData(callback) {
  1047. var that = this;
  1048. that.getData('GetAwardInfo?UserID=' + app.globalData.userInfo.UserID, function (data) {
  1049. if (data) {
  1050. callback(data);
  1051. } else
  1052. callback([]);
  1053. });
  1054. }
  1055. function getUserConfig() {
  1056. var that = this;
  1057. postData('UploadUserConfig?Type=getData&UserID=' + app.globalData.userInfo.UserID, {}, function (data) {
  1058. if (data && !data.CardType)
  1059. data.CardType = 0;
  1060. wx.setStorageSync("CardType", data.CardType);
  1061. wx.setStorageSync("CardMaxNumberNew", data.CardMaxNumberNew);
  1062. wx.setStorageSync("CardMaxNumberHistory", data.CardMaxNumberHistory);
  1063. wx.setStorageSync("CardMaxNumberNewUrgent", data.CardMaxNumberNewUrgent);
  1064. wx.setStorageSync("CardMaxNumberHistoryUrgent", data.CardMaxNumberHistoryUrgent);
  1065. wx.setStorageSync("SortTypeIndex", data.SortTypeIndex);
  1066. wx.setStorageSync("MemoryLevel", data.MemoryLevel);
  1067. wx.setStorageSync("ClickType", data.ClickType);
  1068. wx.setStorageSync("SecondConfigArray", data.SecondConfigArray.split(","));
  1069. wx.setStorageSync("ColorIndexArr", data.ColorIndexArr.split(","));
  1070. var symbol1 = [];
  1071. if (data.SymbolList) {
  1072. for (var i = 0; i < data.SymbolList.length; i++) {
  1073. var obj = {};
  1074. obj.Name = data.SymbolList[i];
  1075. obj.CSS = "btn2";
  1076. symbol1.push(obj);
  1077. }
  1078. } else {
  1079. symbol1 = app.globalData.SymbolMain;
  1080. }
  1081. if (symbol1.length>0){
  1082. wx.setStorageSync("SymboMain", symbol1);
  1083. app.globalData.SymbolMain = symbol1;
  1084. }
  1085. });
  1086. }
  1087. function replaceCardInfoString(str) {
  1088. var that = this;
  1089. //str = str.replace(/\[图]/g, "");
  1090. //str = str.replace(/\[\/图\]/g, "");
  1091. var str2 = "";
  1092. if (str.indexOf("[读 src=") >= 0) {
  1093. str2 = str.substr(str.indexOf("[读 src="));
  1094. str2 = str2.substring(0, str2.indexOf("/读]") + 3);
  1095. }
  1096. str = str.replace(str2, "");
  1097. if (str.indexOf("[读 src=") >= 0) {
  1098. str2 = str.substr(str.indexOf("[读 src"));
  1099. str2 = str2.substring(0, str2.indexOf("/读]") + 3);
  1100. }
  1101. str = str.replace(str2, "");
  1102. str = str.replace(/\[读]/g, "");
  1103. str = str.replace(/\[\/读\]/g, "");
  1104. var str3 = "";
  1105. if (str.indexOf("[图") >= 0) {
  1106. str3 = str.substr(str.indexOf("[图"));
  1107. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1108. }
  1109. str = str.replace(str3, "");
  1110. if (str.indexOf("[图") >= 0) {
  1111. str3 = str.substr(str.indexOf("[图"));
  1112. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1113. }
  1114. str = str.replace(str3, "");
  1115. str = str.replace(/\[线]/g, "");
  1116. str = str.replace(/\[\/线\]/g, "");
  1117. str = that.encryptUrl(str);
  1118. return str;
  1119. }
  1120. function searchInfomation(search,searchtype,author,shiciurl,callback){
  1121. var WORD_LENGTH=18;
  1122. wx.showLoading({
  1123. title: '查询中',
  1124. });
  1125. var timeout=setTimeout(function () {
  1126. wx.hideLoading();
  1127. }, 5000);
  1128. var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
  1129. url += "&Word=" + encodeURI(search);
  1130. if (searchtype)
  1131. url += "&SearchType=" + searchtype;
  1132. if (author)
  1133. url += "&Author=" + encodeURI(author);
  1134. if (shiciurl)
  1135. url += "&ShiciUrl=" + shiciurl;
  1136. getData(url, function (data) {
  1137. wx.hideLoading();
  1138. clearTimeout(timeout);
  1139. if (data) {
  1140. //console.log(data);
  1141. if (data.List) {
  1142. var len = WORD_LENGTH;
  1143. var list = data.List;
  1144. for (var i = 0; i < list.length; i++) {
  1145. var item = list[i];
  1146. if (item.TypeName == "字词") {
  1147. if (item.Key.length == 1)
  1148. item.TypeName = "Z";
  1149. else
  1150. item.TypeName = "C";
  1151. } else if (item.TypeName == "诗词") {
  1152. item.TypeName = "S";
  1153. item.Remark = item.Author + " " + item.Dynasty;
  1154. } else if (item.TypeName == "翻译") {
  1155. item.TypeName = "D";
  1156. }
  1157. if (item.Content && item.Content.length > len)
  1158. item.Content = item.Content.substr(0, len) + "...";
  1159. }
  1160. callback(list);
  1161. } else if (data.CHN || data.ENG) {
  1162. var obj = {};
  1163. obj.Key = search;
  1164. obj.Value = data;
  1165. if (data.CHN && data.CHN.Author)
  1166. obj.Author = data.CHN.Author;
  1167. if (data.CHN && data.CHN.Dynasty)
  1168. obj.Dynasty = data.CHN.Dynasty;
  1169. if (data.CHN && data.CHN.PeomContent) {
  1170. obj.Type = "shici";
  1171. obj.TypeName = "诗词";
  1172. obj.Content = data.CHN.PeomContent.join("").substr(0, WORD_LENGTH);
  1173. obj.ShiciUrl = shiciurl;
  1174. obj.TypeName="S";
  1175. } else if (data.CHN) {
  1176. obj.Type = "zici";
  1177. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].pinyin)
  1178. obj.Remark = data.CHN.PinYin[0].pinyin;
  1179. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].explain) {
  1180. obj.Content = data.CHN.PinYin[0].explain.substr(0, WORD_LENGTH);
  1181. obj.Content = obj.Content.replace("<p>", "");
  1182. obj.Content = obj.Content.replace("</p>", "");
  1183. if (obj.Content.length >= WORD_LENGTH)
  1184. obj.Content += "..."
  1185. }
  1186. if (obj.Key.length == 1)
  1187. obj.TypeName = "Z";
  1188. else
  1189. obj.TypeName = "C";
  1190. }
  1191. if (data.ENG && !data.CHN) {
  1192. obj.Type = "eng";
  1193. obj.TypeName = "D";
  1194. if (data.ENG.Soundmark && data.ENG.Soundmark.Eng)
  1195. obj.Remark = data.ENG.Soundmark.Eng;
  1196. if (data.ENG.Paraphrase.length > 0) {
  1197. if (common.checkIsArray(data.ENG.Paraphrase) && data.ENG.Paraphrase[0].ParaphraseList)
  1198. obj.Content = data.ENG.Paraphrase[0].ParaphraseList.join("; ").substr(0, WORD_LENGTH);
  1199. else
  1200. obj.Content = data.ENG.Paraphrase.substr(0, WORD_LENGTH) + "...";
  1201. }
  1202. }
  1203. app.globalData.TempSearchBackNumber = 2;
  1204. //app.globalData.CardList=[];
  1205. app.globalData.CardList2=[];
  1206. callback([],obj);
  1207. }
  1208. else{
  1209. callback([]);
  1210. }
  1211. } else {
  1212. callback([]);
  1213. }
  1214. });
  1215. }
  1216. module.exports = {
  1217. getData: getData,
  1218. postData: postData,
  1219. payMoney: payMoney,
  1220. getLocalHost: getLocalHost,
  1221. getTimeFormat: getTimeFormat,
  1222. getWindowHeight: getWindowHeight,
  1223. getStorageValue: getStorageValue,
  1224. getProgramList: getProgramList,
  1225. gotoFeedback: gotoFeedback,
  1226. getDetailColor: getDetailColor,
  1227. changeStringToView: changeStringToView,
  1228. changeViewToString: changeViewToString,
  1229. encryptUrl: EncryptUrl,
  1230. decryptUrl: DecryptUrl,
  1231. saveTempImage: saveTempImage,
  1232. getTempImage: getTempImage,
  1233. getTaskTodayList: getTaskTodayList,
  1234. updateSearchList: updateSearchList,
  1235. checkIsIPhoneX: checkIsIPhoneX,
  1236. getMemoryLevelAll: getMemoryLevelAll,
  1237. getMemoryLevel: getMemoryLevel,
  1238. getShareImageBackColor: getShareImageBackColor,
  1239. UpdateMiaoguoCardTodayAll: UpdateMiaoguoCardTodayAll,
  1240. setCollect: setCollect,
  1241. UploadUserConfig: UploadUserConfig,
  1242. getServerImage: getServerImage,
  1243. getBaiduToken: getBaiduToken,
  1244. buildInitData: buildInitData,
  1245. getPinyinNormal: getPinyinNormal,
  1246. getHanzi: getHanzi,
  1247. GetHanziUnitWords: GetHanziUnitWords,
  1248. GetTestReportInfo: GetTestReportInfo,
  1249. getUserConfig: getUserConfig,
  1250. getAwardData: getAwardData,
  1251. replaceCardInfoString: replaceCardInfoString,
  1252. searchInfomation:searchInfomation,
  1253. }