main.js 43 KB

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