main.js 60 KB

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