main.js 60 KB

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