main.js 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417
  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 wordStr = "";
  790. var userTestReportInfo = UserTestReport[n];
  791. var bookid = userTestReportInfo.BookID;
  792. var arrEnglist = [];
  793. if (bookid<110){
  794. if (name1[1]=="英文字母"){
  795. bookid=100;
  796. 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";
  797. }
  798. }
  799. else if (bookid>110 && bookid<120){
  800. arrEnglist = wx.getStorageSync("EnglishAll");
  801. arrEnglist = JSON.parse(arrEnglist);
  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>100 && bookid<110 && UserTestReport[n].Name[2]){
  819. unitsid=Number(UserTestReport[n].Name[2]);
  820. }
  821. else if (bookid>120 && bookid<=124){
  822. unitsid=Number(name2.replace("Lesson ",""));
  823. }
  824. else if (bookid>130 && bookid<=140 && UserTestReport[n].Name[2]){
  825. unitsid=Number(UserTestReport[n].Name[2]);
  826. }
  827. getData('GetTestEnglishWords?UserID=' + app.globalData.userInfo.UserID+'&BookID='+bookid+'&LessonID='+unitsid+ '&Words=' + wordStr+"&TestType="+userTestReportInfo.TestType, function (data) {
  828. if (data) {
  829. var result = {};
  830. result.ID = userTestReportInfo.ID;
  831. result.IsFinished = userTestReportInfo.IsFinished;
  832. result.Name = userTestReportInfo.Name.join("#");
  833. result.TestType = userTestReportInfo.TestType;
  834. result.BookID = bookid;
  835. var TaskList = [];
  836. var words = data;
  837. for (var k = 0; k < words.length; k++) {
  838. var taskInfo = words[k];
  839. if (userTestReportInfo.TestType=="read"){
  840. taskInfo.TagWidth=212;
  841. taskInfo.FontSize=108;
  842. }
  843. else{
  844. taskInfo.TagWidth=186;
  845. taskInfo.FontSize=36;
  846. }
  847. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  848. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  849. taskInfo.Result = 1;
  850. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  851. taskInfo.Result = -1;
  852. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  853. taskInfo.Result = 0;
  854. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  855. taskInfo.Css = "Select2";
  856. TaskList.push(taskInfo);
  857. }
  858. result.TestRightStr = "";
  859. result.TestWrongStr = "";
  860. result.TestSkipStr = "";
  861. result.TestExistStr = "";
  862. if (userTestReportInfo.TestRightStr)
  863. result.TestRightStr = userTestReportInfo.TestRightStr;
  864. if (userTestReportInfo.TestWrongStr)
  865. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  866. if (userTestReportInfo.TestSkipStr)
  867. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  868. if (userTestReportInfo.TestExistStr)
  869. result.TestExistStr = userTestReportInfo.TestExistStr;
  870. result.List = TaskList;
  871. callback(result);
  872. } else {
  873. callback({});
  874. }
  875. });
  876. }
  877. else if (name2=="古诗文") {
  878. //todo
  879. //console.log("古诗文");
  880. var userTestReportInfo = UserTestReport[n];
  881. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  882. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  883. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  884. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  885. getData('GetTestAncientPoetryList?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + userTestReportInfo.BookID, function (data) {
  886. if (data) {
  887. var result = {};
  888. result.ID = userTestReportInfo.ID;
  889. result.IsFinished = userTestReportInfo.IsFinished;
  890. result.Name = userTestReportInfo.Name.join("#");
  891. result.TestType = userTestReportInfo.TestType;
  892. result.BookID = userTestReportInfo.BookID;
  893. var TaskList = [];
  894. for (var k = 0; k < data.length; k++) {
  895. var taskInfo = data[k];
  896. taskInfo.TagWidth=336;
  897. if (taskInfo.Word.length>9)
  898. taskInfo.FontSize=48;
  899. else
  900. taskInfo.FontSize=64;
  901. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  902. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  903. taskInfo.Result = 1;
  904. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  905. taskInfo.Result = -1;
  906. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  907. taskInfo.Result = 0;
  908. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  909. taskInfo.Css = "Select2";
  910. TaskList.push(taskInfo);
  911. }
  912. result.TestRightStr = "";
  913. result.TestWrongStr = "";
  914. result.TestSkipStr = "";
  915. result.TestExistStr = "";
  916. if (userTestReportInfo.TestRightStr)
  917. result.TestRightStr = userTestReportInfo.TestRightStr;
  918. if (userTestReportInfo.TestWrongStr)
  919. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  920. if (userTestReportInfo.TestSkipStr)
  921. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  922. if (userTestReportInfo.TestExistStr)
  923. result.TestExistStr = userTestReportInfo.TestExistStr;
  924. result.List = TaskList;
  925. callback(result);
  926. } else {
  927. callback({});
  928. }
  929. });
  930. }
  931. else {
  932. name1 = name1[0] + name1[1].substr(2, 2) + "能力" + name1[2].substr(0, 1);
  933. var HanziAll = wx.getStorageSync('HanziAll');
  934. HanziAll = JSON.parse(HanziAll);
  935. for (var i = 0; i < HanziAll.length; i++) {
  936. if (name1 == HanziAll[i].Name) {
  937. for (var j = 0; j < HanziAll[i].Units.length; j++) {
  938. if (name2 == HanziAll[i].Units[j].Name) {
  939. var obj = UserTestReport[n];
  940. GetHanziUnitWords(HanziAll[i].Units[j].ID, obj.TestType, function (list) {
  941. if (list) {
  942. for (var k = 0; k < list.length; k++) {
  943. if (obj.TestRightStr && obj.TestRightStr.indexOf(list[k].Word) >= 0)
  944. list[k].Result = 1;
  945. else if (obj.TestWrongStr && obj.TestWrongStr.indexOf(list[k].Word) >= 0)
  946. list[k].Result = -1;
  947. else if (obj.TestSkipStr && obj.TestSkipStr.indexOf(list[k].Word) >= 0)
  948. list[k].Result = 0;
  949. if (obj.TestExistStr && obj.TestExistStr.indexOf(list[k].Word) >= 0)
  950. list[k].Css = "Select2";
  951. }
  952. var result = {};
  953. result.ID = reportid;
  954. result.TestType = obj.TestType;
  955. result.Name = obj.Name.join("#");
  956. result.IsFinished = obj.IsFinished;
  957. result.TestRightStr = obj.TestRightStr;
  958. result.TestWrongStr = obj.TestWrongStr;
  959. result.TestSkipStr = obj.TestSkipStr;
  960. result.TestExistStr = obj.TestExistStr;
  961. result.List = list;
  962. callback(result);
  963. } else
  964. callback({});
  965. });
  966. }
  967. }
  968. }
  969. }
  970. }
  971. }
  972. }
  973. }
  974. function getDetailColor(index) {
  975. var arrDetailColor = constant.arrDetailColor;
  976. if (index > 0)
  977. return arrDetailColor[index];
  978. else if (index == 0)
  979. return arrDetailColor[common.random(1, arr.length - 1)];
  980. else if (index == -1)
  981. return arrDetailColor;
  982. }
  983. function getShareImageBackColor() {
  984. var arr = constant.arrShareImageBackColor;
  985. return arr[common.random(0, arr.length - 1)];
  986. }
  987. function getPinyinNormal(pinyin) {
  988. var result = "";
  989. var arr = constant.arrPinyin;
  990. for (var i = 0; i < arr.length; i++) {
  991. if (arr[i][1] == pinyin) {
  992. result = arr[i][0];
  993. break;
  994. }
  995. }
  996. return result;
  997. }
  998. function getHanzi(callback) {
  999. var that = this;
  1000. wx.showLoading({
  1001. title: '请稍候',
  1002. mask: true,
  1003. });
  1004. var time = wx.getStorageSync("HanziUpdateTime");
  1005. getData('GetHanziAll2?HasEnglish=true&HasHanziWrite=true&UpdateTime=' + time, function (data) {
  1006. wx.hideLoading();
  1007. if (data) {
  1008. var arr = [];
  1009. if (data.List) {
  1010. arr = common.Decrypt(data.List);
  1011. wx.setStorageSync("HanziAll", arr);
  1012. var arrEng = common.Decrypt(data.EngList);
  1013. var arrNewConceptEngList = common.Decrypt(data.NewConceptEngList);
  1014. var arrCambridgeEngList = common.Decrypt(data.CambridgeEngList);
  1015. var arrPhoneticEngList = common.Decrypt(data.PhoneticEngList);
  1016. wx.setStorageSync("EnglishAll", arrEng);
  1017. wx.setStorageSync("NewConceptEngList", arrNewConceptEngList);
  1018. wx.setStorageSync("CambridgeEngList", arrCambridgeEngList);
  1019. wx.setStorageSync("PhoneticEngList", arrPhoneticEngList);
  1020. wx.setStorageSync("HanziUpdateTime", data.UpdateTime);
  1021. } else {
  1022. arr = wx.getStorageSync("HanziAll");
  1023. if (arr)
  1024. arr = JSON.parse(arr);
  1025. }
  1026. callback(arr);
  1027. }
  1028. });
  1029. }
  1030. function UploadUserConfig(callback) {
  1031. var that = this;
  1032. var param1 = {};
  1033. param1.CardType = wx.getStorageSync("CardType");
  1034. param1.CardMaxNumberNew = wx.getStorageSync("CardMaxNumberNew");
  1035. param1.CardMaxNumberHistory = wx.getStorageSync("CardMaxNumberHistory");
  1036. param1.CardMaxNumberNewUrgent = wx.getStorageSync("CardMaxNumberNewUrgent");
  1037. param1.CardMaxNumberHistoryUrgent = wx.getStorageSync("CardMaxNumberHistoryUrgent");
  1038. param1.SortTypeIndex = wx.getStorageSync("SortTypeIndex");
  1039. param1.MemoryLevel = wx.getStorageSync("MemoryLevel");
  1040. param1.ClickType = wx.getStorageSync("ClickType");
  1041. param1.SecondConfigArray = wx.getStorageSync("SecondConfigArray").join(",");
  1042. param1.ColorIndexArr = wx.getStorageSync("ColorIndexArr").join(",");
  1043. param1.IsFolderPractice = wx.getStorageSync("IsFolderPractice");
  1044. param1.IsAutoSound = wx.getStorageSync("IsAutoSound");
  1045. var symboMain = wx.getStorageSync("SymbolMain");
  1046. var symbol1 = [];
  1047. for (var i = 0; i < symboMain.length; i++) {
  1048. symbol1.push(symboMain[i].Name);
  1049. }
  1050. symbol1 = JSON.stringify(symbol1);
  1051. param1.SymbolList = symbol1;
  1052. var folderOrder=wx.getStorageSync("FolderOrderStr");
  1053. if (folderOrder)
  1054. param1.FolderOrder = folderOrder;
  1055. that.postData('UploadUserConfig?Type=update&UserID=' + app.globalData.userInfo.UserID, param1, function (data) {
  1056. if (callback) {
  1057. callback();
  1058. }
  1059. });
  1060. }
  1061. function getAwardData(callback) {
  1062. var that = this;
  1063. that.getData('GetAwardInfo?UserID=' + app.globalData.userInfo.UserID, function (data) {
  1064. if (data) {
  1065. callback(data);
  1066. } else
  1067. callback([]);
  1068. });
  1069. }
  1070. function getUserConfig() {
  1071. var that = this;
  1072. postData('UploadUserConfig?Type=getData&UserID=' + app.globalData.userInfo.UserID, {}, function (data) {
  1073. if (data && !data.CardType)
  1074. data.CardType = 0;
  1075. wx.setStorageSync("CardType", data.CardType);
  1076. wx.setStorageSync("CardMaxNumberNew", data.CardMaxNumberNew);
  1077. wx.setStorageSync("CardMaxNumberHistory", data.CardMaxNumberHistory);
  1078. wx.setStorageSync("CardMaxNumberNewUrgent", data.CardMaxNumberNewUrgent);
  1079. wx.setStorageSync("CardMaxNumberHistoryUrgent", data.CardMaxNumberHistoryUrgent);
  1080. wx.setStorageSync("SortTypeIndex", data.SortTypeIndex);
  1081. wx.setStorageSync("MemoryLevel", data.MemoryLevel);
  1082. wx.setStorageSync("ClickType", data.ClickType);
  1083. wx.setStorageSync("SecondConfigArray", data.SecondConfigArray.split(","));
  1084. wx.setStorageSync("ColorIndexArr", data.ColorIndexArr.split(","));
  1085. wx.setStorageSync("FolderOrderStr", data.FolderOrder);
  1086. wx.setStorageSync("IsFolderPractice", data.IsFolderPractice);
  1087. wx.setStorageSync("IsAutoSound", data.IsAutoSound);
  1088. var symbol1 = [];
  1089. if (data.SymbolList) {
  1090. for (var i = 0; i < data.SymbolList.length; i++) {
  1091. var obj = {};
  1092. obj.Name = data.SymbolList[i];
  1093. obj.CSS = "btn2";
  1094. symbol1.push(obj);
  1095. }
  1096. } else {
  1097. symbol1 = app.globalData.SymbolMain;
  1098. }
  1099. if (symbol1.length>0){
  1100. wx.setStorageSync("SymboMain", symbol1);
  1101. app.globalData.SymbolMain = symbol1;
  1102. }
  1103. });
  1104. }
  1105. function replaceCardInfoString(str) {
  1106. var that = this;
  1107. //str = str.replace(/\[图]/g, "");
  1108. //str = str.replace(/\[\/图\]/g, "");
  1109. var str2 = "";
  1110. if (str.indexOf("[读 src=") >= 0) {
  1111. str2 = str.substr(str.indexOf("[读 src="));
  1112. str2 = str2.substring(0, str2.indexOf("/读]") + 3);
  1113. }
  1114. str = str.replace(str2, "");
  1115. if (str.indexOf("[读 src=") >= 0) {
  1116. str2 = str.substr(str.indexOf("[读 src"));
  1117. str2 = str2.substring(0, str2.indexOf("/读]") + 3);
  1118. }
  1119. str = str.replace(str2, "");
  1120. str = str.replace(/\[读]/g, "");
  1121. str = str.replace(/\[\/读\]/g, "");
  1122. var str3 = "";
  1123. if (str.indexOf("[图") >= 0) {
  1124. str3 = str.substr(str.indexOf("[图"));
  1125. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1126. }
  1127. str = str.replace(str3, "");
  1128. if (str.indexOf("[图") >= 0) {
  1129. str3 = str.substr(str.indexOf("[图"));
  1130. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1131. }
  1132. str = str.replace(str3, "");
  1133. str = str.replace(/\[线]/g, "");
  1134. str = str.replace(/\[\/线\]/g, "");
  1135. str = that.encryptUrl(str);
  1136. return str;
  1137. }
  1138. function searchInfomation(search,searchtype,author,shiciurl,callback){
  1139. var WORD_LENGTH=18;
  1140. wx.showLoading({
  1141. title: '查询中',
  1142. });
  1143. var timeout=setTimeout(function () {
  1144. wx.hideLoading();
  1145. }, 5000);
  1146. var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
  1147. url += "&Word=" + encodeURI(search);
  1148. if (searchtype)
  1149. url += "&SearchType=" + searchtype;
  1150. if (author)
  1151. url += "&Author=" + encodeURI(author);
  1152. if (shiciurl)
  1153. url += "&ShiciUrl=" + shiciurl;
  1154. getData(url, function (data) {
  1155. wx.hideLoading();
  1156. clearTimeout(timeout);
  1157. if (data) {
  1158. //console.log(data);
  1159. if (data.List) {
  1160. var len = WORD_LENGTH;
  1161. var list = data.List;
  1162. for (var i = 0; i < list.length; i++) {
  1163. var item = list[i];
  1164. if (item.TypeName == "字词") {
  1165. if (item.Key.length == 1)
  1166. item.TypeName = "Z";
  1167. else
  1168. item.TypeName = "C";
  1169. } else if (item.TypeName == "诗词") {
  1170. item.TypeName = "S";
  1171. item.Remark = item.Author + " " + item.Dynasty;
  1172. } else if (item.TypeName == "翻译") {
  1173. item.TypeName = "D";
  1174. }
  1175. if (item.Content && item.Content.length > len)
  1176. item.Content = item.Content.substr(0, len) + "...";
  1177. }
  1178. callback(list);
  1179. } else if (data.CHN || data.ENG) {
  1180. var obj = {};
  1181. obj.Key = search;
  1182. obj.Value = data;
  1183. if (data.CHN && data.CHN.Author)
  1184. obj.Author = data.CHN.Author;
  1185. if (data.CHN && data.CHN.Dynasty)
  1186. obj.Dynasty = data.CHN.Dynasty;
  1187. if (data.CHN && data.CHN.PeomContent) {
  1188. obj.Type = "shici";
  1189. obj.TypeName = "诗词";
  1190. obj.Content = data.CHN.PeomContent.join("").substr(0, WORD_LENGTH);
  1191. obj.ShiciUrl = shiciurl;
  1192. obj.TypeName="S";
  1193. } else if (data.CHN) {
  1194. obj.Type = "zici";
  1195. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].pinyin)
  1196. obj.Remark = data.CHN.PinYin[0].pinyin;
  1197. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].explain) {
  1198. obj.Content = data.CHN.PinYin[0].explain.substr(0, WORD_LENGTH);
  1199. obj.Content = obj.Content.replace("<p>", "");
  1200. obj.Content = obj.Content.replace("</p>", "");
  1201. if (obj.Content.length >= WORD_LENGTH)
  1202. obj.Content += "..."
  1203. }
  1204. if (obj.Key.length == 1)
  1205. obj.TypeName = "Z";
  1206. else
  1207. obj.TypeName = "C";
  1208. }
  1209. if (data.ENG && !data.CHN) {
  1210. obj.Type = "eng";
  1211. obj.TypeName = "D";
  1212. if (data.ENG.Soundmark && data.ENG.Soundmark.Eng)
  1213. obj.Remark = data.ENG.Soundmark.Eng;
  1214. if (data.ENG.Paraphrase.length > 0) {
  1215. if (common.checkIsArray(data.ENG.Paraphrase) && data.ENG.Paraphrase[0].ParaphraseList)
  1216. obj.Content = data.ENG.Paraphrase[0].ParaphraseList.join("; ").substr(0, WORD_LENGTH);
  1217. else
  1218. obj.Content = data.ENG.Paraphrase.substr(0, WORD_LENGTH) + "...";
  1219. }
  1220. }
  1221. app.globalData.TempSearchBackNumber = 2;
  1222. //app.globalData.CardList=[];
  1223. app.globalData.CardList2=[];
  1224. callback([],obj);
  1225. }
  1226. else{
  1227. callback([]);
  1228. }
  1229. } else {
  1230. callback([]);
  1231. }
  1232. });
  1233. }
  1234. module.exports = {
  1235. getData: getData,
  1236. postData: postData,
  1237. payMoney: payMoney,
  1238. getLocalHost: getLocalHost,
  1239. getTimeFormat: getTimeFormat,
  1240. getWindowHeight: getWindowHeight,
  1241. getStorageValue: getStorageValue,
  1242. getProgramList: getProgramList,
  1243. gotoFeedback: gotoFeedback,
  1244. getDetailColor: getDetailColor,
  1245. changeStringToView: changeStringToView,
  1246. changeViewToString: changeViewToString,
  1247. encryptUrl: EncryptUrl,
  1248. decryptUrl: DecryptUrl,
  1249. saveTempImage: saveTempImage,
  1250. getTempImage: getTempImage,
  1251. getTaskTodayList: getTaskTodayList,
  1252. updateSearchList: updateSearchList,
  1253. checkIsIPhoneX: checkIsIPhoneX,
  1254. getMemoryLevelAll: getMemoryLevelAll,
  1255. getMemoryLevel: getMemoryLevel,
  1256. getShareImageBackColor: getShareImageBackColor,
  1257. UpdateMiaoguoCardTodayAll: UpdateMiaoguoCardTodayAll,
  1258. setCollect: setCollect,
  1259. UploadUserConfig: UploadUserConfig,
  1260. getServerImage: getServerImage,
  1261. getBaiduToken: getBaiduToken,
  1262. buildInitData: buildInitData,
  1263. getPinyinNormal: getPinyinNormal,
  1264. getHanzi: getHanzi,
  1265. GetHanziUnitWords: GetHanziUnitWords,
  1266. GetTestReportInfo: GetTestReportInfo,
  1267. getUserConfig: getUserConfig,
  1268. getAwardData: getAwardData,
  1269. replaceCardInfoString: replaceCardInfoString,
  1270. searchInfomation:searchInfomation,
  1271. }