var vm; $(document).ready(function () { vm = new Vue({ el: '#app1', data: { PrintList: [], IsShowAnswer:0, CreateTime:formatTime(new Date(),"-",true), CardNumber:0, QRCodeImg:"https://kylx365-1253256735.file.myqcloud.com/web/xcode_a_180x180.png", NickName:serverurl4, PrintID:0, }, methods: { getList: function (event) { $("#loading").css("display","flex"); var param = {}; param.IDSelect = serverurl1; var url = serverurl2; vm.IsShowAnswer = serverurl3; $.post("/apiData/" + url, param, function (data) { //console.log(data); var list = data.result.List; vm.CardNumber=list.length; //console.log(list); for (var i = 0; i < list.length; i++) { list[i].Content = changeStringToView(list[i].Content); if (vm.IsShowAnswer>=1) { var item2=list[i].Content.Field[2]; if (item2) { list[i].HasField2 = true; for(var j=0;j=0 || item2[j].Content.indexOf("bcebos.com")>=0){ list[i].Content.Field[2][j].Type="imageSmall"; } } } } else list[i].HasField2 = false; var item3=list[i].Content.Field[3]; if (item3) { list[i].HasField3 = true; for(var j=0;j=0 || item3[j].Content.indexOf("bcebos.com")>=0){ list[i].Content.Field[3][j].Type="imageSmall"; } } } } else list[i].HasField3 = false; } list[i].Index=i+1; } var result=[],resultTemp=[]; for (var i=0;i0 && tempX!=offset.left) b++; var bRow=2; if (vm.IsShowAnswer==3) bRow=1; if (i>0 && offset.top <= tempY && b>=bRow){ result.push(resultTemp); resultTemp=[]; b=0; } if (p.height()>960){ list[i].ImageHeight="width:50%;"; list[i].ImageHeight2="width:100%;"; } else { list[i].ImageHeight = "auto;"; list[i].ImageHeight2 = "auto;"; } resultTemp.push(list[i]); tempX=offset.left; tempY=offset.top; } } result.push(resultTemp); vm.PrintList = result; //console.log(result); setTimeout(function(){ $("#loading").css("display","none"); $(".panelMain").css("visibility","visible"); },200); vm.PrintID=data.result.PrintID; vm.QRCodeImg="https://miaguo-1253256735.file.myqcloud.com/MiaoguoPrint"+data.result.PrintID+".png"; },5000); }); }, defaultImg: function (event) { setTimeout(function(){ vm.QRCodeImg="https://miaguo-1253256735.file.myqcloud.com/MiaoguoPrint"+vm.PrintID+".png"; },1000); } } }); function init() { vm.getList(); } init(); 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); 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 = obj.ContentServer; result.Images.push(obj.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); for (var n = 0; n < content.length; n++) content[n].ChildID = n; 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"; obj.Content = ""; 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; } } for (var i = 0; i < arrResult.length; i++) { arrResult[i].ID = i; } result.Field.push(arrResult); } else { result.Field.push([]); } } } return result; } function EncryptUrl(str) { if (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.kylx365.com\/sounds/g, "#####3#####"); str = str.replace(/https:\/\/pinyin-1253256735.file.myqcloud.com/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-1253256735.file.myqcloud.com"); str = str.replace(/#####4#####/g, "https://miaguo-1253256735.file.myqcloud.com"); } return str; } });