main.js 61 KB

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