main.js 60 KB

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