main.js 60 KB

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