main.js 72 KB

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