| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954 |
- import common from '../utils/util';
- import constant from '../utils/constant';
- var app = getApp();
- var dataSendTimeout = 0;
- function getData(url, callback) {
- if (!app.globalData.IsProduction)
- console.log("加密前的结果为===", url);
- var url = common.Encrypt(url);
- //console.log("加密后的结果为===",url);
- wx.request({
- url: app.globalData.serverUrl + url,
- success: function (res) {
- if (res.statusCode)
- common.checkError(res.statusCode);
- var data = res.data.result;
- callback(data);
- },
- fail: function () {
- wx.showToast({
- title: '系统忙请稍候',
- // image: "../images/universalpic_warning_white_126x120.png",
- duration: 3000
- });
- },
- });
- }
- function postData(url, postData, callback) {
- var url = common.Encrypt(url);
- //console.log("加密后的结果为===",url);
- wx.request({
- url: app.globalData.serverUrl + url,
- method: "POST",
- data: postData,
- success: function (res) {
- if (res.statusCode)
- common.checkError(res.statusCode);
- var data = res.data.result;
- callback(data);
- },
- fail: function () {
- wx.showToast({
- title: '系统忙请稍候',
- duration: 3000
- });
- },
- });
- }
- function getLocalHost(callback) {
- if (!app.globalData.IsProduction) {
- var url = common.Encrypt("Ping");
- wx.request({
- url: app.globalData.serverUrlLocalhost + url,
- success: function (res) {
- app.globalData.serverUrl = app.globalData.serverUrlLocalhost;
- callback();
- },
- fail: function () {
- app.globalData.serverUrl = app.globalData.serverUrlServer;
- callback();
- },
- });
- } else {
- app.globalData.serverUrl = app.globalData.serverUrlServer;
- callback();
- }
- }
- function getBaiduToken() {
- var that = this
- //调用登录接口
- wx.login({
- success: function (res0) {
- getData('GetBaiduToken20220922?ProgramID='+app.globalData.ProgramID+'&Code='+res0.code, function (data) {
- if (data) {
- app.globalData.BaiduToken = data;
- //console.log(app.globalData.BaiduToken);
- }
- });
- }
- });
- }
- function payMoney(payType, remark, money, detail, callback) {
- console.log(money);
- if (app.globalData.userInfo.UserID < 8 ||
- app.globalData.userInfo.UserID == 3089)
- money = 0.01;
- //登录认证
- wx.login({
- success: function (res) {
- if (res.code) {
- console.log('获取用户登录态成功!' + res.code);
- //预支付
- getData('ProductPayLogin500?code=' + res.code + '&payType=' + payType + '&money=' + money + '&detail=' + detail + '&productID=' + app.globalData.ProgramID + '&Remark=' + remark, function (data) {
- if (data && data.timeStamp) {
- //微信支付
- wx.requestPayment({
- 'timeStamp': data.timeStamp.toString(),
- 'nonceStr': data.nonceStr,
- 'package': data.package,
- 'signType': 'MD5',
- 'paySign': data.paySign,
- 'success': function (res3) {
- console.log("success:" + res3);
- callback(data);
- },
- 'fail': function (err) {
- if (err && err.errMsg && err.errMsg.indexOf("fail cancel")) {
- } else {
- wx.showToast({
- title: '系统忙请稍候',
- duration: 3000
- });
- }
- }
- });
- }
- });
- } else {
- console.log('获取用户登录态失败!' + res.errMsg);
- wx.showToast({
- title: '系统忙请稍候',
- duration: 3000
- });
- }
- }
- });
- }
- function getTimeFormat(duration) {
- //console.log("duration:" + duration);
- var arr = ['', '', '']
- if (duration.indexOf("'") > 0)
- arr[0] = duration.substring(0, duration.indexOf("'"));
- if (duration.indexOf(".") > 0) {
- arr[1] = duration.substring(duration.indexOf("'") + 1, duration.indexOf(".") + 1);
- arr[2] = duration.substring(duration.indexOf(".") + 1, duration.indexOf('"'));
- } else {
- arr[1] = duration.substring(duration.indexOf("'") + 1, duration.indexOf('"'));
- }
- return arr;
- }
- function getWindowHeight() {
- var height = app.globalData.systemInfo.windowHeight;
- //console.log("app.globalData.systemInfo.windowHeight:" + app.globalData.systemInfo.windowHeight * 2);
- if (app.globalData.systemInfo.model) {
- if (height == 504 && (
- app.globalData.systemInfo.model.indexOf("iPhone 6<") >= 0 ||
- app.globalData.systemInfo.model.indexOf("iPhone 7<") >= 0 ||
- app.globalData.systemInfo.model.indexOf("iPhone 6s<") >= 0 ||
- app.globalData.systemInfo.model.indexOf("iPhone 5") >= 0 ||
- app.globalData.systemInfo.model.indexOf("iPhone SE") >= 0
- )) {
- height = 596;
- } else if (app.globalData.systemInfo.model.indexOf("iPad") >= 0) {
- height = 470;
- }
- }
- height = height * 2;
- if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0) {
- height = height + 168;
- } else {
- height = height + 50;
- }
- //console.log("height:" + height);
- //var height = app.globalData.systemInfo.screenHeight * 2;
- return height;
- }
- //获取存储数据,若不存在,则获得缺省值。
- function getStorageValue(obj, name, defaultStatus, callback) {
- wx.getStorage({
- key: name,
- success: function (res) {
- obj.data[name] = res.data;
- obj.setData(obj.data);
- callback();
- },
- fail: function (res) {
- obj.data[name] = defaultStatus;
- obj.setData(obj.data);
- callback();
- },
- });
- }
- function getProgramList() {
- return [{
- id: 89,
- appId: 'wx46a7b4c420e6d38f',
- path: 'pages/index/start?SourceID=' + app.globalData.ProgramID,
- },
- {
- id: 98,
- appId: 'wx331e8dd070f01d0e',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- id: 99,
- appId: 'wxb54a6d5aff836ee3',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- id: 106,
- appId: 'wx313a8f2c0741efe1',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- ];
- }
- function gotoFeedback() {
- wx.navigateToMiniProgram({
- appId: "wx80059777521b897c",
- path: "pages/index/feedback",
- extraData: {},
- success(res) {
- // 打开成功
- }
- });
- }
- function changeViewToString(content) {
- var str = content;
- if (str.constructor == Array) {
- if (str.length > 0)
- str = str.join(",");
- else
- str = "";
- }
- if (!str)
- str = ""
- else {
- str = str.replace(/\n\n\n/g, "\n\n");
- if (str.indexOf("\n") == 0 && str.indexOf("[") == 1) {
- str = str.substr(1);
- }
- if (str.lastIndexOf("\n") == str.length - 1) {
- str = str.substr(0, str.length - 1);
- }
- }
- return str;
- }
- function EncryptUrl(str) {
- if (str && str.constructor && str.constructor == Array) {
- if (str.length > 0)
- str = str.join(",");
- else
- str = "";
- }
- if (str) {
- str = str.replace(/baidu.com/g, "#####1#####");
- str = str.replace(/iciba.com/g, "#####2#####");
- str = str.replace(/https:\/\/pinyin-1253256735.file.myqcloud.com\/sounds/g, "#####3#####");
- str = str.replace(/https:\/\/miaguo-1253256735.file.myqcloud.com/g, "#####4#####");
- if (str.substr(0, 1) == "\n")
- str = str.substr(1);
- }
- return str;
- }
- function DecryptUrl(str) {
- if (str.constructor == Array) {
- if (str.length > 0)
- str = str.join(",");
- else
- str = "";
- }
- if (str) {
- str = str.replace(/#####1#####/g, "baidu.com");
- str = str.replace(/#####2#####/g, "iciba.com");
- str = str.replace(/#####3#####/g, "https://pinyin.kylx365.com/sounds");
- str = str.replace(/#####4#####/g, "https://miaguo-1253256735.file.myqcloud.com");
- }
- return str;
- }
- function changeStringToView(field) {
- var result = {};
- result.Field = [
- []
- ];
- result.Images = [];
- for (var j = 0; j < field.length; j++) {
- if (j == 0) {
- if (field[j].ContentType == 0 && field[j].Content && field[j].Content.length > 0) {
- result.Tags = field[j].Content.toString().split(",");
- } else {
- result.Tags = [];
- }
- } else {
- if (field[j].ContentType == j && field[j].Content && field[j].Content.length > 0) {
- var arrResult = [],
- arrSoundMark = [];
- var str = field[j].Content.toString();
- str = DecryptUrl(str);
- if (str.indexOf("[读") > 0)
- str = str.replace(/\[读/g, "\n[读");
- str = str.replace(/\[图/g, "\n[图");
- if (str.indexOf("[音") > 0)
- str = str.replace(/\[音/g, "\n[音");
- str = str.replace(/\[\/读\]/g, "[\/读]\n");
- str = str.replace(/\[\/图\]/g, "[\/图]\n");
- str = str.replace(/\[\/音\]/g, "[\/音]\n");
- str = str.replace(/\n\n\n/g, "\n\n");
- var arr = str.split("\n");
- for (var k = 0; k < arr.length; k++) {
- if (arr[k].indexOf("[图") >= 0 && arr[k].indexOf("[/图]") > 0) {
- var obj = {};
- obj.Type = "image";
- if (arr[k].indexOf("[图") >= 0) {
- obj.ContentServer = arr[k].substring(arr[k].indexOf("[图") + 3, arr[k].indexOf("[/图]"));
- const w = 650;
- if (obj.ContentServer.indexOf("w='") >= 0 && obj.ContentServer.indexOf("h='") >= 0) {
- obj.Width = obj.ContentServer.substring(obj.ContentServer.indexOf("w='") + 3, obj.ContentServer.indexOf("h='") - 2);
- obj.Height = obj.ContentServer.substring(obj.ContentServer.indexOf("h='") + 3, obj.ContentServer.indexOf("']"));
- obj.Height = Math.round((w * Number(obj.Height)) / Number(obj.Width));
- obj.Width = w;
- } else {
- obj.Width = "";
- obj.Height = "";
- }
- obj.ContentServer = obj.ContentServer.substring(obj.ContentServer.indexOf("]") + 1);
- obj.Content = getTempImage(obj.ContentServer);
- if (obj.Content.lastIndexOf("fm=58") >= 0)
- obj.IsShowBishun = true;
- else if (obj.Content.indexOf("hanyu-word-gif") > 0)
- obj.IsShowKaiti = true;
- result.Images.push(obj.Content);
- }
- arrResult.push(obj);
- } else if (arr[k].indexOf("[特]") >= 0 && arr[k].indexOf("[/特]") > 0) {
- var obj = {};
- obj.Type = "bigword";
- var content = arr[k].substring(arr[k].indexOf("[特]")+3,arr[k].indexOf("[/特]"));
- obj.Content = content;
- arrResult.push(obj);
- } else if ((arr[k].indexOf("[线]") >= 0 && arr[k].indexOf("[/线]") > 0) || (arr[k].indexOf("[光]") >= 0 && arr[k].indexOf("[/光]") > 0)) {
- var obj;
- var content = [],
- temp = arr[k];
- do {
- var num1 = temp.indexOf("[线]");
- var num2 = temp.indexOf("[光]");
- if (num1 >= 0 || num2 >= 0) {
- if ((num1 < num2 && num1 >= 0 && num2 >= 0) || (num1 >= 0 && num2 < 0)) {
- var temp1 = temp.substring(0, temp.indexOf("[线]"));
- if (temp1) {
- content.push({
- key: "normal",
- value: temp1,
- });
- } else {
- if (temp && temp.indexOf("[线]") < 0) {
- content.push({
- key: "normal",
- value: temp,
- });
- temp = "";
- }
- }
- } else if ((num1 > num2 && num1 >= 0 && num2 >= 0) || (num1 < 0 && num2 >= 0)) {
- var temp1 = temp.substring(0, temp.indexOf("[光]"));
- if (temp1) {
- content.push({
- key: "normal",
- value: temp1,
- });
- } else {
- if (temp && temp.indexOf("[光]") < 0) {
- content.push({
- key: "normal",
- value: temp,
- });
- temp = "";
- }
- }
- } else {
- content.push({
- key: "normal",
- value: temp,
- });
- temp = "";
- }
- } else {
- content.push({
- key: "normal",
- value: temp,
- });
- temp = "";
- }
- if (temp.length > 0 && (num1 >= 0 || num2 >= 0)) {
- if ((num1 < num2 && num1 >= 0 && num2 >= 0) || (num1 >= 0 && num2 < 0)) {
- temp = temp.substr(temp.indexOf("[线]") + 3);
- temp1 = temp.substring(0, temp.indexOf("[/线]"));
- if (temp1) {
- content.push({
- key: "line",
- value: temp1,
- });
- }
- temp = temp.substr(temp.indexOf("[/线]") + 4);
- } else if ((num1 > num2 && num1 >= 0 && num2 >= 0) || (num1 < 0 && num2 >= 0)) {
- temp = temp.substr(temp.indexOf("[光]") + 3);
- temp1 = temp.substring(0, temp.indexOf("[/光]"));
- if (temp1) {
- content.push({
- key: "highlighter",
- value: temp1,
- });
- }
- temp = temp.substr(temp.indexOf("[/光]") + 4);
- } else
- temp = "";
- } else
- temp = "";
- }
- while (temp.length > 0);
- obj = {};
- obj.Type = "line";
- obj.Content = content;
- arrResult.push(obj);
- } else if (arr[k].indexOf("[读") >= 0 && arr[k].indexOf("[/读]") > 0) {
- var obj = {};
- obj.Type = "sound";
- if (arr[k].indexOf("[读]") >= 0) {
- obj.Content = arr[k].substring(arr[k].indexOf("[读]") + 3, arr[k].indexOf("[/读]"));
- } else {
- var tempIndex = arr[k].indexOf("\']") + 2;
- obj.Content = arr[k].substring(tempIndex, arr[k].indexOf("[/读]"));
- obj.SoundMark = arr[k].substring(arr[k].indexOf("src='") + 5, arr[k].indexOf("']"));;
- }
- arrResult.push(obj);
- } else if (arr[k].indexOf("[音") >= 0 && arr[k].indexOf("[/音]") > 0) {
- var obj = {};
- obj.Type = "recorder";
- var tempIndex = arr[k].indexOf("\']") + 2;
- //obj.Content = arr[k].substring(tempIndex, arr[k].indexOf("[/音]"));
- obj.SoundMark = arr[k].substring(arr[k].indexOf("url='") + 5, arr[k].indexOf("']"));;
- arrResult.push(obj);
- } else if (arr[k] != "") {
- var obj = {};
- obj.Type = "normal";
- obj.Content = arr[k];
- arrResult.push(obj);
- } else if (k > 0 && arr[k] == "") {
- var obj = {};
- obj.Type = "br";
- obj.Content = "";
- arrResult.push(obj);
- }
- var obj = {};
- obj.Type = "return";
- arrResult.push(obj);
- }
- //去掉前回车换行
- // while (arrResult[0].Type == "return" ||
- // arrResult[0].Type == "br") {
- // arrResult.shift();
- // if (arrResult.length == 0)
- // break;
- // }
- //去掉后回车换行
- for (var i = arrResult.length - 1; i >= 0; i--) {
- if (arrResult[i].Type == "return" ||
- arrResult[i].Type == "br")
- arrResult.pop();
- else {
- break;
- }
- }
- result.Field.push(arrResult);
- } else {
- result.Field.push([]);
- }
- }
- }
- return result;
- }
- //得到当天任务
- function getTaskTodayList(callback) {
- var isNotData = true;
- var intervalTask = setTimeout(function () {
- if (isNotData) {
- wx.showLoading({
- title: '请稍候',
- mask: true,
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 60000);
- }
- }, 2000);
- var that = this;
- var url = 'GetMiaoguoCardToday2?UserID=' + app.globalData.userInfo.UserID;
- getData(url, function (data) {
- clearTimeout(intervalTask);
- if (isNotData) {
- wx.hideLoading();
- }
- isNotData = false;
- if (data) {
- app.globalData.TaskToday = data;
- callback(data);
- }
- });
- }
- function getTempImage(serverUrl) {
- if (serverUrl.indexOf("miaguo-1253256735") >= 0) {
- var list = wx.getStorageSync("TempImageList");
- if (!list)
- list = [];
- for (var i = 0; i < list.length; i++) {
- if (list[i].ServerUrl == serverUrl) {
- return list[i].TempUrl;
- break;
- }
- }
- }
- return serverUrl;
- }
- function getServerImage(tempUrl) {
- if (tempUrl.indexOf("http") < 0) {
- var list = wx.getStorageSync("TempImageList");
- if (!list)
- list = [];
- for (var i = 0; i < list.length; i++) {
- if (list[i].TempUrl == tempUrl) {
- return list[i].ServerUrl;
- break;
- }
- }
- return ""
- }
- }
- function saveTempImage(serverUrl, tempUrl) {
- if (tempUrl.indexOf("http") < 0) {
- var list = wx.getStorageSync("TempImageList");
- if (!list)
- list = [];
- var b = false;
- for (var i = 0; i < list.length; i++) {
- if (list[i].ServerUrl == serverUrl) {
- list[i].TempUrl = tempUrl;
- b = true;
- break;
- }
- }
- if (!b) {
- list.push({
- "ServerUrl": serverUrl,
- "TempUrl": tempUrl
- });
- }
- if (list.length > 200) {
- list.pop();
- }
- wx.setStorageSync("TempImageList", list);
- }
- }
- function UpdateMiaoguoCardTodayAll(isShowLoading, callback) {
- var that = this;
- if (isShowLoading) {
- wx.showLoading({
- title: '请稍候',
- mask: true,
- });
- clearTimeout(dataSendTimeout);
- dataSendTimeout = setTimeout(function () {
- wx.hideLoading();
- }, 60000);
- }
- var list = wx.getStorageSync("ListTaskFinished");
- if (list && list.length > 0) {
- var arr = [];
- for (var i = 0; i < list.length; i++) {
- var obj = {};
- obj.MiaoguoCardID = list[i].Card.MiaoguoCardID;
- obj.IntervalTime = list[i].IntervalTime;
- obj.BtnNumber = list[i].BtnNumber;
- obj.FontSize = list[i].Card.FontSize;
- obj.Duration = list[i].Duration;
- obj.LearningType = list[i].LearningType;
- obj.IsCollect = list[i].Card.IsCollect;
- obj.LastTime = list[i].LastTime;
- arr.push(obj);
- }
- var userid=wx.getStorageSync("ListTaskFinishedUserID");
- that.postData('UpdateMiaoguoCardTodayAll?UserID=' + userid, {
- List: arr,
- }, function (data) {
- if (isShowLoading) {
- wx.hideLoading();
- clearTimeout(dataSendTimeout);
- }
- if (data) {
- wx.removeStorageSync("ListTaskFinished");
- wx.removeStorageSync("ListTaskFinishedUserID");
- }
- if (callback) {
- callback();
- }
- });
- } else {
- wx.hideLoading();
- clearTimeout(dataSendTimeout);
- if (callback) {
- callback();
- }
- }
- }
- function updateSearchList(obj, callback) {
- var arr = wx.getStorageSync("SearchWord3");
- if (!arr)
- arr = [];
- if (obj && obj.Type && obj.Type == "shici") {
- if (obj.Value.CHN.ShiciTitle)
- obj.Key = obj.Value.CHN.ShiciTitle;
- if (obj.Key.indexOf("《") == 0)
- obj.Key = obj.Key.substring(1, obj.Key.length - 1);
- }
- for (var i = 0; i < arr.length; i++) {
- if (obj.Key && arr[i].Key == obj.Key) {
- if (obj.Type == "shici") {
- if (arr[i].ShiciUrl == obj.ShiciUrl) {
- obj.Value = arr[i].Value;
- arr.splice(i, 1);
- break;
- }
- } else {
- var b = true;
- if (obj.Type && arr[i].Type && arr[i].Type != obj.Type)
- b = false;
- if (obj.Author && arr[i].Author && arr[i].Author != obj.Author)
- b = false;
- if (b) {
- obj.Value = arr[i].Value;
- arr.splice(i, 1);
- break;
- }
- }
- }
- }
- if (obj.Key)
- arr.unshift(obj);
- if (arr.length > 30) {
- arr.pop();
- }
- wx.setStorageSync("SearchWord3", arr);
- app.globalData.SearchItem = obj.Value;
- if (obj.TypeName)
- app.globalData.SearchItem.TypeName = obj.TypeName;
- if (callback)
- callback();
- }
- function checkIsIPhoneX() {
- var isIphoneX = false;
- if (app.globalData.systemInfo.model.indexOf("iPhone X") >= 0 ||
- app.globalData.systemInfo.model.indexOf("iPhone X") >= 0) {
- isIphoneX = true;
- }
- return isIphoneX;
- }
- //设置收藏
- function setCollect(id, collect, callback) {
- var that = this;
- if (collect) {
- wx.showToast({
- title: '加注成功',
- image: '../images/universalpic_star_white_120x120.png',
- });
- } else {
- wx.showToast({
- title: '清除成功',
- image: '../images/universalpic_star_whiteline_120x120.png',
- });
- }
- getData("UpdateMiaoguoCardInfo?UserID=" + app.globalData.userInfo.UserID + "&MiaoguoCardID=" + id + "&IsCollect=" + collect, function (data) {
- if (callback)
- callback();
- });
- }
- function getMemoryLevelAll() {
- return constant.arrMemoryLevelAll;
- }
- function getMemoryLevel(index, number, time) {
- var arr = getMemoryLevelAll();
- if (index < 1)
- return arr[index].Value[number].Name;
- else
- return replaceStr(time);
- function replaceStr(data) {
- var result = "";
- if (data.indexOf("d") > 0) {
- var dayNum = Number(data.replace("d", ""));
- if (dayNum >= 365) {
- var year1 = Math.floor(dayNum / 365);
- var year = year1 + Math.round(10 * (dayNum - year1 * 365) / 365) / 10;
- result = year + "年后";
- } else {
- if (dayNum > 31) {
- var month1 = Math.floor(dayNum / 30);
- var month = month1 + Math.round(10 * (dayNum - month1 * 30) / 30) / 10;
- result = month + "月后";
- } else {
- result = Number(data.replace("d", ""));
- if (result == 1)
- result = "明天";
- else if (result == 2)
- result = "后天";
- else
- result = (result - 1) + "天后";
- }
- }
- } else if (data.indexOf("m") > 0)
- result = data.replace("m", "分钟内");
- return result;
- }
- }
- //得到要检验的汉字列表
- function GetHanziUnitWords(unitsID, testType, callback) {
- var url = 'GetHanziUnitWords?UnitID=' + unitsID;
- if (testType)
- url += "&TestType=" + testType;
- getData(url, function (data) {
- if (data) {
- var TaskList = [];
- var words = data;
- //若是单字
- if (words[0].Pinyin) {
- for (var k = 0; k < words.length; k++) {
- var taskInfo = {
- FontSize: 144,
- TagWidth: 136,
- Content: [{
- ContentType: 0,
- Content: []
- },
- {
- ContentType: 1,
- Content: []
- },
- {
- ContentType: 2,
- Content: []
- },
- ]
- };
- taskInfo.Word = words[k].Name;
- var pinyinNormal = "(" + getPinyinNormal(words[k].Pinyin) + ")";
- var combineWords = common.ReplaceAllString(words[k].CombineWords, words[k].Name, words[k].Name + pinyinNormal);
- taskInfo.ReadString = words[k].Name + pinyinNormal + "," + combineWords + "的" + words[k].Name + pinyinNormal;
- if (testType == "read") {
- taskInfo.Content[0].Content = ["怎么念"];
- var question = words[k].CombineWords;
- question = common.ReplaceAllString(question, words[k].Name, "(" + words[k].Name + ")");
- taskInfo.Content[1].Content = question;
- var answer = "[读 src='" + taskInfo.ReadString + "']" + words[k].Pinyin + "[/读]";
- taskInfo.Content[2].Content = answer;
- if (words[k].CombineWords.length > 6) {
- taskInfo.FontSize = 108;
- if (words[k].CombineWords.length > 10) {
- taskInfo.FontSize = 68;
- }
- }
- } else if (testType == "write") {
- taskInfo.Content[0].Content = ["怎么写"];
- var question = words[k].CombineWords;
- //var question2 = common.ReplaceAllString(question, words[k].Name, words[k].Pinyin);
- var question2 = words[k].CombineWords2;
- question = "[读 src='" + taskInfo.ReadString + "']" + question2 + "[/读]"
- taskInfo.Content[1].Content = question;
- var answer = words[k].Name;
- answer += "[图 w='650' h='650']" + words[k].KaitiUrl + "[/图]";
- taskInfo.Content[2].Content = answer;
- if (question2.length > 6) {
- taskInfo.FontSize = 108;
- if (question2.length > 10) {
- taskInfo.FontSize = 68;
- if (question2.length > 14) {
- taskInfo.FontSize = 48;
- }
- }
- }
- }
- taskInfo.ContentNew = changeStringToView(taskInfo.Content);
- TaskList.push(taskInfo);
- }
- }
- else { //若是词语
- for (var k = 0; k < words.length; k++) {
- var taskInfo = words[k];
- taskInfo.TagWidth=136;
- taskInfo.ContentNew = changeStringToView(taskInfo.Content);
- TaskList.push(taskInfo);
- }
- }
- callback(TaskList);
- } else {
- callback([]);
- }
- });
- }
- function GetTestReportInfo(reportid, callback) {
- var UserTestReport = wx.getStorageSync('UserTestReport');
- for (var n = 0; n < UserTestReport.length; n++) {
- if (UserTestReport[n].ID == reportid) {
- var name1 = UserTestReport[n].Name[0].split(" ");
- var name2 = UserTestReport[n].Name[1];
- if (name1[0].indexOf("英语") >= 0
- ||name1[0].indexOf("KET") >= 0
- ||name1[0].indexOf("单词") >= 0
- || name1[0].indexOf("1000") >= 0
- || name1[0].indexOf("2000") >= 0
- || name1[0].indexOf("4000") >= 0) {
- //console.log("英语");
- var wordStr = "";
- var userTestReportInfo = UserTestReport[n];
- var bookid = userTestReportInfo.BookID;
- var arrEnglist = [];
- if (bookid < 110) {
- if (name1[1] == "英文字母") {
- bookid = 100;
- 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";
- }
- } else if (bookid > 110 && bookid < 120) {
- arrEnglist = wx.getStorageSync("EnglishAll");
- arrEnglist = JSON.parse(arrEnglist);
- for (var i = 0; i < arrEnglist.length; i++) {
- if (arrEnglist[i].Name == name1[1]) {
- for (var j = 0; j < arrEnglist[i].Units.length; j++) {
- if (arrEnglist[i].Units[j].Name == name2) {
- wordStr = arrEnglist[i].Units[j].Words.join(",");
- break;
- }
- }
- }
- }
- }
- var tempRight = "," + userTestReportInfo.TestRightStr + ",";
- var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
- var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
- var tempExist = "," + userTestReportInfo.TestExistStr + ",";
- var unitsid = "";
- if (bookid > 100 && bookid < 110 && UserTestReport[n].Name[2]) {
- unitsid = Number(UserTestReport[n].Name[2]);
- } else if (bookid > 120 && bookid <= 124) {
- unitsid = Number(name2.replace("Lesson ", ""));
- } else if (bookid > 130 && bookid <= 170 && UserTestReport[n].Name[2]) {
- unitsid = Number(UserTestReport[n].Name[2]);
- }
-
- getData('GetTestEnglishWords?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + bookid + '&LessonID=' + unitsid + '&Words=' + wordStr + "&TestType=" + userTestReportInfo.TestType, function (data) {
- if (data) {
- var result = {};
- result.ID = userTestReportInfo.ID;
- result.IsFinished = userTestReportInfo.IsFinished;
- result.Name = userTestReportInfo.Name.join("#");
- result.TestType = userTestReportInfo.TestType;
- result.BookID = bookid;
- var TaskList = [];
- var words = data;
- for (var k = 0; k < words.length; k++) {
- var taskInfo = words[k];
- if (userTestReportInfo.TestType == "read") {
- taskInfo.TagWidth = 212;
- if ((name1[0].indexOf("1000")<0) && (name1[0].indexOf("4000")<0))
- taskInfo.FontSize = 108;
- } else if (userTestReportInfo.TestType == "write") {
- taskInfo.TagWidth = 186;
- taskInfo.FontSize = 36;
- }
- taskInfo.ContentNew = changeStringToView(taskInfo.Content);
- if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = 1;
- if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = -1;
- if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = 0;
- if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Css = "Select2";
- TaskList.push(taskInfo);
- }
- result.TestRightStr = "";
- result.TestWrongStr = "";
- result.TestSkipStr = "";
- result.TestExistStr = "";
- if (userTestReportInfo.TestRightStr)
- result.TestRightStr = userTestReportInfo.TestRightStr;
- if (userTestReportInfo.TestWrongStr)
- result.TestWrongStr = userTestReportInfo.TestWrongStr;
- if (userTestReportInfo.TestSkipStr)
- result.TestSkipStr = userTestReportInfo.TestSkipStr;
- if (userTestReportInfo.TestExistStr)
- result.TestExistStr = userTestReportInfo.TestExistStr;
- result.List = TaskList;
- callback(result);
- } else {
- callback({});
- }
- });
- } else if (name1[1].indexOf("拼音") >= 0) {
- //console.log("拼音");
- var userTestReportInfo = UserTestReport[n];
- var bookid = userTestReportInfo.BookID;
- var tempRight = "," + userTestReportInfo.TestRightStr + ",";
- var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
- var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
- var tempExist = "," + userTestReportInfo.TestExistStr + ",";
- var unitsid = "";
- var name2 = userTestReportInfo.Name[1];
- if (bookid == 43) {
- switch (name2) {
- case "声母1":
- unitsid = 431;
- break;
- case "声母2":
- unitsid = 432;
- break;
- case "声母3":
- unitsid = 433;
- break;
- case "韵母1":
- unitsid = 434;
- break;
- case "韵母2":
- unitsid = 435;
- break;
- case "韵母3":
- unitsid = 436;
- break;
- case "整体认读1":
- unitsid = 437;
- break;
- case "整体认读2":
- unitsid = 438;
- break;
- }
- }
- getData('GetPinyinUnitWords?TestType='+userTestReportInfo.TestType+'&UserID=' + app.globalData.userInfo.UserID + '&BookID=' + bookid + '&UnitID=' + unitsid + '&Word=' + name2, function (data) {
- if (data) {
- var result = {};
- result.ID = userTestReportInfo.ID;
- result.IsFinished = userTestReportInfo.IsFinished;
- result.Name = userTestReportInfo.Name.join("#");
- result.TestType = userTestReportInfo.TestType;
- result.BookID = bookid;
- var TaskList = [];
- var words = data;
- for (var k = 0; k < words.length; k++) {
- var taskInfo = words[k];
- taskInfo.TagWidth = 230;
- taskInfo.FontSize = 108;
- taskInfo.ContentNew = changeStringToView(taskInfo.Content);
- if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = 1;
- if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = -1;
- if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = 0;
- if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Css = "Select2";
- TaskList.push(taskInfo);
- }
- result.TestRightStr = "";
- result.TestWrongStr = "";
- result.TestSkipStr = "";
- result.TestExistStr = "";
- if (userTestReportInfo.TestRightStr)
- result.TestRightStr = userTestReportInfo.TestRightStr;
- if (userTestReportInfo.TestWrongStr)
- result.TestWrongStr = userTestReportInfo.TestWrongStr;
- if (userTestReportInfo.TestSkipStr)
- result.TestSkipStr = userTestReportInfo.TestSkipStr;
- if (userTestReportInfo.TestExistStr)
- result.TestExistStr = userTestReportInfo.TestExistStr;
- result.List = TaskList;
- callback(result);
- } else {
- callback({});
- }
- });
- } else if (name2 == "古诗文") {
- //todo
- //console.log("古诗文");
- var userTestReportInfo = UserTestReport[n];
- var tempRight = "," + userTestReportInfo.TestRightStr + ",";
- var tempWrong = "," + userTestReportInfo.TestWrongStr + ",";
- var tempSkip = "," + userTestReportInfo.TestSkipStr + ",";
- var tempExist = "," + userTestReportInfo.TestExistStr + ",";
- getData('GetTestAncientPoetryList?UserID=' + app.globalData.userInfo.UserID + '&BookID=' + userTestReportInfo.BookID, function (data) {
- if (data) {
- var result = {};
- result.ID = userTestReportInfo.ID;
- result.IsFinished = userTestReportInfo.IsFinished;
- result.Name = userTestReportInfo.Name.join("#");
- result.TestType = userTestReportInfo.TestType;
- result.BookID = userTestReportInfo.BookID;
- var TaskList = [];
- for (var k = 0; k < data.length; k++) {
- var taskInfo = data[k];
- taskInfo.TagWidth = 336;
- if (taskInfo.Word.length > 9)
- taskInfo.FontSize = 48;
- else
- taskInfo.FontSize = 64;
- taskInfo.ContentNew = changeStringToView(taskInfo.Content);
- if (tempRight.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = 1;
- if (tempWrong.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = -1;
- if (tempSkip.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Result = 0;
- if (tempExist.indexOf("," + taskInfo.Word + ",") >= 0)
- taskInfo.Css = "Select2";
- TaskList.push(taskInfo);
- }
- result.TestRightStr = "";
- result.TestWrongStr = "";
- result.TestSkipStr = "";
- result.TestExistStr = "";
- if (userTestReportInfo.TestRightStr)
- result.TestRightStr = userTestReportInfo.TestRightStr;
- if (userTestReportInfo.TestWrongStr)
- result.TestWrongStr = userTestReportInfo.TestWrongStr;
- if (userTestReportInfo.TestSkipStr)
- result.TestSkipStr = userTestReportInfo.TestSkipStr;
- if (userTestReportInfo.TestExistStr)
- result.TestExistStr = userTestReportInfo.TestExistStr;
- result.List = TaskList;
- callback(result);
- } else {
- callback({});
- }
- });
- } else {
- var obj = UserTestReport[n];
- if (obj.BookID >= 43 && obj.BookID <= 60)
- name1 = name1[0] + "生词" + name1[2].substr(0, 1);
- else if (obj.BookID == 73)
- name1 = name1[0] + name1[1].substr(2, 3) + name1[2];
- else if (obj.BookID == 86)
- name1 = name1[1] + name1[2];
- else
- name1 = name1[0] + name1[1].substr(2, 2) + "能力" + name1[2].substr(0, 1);
- var HanziAll = wx.getStorageSync('HanziAll');
- HanziAll = JSON.parse(HanziAll);
- for (var i = 0; i < HanziAll.length; i++) {
- if (name1 == HanziAll[i].Name) {
- for (var j = 0; j < HanziAll[i].Units.length; j++) {
- if (name2 == HanziAll[i].Units[j].Name) {
- GetHanziUnitWords(HanziAll[i].Units[j].ID, obj.TestType, function (list) {
- if (list) {
- for (var k = 0; k < list.length; k++) {
- if (obj.TestRightStr && obj.TestRightStr.indexOf(list[k].Word) >= 0)
- list[k].Result = 1;
- else if (obj.TestWrongStr && obj.TestWrongStr.indexOf(list[k].Word) >= 0)
- list[k].Result = -1;
- else if (obj.TestSkipStr && obj.TestSkipStr.indexOf(list[k].Word) >= 0)
- list[k].Result = 0;
- if (obj.TestExistStr && obj.TestExistStr.indexOf(list[k].Word) >= 0)
- list[k].Css = "Select2";
- }
- var result = {};
- result.ID = reportid;
- result.BookID = obj.BookID;
- result.TestType = obj.TestType;
- result.Name = obj.Name.join("#");
- result.IsFinished = obj.IsFinished;
- result.TestRightStr = obj.TestRightStr;
- result.TestWrongStr = obj.TestWrongStr;
- result.TestSkipStr = obj.TestSkipStr;
- result.TestExistStr = obj.TestExistStr;
- result.List = list;
- callback(result);
- } else
- callback({});
- });
- }
- }
- }
- }
- }
- }
- }
- }
- function getDetailColor(index) {
- var arrDetailColor = constant.arrDetailColor;
- if (index > 0)
- return arrDetailColor[index];
- else if (index == 0)
- return arrDetailColor[common.random(1, arrDetailColor.length - 1)];
- else if (index == -1)
- return arrDetailColor;
- }
- function getShareImageBackColor() {
- var arr = constant.arrShareImageBackColor;
- return arr[common.random(0, arr.length - 1)];
- }
- function getPinyinNormal(pinyin) {
- var result = "";
- var arr = constant.arrPinyin;
- for (var i = 0; i < arr.length; i++) {
- if (arr[i][1] == pinyin) {
- result = arr[i][0];
- break;
- }
- }
- return result;
- }
- function getHanzi(callback) {
- var that = this;
- wx.showLoading({
- title: '请稍候',
- mask: true,
- });
- var time = wx.getStorageSync("HanziUpdateTime");
- getData('GetHanziAll3?UpdateTime=' + time, function (data) {
- wx.hideLoading();
- if (data) {
- var arr = [];
- if (data.List) {
- arr = common.Decrypt(data.List);
- wx.setStorageSync("HanziAll", arr);
- wx.setStorageSync("HanziUpdateTime", data.UpdateTime);
- callback(true);
- } else {
- callback(false);
- }
- }
- });
- }
- function getServerSoundErrorArr(){
- var time = wx.getStorageSync("SoundErrorUpdateTime");
- getData('GetSoundErrorArr?UpdateTime=' + time, function (data) {
- if (data && data.List) {
- wx.setStorageSync("SoundErrorArr", data.List);
- wx.setStorageSync("SoundErrorUpdateTime", data.UpdateTime);
- }
- });
- }
- function getEnglish(callback) {
- var that = this;
- wx.showLoading({
- title: '请稍候',
- mask: true,
- });
- var time = wx.getStorageSync("HanziUpdateTime");
- getData('GetEnglishAll3?UpdateTime=' + time, function (data) {
- wx.hideLoading();
- if (data.EngList) {
- var arrEng = common.Decrypt(data.EngList);
- var arrNewConceptEngList = common.Decrypt(data.NewConceptEngList);
- var arrCambridgeEngList = common.Decrypt(data.CambridgeEngList);
- var arrEEWEngList = common.Decrypt(data.EEWEngList);
- var arrCEWEngList = common.Decrypt(data.CEWEngList);
- var arrBEWEngList = common.Decrypt(data.BEWEngList);
- var arrMiddleSchoolTestWords = common.Decrypt(data.MiddleSchoolTestWords);
- var arrPhoneticEngList = common.Decrypt(data.PhoneticEngList);
- wx.setStorageSync("EnglishAll", arrEng);
- wx.setStorageSync("NewConceptEngList", arrNewConceptEngList);
- wx.setStorageSync("CambridgeEngList", arrCambridgeEngList);
- wx.setStorageSync("EEWEngList", arrEEWEngList);
- wx.setStorageSync("CEWEngList", arrCEWEngList);
- wx.setStorageSync("BEWEngList", arrBEWEngList);
- wx.setStorageSync("MiddleSchoolTestWords", arrMiddleSchoolTestWords);
- wx.setStorageSync("PhoneticEngList", arrPhoneticEngList);
- wx.setStorageSync("EnglishUpdateTime", data.UpdateTime);
- callback(true);
- } else {
- callback(false);
- }
- });
- }
- function UploadUserConfig(callback) {
- var that = this;
- var param1 = {};
- param1.CardType = wx.getStorageSync("CardType");
- param1.CardMaxNumberNew = wx.getStorageSync("CardMaxNumberNew");
- param1.CardMaxNumberHistory = wx.getStorageSync("CardMaxNumberHistory");
- param1.CardMaxNumberNewUrgent = wx.getStorageSync("CardMaxNumberNewUrgent");
- param1.CardMaxNumberHistoryUrgent = wx.getStorageSync("CardMaxNumberHistoryUrgent");
- param1.SortTypeIndex = wx.getStorageSync("SortTypeIndex");
- param1.MemoryLevel = wx.getStorageSync("MemoryLevel");
- param1.ClickType = wx.getStorageSync("ClickType");
- param1.SecondConfigArray = wx.getStorageSync("SecondConfigArray").join(",");
- param1.ColorIndexArr = wx.getStorageSync("ColorIndexArr").join(",");
- param1.IsFolderPractice = wx.getStorageSync("IsFolderPractice");
- param1.IsAutoSound = wx.getStorageSync("IsAutoSound");
- var symboMain = wx.getStorageSync("SymbolMain");
- var symbol1 = [];
- for (var i = 0; i < symboMain.length; i++) {
- symbol1.push(symboMain[i].Name);
- }
- symbol1 = JSON.stringify(symbol1);
- param1.SymbolList = symbol1;
- var folderOrder = wx.getStorageSync("FolderOrderStr");
- if (folderOrder)
- param1.FolderOrder = folderOrder;
- //console.log(param1);
- that.postData('UploadUserConfig?Type=update&UserID=' + app.globalData.userInfo.UserID, param1, function (data) {
- if (callback) {
- callback();
- }
- });
- }
- function getAwardData(callback) {
- var that = this;
- that.getData('GetAwardInfo?UserID=' + app.globalData.userInfo.UserID, function (data) {
- if (data) {
- callback(data);
- } else
- callback([]);
- });
- }
- function getUserConfig() {
- var that = this;
- postData('UploadUserConfig?Type=getData&UserID=' + app.globalData.userInfo.UserID, {}, function (data) {
- if (data && !data.CardType)
- data.CardType = 0;
- wx.setStorageSync("CardType", data.CardType);
- wx.setStorageSync("CardMaxNumberNew", data.CardMaxNumberNew);
- wx.setStorageSync("CardMaxNumberHistory", data.CardMaxNumberHistory);
- wx.setStorageSync("CardMaxNumberNewUrgent", data.CardMaxNumberNewUrgent);
- wx.setStorageSync("CardMaxNumberHistoryUrgent", data.CardMaxNumberHistoryUrgent);
- wx.setStorageSync("SortTypeIndex", data.SortTypeIndex);
- wx.setStorageSync("MemoryLevel", data.MemoryLevel);
- wx.setStorageSync("ClickType", data.ClickType);
- wx.setStorageSync("SecondConfigArray", data.SecondConfigArray.split(","));
- wx.setStorageSync("ColorIndexArr", data.ColorIndexArr.split(","));
- wx.setStorageSync("FolderOrderStr", data.FolderOrder);
- wx.setStorageSync("IsFolderPractice", data.IsFolderPractice);
- wx.setStorageSync("IsAutoSound", data.IsAutoSound);
- var symbol1 = [];
- if (data.SymbolList) {
- for (var i = 0; i < data.SymbolList.length; i++) {
- var obj = {};
- obj.Name = data.SymbolList[i];
- obj.CSS = "btn2";
- symbol1.push(obj);
- }
- } else {
- symbol1 = app.globalData.SymbolMain;
- }
- if (symbol1.length > 0) {
- wx.setStorageSync("SymboMain", symbol1);
- app.globalData.SymbolMain = symbol1;
- }
- });
- }
- function replaceCardInfoString(str) {
- var that = this;
- //str = str.replace(/\[图]/g, "");
- //str = str.replace(/\[\/图\]/g, "");
- //console.log(str);
- if (str && str!=null) {
- var str2 = "";
- if (str.indexOf("[读 src=") >= 0) {
- str2 = str.substr(str.indexOf("[读 src="));
- str2 = str2.substring(0, str2.indexOf("]") + 1);
- }
- str = str.replace(str2, "");
- if (str.indexOf("[/读") >= 0) {
- str2 = str.substr(str.indexOf("[/读"));
- str2 = str2.substring(0, 4);
- }
- str = str.replace(str2, "");
- if (str.indexOf("[读 src=") >= 0) {
- str2 = str.substr(str.indexOf("[读 src"));
- str2 = str2.substring(0, str2.indexOf("/读]") + 3);
- }
- str = str.replace(str2, "");
- if (str.indexOf("[/读") >= 0) {
- str2 = str.substr(str.indexOf("[/读"));
- str2 = str2.substring(0, 4);
- }
- str = str.replace(str2, "");
- str = str.replace(/\[读]/g, "");
- str = str.replace(/\[\/读\]/g, "");
- var str3 = "";
- if (str.indexOf("[图") >= 0) {
- str3 = str.substr(str.indexOf("[图"));
- str3 = str3.substring(0, str3.indexOf("/图]") + 3);
- }
- str = str.replace(str3, "");
- if (str.indexOf("[图") >= 0) {
- str3 = str.substr(str.indexOf("[图"));
- str3 = str3.substring(0, str3.indexOf("/图]") + 3);
- }
- str = str.replace(str3, "");
- str = str.replace(/\[线]/g, "");
- str = str.replace(/\[\/线\]/g, "");
- str = that.encryptUrl(str);
- }
- return str;
- }
- function searchInfomation(search, searchtype, author, shiciurl, callback) {
- var WORD_LENGTH = 18;
- wx.showLoading({
- title: '查询中',
- });
- var timeout = setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
- url += "&Word=" + encodeURI(search);
- if (searchtype)
- url += "&SearchType=" + searchtype;
- if (author)
- url += "&Author=" + encodeURI(author);
- if (shiciurl)
- url += "&ShiciUrl=" + shiciurl;
- getData(url, function (data) {
- wx.hideLoading();
- clearTimeout(timeout);
- if (data) {
- //console.log(data);
- if (data.List) {
- var len = WORD_LENGTH;
- var list = data.List;
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- if (item.TypeName == "字词") {
- if (item.Key.length == 1)
- item.TypeName = "Z";
- else
- item.TypeName = "C";
- } else if (item.TypeName == "诗词") {
- item.TypeName = "S";
- item.Remark = item.Author + " " + item.Dynasty;
- } else if (item.TypeName == "翻译") {
- item.TypeName = "D";
- }
- if (item.Content && item.Content.length > len)
- item.Content = item.Content.substr(0, len) + "...";
- }
- callback(list);
- } else if (data.CHN || data.ENG) {
- var obj = {};
- obj.Key = search;
- obj.Value = data;
- if (data.CHN && data.CHN.Author)
- obj.Author = data.CHN.Author;
- if (data.CHN && data.CHN.Dynasty)
- obj.Dynasty = data.CHN.Dynasty;
- if (data.CHN && data.CHN.PeomContent) {
- obj.Type = "shici";
- obj.TypeName = "诗词";
- obj.Content = data.CHN.PeomContent.join("").substr(0, WORD_LENGTH);
- obj.ShiciUrl = shiciurl;
- obj.TypeName = "S";
- } else if (data.CHN) {
- obj.Type = "zici";
- if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].pinyin)
- obj.Remark = data.CHN.PinYin[0].pinyin;
- if (data.CHN.PinYin && data.CHN.PinYin[0] && data.CHN.PinYin[0].explain) {
- obj.Content = data.CHN.PinYin[0].explain.substr(0, WORD_LENGTH);
- obj.Content = obj.Content.replace("<p>", "");
- obj.Content = obj.Content.replace("</p>", "");
- if (obj.Content.length >= WORD_LENGTH)
- obj.Content += "..."
- }
- if (obj.Key.length == 1)
- obj.TypeName = "Z";
- else
- obj.TypeName = "C";
- }
- if (data.ENG && !data.CHN) {
- obj.Type = "eng";
- obj.TypeName = "D";
- if (data.ENG.Soundmark && data.ENG.Soundmark.Eng)
- obj.Remark = data.ENG.Soundmark.Eng;
- if (data.ENG.Paraphrase.length > 0) {
- if (common.checkIsArray(data.ENG.Paraphrase) && data.ENG.Paraphrase[0].ParaphraseList)
- obj.Content = data.ENG.Paraphrase[0].ParaphraseList.join("; ").substr(0, WORD_LENGTH);
- else
- obj.Content = data.ENG.Paraphrase.substr(0, WORD_LENGTH) + "...";
- }
- }
- app.globalData.TempSearchBackNumber = 2;
- //app.globalData.CardList=[];
- app.globalData.CardList2 = [];
- callback([], obj);
- } else {
- callback([]);
- }
- } else {
- callback([]);
- }
- });
- }
- function downloadBishunKaitiImage(url, serverUrl, dataType, Fields, callback) {
- var param = {};
- param.Url = url;
- param.DataType = dataType;
- if (param.Url == serverUrl) {
- postData("GetBiShunByKaitiUrl", param, function (data) {
- if (data) {
- wx.downloadFile({
- url: data, // 仅为示例,并非真实的资源
- success(res) {
- // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
- if (res.statusCode === 200) {
- //console.log("serverUrl2:" + serverUrl);
- console.log(res.tempFilePath);
- callback(change(Fields, res.tempFilePath, param));
- }
- },
- complete() {
- }
- });
- }
- });
- } else {
- callback(change(Fields, serverUrl, param));
- }
- function change(Fields, filepath, param) {
- var iStart = 0;
- if (Fields.length == 4)
- iStart = 1
- for (var i = iStart; i < Fields.length; i++) {
- for (var j = 0; j < Fields[i].length; j++) {
- if (Fields[i][j].Type == "image") {
- if (Fields[i][j].Content == param.Url) {
- Fields[i][j].Content = filepath;
- if (param.DataType == "bishun") {
- Fields[i][j].IsShowKaiti = true;
- Fields[i][j].IsShowBishun = false;
- } else if (param.DataType == "kaiti") {
- Fields[i][j].IsShowKaiti = false;
- Fields[i][j].IsShowBishun = true;
- }
- }
- }
- }
- }
- return Fields;
- }
- }
- function GetSoundError(str) {
- var result = str;
- var arr = wx.getStorageSync('SoundErrorArr');
- if (arr && arr.length>0){
- for (var i = 0; i < arr.length; i++) {
- if (str.indexOf(arr[i].Word) > 0) {
- result = common.ReplaceAllString(str, arr[i].Word, arr[i].Sound);
- break;
- } else if (str == arr[i].Word) {
- result = arr[i].Sound;
- }
- }
- }
- return result;
- }
- function GetTestReportList(userID, callback) {
- getData('GetTestGradeArr', function (GradeArr) {
- for (var i = 0; i < GradeArr.length; i++) {
- for (var j = 0; j < GradeArr[i].List.length; j++) {
- GradeArr[i].List[j].Finish = 0;
- }
- }
- getData('GetTestReportList?UserID=' + userID, function (data) {
- if (data) {
- var dataTemp = [];
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < dataTemp.length; j++) {
- if (dataTemp[j].Name[0] == data[i].Name[0] &&
- dataTemp[j].Name[1] == data[i].Name[1] &&
- dataTemp[j].TestType == data[i].TestType &&
- data[i].IsFinished == 1
- ) {
- dataTemp.splice(j, 1);
- break;
- }
- }
- dataTemp.push(data[i]);
- if (data[i].Name[0].indexOf("英语") >= 0
- || data[i].Name[0].indexOf("单词") >= 0
- || data[i].Name[0].indexOf("KET") >= 0
- || data[i].Name[0].indexOf("1000") >= 0
- || data[i].Name[0].indexOf("2000") >= 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
- || data[i].Name[0].indexOf("小古文") >= 0) {
- if (data[i].TestRightStr) {
- data[i].TestRightStr = data[i].TestRightStr.split(",");
- }
- if (data[i].TestWrongStr) {
- data[i].TestWrongStr = data[i].TestWrongStr.split(",");
- }
- if (data[i].TestSkipStr) {
- data[i].TestSkipStr = data[i].TestSkipStr.split(",");
- }
- if (data[i].TestExistStr) {
- data[i].TestExistStr = data[i].TestExistStr.split(",");
- }
- }
- if (!data[i].TestRightStr)
- data[i].TestRightStr = "";
- if (!data[i].TestWrongStr)
- data[i].TestWrongStr = "";
- if (!data[i].TestSkipStr)
- data[i].TestSkipStr = "";
- if (!data[i].TestExistStr)
- data[i].TestExistStr = "";
- }
- for (var i = 0; i < dataTemp.length; i++) {
- var name = dataTemp[i].Name[0].split(" ");
- for (var j = 0; j < GradeArr.length; j++) {
- var item = GradeArr[j];
- if (name[0] == item.Name) {
- for (var k = 0; k < item.List.length; k++) {
- //音标计算进度
- if (item.List[k].ID == 101 && dataTemp[i].BookID == 101) {
- for (var n = 1; n <= 4; n++) {
- if (Number(dataTemp[i].Name[2]) == n && dataTemp[i].IsFinished == 1)
- item.List[k].Finish++;
- }
- }
- //古诗词计算进度
- else if (item.List[k].ID == dataTemp[i].BookID && dataTemp[i].TestType == "recite" && dataTemp[i].IsFinished == 1)
- item.List[k].Finish = 1;
- else {
- if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
- if (dataTemp[i].IsFinished == 1)
- item.List[k].Finish++;
- }
- }
- }
- }
- }
- }
- for (var j = 0; j < GradeArr.length; j++) {
- var item = GradeArr[j];
- for (var k = 0; k < item.List.length; k++) {
- item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
- item.List[k].NameStr = item.List[k].Name.replace("语文", "");
- }
- }
- wx.setStorageSync("UserTestReport", data);
- callback(data, GradeArr);
- }
- });
- });
- }
- function showHelp(obj,myClass,textTopDirection,helpText,closePos){
- setTimeout(function(){
- wx.createSelectorQuery().select(myClass).boundingClientRect(function (rect) {
- console.log("rect.left:"+rect.left);
- console.log("rect.top:"+rect.top);
- console.log("rect.width:"+rect.width);
- console.log("rect.height:"+rect.height);
- var textTop=rect.bottom+5;
- if (textTopDirection=="up")
- textTop=rect.top-47;
- if (!closePos)
- closePos="Right";
- obj.setData({
- HelpTop:rect.top,
- HelpWidth1:rect.left,
- HelpHeight1:rect.height,
- HelpLeft2:rect.right,
- HelpHeight2:rect.height,
- HelpBottom:rect.bottom-1,
- HelpTextTop:textTop,
- HelpText:helpText,
- HelpClosePos:closePos,
- });
- }).exec();
- },500);
-
- }
- function gotoTaskList(id,cardType) {
- wx.showLoading({
- title: '请稍候',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- var that = this;
- //未练完的题卡
- if (id == 1) {
- getTaskTodayList(function (task) {
- var list = [];
- for (var i = 0; i < task.ListNew.length; i++) {
- list.push(task.ListNew[i]);
- }
- for (var i = 0; i < task.ListHistory.length; i++) {
- list.push(task.ListHistory[i]);
- }
- for (var i = 0; i < task.ListReview.length; i++) {
- list.push(task.ListReview[i]);
- }
- app.globalData.CardList = list;
- wx.navigateTo({
- url: '../main/mainlist?type=1&Count=' + list.length,
- });
- });
- } else {
- var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID + "&IsToday=2&CardType="+ cardType +"&OrderType=ac.LastTime desc";
- getData(url, function (data) {
- if (data) {
- var list = [];
- for (var i = 0; i < data.List.length; i++) {
- data.List[i].LastTimeStr = common.formatDateCHS(data.List[i].LastTime);
- list.push(data.List[i]);
- }
- app.globalData.CardList = list;
- wx.navigateTo({
- url: '../main/mainlist?type=2&Count=' + data.length,
- });
- }
- });
- }
- }
- function resetTodayTask(){
- wx.showModal({
- title: '提醒',
- content: '此操作无法撤销。确认重置今天的任务量吗?',
- showCancel:true,
- cancelText:"确定",
- confirmColor:"#000000",
- confirmText:"取消",
- success (res) {
- if (res.confirm) {
- //console.log('用户点击取消');
- } else if (res.cancel) {
- //console.log('用户点击确定')
- var url = "ResetMiaoguoCardTask?UserID=" + app.globalData.userInfo.UserID;
- getData(url, function (data) {
- if (data) {
- wx.showModal({
- title: '提醒',
- content: '重置已完成。请重新开始今天的练习吧。',
- showCancel:false,
- confirmColor:"#000000",
- confirmText:"返回首页",
- success (res) {
- wx.navigateBack({
- delta: 2,
- });
- }
- });
- }
- });
- }
- }
- });
- }
- //下载图片
- function downloadFile(url,isShowLoading,callback){
- if (isShowLoading){
- wx.showLoading({
- title: '下载中',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- }
- wx.downloadFile({
- url: url,
- success(resDownload) {
- // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
- if (resDownload.statusCode === 200) {
- callback(resDownload.tempFilePath);
- }
- else if (resDownload.statusCode === 404){
- wx.showToast({
- title: '图片不存在',
- });
- }
- if (isShowLoading)
- wx.hideLoading();
- },
- fail: function (e) {
- if (isShowLoading)
- wx.hideLoading();
- wx.showToast({
- title: '下载失败',
- });
- }
- });
- }
- //生成图片
- function buildImage(width,height,canvas,callback){
- var that=this;
- wx.showLoading({
- title: '生成中',
- });
- setTimeout(function () {
- //console.log("生成后1");
- wx.canvasToTempFilePath({
- x: 0,
- y: 0,
- width: width,
- height: height,
- destWidth: width,
- destHeight: height,
- canvas: canvas,
- success: function (res2) {
- wx.hideLoading();
- //console.log("生成后2");
- wx.previewImage({
- current: res2.tempFilePath, // 当前显示图片的http链接
- urls: [res2.tempFilePath] // 需要预览的图片http链接列表
- });
- callback();
- },
- fail: function (e) {
- wx.hideLoading();
- //console.log("生成错误:"+e);
- }
- })
- }, 500);
- }
- function showHelpImage() {
- var arr=[];
- arr.push(app.globalData.uploadImageUrl+"web/doc_xnl_36_1.png")
- arr.push(app.globalData.uploadImageUrl+"web/doc_xnl_36_2.png")
- wx.previewImage({
- current: arr[0],
- urls: arr,
- });
- }
- module.exports = {
- getData: getData,
- postData: postData,
- payMoney: payMoney,
- getLocalHost: getLocalHost,
- getTimeFormat: getTimeFormat,
- getWindowHeight: getWindowHeight,
- getStorageValue: getStorageValue,
- getProgramList: getProgramList,
- gotoFeedback: gotoFeedback,
- getDetailColor: getDetailColor,
- changeStringToView: changeStringToView,
- changeViewToString: changeViewToString,
- encryptUrl: EncryptUrl,
- decryptUrl: DecryptUrl,
- saveTempImage: saveTempImage,
- getTempImage: getTempImage,
- getTaskTodayList: getTaskTodayList,
- updateSearchList: updateSearchList,
- checkIsIPhoneX: checkIsIPhoneX,
- getMemoryLevelAll: getMemoryLevelAll,
- getMemoryLevel: getMemoryLevel,
- getShareImageBackColor: getShareImageBackColor,
- UpdateMiaoguoCardTodayAll: UpdateMiaoguoCardTodayAll,
- setCollect: setCollect,
- UploadUserConfig: UploadUserConfig,
- getServerImage: getServerImage,
- getBaiduToken: getBaiduToken,
- getPinyinNormal: getPinyinNormal,
- getHanzi: getHanzi,
- getEnglish: getEnglish,
- GetHanziUnitWords: GetHanziUnitWords,
- GetTestReportInfo: GetTestReportInfo,
- getUserConfig: getUserConfig,
- getAwardData: getAwardData,
- replaceCardInfoString: replaceCardInfoString,
- searchInfomation: searchInfomation,
- downloadBishunKaitiImage: downloadBishunKaitiImage,
- GetSoundError: GetSoundError,
- GetTestReportList: GetTestReportList,
- ShowHelp:showHelp,
- GotoTaskList:gotoTaskList,
- ResetTodayTask:resetTodayTask,
- DownloadFile:downloadFile,
- BuildImage:buildImage,
- ShowHelpImage:showHelpImage,
- getServerSoundErrorArr:getServerSoundErrorArr,
- }
|