| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958 |
- 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
- });
- var err={};
- err.errCode=100;
- err.errMsg="网络错误";
- callback(null,err);
- },
- });
- }
- 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+'&UserID='+app.globalData.userInfo.ShowUserID, 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[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,
- }
|