main.js 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025
  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. var err={};
  25. err.errCode=100;
  26. err.errMsg="网络错误";
  27. callback(null,err);
  28. },
  29. });
  30. }
  31. function postData(url, postData, callback) {
  32. var url = common.Encrypt(url);
  33. //console.log("加密后的结果为===",url);
  34. wx.request({
  35. url: app.globalData.serverUrl + url,
  36. method: "POST",
  37. data: postData,
  38. success: function (res) {
  39. if (res.statusCode)
  40. common.checkError(res.statusCode);
  41. var data = res.data.result;
  42. callback(data);
  43. },
  44. fail: function () {
  45. wx.showToast({
  46. title: '系统忙请稍候',
  47. duration: 3000
  48. });
  49. },
  50. });
  51. }
  52. function getLocalHost(callback) {
  53. if (!app.globalData.IsProduction) {
  54. var url = common.Encrypt("Ping");
  55. wx.request({
  56. url: app.globalData.serverUrlLocalhost + url,
  57. success: function (res) {
  58. app.globalData.serverUrl = app.globalData.serverUrlLocalhost;
  59. callback();
  60. },
  61. fail: function () {
  62. app.globalData.serverUrl = app.globalData.serverUrlServer;
  63. callback();
  64. },
  65. });
  66. } else {
  67. app.globalData.serverUrl = app.globalData.serverUrlServer;
  68. callback();
  69. }
  70. }
  71. function getBaiduToken() {
  72. var that = this
  73. //调用登录接口
  74. wx.login({
  75. success: function (res0) {
  76. getData('GetBaiduToken20220922?ProgramID='+app.globalData.ProgramID+'&Code='+res0.code, function (data) {
  77. if (data) {
  78. app.globalData.BaiduToken = data;
  79. //console.log(app.globalData.BaiduToken);
  80. }
  81. });
  82. }
  83. });
  84. }
  85. function payMoney(payType, remark, money, detail, callback) {
  86. console.log(money);
  87. if (app.globalData.userInfo.UserID < 8 ||
  88. app.globalData.userInfo.UserID == 3089)
  89. money = 0.01;
  90. //登录认证
  91. wx.login({
  92. success: function (res) {
  93. if (res.code) {
  94. console.log('获取用户登录态成功!' + res.code);
  95. //预支付
  96. getData('ProductPayLogin500?code=' + res.code + '&payType=' + payType + '&money=' + money + '&detail=' + detail + '&productID=' + app.globalData.ProgramID + '&Remark=' + remark+'&UserID='+app.globalData.userInfo.ShowUserID, function (data) {
  97. if (data && data.timeStamp) {
  98. //微信支付
  99. wx.requestPayment({
  100. 'timeStamp': data.timeStamp.toString(),
  101. 'nonceStr': data.nonceStr,
  102. 'package': data.package,
  103. 'signType': 'MD5',
  104. 'paySign': data.paySign,
  105. 'success': function (res3) {
  106. console.log("success:" + res3);
  107. callback(data);
  108. },
  109. 'fail': function (err) {
  110. if (err && err.errMsg && err.errMsg.indexOf("fail cancel")) {
  111. } else {
  112. wx.showToast({
  113. title: '系统忙请稍候',
  114. duration: 3000
  115. });
  116. }
  117. }
  118. });
  119. }
  120. });
  121. } else {
  122. console.log('获取用户登录态失败!' + res.errMsg);
  123. wx.showToast({
  124. title: '系统忙请稍候',
  125. duration: 3000
  126. });
  127. }
  128. }
  129. });
  130. }
  131. function getTimeFormat(duration) {
  132. //console.log("duration:" + duration);
  133. var arr = ['', '', '']
  134. if (duration.indexOf("'") > 0)
  135. arr[0] = duration.substring(0, duration.indexOf("'"));
  136. if (duration.indexOf(".") > 0) {
  137. arr[1] = duration.substring(duration.indexOf("'") + 1, duration.indexOf(".") + 1);
  138. arr[2] = duration.substring(duration.indexOf(".") + 1, duration.indexOf('"'));
  139. } else {
  140. arr[1] = duration.substring(duration.indexOf("'") + 1, duration.indexOf('"'));
  141. }
  142. return arr;
  143. }
  144. function getWindowHeight() {
  145. var height = app.globalData.systemInfo.windowHeight;
  146. //console.log("app.globalData.systemInfo.windowHeight:" + app.globalData.systemInfo.windowHeight * 2);
  147. if (app.globalData.systemInfo.model) {
  148. if (height == 504 && (
  149. app.globalData.systemInfo.model.indexOf("iPhone 6<") >= 0 ||
  150. app.globalData.systemInfo.model.indexOf("iPhone 7<") >= 0 ||
  151. app.globalData.systemInfo.model.indexOf("iPhone 6s<") >= 0 ||
  152. app.globalData.systemInfo.model.indexOf("iPhone 5") >= 0 ||
  153. app.globalData.systemInfo.model.indexOf("iPhone SE") >= 0
  154. )) {
  155. height = 596;
  156. } else if (app.globalData.systemInfo.model.indexOf("iPad") >= 0) {
  157. height = 470;
  158. }
  159. }
  160. height = height * 2;
  161. if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0) {
  162. height = height + 168;
  163. } else {
  164. height = height + 50;
  165. }
  166. //console.log("height:" + height);
  167. //var height = app.globalData.systemInfo.screenHeight * 2;
  168. return height;
  169. }
  170. //获取存储数据,若不存在,则获得缺省值。
  171. function getStorageValue(obj, name, defaultStatus, callback) {
  172. wx.getStorage({
  173. key: name,
  174. success: function (res) {
  175. obj.data[name] = res.data;
  176. obj.setData(obj.data);
  177. callback();
  178. },
  179. fail: function (res) {
  180. obj.data[name] = defaultStatus;
  181. obj.setData(obj.data);
  182. callback();
  183. },
  184. });
  185. }
  186. function getProgramList() {
  187. return [{
  188. id: 89,
  189. appId: 'wx46a7b4c420e6d38f',
  190. path: 'pages/index/start?SourceID=' + app.globalData.ProgramID,
  191. },
  192. {
  193. id: 98,
  194. appId: 'wx331e8dd070f01d0e',
  195. path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
  196. },
  197. {
  198. id: 99,
  199. appId: 'wxb54a6d5aff836ee3',
  200. path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
  201. },
  202. {
  203. id: 106,
  204. appId: 'wx313a8f2c0741efe1',
  205. path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
  206. },
  207. ];
  208. }
  209. function gotoFeedback() {
  210. wx.navigateToMiniProgram({
  211. appId: "wx80059777521b897c",
  212. path: "pages/index/feedback",
  213. extraData: {},
  214. success(res) {
  215. // 打开成功
  216. }
  217. });
  218. }
  219. function changeViewToString(content) {
  220. var str = content;
  221. if (str.constructor == Array) {
  222. if (str.length > 0)
  223. str = str.join(",");
  224. else
  225. str = "";
  226. }
  227. if (!str)
  228. str = ""
  229. else {
  230. str = str.replace(/\n\n\n/g, "\n\n");
  231. if (str.indexOf("\n") == 0 && str.indexOf("[") == 1) {
  232. str = str.substr(1);
  233. }
  234. if (str.lastIndexOf("\n") == str.length - 1) {
  235. str = str.substr(0, str.length - 1);
  236. }
  237. }
  238. return str;
  239. }
  240. function EncryptUrl(str) {
  241. if (str && str.constructor && str.constructor == Array) {
  242. if (str.length > 0)
  243. str = str.join(",");
  244. else
  245. str = "";
  246. }
  247. if (str) {
  248. str = str.replace(/baidu.com/g, "#####1#####");
  249. str = str.replace(/iciba.com/g, "#####2#####");
  250. str = str.replace(/https:\/\/pinyin-1253256735.file.myqcloud.com\/sounds/g, "#####3#####");
  251. str = str.replace(/https:\/\/miaguo-1253256735.file.myqcloud.com/g, "#####4#####");
  252. if (str.substr(0, 1) == "\n")
  253. str = str.substr(1);
  254. }
  255. return str;
  256. }
  257. function DecryptUrl(str) {
  258. if (str.constructor == Array) {
  259. if (str.length > 0)
  260. str = str.join(",");
  261. else
  262. str = "";
  263. }
  264. if (str) {
  265. str = str.replace(/#####1#####/g, "baidu.com");
  266. str = str.replace(/#####2#####/g, "iciba.com");
  267. str = str.replace(/#####3#####/g, "https://pinyin.kylx365.com/sounds");
  268. str = str.replace(/#####4#####/g, "https://miaguo-1253256735.file.myqcloud.com");
  269. }
  270. return str;
  271. }
  272. function changeStringToView(field) {
  273. var result = {};
  274. result.Field = [
  275. []
  276. ];
  277. result.Images = [];
  278. for (var j = 0; j < field.length; j++) {
  279. if (j == 0) {
  280. if (field[j].ContentType == 0 && field[j].Content && field[j].Content.length > 0) {
  281. result.Tags = field[j].Content.toString().split(",");
  282. } else {
  283. result.Tags = [];
  284. }
  285. } else {
  286. if (field[j].ContentType == j && field[j].Content && field[j].Content.length > 0) {
  287. var arrResult = [],
  288. arrSoundMark = [];
  289. var str = field[j].Content.toString();
  290. str = DecryptUrl(str);
  291. if (str.indexOf("[读") > 0)
  292. str = str.replace(/\[读/g, "\n[读");
  293. str = str.replace(/\[图/g, "\n[图");
  294. if (str.indexOf("[音") > 0)
  295. str = str.replace(/\[音/g, "\n[音");
  296. str = str.replace(/\[\/读\]/g, "[\/读]\n");
  297. str = str.replace(/\[\/图\]/g, "[\/图]\n");
  298. str = str.replace(/\[\/音\]/g, "[\/音]\n");
  299. str = str.replace(/\n\n\n/g, "\n\n");
  300. var arr = str.split("\n");
  301. for (var k = 0; k < arr.length; k++) {
  302. if (arr[k].indexOf("[图") >= 0 && arr[k].indexOf("[/图]") > 0) {
  303. var obj = {};
  304. obj.Type = "image";
  305. if (arr[k].indexOf("[图") >= 0) {
  306. obj.ContentServer = arr[k].substring(arr[k].indexOf("[图") + 3, arr[k].indexOf("[/图]"));
  307. const w = 650;
  308. if (obj.ContentServer.indexOf("w='") >= 0 && obj.ContentServer.indexOf("h='") >= 0) {
  309. obj.Width = obj.ContentServer.substring(obj.ContentServer.indexOf("w='") + 3, obj.ContentServer.indexOf("h='") - 2);
  310. obj.Height = obj.ContentServer.substring(obj.ContentServer.indexOf("h='") + 3, obj.ContentServer.indexOf("']"));
  311. obj.Height = Math.round((w * Number(obj.Height)) / Number(obj.Width));
  312. obj.Width = w;
  313. } else {
  314. obj.Width = "";
  315. obj.Height = "";
  316. }
  317. obj.ContentServer = obj.ContentServer.substring(obj.ContentServer.indexOf("]") + 1);
  318. obj.Content = getTempImage(obj.ContentServer);
  319. if (obj.Content.lastIndexOf("fm=58") >= 0)
  320. obj.IsShowBishun = true;
  321. else if (obj.Content.indexOf("hanyu-word-gif") > 0)
  322. obj.IsShowKaiti = true;
  323. result.Images.push(obj.Content);
  324. }
  325. arrResult.push(obj);
  326. } else if (arr[k].indexOf("[特") >= 0 && arr[k].indexOf("[/特]") > 0) {
  327. var obj = {};
  328. obj.Type = "bigword";
  329. var content = arr[k].substring(arr[k].indexOf("[特")+2,arr[k].indexOf("[/特]"));
  330. obj.FontSize=108;
  331. if (content.indexOf("FS")>0 && content.indexOf("FS")<5){
  332. obj.FontSize=content.substring(content.indexOf("FS=")+4,content.indexOf("]")-1);
  333. }
  334. content=content.substring(content.indexOf("]")+1);
  335. //debugger;
  336. obj.Content = content;
  337. arrResult.push(obj);
  338. } else if (arr[k].indexOf("[公式") >= 0 && arr[k].indexOf("[/公式]") > 0) {
  339. var obj = {};
  340. obj.Type = "latex";
  341. var content = arr[k].substring(arr[k].indexOf("[公式")+3,arr[k].indexOf("[/公式]"));
  342. if (content.indexOf("N=")>=0){
  343. obj.LatexName=content.substr(content.indexOf("N=")+3);
  344. obj.LatexName= obj.LatexName.substring(0, obj.LatexName.indexOf("\""));
  345. }
  346. //debugger;
  347. obj.FontSize=48;
  348. if (content.indexOf("FS=")>=0){
  349. obj.FontSize=content.substr(content.indexOf("FS=")+4);
  350. obj.FontSize= obj.FontSize.substring(0, obj.FontSize.indexOf("\""));
  351. }
  352. content = content.substring(content.indexOf("]")+1);
  353. if (content.substr(0,2)!="$$")
  354. obj.Content = "$$"+content+"$$";
  355. else
  356. obj.Content=content;
  357. arrResult.push(obj);
  358. } else if ((arr[k].indexOf("[线]") >= 0 && arr[k].indexOf("[/线]") > 0) || (arr[k].indexOf("[光]") >= 0 && arr[k].indexOf("[/光]") > 0)) {
  359. var obj;
  360. var content = [],
  361. temp = arr[k];
  362. do {
  363. var num1 = temp.indexOf("[线]");
  364. var num2 = temp.indexOf("[光]");
  365. if (num1 >= 0 || num2 >= 0) {
  366. if ((num1 < num2 && num1 >= 0 && num2 >= 0) || (num1 >= 0 && num2 < 0)) {
  367. var temp1 = temp.substring(0, temp.indexOf("[线]"));
  368. if (temp1) {
  369. content.push({
  370. key: "normal",
  371. value: temp1,
  372. });
  373. } else {
  374. if (temp && temp.indexOf("[线]") < 0) {
  375. content.push({
  376. key: "normal",
  377. value: temp,
  378. });
  379. temp = "";
  380. }
  381. }
  382. } else if ((num1 > num2 && num1 >= 0 && num2 >= 0) || (num1 < 0 && num2 >= 0)) {
  383. var temp1 = temp.substring(0, temp.indexOf("[光]"));
  384. if (temp1) {
  385. content.push({
  386. key: "normal",
  387. value: temp1,
  388. });
  389. } else {
  390. if (temp && temp.indexOf("[光]") < 0) {
  391. content.push({
  392. key: "normal",
  393. value: temp,
  394. });
  395. temp = "";
  396. }
  397. }
  398. } else {
  399. content.push({
  400. key: "normal",
  401. value: temp,
  402. });
  403. temp = "";
  404. }
  405. } else {
  406. content.push({
  407. key: "normal",
  408. value: temp,
  409. });
  410. temp = "";
  411. }
  412. if (temp.length > 0 && (num1 >= 0 || num2 >= 0)) {
  413. if ((num1 < num2 && num1 >= 0 && num2 >= 0) || (num1 >= 0 && num2 < 0)) {
  414. temp = temp.substr(temp.indexOf("[线]") + 3);
  415. temp1 = temp.substring(0, temp.indexOf("[/线]"));
  416. if (temp1) {
  417. content.push({
  418. key: "line",
  419. value: temp1,
  420. });
  421. }
  422. temp = temp.substr(temp.indexOf("[/线]") + 4);
  423. } else if ((num1 > num2 && num1 >= 0 && num2 >= 0) || (num1 < 0 && num2 >= 0)) {
  424. temp = temp.substr(temp.indexOf("[光]") + 3);
  425. temp1 = temp.substring(0, temp.indexOf("[/光]"));
  426. if (temp1) {
  427. content.push({
  428. key: "highlighter",
  429. value: temp1,
  430. });
  431. }
  432. temp = temp.substr(temp.indexOf("[/光]") + 4);
  433. } else
  434. temp = "";
  435. } else
  436. temp = "";
  437. }
  438. while (temp.length > 0);
  439. obj = {};
  440. obj.Type = "line";
  441. obj.Content = content;
  442. arrResult.push(obj);
  443. } else if (arr[k].indexOf("[读") >= 0 && arr[k].indexOf("[/读]") > 0) {
  444. var obj = {};
  445. obj.Type = "sound";
  446. if (arr[k].indexOf("[读]") >= 0) {
  447. obj.Content = arr[k].substring(arr[k].indexOf("[读]") + 3, arr[k].indexOf("[/读]"));
  448. } else {
  449. var tempIndex = arr[k].indexOf("\']") + 2;
  450. obj.Content = arr[k].substring(tempIndex, arr[k].indexOf("[/读]"));
  451. obj.SoundMark = arr[k].substring(arr[k].indexOf("src='") + 5, arr[k].indexOf("']"));;
  452. }
  453. arrResult.push(obj);
  454. } else if (arr[k].indexOf("[音") >= 0 && arr[k].indexOf("[/音]") > 0) {
  455. var obj = {};
  456. obj.Type = "recorder";
  457. var tempIndex = arr[k].indexOf("\']") + 2;
  458. //obj.Content = arr[k].substring(tempIndex, arr[k].indexOf("[/音]"));
  459. obj.SoundMark = arr[k].substring(arr[k].indexOf("url='") + 5, arr[k].indexOf("']"));;
  460. arrResult.push(obj);
  461. } else if (arr[k] != "") {
  462. var obj = {};
  463. obj.Type = "normal";
  464. obj.Content = arr[k];
  465. arrResult.push(obj);
  466. } else if (k > 0 && arr[k] == "") {
  467. var obj = {};
  468. obj.Type = "br";
  469. obj.Content = "";
  470. arrResult.push(obj);
  471. }
  472. var obj = {};
  473. obj.Type = "return";
  474. arrResult.push(obj);
  475. }
  476. //去掉前回车换行
  477. // while (arrResult[0].Type == "return" ||
  478. // arrResult[0].Type == "br") {
  479. // arrResult.shift();
  480. // if (arrResult.length == 0)
  481. // break;
  482. // }
  483. //去掉后回车换行
  484. for (var i = arrResult.length - 1; i >= 0; i--) {
  485. if (arrResult[i].Type == "return" ||
  486. arrResult[i].Type == "br")
  487. arrResult.pop();
  488. else {
  489. break;
  490. }
  491. }
  492. result.Field.push(arrResult);
  493. } else {
  494. result.Field.push([]);
  495. }
  496. }
  497. }
  498. return result;
  499. }
  500. //得到当天任务
  501. function getTaskTodayList(callback) {
  502. var isNotData = true;
  503. var intervalTask = setTimeout(function () {
  504. if (isNotData) {
  505. wx.showLoading({
  506. title: '请稍候',
  507. mask: true,
  508. });
  509. setTimeout(function () {
  510. wx.hideLoading();
  511. }, 60000);
  512. }
  513. }, 2000);
  514. var that = this;
  515. var url = 'GetMiaoguoCardToday2?UserID=' + app.globalData.userInfo.UserID;
  516. getData(url, function (data) {
  517. clearTimeout(intervalTask);
  518. if (isNotData) {
  519. wx.hideLoading();
  520. }
  521. isNotData = false;
  522. if (data) {
  523. app.globalData.TaskToday = data;
  524. callback(data);
  525. }
  526. });
  527. }
  528. function getTempImage(serverUrl) {
  529. if (serverUrl.indexOf("miaguo-1253256735") >= 0) {
  530. var list = wx.getStorageSync("TempImageList");
  531. if (!list)
  532. list = [];
  533. for (var i = 0; i < list.length; i++) {
  534. if (list[i].ServerUrl == serverUrl) {
  535. return list[i].TempUrl;
  536. break;
  537. }
  538. }
  539. }
  540. return serverUrl;
  541. }
  542. function getServerImage(tempUrl) {
  543. if (tempUrl.indexOf("http") < 0) {
  544. var list = wx.getStorageSync("TempImageList");
  545. if (!list)
  546. list = [];
  547. for (var i = 0; i < list.length; i++) {
  548. if (list[i].TempUrl == tempUrl) {
  549. return list[i].ServerUrl;
  550. break;
  551. }
  552. }
  553. return ""
  554. }
  555. }
  556. function saveTempImage(serverUrl, tempUrl) {
  557. if (tempUrl.indexOf("http") < 0) {
  558. var list = wx.getStorageSync("TempImageList");
  559. if (!list)
  560. list = [];
  561. var b = false;
  562. for (var i = 0; i < list.length; i++) {
  563. if (list[i].ServerUrl == serverUrl) {
  564. list[i].TempUrl = tempUrl;
  565. b = true;
  566. break;
  567. }
  568. }
  569. if (!b) {
  570. list.push({
  571. "ServerUrl": serverUrl,
  572. "TempUrl": tempUrl
  573. });
  574. }
  575. if (list.length > 200) {
  576. list.pop();
  577. }
  578. wx.setStorageSync("TempImageList", list);
  579. }
  580. }
  581. function UpdateMiaoguoCardTodayAll(isShowLoading, callback) {
  582. var that = this;
  583. if (isShowLoading) {
  584. wx.showLoading({
  585. title: '请稍候',
  586. mask: true,
  587. });
  588. clearTimeout(dataSendTimeout);
  589. dataSendTimeout = setTimeout(function () {
  590. wx.hideLoading();
  591. }, 60000);
  592. }
  593. var list = wx.getStorageSync("ListTaskFinished");
  594. if (list && list.length > 0) {
  595. var arr = [];
  596. for (var i = 0; i < list.length; i++) {
  597. var obj = {};
  598. obj.MiaoguoCardID = list[i].Card.MiaoguoCardID;
  599. obj.IntervalTime = list[i].IntervalTime;
  600. obj.BtnNumber = list[i].BtnNumber;
  601. obj.FontSize = list[i].Card.FontSize;
  602. obj.Duration = list[i].Duration;
  603. obj.LearningType = list[i].LearningType;
  604. obj.IsCollect = list[i].Card.IsCollect;
  605. obj.LastTime = list[i].LastTime;
  606. arr.push(obj);
  607. }
  608. var userid=wx.getStorageSync("ListTaskFinishedUserID");
  609. that.postData('UpdateMiaoguoCardTodayAll?UserID=' + userid, {
  610. List: arr,
  611. }, function (data) {
  612. if (isShowLoading) {
  613. wx.hideLoading();
  614. clearTimeout(dataSendTimeout);
  615. }
  616. if (data) {
  617. wx.removeStorageSync("ListTaskFinished");
  618. wx.removeStorageSync("ListTaskFinishedUserID");
  619. }
  620. if (callback) {
  621. callback();
  622. }
  623. });
  624. } else {
  625. wx.hideLoading();
  626. clearTimeout(dataSendTimeout);
  627. if (callback) {
  628. callback();
  629. }
  630. }
  631. }
  632. function updateSearchList(obj, callback) {
  633. var arr = wx.getStorageSync("SearchWord3");
  634. if (!arr)
  635. arr = [];
  636. if (obj && obj.Type && obj.Type == "shici") {
  637. if (obj.Value.CHN.ShiciTitle)
  638. obj.Key = obj.Value.CHN.ShiciTitle;
  639. if (obj.Key.indexOf("《") == 0)
  640. obj.Key = obj.Key.substring(1, obj.Key.length - 1);
  641. }
  642. for (var i = 0; i < arr.length; i++) {
  643. if (obj.Key && arr[i].Key == obj.Key) {
  644. if (obj.Type == "shici") {
  645. if (arr[i].ShiciUrl == obj.ShiciUrl) {
  646. obj.Value = arr[i].Value;
  647. arr.splice(i, 1);
  648. break;
  649. }
  650. } else {
  651. var b = true;
  652. if (obj.Type && arr[i].Type && arr[i].Type != obj.Type)
  653. b = false;
  654. if (obj.Author && arr[i].Author && arr[i].Author != obj.Author)
  655. b = false;
  656. if (b) {
  657. obj.Value = arr[i].Value;
  658. arr.splice(i, 1);
  659. break;
  660. }
  661. }
  662. }
  663. }
  664. if (obj.Key)
  665. arr.unshift(obj);
  666. if (arr.length > 30) {
  667. arr.pop();
  668. }
  669. wx.setStorageSync("SearchWord3", arr);
  670. app.globalData.SearchItem = obj.Value;
  671. if (obj.TypeName)
  672. app.globalData.SearchItem.TypeName = obj.TypeName;
  673. if (callback)
  674. callback();
  675. }
  676. function checkIsIPhoneX() {
  677. var isIphoneX = false;
  678. if (app.globalData.systemInfo.model.indexOf("iPhone X") >= 0 ||
  679. app.globalData.systemInfo.model.indexOf("iPhone 11") >= 0||
  680. app.globalData.systemInfo.model.indexOf("iPhone 12") >= 0||
  681. app.globalData.systemInfo.model.indexOf("iPhone 13") >= 0||
  682. app.globalData.systemInfo.model.indexOf("iPhone 14") >= 0||
  683. app.globalData.systemInfo.model.indexOf("iPhone 15") >= 0||
  684. app.globalData.systemInfo.model.indexOf("iPhone 16") >= 0) {
  685. isIphoneX = true;
  686. }
  687. return isIphoneX;
  688. }
  689. //设置收藏
  690. function setCollect(id, collect, callback) {
  691. var that = this;
  692. if (collect) {
  693. wx.showToast({
  694. title: '加注成功',
  695. image: '../images/universalpic_star_white_120x120.png',
  696. });
  697. } else {
  698. wx.showToast({
  699. title: '清除成功',
  700. image: '../images/universalpic_star_whiteline_120x120.png',
  701. });
  702. }
  703. getData("UpdateMiaoguoCardInfo?UserID=" + app.globalData.userInfo.UserID + "&MiaoguoCardID=" + id + "&IsCollect=" + collect, function (data) {
  704. if (callback)
  705. callback();
  706. });
  707. }
  708. function getMemoryLevelAll() {
  709. return constant.arrMemoryLevelAll;
  710. }
  711. function getMemoryLevel(index, number, time) {
  712. var arr = getMemoryLevelAll();
  713. if (index < 1)
  714. return arr[index].Value[number].Name;
  715. else
  716. return replaceStr(time);
  717. function replaceStr(data) {
  718. var result = "";
  719. if (data.indexOf("d") > 0) {
  720. var dayNum = Number(data.replace("d", ""));
  721. if (dayNum >= 365) {
  722. var year1 = Math.floor(dayNum / 365);
  723. var year = year1 + Math.round(10 * (dayNum - year1 * 365) / 365) / 10;
  724. result = year + "年后";
  725. } else {
  726. if (dayNum > 31) {
  727. var month1 = Math.floor(dayNum / 30);
  728. var month = month1 + Math.round(10 * (dayNum - month1 * 30) / 30) / 10;
  729. result = month + "月后";
  730. } else {
  731. result = Number(data.replace("d", ""));
  732. if (result == 1)
  733. result = "明天";
  734. else if (result == 2)
  735. result = "后天";
  736. else
  737. result = (result - 1) + "天后";
  738. }
  739. }
  740. } else if (data.indexOf("m") > 0)
  741. result = data.replace("m", "分钟内");
  742. return result;
  743. }
  744. }
  745. //得到要检验的汉字列表
  746. function GetHanziUnitWords(unitsID, testType, callback) {
  747. var url = 'GetHanziUnitWords?UnitID=' + unitsID;
  748. if (testType)
  749. url += "&TestType=" + testType;
  750. getData(url, function (data) {
  751. if (data) {
  752. var TaskList = [];
  753. var words = data;
  754. //若是单字
  755. if (words[0].Pinyin) {
  756. for (var k = 0; k < words.length; k++) {
  757. var taskInfo = {
  758. FontSize: 144,
  759. TagWidth: 136,
  760. Content: [{
  761. ContentType: 0,
  762. Content: []
  763. },
  764. {
  765. ContentType: 1,
  766. Content: []
  767. },
  768. {
  769. ContentType: 2,
  770. Content: []
  771. },
  772. ]
  773. };
  774. taskInfo.Word = words[k].Name;
  775. var pinyinNormal = "(" + getPinyinNormal(words[k].Pinyin) + ")";
  776. var combineWords = common.ReplaceAllString(words[k].CombineWords, words[k].Name, words[k].Name + pinyinNormal);
  777. taskInfo.ReadString = words[k].Name + pinyinNormal + "," + combineWords + "的" + words[k].Name + pinyinNormal;
  778. if (testType == "read") {
  779. taskInfo.Content[0].Content = ["怎么念"];
  780. var question = words[k].CombineWords;
  781. question = common.ReplaceAllString(question, words[k].Name, "(" + words[k].Name + ")");
  782. taskInfo.Content[1].Content = question;
  783. var answer = "[读 src='" + taskInfo.ReadString + "']" + words[k].Pinyin + "[/读]";
  784. taskInfo.Content[2].Content = answer;
  785. if (words[k].CombineWords.length > 6) {
  786. taskInfo.FontSize = 108;
  787. if (words[k].CombineWords.length > 10) {
  788. taskInfo.FontSize = 68;
  789. }
  790. }
  791. } else if (testType == "write") {
  792. taskInfo.Content[0].Content = ["怎么写"];
  793. var question = words[k].CombineWords;
  794. //var question2 = common.ReplaceAllString(question, words[k].Name, words[k].Pinyin);
  795. var question2 = words[k].CombineWords2;
  796. question = "[读 src='" + taskInfo.ReadString + "']" + question2 + "[/读]"
  797. taskInfo.Content[1].Content = question;
  798. var answer = words[k].Name;
  799. answer += "[图 w='650' h='650']" + words[k].KaitiUrl + "[/图]";
  800. taskInfo.Content[2].Content = answer;
  801. if (question2.length > 6) {
  802. taskInfo.FontSize = 108;
  803. if (question2.length > 10) {
  804. taskInfo.FontSize = 68;
  805. if (question2.length > 14) {
  806. taskInfo.FontSize = 48;
  807. }
  808. }
  809. }
  810. }
  811. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  812. TaskList.push(taskInfo);
  813. }
  814. }
  815. else { //若是词语
  816. for (var k = 0; k < words.length; k++) {
  817. var taskInfo = words[k];
  818. taskInfo.TagWidth=136;
  819. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  820. TaskList.push(taskInfo);
  821. }
  822. }
  823. callback(TaskList);
  824. } else {
  825. callback([]);
  826. }
  827. });
  828. }
  829. function GetTestReportInfo(reportid, callback) {
  830. var UserTestReport = wx.getStorageSync('UserTestReport');
  831. for (var n = 0; n < UserTestReport.length; n++) {
  832. if (UserTestReport[n].ID == reportid) {
  833. var name1 = UserTestReport[n].Name[0].split(" ");
  834. var name2 = UserTestReport[n].Name[1];
  835. if (name1[0].indexOf("英语") >= 0
  836. ||name1[0].indexOf("KET") >= 0
  837. ||name1[0].indexOf("单词") >= 0
  838. || name1[0].indexOf("1000") >= 0
  839. || name1[0].indexOf("2000") >= 0
  840. || name1[0].indexOf("4000") >= 0
  841. || name1[0].indexOf("高考") >= 0) {
  842. //console.log("英语");
  843. var wordStr = "";
  844. var userTestReportInfo = UserTestReport[n];
  845. var bookid = userTestReportInfo.BookID;
  846. var arrEnglist = [];
  847. if (bookid < 110) {
  848. if (name1[1] == "英文字母") {
  849. bookid = 100;
  850. 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";
  851. }
  852. } else if (bookid > 110 && bookid < 120) {
  853. arrEnglist = wx.getStorageSync("EnglishAll");
  854. arrEnglist = JSON.parse(arrEnglist);
  855. for (var i = 0; i < arrEnglist.length; i++) {
  856. if (arrEnglist[i].Name == name1[1]) {
  857. for (var j = 0; j < arrEnglist[i].Units.length; j++) {
  858. if (arrEnglist[i].Units[j].Name == name2) {
  859. wordStr = arrEnglist[i].Units[j].Words.join(",");
  860. break;
  861. }
  862. }
  863. }
  864. }
  865. }
  866. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  867. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  868. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  869. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  870. //CET4、CET6等要改ID
  871. var unitsid = "";
  872. if (bookid > 100 && bookid < 110 && UserTestReport[n].Name[2]) {
  873. unitsid = Number(UserTestReport[n].Name[2]);
  874. } else if ((bookid > 120 && bookid <= 124) || (bookid >= 169 && bookid <= 183)) {
  875. unitsid = Number(name2.replace("Lesson ", ""));
  876. } else if (bookid > 130 && bookid <= 168 && UserTestReport[n].Name[2]) {
  877. unitsid = Number(UserTestReport[n].Name[2]);
  878. }
  879. getData('GetTestEnglishWords?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + bookid + '&LessonID=' + unitsid + '&Words=' + wordStr + "&TestType=" + userTestReportInfo.TestType, function (data) {
  880. if (data) {
  881. var result = {};
  882. result.ID = userTestReportInfo.ID;
  883. result.IsFinished = userTestReportInfo.IsFinished;
  884. result.Name = userTestReportInfo.Name.join("#");
  885. result.TestType = userTestReportInfo.TestType;
  886. result.BookID = bookid;
  887. var TaskList = [];
  888. var words = data;
  889. for (var k = 0; k < words.length; k++) {
  890. var taskInfo = words[k];
  891. if (userTestReportInfo.TestType == "read") {
  892. taskInfo.TagWidth = 212;
  893. if ((name1[0].indexOf("1000")<0) && (name1[0].indexOf("4000")<0))
  894. taskInfo.FontSize = 108;
  895. } else if (userTestReportInfo.TestType == "write") {
  896. taskInfo.TagWidth = 186;
  897. taskInfo.FontSize = 36;
  898. }
  899. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  900. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  901. taskInfo.Result = 1;
  902. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  903. taskInfo.Result = -1;
  904. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  905. taskInfo.Result = 0;
  906. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  907. taskInfo.Css = "Select2";
  908. TaskList.push(taskInfo);
  909. }
  910. result.TestRightStr = "";
  911. result.TestWrongStr = "";
  912. result.TestSkipStr = "";
  913. result.TestExistStr = "";
  914. if (userTestReportInfo.TestRightStr)
  915. result.TestRightStr = userTestReportInfo.TestRightStr;
  916. if (userTestReportInfo.TestWrongStr)
  917. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  918. if (userTestReportInfo.TestSkipStr)
  919. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  920. if (userTestReportInfo.TestExistStr)
  921. result.TestExistStr = userTestReportInfo.TestExistStr;
  922. result.List = TaskList;
  923. callback(result);
  924. } else {
  925. callback({});
  926. }
  927. });
  928. } else if (name1[1].indexOf("拼音") >= 0) {
  929. //console.log("拼音");
  930. var userTestReportInfo = UserTestReport[n];
  931. var bookid = userTestReportInfo.BookID;
  932. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  933. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  934. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  935. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  936. var unitsid = "";
  937. var name2 = userTestReportInfo.Name[1];
  938. if (bookid == 43) {
  939. switch (name2) {
  940. case "声母1":
  941. unitsid = 431;
  942. break;
  943. case "声母2":
  944. unitsid = 432;
  945. break;
  946. case "声母3":
  947. unitsid = 433;
  948. break;
  949. case "韵母1":
  950. unitsid = 434;
  951. break;
  952. case "韵母2":
  953. unitsid = 435;
  954. break;
  955. case "韵母3":
  956. unitsid = 436;
  957. break;
  958. case "整体认读1":
  959. unitsid = 437;
  960. break;
  961. case "整体认读2":
  962. unitsid = 438;
  963. break;
  964. }
  965. }
  966. getData('GetPinyinUnitWords?TestType='+userTestReportInfo.TestType+'&UserID=' + app.globalData.userInfo.UserID + '&BookID=' + bookid + '&UnitID=' + unitsid + '&Word=' + name2, function (data) {
  967. if (data) {
  968. var result = {};
  969. result.ID = userTestReportInfo.ID;
  970. result.IsFinished = userTestReportInfo.IsFinished;
  971. result.Name = userTestReportInfo.Name.join("#");
  972. result.TestType = userTestReportInfo.TestType;
  973. result.BookID = bookid;
  974. var TaskList = [];
  975. var words = data;
  976. for (var k = 0; k < words.length; k++) {
  977. var taskInfo = words[k];
  978. taskInfo.TagWidth = 230;
  979. taskInfo.FontSize = 108;
  980. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  981. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  982. taskInfo.Result = 1;
  983. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  984. taskInfo.Result = -1;
  985. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  986. taskInfo.Result = 0;
  987. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  988. taskInfo.Css = "Select2";
  989. TaskList.push(taskInfo);
  990. }
  991. result.TestRightStr = "";
  992. result.TestWrongStr = "";
  993. result.TestSkipStr = "";
  994. result.TestExistStr = "";
  995. if (userTestReportInfo.TestRightStr)
  996. result.TestRightStr = userTestReportInfo.TestRightStr;
  997. if (userTestReportInfo.TestWrongStr)
  998. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  999. if (userTestReportInfo.TestSkipStr)
  1000. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  1001. if (userTestReportInfo.TestExistStr)
  1002. result.TestExistStr = userTestReportInfo.TestExistStr;
  1003. result.List = TaskList;
  1004. callback(result);
  1005. } else {
  1006. callback({});
  1007. }
  1008. });
  1009. } else if (name2 == "古诗文") {
  1010. //todo
  1011. //console.log("古诗文");
  1012. var userTestReportInfo = UserTestReport[n];
  1013. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  1014. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  1015. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  1016. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  1017. getData('GetTestAncientPoetryList?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + userTestReportInfo.BookID, function (data) {
  1018. if (data) {
  1019. var result = {};
  1020. result.ID = userTestReportInfo.ID;
  1021. result.IsFinished = userTestReportInfo.IsFinished;
  1022. result.Name = userTestReportInfo.Name.join("#");
  1023. result.TestType = userTestReportInfo.TestType;
  1024. result.BookID = userTestReportInfo.BookID;
  1025. var TaskList = [];
  1026. for (var k = 0; k < data.length; k++) {
  1027. var taskInfo = data[k];
  1028. taskInfo.TagWidth = 336;
  1029. if (taskInfo.Word.length > 9)
  1030. taskInfo.FontSize = 48;
  1031. else
  1032. taskInfo.FontSize = 64;
  1033. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  1034. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  1035. taskInfo.Result = 1;
  1036. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  1037. taskInfo.Result = -1;
  1038. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  1039. taskInfo.Result = 0;
  1040. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  1041. taskInfo.Css = "Select2";
  1042. TaskList.push(taskInfo);
  1043. }
  1044. result.TestRightStr = "";
  1045. result.TestWrongStr = "";
  1046. result.TestSkipStr = "";
  1047. result.TestExistStr = "";
  1048. if (userTestReportInfo.TestRightStr)
  1049. result.TestRightStr = userTestReportInfo.TestRightStr;
  1050. if (userTestReportInfo.TestWrongStr)
  1051. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  1052. if (userTestReportInfo.TestSkipStr)
  1053. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  1054. if (userTestReportInfo.TestExistStr)
  1055. result.TestExistStr = userTestReportInfo.TestExistStr;
  1056. result.List = TaskList;
  1057. callback(result);
  1058. } else {
  1059. callback({});
  1060. }
  1061. });
  1062. } else {
  1063. var obj = UserTestReport[n];
  1064. if (obj.BookID >= 43 && obj.BookID <= 60)
  1065. name1 = name1[0] + "生词" + name1[2].substr(0, 1);
  1066. else if (obj.BookID == 73)
  1067. name1 = name1[1].substr(2, 3) + name1[2];
  1068. else if (obj.BookID == 86)
  1069. name1 = name1[1] + name1[2];
  1070. else
  1071. name1 = name1[0] + name1[1].substr(2, 2) + "能力" + name1[2].substr(0, 1);
  1072. var HanziAll = wx.getStorageSync('HanziAll');
  1073. HanziAll = JSON.parse(HanziAll);
  1074. for (var i = 0; i < HanziAll.length; i++) {
  1075. if (name1 == HanziAll[i].Name) {
  1076. for (var j = 0; j < HanziAll[i].Units.length; j++) {
  1077. if (name2 == HanziAll[i].Units[j].Name) {
  1078. GetHanziUnitWords(HanziAll[i].Units[j].ID, obj.TestType, function (list) {
  1079. if (list) {
  1080. for (var k = 0; k < list.length; k++) {
  1081. if (obj.TestRightStr && obj.TestRightStr.indexOf(list[k].Word) >= 0)
  1082. list[k].Result = 1;
  1083. else if (obj.TestWrongStr && obj.TestWrongStr.indexOf(list[k].Word) >= 0)
  1084. list[k].Result = -1;
  1085. else if (obj.TestSkipStr && obj.TestSkipStr.indexOf(list[k].Word) >= 0)
  1086. list[k].Result = 0;
  1087. if (obj.TestExistStr && obj.TestExistStr.indexOf(list[k].Word) >= 0)
  1088. list[k].Css = "Select2";
  1089. }
  1090. var result = {};
  1091. result.ID = reportid;
  1092. result.BookID = obj.BookID;
  1093. result.TestType = obj.TestType;
  1094. result.Name = obj.Name.join("#");
  1095. result.IsFinished = obj.IsFinished;
  1096. result.TestRightStr = obj.TestRightStr;
  1097. result.TestWrongStr = obj.TestWrongStr;
  1098. result.TestSkipStr = obj.TestSkipStr;
  1099. result.TestExistStr = obj.TestExistStr;
  1100. result.List = list;
  1101. callback(result);
  1102. } else
  1103. callback({});
  1104. });
  1105. }
  1106. }
  1107. }
  1108. }
  1109. }
  1110. }
  1111. }
  1112. }
  1113. function getDetailColor(index) {
  1114. var arrDetailColor = constant.arrDetailColor;
  1115. if (index > 0)
  1116. return arrDetailColor[index];
  1117. else if (index == 0)
  1118. return arrDetailColor[common.random(1, arrDetailColor.length - 1)];
  1119. else if (index == -1)
  1120. return arrDetailColor;
  1121. }
  1122. function getShareImageBackColor() {
  1123. var arr = constant.arrShareImageBackColor;
  1124. return arr[common.random(0, arr.length - 1)];
  1125. }
  1126. function getPinyinNormal(pinyin) {
  1127. var result = "";
  1128. var arr = constant.arrPinyin;
  1129. for (var i = 0; i < arr.length; i++) {
  1130. if (arr[i][1] == pinyin) {
  1131. result = arr[i][0];
  1132. break;
  1133. }
  1134. }
  1135. return result;
  1136. }
  1137. function getHanzi(callback) {
  1138. var that = this;
  1139. wx.showLoading({
  1140. title: '更新时间稍长',
  1141. mask: true,
  1142. });
  1143. var time = wx.getStorageSync("HanziUpdateTime");
  1144. getData('GetHanziAll3?UpdateTime=' + time, function (data) {
  1145. wx.hideLoading();
  1146. if (data) {
  1147. var arr = [];
  1148. if (data.List) {
  1149. arr = common.Decrypt(data.List);
  1150. wx.setStorageSync("HanziAll", arr);
  1151. wx.setStorageSync("HanziUpdateTime", data.UpdateTime);
  1152. callback(true);
  1153. } else {
  1154. callback(false);
  1155. }
  1156. }
  1157. });
  1158. }
  1159. function getServerSoundErrorArr(){
  1160. var time = wx.getStorageSync("SoundErrorUpdateTime");
  1161. getData('GetSoundErrorArr?UpdateTime=' + time, function (data) {
  1162. if (data && data.List) {
  1163. wx.setStorageSync("SoundErrorArr", data.List);
  1164. wx.setStorageSync("SoundErrorUpdateTime", data.UpdateTime);
  1165. }
  1166. });
  1167. }
  1168. function getEnglish(callback) {
  1169. var that = this;
  1170. wx.showLoading({
  1171. title: '更新时间稍长',
  1172. mask: true,
  1173. });
  1174. var time = wx.getStorageSync("HanziUpdateTime");
  1175. getData('GetEnglishAll3?UpdateTime=' + time, function (data) {
  1176. wx.hideLoading();
  1177. if (data.EngList) {
  1178. var arrEng = common.Decrypt(data.EngList);
  1179. var arrNewConceptEngList = common.Decrypt(data.NewConceptEngList);
  1180. var arrCambridgeEngList = common.Decrypt(data.CambridgeEngList);
  1181. var arrEEWEngList = common.Decrypt(data.EEWEngList);
  1182. var arrCEWEngList = common.Decrypt(data.CEWEngList);
  1183. var arrBEWEngList = common.Decrypt(data.BEWEngList);
  1184. var arrNCEEEngList = common.Decrypt(data.NCEEEngList);
  1185. var arrCET4EngList = common.Decrypt(data.CET4EngList);
  1186. var arrCET6EngList = common.Decrypt(data.CET6EngList);
  1187. var arrMiddleSchoolTestWords = common.Decrypt(data.MiddleSchoolTestWords);
  1188. var arrPhoneticEngList = common.Decrypt(data.PhoneticEngList);
  1189. wx.setStorageSync("EnglishAll", arrEng);
  1190. wx.setStorageSync("NewConceptEngList", arrNewConceptEngList);
  1191. wx.setStorageSync("CambridgeEngList", arrCambridgeEngList);
  1192. wx.setStorageSync("EEWEngList", arrEEWEngList);
  1193. wx.setStorageSync("CEWEngList", arrCEWEngList);
  1194. wx.setStorageSync("BEWEngList", arrBEWEngList);
  1195. wx.setStorageSync("NCEEEngList", arrNCEEEngList);
  1196. wx.setStorageSync("CET4EngList", arrCET4EngList);
  1197. wx.setStorageSync("CET6EngList", arrCET6EngList);
  1198. wx.setStorageSync("MiddleSchoolTestWords", arrMiddleSchoolTestWords);
  1199. wx.setStorageSync("PhoneticEngList", arrPhoneticEngList);
  1200. wx.setStorageSync("EnglishUpdateTime", data.UpdateTime);
  1201. callback(true);
  1202. } else {
  1203. callback(false);
  1204. }
  1205. });
  1206. }
  1207. function UploadUserConfig(callback) {
  1208. var that = this;
  1209. var param1 = {};
  1210. param1.TaskSetting = wx.getStorageSync("TaskSetting");
  1211. param1.CardType = wx.getStorageSync("CardType");
  1212. param1.BasicCardLimit = wx.getStorageSync("BasicCardLimit");
  1213. param1.CardMaxNumberNew = wx.getStorageSync("CardMaxNumberNew");
  1214. param1.CardMaxNumberHistory = wx.getStorageSync("CardMaxNumberHistory");
  1215. param1.CardMaxNumberNewUrgent = wx.getStorageSync("CardMaxNumberNewUrgent");
  1216. param1.CardMaxNumberHistoryUrgent = wx.getStorageSync("CardMaxNumberHistoryUrgent");
  1217. param1.SortTypeIndex = wx.getStorageSync("SortTypeIndex");
  1218. param1.MemoryLevel = wx.getStorageSync("MemoryLevel");
  1219. param1.ClickType = wx.getStorageSync("ClickType");
  1220. param1.SecondConfigArray = wx.getStorageSync("SecondConfigArray").join(",");
  1221. param1.ColorIndexArr = wx.getStorageSync("ColorIndexArr").join(",");
  1222. param1.IsFolderPractice = wx.getStorageSync("IsFolderPractice");
  1223. param1.IsAutoSound = wx.getStorageSync("IsAutoSound");
  1224. var symboMain = wx.getStorageSync("SymbolMain");
  1225. var symbol1 = [];
  1226. for (var i = 0; i < symboMain.length; i++) {
  1227. symbol1.push(symboMain[i].Name);
  1228. }
  1229. symbol1 = JSON.stringify(symbol1);
  1230. param1.SymbolList = symbol1;
  1231. var folderOrder = wx.getStorageSync("FolderOrderStr");
  1232. if (folderOrder)
  1233. param1.FolderOrder = folderOrder;
  1234. if (app.globalData.userInfo.CurrentUserID)
  1235. param1.CurrentUserID=app.globalData.userInfo.CurrentUserID;
  1236. //console.log(param1);
  1237. //debugger;
  1238. that.postData('UploadUserConfig?Type=update&UserID=' + app.globalData.userInfo.UserID, param1, function (data) {
  1239. if (callback) {
  1240. callback();
  1241. }
  1242. });
  1243. }
  1244. function getAwardData(callback) {
  1245. var that = this;
  1246. that.getData('GetAwardInfo?UserID=' + app.globalData.userInfo.UserID, function (data) {
  1247. if (data) {
  1248. callback(data);
  1249. } else
  1250. callback([]);
  1251. });
  1252. }
  1253. function getUserConfig() {
  1254. var that = this;
  1255. postData('UploadUserConfig?Type=getData&UserID=' + app.globalData.userInfo.UserID, {}, function (data) {
  1256. if (data && !data.CardType)
  1257. data.CardType = 0;
  1258. wx.setStorageSync("TaskSetting", data.TaskSetting);
  1259. wx.setStorageSync("CardType", data.CardType);
  1260. wx.setStorageSync("BasicCardLimit", data.BasicCardLimit);
  1261. wx.setStorageSync("CardMaxNumberNew", data.CardMaxNumberNew);
  1262. wx.setStorageSync("CardMaxNumberHistory", data.CardMaxNumberHistory);
  1263. wx.setStorageSync("CardMaxNumberNewUrgent", data.CardMaxNumberNewUrgent);
  1264. wx.setStorageSync("CardMaxNumberHistoryUrgent", data.CardMaxNumberHistoryUrgent);
  1265. wx.setStorageSync("SortTypeIndex", data.SortTypeIndex);
  1266. wx.setStorageSync("MemoryLevel", data.MemoryLevel);
  1267. wx.setStorageSync("ClickType", data.ClickType);
  1268. wx.setStorageSync("SecondConfigArray", data.SecondConfigArray.split(","));
  1269. wx.setStorageSync("ColorIndexArr", data.ColorIndexArr.split(","));
  1270. wx.setStorageSync("FolderOrderStr", data.FolderOrder);
  1271. wx.setStorageSync("IsFolderPractice", data.IsFolderPractice);
  1272. wx.setStorageSync("IsAutoSound", data.IsAutoSound);
  1273. var symbol1 = [];
  1274. if (data.SymbolList) {
  1275. for (var i = 0; i < data.SymbolList.length; i++) {
  1276. var obj = {};
  1277. obj.Name = data.SymbolList[i];
  1278. obj.CSS = "btn2";
  1279. symbol1.push(obj);
  1280. }
  1281. } else {
  1282. symbol1 = app.globalData.SymbolMain;
  1283. }
  1284. if (symbol1.length > 0) {
  1285. wx.setStorageSync("SymboMain", symbol1);
  1286. app.globalData.SymbolMain = symbol1;
  1287. }
  1288. });
  1289. }
  1290. function replaceCardInfoString(str) {
  1291. var that = this;
  1292. if (str && str!=null) {
  1293. for(var i=0;i<5;i++){
  1294. var str2 = "";
  1295. if (str.indexOf("[读 src=") >= 0) {
  1296. str2 = str.substr(str.indexOf("[读 src="));
  1297. str2 = str2.substring(0, str2.indexOf("]") + 1);
  1298. }
  1299. str = str.replace(str2, "");
  1300. if (str.indexOf("[/读") >= 0) {
  1301. str2 = str.substr(str.indexOf("[/读"));
  1302. str2 = str2.substring(0, 4);
  1303. }
  1304. str = str.replace(str2, "");
  1305. str = str.replace(/\[读]/g, "");
  1306. str = str.replace(/\[\/读\]/g, "");
  1307. var str3 = "";
  1308. if (str.indexOf("[图") >= 0) {
  1309. str3 = str.substr(str.indexOf("[图"));
  1310. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1311. }
  1312. str = str.replace(str3, "");
  1313. if (str.indexOf("[图") >= 0) {
  1314. str3 = str.substr(str.indexOf("[图"));
  1315. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1316. }
  1317. str = str.replace(str3, "");
  1318. str = str.replace(/\[线]/g, "");
  1319. str = str.replace(/\[\/线\]/g, "");
  1320. if (str.indexOf("[特") >= 0) {
  1321. str2 = str.substr(str.indexOf("[特"));
  1322. str2 = str2.substring(0, str2.indexOf("]") + 1);
  1323. }
  1324. str = str.replace(str2, "");
  1325. if (str.indexOf("[/特") >= 0) {
  1326. str2 = str.substr(str.indexOf("[/特"));
  1327. str2 = str2.substring(0, 4);
  1328. }
  1329. str = str.replace(str2, "");
  1330. if (str.indexOf("[公式") >= 0) {
  1331. str2 = str.substr(str.indexOf("[公式"));
  1332. str2 = str2.substring(0, str2.indexOf("]") + 1);
  1333. }
  1334. str = str.replace(str2, "");
  1335. if (str.indexOf("[/公式") >= 0) {
  1336. str2 = str.substr(str.indexOf("[/公式"));
  1337. str2 = str2.substring(0, 5);
  1338. }
  1339. str = str.replace(str2, "");
  1340. str = that.encryptUrl(str);
  1341. }
  1342. }
  1343. return str;
  1344. }
  1345. function searchInfomation(search, searchtype, author, shiciurl, callback) {
  1346. var WORD_LENGTH = 18;
  1347. wx.showLoading({
  1348. title: '查询中',
  1349. });
  1350. var timeout = setTimeout(function () {
  1351. wx.hideLoading();
  1352. }, 5000);
  1353. var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
  1354. url += "&Word=" + encodeURI(search);
  1355. if (searchtype)
  1356. url += "&SearchType=" + searchtype;
  1357. if (author)
  1358. url += "&Author=" + encodeURI(author);
  1359. if (shiciurl)
  1360. url += "&ShiciUrl=" + shiciurl;
  1361. getData(url, function (data) {
  1362. wx.hideLoading();
  1363. clearTimeout(timeout);
  1364. if (data) {
  1365. //console.log(data);
  1366. if (data.List) {
  1367. var len = WORD_LENGTH;
  1368. var list = data.List;
  1369. for (var i = 0; i < list.length; i++) {
  1370. var item = list[i];
  1371. if (item.TypeName == "字词") {
  1372. if (item.Key.length == 1)
  1373. item.TypeName = "Z";
  1374. else
  1375. item.TypeName = "C";
  1376. } else if (item.TypeName == "诗词") {
  1377. item.TypeName = "S";
  1378. item.Remark = item.Author + " " + item.Dynasty;
  1379. } else if (item.TypeName == "翻译") {
  1380. item.TypeName = "D";
  1381. } else if (item.TypeName == "公式") {
  1382. item.TypeName = "G";
  1383. }
  1384. if (item.Content && item.Content.length > len)
  1385. item.Content = item.Content.substr(0, len) + "...";
  1386. }
  1387. callback(list);
  1388. } else if (data.CHN || data.ENG || data.LATEX) {
  1389. var obj = {};
  1390. obj.Key = search;
  1391. obj.Value = data;
  1392. if (data.CHN && data.CHN.Author)
  1393. obj.Author = data.CHN.Author;
  1394. if (data.CHN && data.CHN.Dynasty)
  1395. obj.Dynasty = data.CHN.Dynasty;
  1396. if (data.CHN && data.CHN.PeomContent) {
  1397. obj.Type = "shici";
  1398. obj.TypeName = "诗词";
  1399. obj.Content = data.CHN.PeomContent.join("").substr(0, WORD_LENGTH);
  1400. obj.ShiciUrl = shiciurl;
  1401. obj.TypeName = "S";
  1402. } else if (data.CHN) {
  1403. obj.Type = "zici";
  1404. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].pinyin)
  1405. obj.Remark = data.CHN.PinYin[0].pinyin;
  1406. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].explain) {
  1407. obj.Content = data.CHN.PinYin[0].explain.substr(0, WORD_LENGTH);
  1408. obj.Content = obj.Content.replace("<p>", "");
  1409. obj.Content = obj.Content.replace("</p>", "");
  1410. if (obj.Content.length >= WORD_LENGTH)
  1411. obj.Content += "..."
  1412. }
  1413. if (obj.Key.length == 1)
  1414. obj.TypeName = "Z";
  1415. else
  1416. obj.TypeName = "C";
  1417. }
  1418. if (data.ENG && !data.CHN) {
  1419. obj.Type = "eng";
  1420. obj.TypeName = "D";
  1421. if (data.ENG.Soundmark && data.ENG.Soundmark.Eng)
  1422. obj.Remark = data.ENG.Soundmark.Eng;
  1423. if (data.ENG.Paraphrase.length > 0) {
  1424. if (common.checkIsArray(data.ENG.Paraphrase) && data.ENG.Paraphrase[0].ParaphraseList)
  1425. obj.Content = data.ENG.Paraphrase[0].ParaphraseList.join("; ").substr(0, WORD_LENGTH);
  1426. else
  1427. obj.Content = data.ENG.Paraphrase.substr(0, WORD_LENGTH) + "...";
  1428. }
  1429. }
  1430. if (data.LATEX && !data.CHN && !data.ENG) {
  1431. obj.Type = "latex";
  1432. obj.TypeName = "G";
  1433. obj.Remark = data.LATEX.Grade +" "+data.LATEX.Category;
  1434. obj.Content = data.LATEX.Subject;
  1435. if (app.globalData.TempStr)
  1436. obj.Value.LATEX.SearchText=app.globalData.TempStr;
  1437. }
  1438. app.globalData.TempSearchBackNumber = 2;
  1439. //app.globalData.CardList=[];
  1440. app.globalData.CardList2 = [];
  1441. callback([], obj);
  1442. } else {
  1443. callback([]);
  1444. }
  1445. } else {
  1446. callback([]);
  1447. }
  1448. });
  1449. }
  1450. function downloadBishunKaitiImage(url, serverUrl, dataType, Fields, callback) {
  1451. var param = {};
  1452. param.Url = url;
  1453. param.DataType = dataType;
  1454. if (param.Url == serverUrl) {
  1455. postData("GetBiShunByKaitiUrl", param, function (data) {
  1456. if (data) {
  1457. wx.downloadFile({
  1458. url: data, // 仅为示例,并非真实的资源
  1459. success(res) {
  1460. // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  1461. if (res.statusCode === 200) {
  1462. //console.log("serverUrl2:" + serverUrl);
  1463. console.log(res.tempFilePath);
  1464. callback(change(Fields, res.tempFilePath, param));
  1465. }
  1466. },
  1467. complete() {
  1468. }
  1469. });
  1470. }
  1471. });
  1472. } else {
  1473. callback(change(Fields, serverUrl, param));
  1474. }
  1475. function change(Fields, filepath, param) {
  1476. var iStart = 0;
  1477. if (Fields.length == 4)
  1478. iStart = 1
  1479. for (var i = iStart; i < Fields.length; i++) {
  1480. for (var j = 0; j < Fields[i].length; j++) {
  1481. if (Fields[i][j].Type == "image") {
  1482. if (Fields[i][j].Content == param.Url) {
  1483. Fields[i][j].Content = filepath;
  1484. if (param.DataType == "bishun") {
  1485. Fields[i][j].IsShowKaiti = true;
  1486. Fields[i][j].IsShowBishun = false;
  1487. } else if (param.DataType == "kaiti") {
  1488. Fields[i][j].IsShowKaiti = false;
  1489. Fields[i][j].IsShowBishun = true;
  1490. }
  1491. }
  1492. }
  1493. }
  1494. }
  1495. return Fields;
  1496. }
  1497. }
  1498. function GetSoundError(str) {
  1499. var result = str;
  1500. var arr = wx.getStorageSync('SoundErrorArr');
  1501. if (arr && arr.length>0){
  1502. for (var i = 0; i < arr.length; i++) {
  1503. if (str.indexOf(arr[i].Word) > 0) {
  1504. result = common.ReplaceAllString(str, arr[i].Word, arr[i].Sound);
  1505. break;
  1506. } else if (str == arr[i].Word) {
  1507. result = arr[i].Sound;
  1508. }
  1509. }
  1510. }
  1511. return result;
  1512. }
  1513. function GetTestReportList(userID, callback) {
  1514. getData('GetTestGradeArr', function (GradeArr) {
  1515. for (var i = 0; i < GradeArr.length; i++) {
  1516. for (var j = 0; j < GradeArr[i].List.length; j++) {
  1517. GradeArr[i].List[j].Finish = 0;
  1518. }
  1519. }
  1520. getData('GetTestReportList?UserID=' + userID, function (data) {
  1521. if (data) {
  1522. var dataTemp = [];
  1523. for (var i = 0; i < data.length; i++) {
  1524. for (var j = 0; j < dataTemp.length; j++) {
  1525. if (dataTemp[j].Name[0] == data[i].Name[0] &&
  1526. dataTemp[j].Name[1] == data[i].Name[1] &&
  1527. dataTemp[j].TestType == data[i].TestType &&
  1528. data[i].IsFinished == 1
  1529. ) {
  1530. dataTemp.splice(j, 1);
  1531. break;
  1532. }
  1533. }
  1534. dataTemp.push(data[i]);
  1535. if (data[i].Name[0].indexOf("英语") >= 0
  1536. || data[i].Name[0].indexOf("单词") >= 0
  1537. || data[i].Name[0].indexOf("高考") >= 0
  1538. || data[i].Name[0].indexOf("KET") >= 0
  1539. || data[i].Name[0].indexOf("1000") >= 0
  1540. || data[i].Name[0].indexOf("2000") >= 0
  1541. || data[i].Name[0].indexOf("4000") >= 0
  1542. || data[i].Name[0].indexOf("语文词语") >= 0
  1543. || data[i].Name[0].indexOf("识字 上学期") >= 0
  1544. || data[i].Name[0].indexOf("拼音") >= 0
  1545. || data[i].Name[1].indexOf("古诗文") >= 0
  1546. || data[i].Name[0].indexOf("文言文") >= 0
  1547. || data[i].Name[0].indexOf("小古文") >= 0) {
  1548. if (data[i].TestRightStr) {
  1549. data[i].TestRightStr = data[i].TestRightStr.split(",");
  1550. }
  1551. if (data[i].TestWrongStr) {
  1552. data[i].TestWrongStr = data[i].TestWrongStr.split(",");
  1553. }
  1554. if (data[i].TestSkipStr) {
  1555. data[i].TestSkipStr = data[i].TestSkipStr.split(",");
  1556. }
  1557. if (data[i].TestExistStr) {
  1558. data[i].TestExistStr = data[i].TestExistStr.split(",");
  1559. }
  1560. }
  1561. if (!data[i].TestRightStr)
  1562. data[i].TestRightStr = "";
  1563. if (!data[i].TestWrongStr)
  1564. data[i].TestWrongStr = "";
  1565. if (!data[i].TestSkipStr)
  1566. data[i].TestSkipStr = "";
  1567. if (!data[i].TestExistStr)
  1568. data[i].TestExistStr = "";
  1569. }
  1570. //debugger;
  1571. for (var i = 0; i < dataTemp.length; i++) {
  1572. var name = dataTemp[i].Name[0].split(" ");
  1573. for (var j = 0; j < GradeArr.length; j++) {
  1574. var item = GradeArr[j];
  1575. if (name[0] == item.Name) {
  1576. for (var k = 0; k < item.List.length; k++) {
  1577. //音标计算进度
  1578. if (item.List[k].ID == 101 && dataTemp[i].BookID == 101) {
  1579. for (var n = 1; n <= 4; n++) {
  1580. if (Number(dataTemp[i].Name[2]) == n && dataTemp[i].IsFinished == 1)
  1581. item.List[k].Finish++;
  1582. }
  1583. }
  1584. //古诗词计算进度
  1585. else if (item.List[k].ID == dataTemp[i].BookID && dataTemp[i].TestType == "recite" && dataTemp[i].IsFinished == 1)
  1586. item.List[k].Finish = 1;
  1587. else {
  1588. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
  1589. if (dataTemp[i].IsFinished == 1)
  1590. item.List[k].Finish++;
  1591. }
  1592. }
  1593. }
  1594. }
  1595. }
  1596. }
  1597. for (var j = 0; j < GradeArr.length; j++) {
  1598. var item = GradeArr[j];
  1599. for (var k = 0; k < item.List.length; k++) {
  1600. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  1601. //debugger;
  1602. item.List[k].NameStr = item.List[k].Name.replace("语文", "");
  1603. }
  1604. }
  1605. wx.setStorageSync("UserTestReport", data);
  1606. callback(data, GradeArr);
  1607. }
  1608. });
  1609. });
  1610. }
  1611. function showHelp(obj,myClass,textTopDirection,helpText,closePos){
  1612. setTimeout(function(){
  1613. wx.createSelectorQuery().select(myClass).boundingClientRect(function (rect) {
  1614. console.log("rect.left:"+rect.left);
  1615. console.log("rect.top:"+rect.top);
  1616. console.log("rect.width:"+rect.width);
  1617. console.log("rect.height:"+rect.height);
  1618. var textTop=rect.bottom+5;
  1619. if (textTopDirection=="up")
  1620. textTop=rect.top-47;
  1621. if (!closePos)
  1622. closePos="Right";
  1623. obj.setData({
  1624. HelpTop:rect.top,
  1625. HelpWidth1:rect.left,
  1626. HelpHeight1:rect.height,
  1627. HelpLeft2:rect.right,
  1628. HelpHeight2:rect.height,
  1629. HelpBottom:rect.bottom-1,
  1630. HelpTextTop:textTop,
  1631. HelpText:helpText,
  1632. HelpClosePos:closePos,
  1633. });
  1634. }).exec();
  1635. },500);
  1636. }
  1637. function gotoTaskList(id,cardType) {
  1638. wx.showLoading({
  1639. title: '请稍候',
  1640. });
  1641. setTimeout(function () {
  1642. wx.hideLoading();
  1643. }, 5000);
  1644. var that = this;
  1645. //未练完的题卡
  1646. if (id == 1) {
  1647. getTaskTodayList(function (task) {
  1648. var list = [];
  1649. for (var i = 0; i < task.ListNew.length; i++) {
  1650. list.push(task.ListNew[i]);
  1651. }
  1652. for (var i = 0; i < task.ListHistory.length; i++) {
  1653. list.push(task.ListHistory[i]);
  1654. }
  1655. for (var i = 0; i < task.ListReview.length; i++) {
  1656. list.push(task.ListReview[i]);
  1657. }
  1658. app.globalData.CardList = list;
  1659. var url='../../pages/main/mainlist?type=1&Count=' + list.length;
  1660. wx.navigateTo({
  1661. url: url,
  1662. });
  1663. });
  1664. } else {
  1665. var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID + "&IsToday=2&CardType="+ cardType +"&OrderType=ac.LastTime desc";
  1666. getData(url, function (data) {
  1667. if (data) {
  1668. var list = [];
  1669. for (var i = 0; i < data.List.length; i++) {
  1670. data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
  1671. list.push(data.List[i]);
  1672. }
  1673. app.globalData.CardList = list;
  1674. var url='../../pages/main/mainlist?type=2&Count=' + data.length;
  1675. wx.navigateTo({
  1676. url: url,
  1677. });
  1678. }
  1679. });
  1680. }
  1681. }
  1682. function resetTodayTask(){
  1683. wx.showModal({
  1684. title: '提醒',
  1685. content: '此操作无法撤销。确认重置今天的任务量吗?',
  1686. showCancel:true,
  1687. cancelText:"取消",
  1688. confirmColor:"#ff0000",
  1689. confirmText:"确定",
  1690. success (res) {
  1691. if (res.confirm) {
  1692. //console.log('用户点击确定')
  1693. var url = "ResetMiaoguoCardTask?UserID=" + app.globalData.userInfo.UserID;
  1694. getData(url, function (data) {
  1695. if (data) {
  1696. wx.showModal({
  1697. title: '提醒',
  1698. content: '重置已完成。请重新开始今天的练习吧。',
  1699. showCancel:false,
  1700. confirmColor:"#000000",
  1701. confirmText:"返回首页",
  1702. success (res) {
  1703. wx.navigateBack({
  1704. delta: 2,
  1705. });
  1706. }
  1707. });
  1708. }
  1709. });
  1710. }
  1711. }
  1712. });
  1713. }
  1714. //下载图片
  1715. function downloadFile(url,isShowLoading,callback){
  1716. if (isShowLoading){
  1717. wx.showLoading({
  1718. title: '下载中',
  1719. });
  1720. setTimeout(function () {
  1721. wx.hideLoading();
  1722. }, 5000);
  1723. }
  1724. console.log(url);
  1725. wx.downloadFile({
  1726. url: url,
  1727. success(resDownload) {
  1728. // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  1729. if (resDownload.statusCode === 200) {
  1730. callback(resDownload.tempFilePath);
  1731. }
  1732. else if (resDownload.statusCode === 404){
  1733. wx.showToast({
  1734. title: '图片不存在',
  1735. });
  1736. }
  1737. if (isShowLoading)
  1738. wx.hideLoading();
  1739. },
  1740. fail: function (e) {
  1741. if (isShowLoading)
  1742. wx.hideLoading();
  1743. wx.showToast({
  1744. title: '下载失败',
  1745. });
  1746. }
  1747. });
  1748. }
  1749. //生成图片
  1750. function buildImage(width,height,canvas,callback){
  1751. var that=this;
  1752. wx.showLoading({
  1753. title: '生成中',
  1754. });
  1755. setTimeout(function () {
  1756. //console.log("生成后1");
  1757. wx.canvasToTempFilePath({
  1758. x: 0,
  1759. y: 0,
  1760. width: width,
  1761. height: height,
  1762. destWidth: width,
  1763. destHeight: height,
  1764. canvas: canvas,
  1765. success: function (res2) {
  1766. wx.hideLoading();
  1767. //console.log("生成后2");
  1768. wx.previewImage({
  1769. current: res2.tempFilePath, // 当前显示图片的http链接
  1770. urls: [res2.tempFilePath] // 需要预览的图片http链接列表
  1771. });
  1772. callback();
  1773. },
  1774. fail: function (e) {
  1775. wx.hideLoading();
  1776. //console.log("生成错误:"+e);
  1777. }
  1778. })
  1779. }, 500);
  1780. }
  1781. function showHelpImage() {
  1782. var arr=[];
  1783. arr.push(app.globalData.uploadImageUrl+"web/doc_xnl_36_1.png")
  1784. arr.push(app.globalData.uploadImageUrl+"web/doc_xnl_36_2.png")
  1785. wx.previewImage({
  1786. current: arr[0],
  1787. urls: arr,
  1788. });
  1789. }
  1790. module.exports = {
  1791. getData: getData,
  1792. postData: postData,
  1793. payMoney: payMoney,
  1794. getLocalHost: getLocalHost,
  1795. getTimeFormat: getTimeFormat,
  1796. getWindowHeight: getWindowHeight,
  1797. getStorageValue: getStorageValue,
  1798. getProgramList: getProgramList,
  1799. gotoFeedback: gotoFeedback,
  1800. getDetailColor: getDetailColor,
  1801. changeStringToView: changeStringToView,
  1802. changeViewToString: changeViewToString,
  1803. encryptUrl: EncryptUrl,
  1804. decryptUrl: DecryptUrl,
  1805. saveTempImage: saveTempImage,
  1806. getTempImage: getTempImage,
  1807. getTaskTodayList: getTaskTodayList,
  1808. updateSearchList: updateSearchList,
  1809. checkIsIPhoneX: checkIsIPhoneX,
  1810. getMemoryLevelAll: getMemoryLevelAll,
  1811. getMemoryLevel: getMemoryLevel,
  1812. getShareImageBackColor: getShareImageBackColor,
  1813. UpdateMiaoguoCardTodayAll: UpdateMiaoguoCardTodayAll,
  1814. setCollect: setCollect,
  1815. UploadUserConfig: UploadUserConfig,
  1816. getServerImage: getServerImage,
  1817. getBaiduToken: getBaiduToken,
  1818. getPinyinNormal: getPinyinNormal,
  1819. getHanzi: getHanzi,
  1820. getEnglish: getEnglish,
  1821. GetHanziUnitWords: GetHanziUnitWords,
  1822. GetTestReportInfo: GetTestReportInfo,
  1823. getUserConfig: getUserConfig,
  1824. getAwardData: getAwardData,
  1825. replaceCardInfoString: replaceCardInfoString,
  1826. searchInfomation: searchInfomation,
  1827. downloadBishunKaitiImage: downloadBishunKaitiImage,
  1828. GetSoundError: GetSoundError,
  1829. GetTestReportList: GetTestReportList,
  1830. ShowHelp:showHelp,
  1831. GotoTaskList:gotoTaskList,
  1832. ResetTodayTask:resetTodayTask,
  1833. DownloadFile:downloadFile,
  1834. BuildImage:buildImage,
  1835. ShowHelpImage:showHelpImage,
  1836. getServerSoundErrorArr:getServerSoundErrorArr,
  1837. }