| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- 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<item2.length;j++){
- if (item2[j].Type=="image"){
- console.log(item2[j].Content);
- if (item2[j].Content.indexOf("baidu.com")>=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<item3.length;j++){
- if (item3[j].Type=="image"){
- console.log(item3[j].Content);
- if (item3[j].Content.indexOf("baidu.com")>=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;i<list.length;i++){
- resultTemp.push(list[i]);
- }
- result.push(resultTemp);
- vm.PrintList = result;
- var count=result[0].length;
- setTimeout(function(){
- result=[],resultTemp=[],tempX=0,tempY=0,b=false;
- for(var i=0;i<count;i++){
- var p = $("#item"+i);
- //console.log("i:"+i);
- var offset = p.offset();
- //console.log("offset::"+JSON.stringify(offset));
- //console.log("height:"+p.height());
- if (offset){
- //console.log(i+" x:"+offset.left+" y:"+offset.top);
- if (i>0 && 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;
- }
- });
|