main.js 64 KB

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