main.js 66 KB

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