main.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948
  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].BiShunUrl + "[/图]";
  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. } else { //若是词语
  780. for (var k = 0; k < words.length; k++) {
  781. var taskInfo = words[k];
  782. taskInfo.TagWidth=136;
  783. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  784. TaskList.push(taskInfo);
  785. }
  786. }
  787. callback(TaskList);
  788. } else {
  789. callback([]);
  790. }
  791. });
  792. }
  793. function GetTestReportInfo(reportid, callback) {
  794. var UserTestReport = wx.getStorageSync('UserTestReport');
  795. for (var n = 0; n < UserTestReport.length; n++) {
  796. if (UserTestReport[n].ID == reportid) {
  797. var name1 = UserTestReport[n].Name[0].split(" ");
  798. var name2 = UserTestReport[n].Name[1];
  799. if (name1[0].indexOf("英语") >= 0
  800. ||name1[0].indexOf("KET") >= 0
  801. ||name1[0].indexOf("单词") >= 0
  802. || name1[0].indexOf("1000") >= 0
  803. || name1[0].indexOf("2000") >= 0
  804. || name1[0].indexOf("4000") >= 0) {
  805. //console.log("英语");
  806. var wordStr = "";
  807. var userTestReportInfo = UserTestReport[n];
  808. var bookid = userTestReportInfo.BookID;
  809. var arrEnglist = [];
  810. if (bookid < 110) {
  811. if (name1[1] == "英文字母") {
  812. bookid = 100;
  813. 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";
  814. }
  815. } else if (bookid > 110 && bookid < 120) {
  816. arrEnglist = wx.getStorageSync("EnglishAll");
  817. arrEnglist = JSON.parse(arrEnglist);
  818. for (var i = 0; i < arrEnglist.length; i++) {
  819. if (arrEnglist[i].Name == name1[1]) {
  820. for (var j = 0; j < arrEnglist[i].Units.length; j++) {
  821. if (arrEnglist[i].Units[j].Name == name2) {
  822. wordStr = arrEnglist[i].Units[j].Words.join(",");
  823. break;
  824. }
  825. }
  826. }
  827. }
  828. }
  829. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  830. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  831. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  832. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  833. var unitsid = "";
  834. if (bookid > 100 && bookid < 110 && UserTestReport[n].Name[2]) {
  835. unitsid = Number(UserTestReport[n].Name[2]);
  836. } else if (bookid > 120 && bookid <= 124) {
  837. unitsid = Number(name2.replace("Lesson ", ""));
  838. } else if (bookid > 130 && bookid <= 170 && UserTestReport[n].Name[2]) {
  839. unitsid = Number(UserTestReport[n].Name[2]);
  840. }
  841. getData('GetTestEnglishWords?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + bookid + '&LessonID=' + unitsid + '&Words=' + wordStr + "&TestType=" + userTestReportInfo.TestType, function (data) {
  842. if (data) {
  843. var result = {};
  844. result.ID = userTestReportInfo.ID;
  845. result.IsFinished = userTestReportInfo.IsFinished;
  846. result.Name = userTestReportInfo.Name.join("#");
  847. result.TestType = userTestReportInfo.TestType;
  848. result.BookID = bookid;
  849. var TaskList = [];
  850. var words = data;
  851. for (var k = 0; k < words.length; k++) {
  852. var taskInfo = words[k];
  853. if (userTestReportInfo.TestType == "read") {
  854. taskInfo.TagWidth = 212;
  855. taskInfo.FontSize = 108;
  856. } else {
  857. taskInfo.TagWidth = 186;
  858. taskInfo.FontSize = 36;
  859. }
  860. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  861. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  862. taskInfo.Result = 1;
  863. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  864. taskInfo.Result = -1;
  865. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  866. taskInfo.Result = 0;
  867. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  868. taskInfo.Css = "Select2";
  869. TaskList.push(taskInfo);
  870. }
  871. result.TestRightStr = "";
  872. result.TestWrongStr = "";
  873. result.TestSkipStr = "";
  874. result.TestExistStr = "";
  875. if (userTestReportInfo.TestRightStr)
  876. result.TestRightStr = userTestReportInfo.TestRightStr;
  877. if (userTestReportInfo.TestWrongStr)
  878. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  879. if (userTestReportInfo.TestSkipStr)
  880. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  881. if (userTestReportInfo.TestExistStr)
  882. result.TestExistStr = userTestReportInfo.TestExistStr;
  883. result.List = TaskList;
  884. callback(result);
  885. } else {
  886. callback({});
  887. }
  888. });
  889. } else if (name1[1].indexOf("拼音") >= 0) {
  890. //console.log("拼音");
  891. var userTestReportInfo = UserTestReport[n];
  892. var bookid = userTestReportInfo.BookID;
  893. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  894. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  895. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  896. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  897. var unitsid = "";
  898. var name2 = userTestReportInfo.Name[1];
  899. if (bookid == 43) {
  900. switch (name2) {
  901. case "声母1":
  902. unitsid = 431;
  903. break;
  904. case "声母2":
  905. unitsid = 432;
  906. break;
  907. case "声母3":
  908. unitsid = 433;
  909. break;
  910. case "韵母1":
  911. unitsid = 434;
  912. break;
  913. case "韵母2":
  914. unitsid = 435;
  915. break;
  916. case "韵母3":
  917. unitsid = 436;
  918. break;
  919. case "整体认读1":
  920. unitsid = 437;
  921. break;
  922. case "整体认读2":
  923. unitsid = 438;
  924. break;
  925. }
  926. }
  927. getData('GetPinyinUnitWords?TestType='+userTestReportInfo.TestType+'&UserID=' + app.globalData.userInfo.UserID + '&BookID=' + bookid + '&UnitID=' + unitsid + '&Word=' + name2, function (data) {
  928. if (data) {
  929. var result = {};
  930. result.ID = userTestReportInfo.ID;
  931. result.IsFinished = userTestReportInfo.IsFinished;
  932. result.Name = userTestReportInfo.Name.join("#");
  933. result.TestType = userTestReportInfo.TestType;
  934. result.BookID = bookid;
  935. var TaskList = [];
  936. var words = data;
  937. for (var k = 0; k < words.length; k++) {
  938. var taskInfo = words[k];
  939. taskInfo.TagWidth = 230;
  940. taskInfo.FontSize = 108;
  941. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  942. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  943. taskInfo.Result = 1;
  944. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  945. taskInfo.Result = -1;
  946. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  947. taskInfo.Result = 0;
  948. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  949. taskInfo.Css = "Select2";
  950. TaskList.push(taskInfo);
  951. }
  952. result.TestRightStr = "";
  953. result.TestWrongStr = "";
  954. result.TestSkipStr = "";
  955. result.TestExistStr = "";
  956. if (userTestReportInfo.TestRightStr)
  957. result.TestRightStr = userTestReportInfo.TestRightStr;
  958. if (userTestReportInfo.TestWrongStr)
  959. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  960. if (userTestReportInfo.TestSkipStr)
  961. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  962. if (userTestReportInfo.TestExistStr)
  963. result.TestExistStr = userTestReportInfo.TestExistStr;
  964. result.List = TaskList;
  965. callback(result);
  966. } else {
  967. callback({});
  968. }
  969. });
  970. } else if (name2 == "古诗文") {
  971. //todo
  972. //console.log("古诗文");
  973. var userTestReportInfo = UserTestReport[n];
  974. var tempRight = "," + userTestReportInfo.TestRightStr + ",";
  975. var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
  976. var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
  977. var tempExist = "," + userTestReportInfo.TestExistStr + ",";
  978. getData('GetTestAncientPoetryList?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + userTestReportInfo.BookID, function (data) {
  979. if (data) {
  980. var result = {};
  981. result.ID = userTestReportInfo.ID;
  982. result.IsFinished = userTestReportInfo.IsFinished;
  983. result.Name = userTestReportInfo.Name.join("#");
  984. result.TestType = userTestReportInfo.TestType;
  985. result.BookID = userTestReportInfo.BookID;
  986. var TaskList = [];
  987. for (var k = 0; k < data.length; k++) {
  988. var taskInfo = data[k];
  989. taskInfo.TagWidth = 336;
  990. if (taskInfo.Word.length > 9)
  991. taskInfo.FontSize = 48;
  992. else
  993. taskInfo.FontSize = 64;
  994. taskInfo.ContentNew = changeStringToView(taskInfo.Content);
  995. if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
  996. taskInfo.Result = 1;
  997. if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
  998. taskInfo.Result = -1;
  999. if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
  1000. taskInfo.Result = 0;
  1001. if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
  1002. taskInfo.Css = "Select2";
  1003. TaskList.push(taskInfo);
  1004. }
  1005. result.TestRightStr = "";
  1006. result.TestWrongStr = "";
  1007. result.TestSkipStr = "";
  1008. result.TestExistStr = "";
  1009. if (userTestReportInfo.TestRightStr)
  1010. result.TestRightStr = userTestReportInfo.TestRightStr;
  1011. if (userTestReportInfo.TestWrongStr)
  1012. result.TestWrongStr = userTestReportInfo.TestWrongStr;
  1013. if (userTestReportInfo.TestSkipStr)
  1014. result.TestSkipStr = userTestReportInfo.TestSkipStr;
  1015. if (userTestReportInfo.TestExistStr)
  1016. result.TestExistStr = userTestReportInfo.TestExistStr;
  1017. result.List = TaskList;
  1018. callback(result);
  1019. } else {
  1020. callback({});
  1021. }
  1022. });
  1023. } else {
  1024. var obj = UserTestReport[n];
  1025. if (obj.BookID >= 43 && obj.BookID <= 60)
  1026. name1 = name1[0] + "生词" + name1[2].substr(0, 1);
  1027. else if (obj.BookID == 73)
  1028. name1 = name1[0] + name1[1].substr(2, 3) + name1[2];
  1029. else
  1030. name1 = name1[0] + name1[1].substr(2, 2) + "能力" + name1[2].substr(0, 1);
  1031. var HanziAll = wx.getStorageSync('HanziAll');
  1032. HanziAll = JSON.parse(HanziAll);
  1033. for (var i = 0; i < HanziAll.length; i++) {
  1034. if (name1 == HanziAll[i].Name) {
  1035. for (var j = 0; j < HanziAll[i].Units.length; j++) {
  1036. if (name2 == HanziAll[i].Units[j].Name) {
  1037. GetHanziUnitWords(HanziAll[i].Units[j].ID, obj.TestType, function (list) {
  1038. if (list) {
  1039. for (var k = 0; k < list.length; k++) {
  1040. if (obj.TestRightStr && obj.TestRightStr.indexOf(list[k].Word) >= 0)
  1041. list[k].Result = 1;
  1042. else if (obj.TestWrongStr && obj.TestWrongStr.indexOf(list[k].Word) >= 0)
  1043. list[k].Result = -1;
  1044. else if (obj.TestSkipStr && obj.TestSkipStr.indexOf(list[k].Word) >= 0)
  1045. list[k].Result = 0;
  1046. if (obj.TestExistStr && obj.TestExistStr.indexOf(list[k].Word) >= 0)
  1047. list[k].Css = "Select2";
  1048. }
  1049. var result = {};
  1050. result.ID = reportid;
  1051. result.BookID = obj.BookID;
  1052. result.TestType = obj.TestType;
  1053. result.Name = obj.Name.join("#");
  1054. result.IsFinished = obj.IsFinished;
  1055. result.TestRightStr = obj.TestRightStr;
  1056. result.TestWrongStr = obj.TestWrongStr;
  1057. result.TestSkipStr = obj.TestSkipStr;
  1058. result.TestExistStr = obj.TestExistStr;
  1059. result.List = list;
  1060. callback(result);
  1061. } else
  1062. callback({});
  1063. });
  1064. }
  1065. }
  1066. }
  1067. }
  1068. }
  1069. }
  1070. }
  1071. }
  1072. function getDetailColor(index) {
  1073. var arrDetailColor = constant.arrDetailColor;
  1074. if (index > 0)
  1075. return arrDetailColor[index];
  1076. else if (index == 0)
  1077. return arrDetailColor[common.random(1, arrDetailColor.length - 1)];
  1078. else if (index == -1)
  1079. return arrDetailColor;
  1080. }
  1081. function getShareImageBackColor() {
  1082. var arr = constant.arrShareImageBackColor;
  1083. return arr[common.random(0, arr.length - 1)];
  1084. }
  1085. function getPinyinNormal(pinyin) {
  1086. var result = "";
  1087. var arr = constant.arrPinyin;
  1088. for (var i = 0; i < arr.length; i++) {
  1089. if (arr[i][1] == pinyin) {
  1090. result = arr[i][0];
  1091. break;
  1092. }
  1093. }
  1094. return result;
  1095. }
  1096. function getHanzi(callback) {
  1097. var that = this;
  1098. wx.showLoading({
  1099. title: '请稍候',
  1100. mask: true,
  1101. });
  1102. var time = wx.getStorageSync("HanziUpdateTime");
  1103. getData('GetHanziAll3?UpdateTime=' + time, function (data) {
  1104. wx.hideLoading();
  1105. if (data) {
  1106. var arr = [];
  1107. if (data.List) {
  1108. arr = common.Decrypt(data.List);
  1109. wx.setStorageSync("HanziAll", arr);
  1110. wx.setStorageSync("HanziUpdateTime", data.UpdateTime);
  1111. callback(true);
  1112. } else {
  1113. callback(false);
  1114. }
  1115. }
  1116. });
  1117. }
  1118. function getServerSoundErrorArr(){
  1119. var time = wx.getStorageSync("SoundErrorUpdateTime");
  1120. getData('GetSoundErrorArr?UpdateTime=' + time, function (data) {
  1121. if (data && data.List) {
  1122. wx.setStorageSync("SoundErrorArr", data.List);
  1123. wx.setStorageSync("SoundErrorUpdateTime", data.UpdateTime);
  1124. }
  1125. });
  1126. }
  1127. function getEnglish(callback) {
  1128. var that = this;
  1129. wx.showLoading({
  1130. title: '请稍候',
  1131. mask: true,
  1132. });
  1133. var time = wx.getStorageSync("HanziUpdateTime");
  1134. getData('GetEnglishAll3?UpdateTime=' + time, function (data) {
  1135. wx.hideLoading();
  1136. if (data.EngList) {
  1137. var arrEng = common.Decrypt(data.EngList);
  1138. var arrNewConceptEngList = common.Decrypt(data.NewConceptEngList);
  1139. var arrCambridgeEngList = common.Decrypt(data.CambridgeEngList);
  1140. var arrEEWEngList = common.Decrypt(data.EEWEngList);
  1141. var arrCEWEngList = common.Decrypt(data.CEWEngList);
  1142. var arrBEWEngList = common.Decrypt(data.BEWEngList);
  1143. var arrMiddleSchoolTestWords = common.Decrypt(data.MiddleSchoolTestWords);
  1144. var arrPhoneticEngList = common.Decrypt(data.PhoneticEngList);
  1145. wx.setStorageSync("EnglishAll", arrEng);
  1146. wx.setStorageSync("NewConceptEngList", arrNewConceptEngList);
  1147. wx.setStorageSync("CambridgeEngList", arrCambridgeEngList);
  1148. wx.setStorageSync("EEWEngList", arrEEWEngList);
  1149. wx.setStorageSync("CEWEngList", arrCEWEngList);
  1150. wx.setStorageSync("BEWEngList", arrBEWEngList);
  1151. wx.setStorageSync("MiddleSchoolTestWords", arrMiddleSchoolTestWords);
  1152. wx.setStorageSync("PhoneticEngList", arrPhoneticEngList);
  1153. wx.setStorageSync("EnglishUpdateTime", data.UpdateTime);
  1154. callback(true);
  1155. } else {
  1156. callback(false);
  1157. }
  1158. });
  1159. }
  1160. function UploadUserConfig(callback) {
  1161. var that = this;
  1162. var param1 = {};
  1163. param1.CardType = wx.getStorageSync("CardType");
  1164. param1.CardMaxNumberNew = wx.getStorageSync("CardMaxNumberNew");
  1165. param1.CardMaxNumberHistory = wx.getStorageSync("CardMaxNumberHistory");
  1166. param1.CardMaxNumberNewUrgent = wx.getStorageSync("CardMaxNumberNewUrgent");
  1167. param1.CardMaxNumberHistoryUrgent = wx.getStorageSync("CardMaxNumberHistoryUrgent");
  1168. param1.SortTypeIndex = wx.getStorageSync("SortTypeIndex");
  1169. param1.MemoryLevel = wx.getStorageSync("MemoryLevel");
  1170. param1.ClickType = wx.getStorageSync("ClickType");
  1171. param1.SecondConfigArray = wx.getStorageSync("SecondConfigArray").join(",");
  1172. param1.ColorIndexArr = wx.getStorageSync("ColorIndexArr").join(",");
  1173. param1.IsFolderPractice = wx.getStorageSync("IsFolderPractice");
  1174. param1.IsAutoSound = wx.getStorageSync("IsAutoSound");
  1175. var symboMain = wx.getStorageSync("SymbolMain");
  1176. var symbol1 = [];
  1177. for (var i = 0; i < symboMain.length; i++) {
  1178. symbol1.push(symboMain[i].Name);
  1179. }
  1180. symbol1 = JSON.stringify(symbol1);
  1181. param1.SymbolList = symbol1;
  1182. var folderOrder = wx.getStorageSync("FolderOrderStr");
  1183. if (folderOrder)
  1184. param1.FolderOrder = folderOrder;
  1185. //console.log(param1);
  1186. that.postData('UploadUserConfig?Type=update&UserID=' + app.globalData.userInfo.UserID, param1, function (data) {
  1187. if (callback) {
  1188. callback();
  1189. }
  1190. });
  1191. }
  1192. function getAwardData(callback) {
  1193. var that = this;
  1194. that.getData('GetAwardInfo?UserID=' + app.globalData.userInfo.UserID, function (data) {
  1195. if (data) {
  1196. callback(data);
  1197. } else
  1198. callback([]);
  1199. });
  1200. }
  1201. function getUserConfig() {
  1202. var that = this;
  1203. postData('UploadUserConfig?Type=getData&UserID=' + app.globalData.userInfo.UserID, {}, function (data) {
  1204. if (data && !data.CardType)
  1205. data.CardType = 0;
  1206. wx.setStorageSync("CardType", data.CardType);
  1207. wx.setStorageSync("CardMaxNumberNew", data.CardMaxNumberNew);
  1208. wx.setStorageSync("CardMaxNumberHistory", data.CardMaxNumberHistory);
  1209. wx.setStorageSync("CardMaxNumberNewUrgent", data.CardMaxNumberNewUrgent);
  1210. wx.setStorageSync("CardMaxNumberHistoryUrgent", data.CardMaxNumberHistoryUrgent);
  1211. wx.setStorageSync("SortTypeIndex", data.SortTypeIndex);
  1212. wx.setStorageSync("MemoryLevel", data.MemoryLevel);
  1213. wx.setStorageSync("ClickType", data.ClickType);
  1214. wx.setStorageSync("SecondConfigArray", data.SecondConfigArray.split(","));
  1215. wx.setStorageSync("ColorIndexArr", data.ColorIndexArr.split(","));
  1216. wx.setStorageSync("FolderOrderStr", data.FolderOrder);
  1217. wx.setStorageSync("IsFolderPractice", data.IsFolderPractice);
  1218. wx.setStorageSync("IsAutoSound", data.IsAutoSound);
  1219. var symbol1 = [];
  1220. if (data.SymbolList) {
  1221. for (var i = 0; i < data.SymbolList.length; i++) {
  1222. var obj = {};
  1223. obj.Name = data.SymbolList[i];
  1224. obj.CSS = "btn2";
  1225. symbol1.push(obj);
  1226. }
  1227. } else {
  1228. symbol1 = app.globalData.SymbolMain;
  1229. }
  1230. if (symbol1.length > 0) {
  1231. wx.setStorageSync("SymboMain", symbol1);
  1232. app.globalData.SymbolMain = symbol1;
  1233. }
  1234. });
  1235. }
  1236. function replaceCardInfoString(str) {
  1237. var that = this;
  1238. //str = str.replace(/\[图]/g, "");
  1239. //str = str.replace(/\[\/图\]/g, "");
  1240. //console.log(str);
  1241. if (str && str!=null) {
  1242. var str2 = "";
  1243. if (str.indexOf("[读 src=") >= 0) {
  1244. str2 = str.substr(str.indexOf("[读 src="));
  1245. str2 = str2.substring(0, str2.indexOf("]") + 1);
  1246. }
  1247. str = str.replace(str2, "");
  1248. if (str.indexOf("[/读") >= 0) {
  1249. str2 = str.substr(str.indexOf("[/读"));
  1250. str2 = str2.substring(0, 4);
  1251. }
  1252. str = str.replace(str2, "");
  1253. if (str.indexOf("[读 src=") >= 0) {
  1254. str2 = str.substr(str.indexOf("[读 src"));
  1255. str2 = str2.substring(0, str2.indexOf("/读]") + 3);
  1256. }
  1257. str = str.replace(str2, "");
  1258. if (str.indexOf("[/读") >= 0) {
  1259. str2 = str.substr(str.indexOf("[/读"));
  1260. str2 = str2.substring(0, 4);
  1261. }
  1262. str = str.replace(str2, "");
  1263. str = str.replace(/\[读]/g, "");
  1264. str = str.replace(/\[\/读\]/g, "");
  1265. var str3 = "";
  1266. if (str.indexOf("[图") >= 0) {
  1267. str3 = str.substr(str.indexOf("[图"));
  1268. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1269. }
  1270. str = str.replace(str3, "");
  1271. if (str.indexOf("[图") >= 0) {
  1272. str3 = str.substr(str.indexOf("[图"));
  1273. str3 = str3.substring(0, str3.indexOf("/图]") + 3);
  1274. }
  1275. str = str.replace(str3, "");
  1276. str = str.replace(/\[线]/g, "");
  1277. str = str.replace(/\[\/线\]/g, "");
  1278. str = that.encryptUrl(str);
  1279. }
  1280. return str;
  1281. }
  1282. function searchInfomation(search, searchtype, author, shiciurl, callback) {
  1283. var WORD_LENGTH = 18;
  1284. wx.showLoading({
  1285. title: '查询中',
  1286. });
  1287. var timeout = setTimeout(function () {
  1288. wx.hideLoading();
  1289. }, 5000);
  1290. var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
  1291. url += "&Word=" + encodeURI(search);
  1292. if (searchtype)
  1293. url += "&SearchType=" + searchtype;
  1294. if (author)
  1295. url += "&Author=" + encodeURI(author);
  1296. if (shiciurl)
  1297. url += "&ShiciUrl=" + shiciurl;
  1298. getData(url, function (data) {
  1299. wx.hideLoading();
  1300. clearTimeout(timeout);
  1301. if (data) {
  1302. //console.log(data);
  1303. if (data.List) {
  1304. var len = WORD_LENGTH;
  1305. var list = data.List;
  1306. for (var i = 0; i < list.length; i++) {
  1307. var item = list[i];
  1308. if (item.TypeName == "字词") {
  1309. if (item.Key.length == 1)
  1310. item.TypeName = "Z";
  1311. else
  1312. item.TypeName = "C";
  1313. } else if (item.TypeName == "诗词") {
  1314. item.TypeName = "S";
  1315. item.Remark = item.Author + " " + item.Dynasty;
  1316. } else if (item.TypeName == "翻译") {
  1317. item.TypeName = "D";
  1318. }
  1319. if (item.Content && item.Content.length > len)
  1320. item.Content = item.Content.substr(0, len) + "...";
  1321. }
  1322. callback(list);
  1323. } else if (data.CHN || data.ENG) {
  1324. var obj = {};
  1325. obj.Key = search;
  1326. obj.Value = data;
  1327. if (data.CHN && data.CHN.Author)
  1328. obj.Author = data.CHN.Author;
  1329. if (data.CHN && data.CHN.Dynasty)
  1330. obj.Dynasty = data.CHN.Dynasty;
  1331. if (data.CHN && data.CHN.PeomContent) {
  1332. obj.Type = "shici";
  1333. obj.TypeName = "诗词";
  1334. obj.Content = data.CHN.PeomContent.join("").substr(0, WORD_LENGTH);
  1335. obj.ShiciUrl = shiciurl;
  1336. obj.TypeName = "S";
  1337. } else if (data.CHN) {
  1338. obj.Type = "zici";
  1339. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].pinyin)
  1340. obj.Remark = data.CHN.PinYin[0].pinyin;
  1341. if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].explain) {
  1342. obj.Content = data.CHN.PinYin[0].explain.substr(0, WORD_LENGTH);
  1343. obj.Content = obj.Content.replace("<p>", "");
  1344. obj.Content = obj.Content.replace("</p>", "");
  1345. if (obj.Content.length >= WORD_LENGTH)
  1346. obj.Content += "..."
  1347. }
  1348. if (obj.Key.length == 1)
  1349. obj.TypeName = "Z";
  1350. else
  1351. obj.TypeName = "C";
  1352. }
  1353. if (data.ENG && !data.CHN) {
  1354. obj.Type = "eng";
  1355. obj.TypeName = "D";
  1356. if (data.ENG.Soundmark && data.ENG.Soundmark.Eng)
  1357. obj.Remark = data.ENG.Soundmark.Eng;
  1358. if (data.ENG.Paraphrase.length > 0) {
  1359. if (common.checkIsArray(data.ENG.Paraphrase) && data.ENG.Paraphrase[0].ParaphraseList)
  1360. obj.Content = data.ENG.Paraphrase[0].ParaphraseList.join("; ").substr(0, WORD_LENGTH);
  1361. else
  1362. obj.Content = data.ENG.Paraphrase.substr(0, WORD_LENGTH) + "...";
  1363. }
  1364. }
  1365. app.globalData.TempSearchBackNumber = 2;
  1366. //app.globalData.CardList=[];
  1367. app.globalData.CardList2 = [];
  1368. callback([], obj);
  1369. } else {
  1370. callback([]);
  1371. }
  1372. } else {
  1373. callback([]);
  1374. }
  1375. });
  1376. }
  1377. function downloadBishunKaitiImage(url, serverUrl, dataType, Fields, callback) {
  1378. var param = {};
  1379. param.Url = url;
  1380. param.DataType = dataType;
  1381. if (param.Url == serverUrl) {
  1382. postData("GetBiShunByKaitiUrl", param, function (data) {
  1383. if (data) {
  1384. wx.downloadFile({
  1385. url: data, // 仅为示例,并非真实的资源
  1386. success(res) {
  1387. // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  1388. if (res.statusCode === 200) {
  1389. //console.log("serverUrl2:" + serverUrl);
  1390. console.log(res.tempFilePath);
  1391. callback(change(Fields, res.tempFilePath, param));
  1392. }
  1393. },
  1394. complete() {
  1395. }
  1396. });
  1397. }
  1398. });
  1399. } else {
  1400. callback(change(Fields, serverUrl, param));
  1401. }
  1402. function change(Fields, filepath, param) {
  1403. var iStart = 0;
  1404. if (Fields.length == 4)
  1405. iStart = 1
  1406. for (var i = iStart; i < Fields.length; i++) {
  1407. for (var j = 0; j < Fields[i].length; j++) {
  1408. if (Fields[i][j].Type == "image") {
  1409. if (Fields[i][j].Content == param.Url) {
  1410. Fields[i][j].Content = filepath;
  1411. if (param.DataType == "bishun") {
  1412. Fields[i][j].IsShowKaiti = true;
  1413. Fields[i][j].IsShowBishun = false;
  1414. } else if (param.DataType == "kaiti") {
  1415. Fields[i][j].IsShowKaiti = false;
  1416. Fields[i][j].IsShowBishun = true;
  1417. }
  1418. }
  1419. }
  1420. }
  1421. }
  1422. return Fields;
  1423. }
  1424. }
  1425. function GetSoundError(str) {
  1426. var result = str;
  1427. var arr = wx.getStorageSync('SoundErrorArr');
  1428. if (arr && arr.length>0){
  1429. for (var i = 0; i < arr.length; i++) {
  1430. if (str.indexOf(arr[i].Word) > 0) {
  1431. result = common.ReplaceAllString(str, arr[i].Word, arr[i].Sound);
  1432. break;
  1433. } else if (str == arr[i].Word) {
  1434. result = arr[i].Sound;
  1435. }
  1436. }
  1437. }
  1438. return result;
  1439. }
  1440. function GetTestReportList(userID, callback) {
  1441. getData('GetTestGradeArr', function (GradeArr) {
  1442. for (var i = 0; i < GradeArr.length; i++) {
  1443. for (var j = 0; j < GradeArr[i].List.length; j++) {
  1444. GradeArr[i].List[j].Finish = 0;
  1445. }
  1446. }
  1447. getData('GetTestReportList?UserID=' + userID, function (data) {
  1448. if (data) {
  1449. var dataTemp = [];
  1450. for (var i = 0; i < data.length; i++) {
  1451. for (var j = 0; j < dataTemp.length; j++) {
  1452. if (dataTemp[j].Name[0] == data[i].Name[0] &&
  1453. dataTemp[j].Name[1] == data[i].Name[1] &&
  1454. dataTemp[j].TestType == data[i].TestType &&
  1455. data[i].IsFinished == 1
  1456. ) {
  1457. dataTemp.splice(j, 1);
  1458. break;
  1459. }
  1460. }
  1461. dataTemp.push(data[i]);
  1462. if (data[i].Name[0].indexOf("英语") >= 0
  1463. || data[i].Name[0].indexOf("单词") >= 0
  1464. || data[i].Name[0].indexOf("KET") >= 0
  1465. || data[i].Name[0].indexOf("1000") >= 0
  1466. || data[i].Name[0].indexOf("2000") >= 0
  1467. || data[i].Name[0].indexOf("4000") >= 0
  1468. || data[i].Name[0].indexOf("语文词语") >= 0
  1469. || data[i].Name[0].indexOf("识字 上学期") >= 0
  1470. || data[i].Name[0].indexOf("拼音") >= 0
  1471. || data[i].Name[1].indexOf("古诗文") >= 0
  1472. || data[i].Name[0].indexOf("文言文") >= 0) {
  1473. if (data[i].TestRightStr) {
  1474. data[i].TestRightStr = data[i].TestRightStr.split(",");
  1475. }
  1476. if (data[i].TestWrongStr) {
  1477. data[i].TestWrongStr = data[i].TestWrongStr.split(",");
  1478. }
  1479. if (data[i].TestSkipStr) {
  1480. data[i].TestSkipStr = data[i].TestSkipStr.split(",");
  1481. }
  1482. if (data[i].TestExistStr) {
  1483. data[i].TestExistStr = data[i].TestExistStr.split(",");
  1484. }
  1485. }
  1486. if (!data[i].TestRightStr)
  1487. data[i].TestRightStr = "";
  1488. if (!data[i].TestWrongStr)
  1489. data[i].TestWrongStr = "";
  1490. if (!data[i].TestSkipStr)
  1491. data[i].TestSkipStr = "";
  1492. if (!data[i].TestExistStr)
  1493. data[i].TestExistStr = "";
  1494. }
  1495. for (var i = 0; i < dataTemp.length; i++) {
  1496. var name = dataTemp[i].Name[0].split(" ");
  1497. for (var j = 0; j < GradeArr.length; j++) {
  1498. var item = GradeArr[j];
  1499. if (name[0] == item.Name) {
  1500. for (var k = 0; k < item.List.length; k++) {
  1501. //音标计算进度
  1502. if (item.List[k].ID == 101 && dataTemp[i].BookID == 101) {
  1503. for (var n = 1; n <= 4; n++) {
  1504. if (Number(dataTemp[i].Name[2]) == n && dataTemp[i].IsFinished == 1)
  1505. item.List[k].Finish++;
  1506. }
  1507. }
  1508. //古诗词计算进度
  1509. else if (item.List[k].ID == dataTemp[i].BookID && dataTemp[i].TestType == "recite" && dataTemp[i].IsFinished == 1)
  1510. item.List[k].Finish = 1;
  1511. else {
  1512. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
  1513. if (dataTemp[i].IsFinished == 1)
  1514. item.List[k].Finish++;
  1515. }
  1516. }
  1517. }
  1518. }
  1519. }
  1520. }
  1521. for (var j = 0; j < GradeArr.length; j++) {
  1522. var item = GradeArr[j];
  1523. for (var k = 0; k < item.List.length; k++) {
  1524. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  1525. item.List[k].NameStr = item.List[k].Name.replace("语文", "");
  1526. }
  1527. }
  1528. wx.setStorageSync("UserTestReport", data);
  1529. callback(data, GradeArr);
  1530. }
  1531. });
  1532. });
  1533. }
  1534. function showHelp(obj,myClass,textTopDirection,helpText,closePos){
  1535. setTimeout(function(){
  1536. wx.createSelectorQuery().select(myClass).boundingClientRect(function (rect) {
  1537. console.log("rect.left:"+rect.left);
  1538. console.log("rect.top:"+rect.top);
  1539. console.log("rect.width:"+rect.width);
  1540. console.log("rect.height:"+rect.height);
  1541. var textTop=rect.bottom+5;
  1542. if (textTopDirection=="up")
  1543. textTop=rect.top-47;
  1544. if (!closePos)
  1545. closePos="Right";
  1546. obj.setData({
  1547. HelpTop:rect.top,
  1548. HelpWidth1:rect.left,
  1549. HelpHeight1:rect.height,
  1550. HelpLeft2:rect.right,
  1551. HelpHeight2:rect.height,
  1552. HelpBottom:rect.bottom-1,
  1553. HelpTextTop:textTop,
  1554. HelpText:helpText,
  1555. HelpClosePos:closePos,
  1556. });
  1557. }).exec();
  1558. },500);
  1559. }
  1560. function gotoTaskList(id,cardType) {
  1561. wx.showLoading({
  1562. title: '请稍候',
  1563. });
  1564. setTimeout(function () {
  1565. wx.hideLoading();
  1566. }, 5000);
  1567. var that = this;
  1568. //未练完的题卡
  1569. if (id == 1) {
  1570. getTaskTodayList(function (task) {
  1571. var list = [];
  1572. for (var i = 0; i < task.ListNew.length; i++) {
  1573. list.push(task.ListNew[i]);
  1574. }
  1575. for (var i = 0; i < task.ListHistory.length; i++) {
  1576. list.push(task.ListHistory[i]);
  1577. }
  1578. for (var i = 0; i < task.ListReview.length; i++) {
  1579. list.push(task.ListReview[i]);
  1580. }
  1581. app.globalData.CardList = list;
  1582. wx.navigateTo({
  1583. url: '../main/mainlist?type=1&Count=' + list.length,
  1584. });
  1585. });
  1586. } else {
  1587. var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID + "&IsToday=2&CardType="+ cardType +"&OrderType=ac.LastTime desc";
  1588. getData(url, function (data) {
  1589. if (data) {
  1590. var list = [];
  1591. for (var i = 0; i < data.List.length; i++) {
  1592. data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
  1593. list.push(data.List[i]);
  1594. }
  1595. app.globalData.CardList = list;
  1596. wx.navigateTo({
  1597. url: '../main/mainlist?type=2&Count=' + data.length,
  1598. });
  1599. }
  1600. });
  1601. }
  1602. }
  1603. function resetTodayTask(){
  1604. wx.showModal({
  1605. title: '提醒',
  1606. content: '此操作无法撤销。确认重置今天的任务量吗?',
  1607. showCancel:true,
  1608. cancelText:"确定",
  1609. confirmColor:"#000000",
  1610. confirmText:"取消",
  1611. success (res) {
  1612. if (res.confirm) {
  1613. //console.log('用户点击取消');
  1614. } else if (res.cancel) {
  1615. //console.log('用户点击确定')
  1616. var url = "ResetMiaoguoCardTask?UserID=" + app.globalData.userInfo.UserID;
  1617. getData(url, function (data) {
  1618. if (data) {
  1619. wx.showModal({
  1620. title: '提醒',
  1621. content: '重置已完成。请重新开始今天的练习吧。',
  1622. showCancel:false,
  1623. confirmColor:"#000000",
  1624. confirmText:"返回首页",
  1625. success (res) {
  1626. wx.navigateBack({
  1627. delta: 2,
  1628. });
  1629. }
  1630. });
  1631. }
  1632. });
  1633. }
  1634. }
  1635. });
  1636. }
  1637. //下载图片
  1638. function downloadFile(url,isShowLoading,callback){
  1639. if (isShowLoading){
  1640. wx.showLoading({
  1641. title: '下载中',
  1642. });
  1643. setTimeout(function () {
  1644. wx.hideLoading();
  1645. }, 5000);
  1646. }
  1647. wx.downloadFile({
  1648. url: url,
  1649. success(resDownload) {
  1650. // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  1651. if (resDownload.statusCode === 200) {
  1652. callback(resDownload.tempFilePath);
  1653. }
  1654. else if (resDownload.statusCode === 404){
  1655. wx.showToast({
  1656. title: '图片不存在',
  1657. });
  1658. }
  1659. if (isShowLoading)
  1660. wx.hideLoading();
  1661. },
  1662. fail: function (e) {
  1663. if (isShowLoading)
  1664. wx.hideLoading();
  1665. wx.showToast({
  1666. title: '下载失败',
  1667. });
  1668. }
  1669. });
  1670. }
  1671. //生成图片
  1672. function buildImage(width,height,canvas,callback){
  1673. var that=this;
  1674. wx.showLoading({
  1675. title: '生成中',
  1676. });
  1677. setTimeout(function () {
  1678. //console.log("生成后1");
  1679. wx.canvasToTempFilePath({
  1680. x: 0,
  1681. y: 0,
  1682. width: width,
  1683. height: height,
  1684. destWidth: width,
  1685. destHeight: height,
  1686. canvas: canvas,
  1687. success: function (res2) {
  1688. wx.hideLoading();
  1689. //console.log("生成后2");
  1690. wx.previewImage({
  1691. current: res2.tempFilePath, // 当前显示图片的http链接
  1692. urls: [res2.tempFilePath] // 需要预览的图片http链接列表
  1693. });
  1694. callback();
  1695. },
  1696. fail: function (e) {
  1697. wx.hideLoading();
  1698. //console.log("生成错误:"+e);
  1699. }
  1700. })
  1701. }, 500);
  1702. }
  1703. function showHelpImage() {
  1704. var arr=[];
  1705. arr.push(app.globalData.uploadImageUrl+"web/doc_xnl_36_1.png")
  1706. arr.push(app.globalData.uploadImageUrl+"web/doc_xnl_36_2.png")
  1707. wx.previewImage({
  1708. current: arr[0],
  1709. urls: arr,
  1710. });
  1711. }
  1712. module.exports = {
  1713. getData: getData,
  1714. postData: postData,
  1715. payMoney: payMoney,
  1716. getLocalHost: getLocalHost,
  1717. getTimeFormat: getTimeFormat,
  1718. getWindowHeight: getWindowHeight,
  1719. getStorageValue: getStorageValue,
  1720. getProgramList: getProgramList,
  1721. gotoFeedback: gotoFeedback,
  1722. getDetailColor: getDetailColor,
  1723. changeStringToView: changeStringToView,
  1724. changeViewToString: changeViewToString,
  1725. encryptUrl: EncryptUrl,
  1726. decryptUrl: DecryptUrl,
  1727. saveTempImage: saveTempImage,
  1728. getTempImage: getTempImage,
  1729. getTaskTodayList: getTaskTodayList,
  1730. updateSearchList: updateSearchList,
  1731. checkIsIPhoneX: checkIsIPhoneX,
  1732. getMemoryLevelAll: getMemoryLevelAll,
  1733. getMemoryLevel: getMemoryLevel,
  1734. getShareImageBackColor: getShareImageBackColor,
  1735. UpdateMiaoguoCardTodayAll: UpdateMiaoguoCardTodayAll,
  1736. setCollect: setCollect,
  1737. UploadUserConfig: UploadUserConfig,
  1738. getServerImage: getServerImage,
  1739. getBaiduToken: getBaiduToken,
  1740. getPinyinNormal: getPinyinNormal,
  1741. getHanzi: getHanzi,
  1742. getEnglish: getEnglish,
  1743. GetHanziUnitWords: GetHanziUnitWords,
  1744. GetTestReportInfo: GetTestReportInfo,
  1745. getUserConfig: getUserConfig,
  1746. getAwardData: getAwardData,
  1747. replaceCardInfoString: replaceCardInfoString,
  1748. searchInfomation: searchInfomation,
  1749. downloadBishunKaitiImage: downloadBishunKaitiImage,
  1750. GetSoundError: GetSoundError,
  1751. GetTestReportList: GetTestReportList,
  1752. ShowHelp:showHelp,
  1753. GotoTaskList:gotoTaskList,
  1754. ResetTodayTask:resetTodayTask,
  1755. DownloadFile:downloadFile,
  1756. BuildImage:buildImage,
  1757. ShowHelpImage:showHelpImage,
  1758. getServerSoundErrorArr:getServerSoundErrorArr,
  1759. }