console
<!DOCTYPE html>
<html>
<head>
<title>旧版weex代码转换</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
<meta name="format-detection" content="telephone=no" />
<meta http-equiv="pragma" content="no-cache" />
<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.5.0/jquery.min.js"></script>
<script>
var w = document.documentElement.clientWidth;
if (w <= 640) {
document.documentElement.style.fontSize = Math.floor(w * 100 / 640) + "px";
}
else {
document.documentElement.style.fontSize = 640 * 100 / 640 + "px";
}
</script>
<style>
#from {
position: absolute;
width: 800px;
height: 300px
}
#from .area {
transform: translateX(25px);
text-align: left;
width: 750px;
height: 250px;
display: block;
}
#from h6 {
position: relative;
display: block;
height: 50px;
line-height: 50px;
font-size: 26px;
margin: 0;
padding: auto;
}
.el-button {
position: absolute;
right: 50px;
display: line-block;
line-height: 1;
white-space: nowrap;
cursor: pointer;
background: #fff;
border: 1px solid #dcdfe6;
color: #606266;
-webkit-appearance: none;
text-align: center;
box-sizing: border-box;
outline: none;
transition: .1s;
font-weight: 500;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
padding: 12px 20px;
font-size: 14px;
border-radius: 4px;
}
.el-button--primary {
color: #fff;
background-color: #409eff;
border-color: #409eff;
}
</style>
</head>
<body>
<div id="from">
<h6>原代码:<button id="changebtn" class="el-button el-button--primary">转换</button></h6>
<textarea id="zhq" class="area" value=""></textarea>
<h6>输出结果</h6>
<textarea id="zhh" class="area" value=""></textarea>
</div>
</body>
<script>
$("#changebtn").on("click", function(){
let json = $("#zhq").val();
if(json){
let d1 = JSON.parse(json);
let zhdata = {
"moduleType": "xyxflcz",
"show": true,
"tab1": {
"lb_tl": "0|200",
"pop_wh": "200|120",
"pop_mbr": "0",
"pop_tl": "0",
"mr_fc": "30|#999",
"act_fc": "30|#000",
"auto": "2",
"auto1": {
"autot": "3"
},
"lbtype": "7",
"topcontent": "",
"popanisel": "0"
},
"tab2": {
"jsonarray": [
]
}
}
let mrh = 0;
d1.tabs.forEach((item, index)=>{
let zqitem = {};
if(index == 0){
zhdata.tab1.pop_wh = parseInt(item.width)+'|'+parseInt(item.height);
mrh = parseInt(item.height)
}
if(parseInt(item.height) != mrh){
zqitem.it_h = parseInt(item.height)
}
zqitem.classImage = item.tI;
zqitem.classActiveImage = item.tSI;
let con1 = JSON.parse(item.bIs);
let con = {"width":550,"height":"1000","bC":"",
"name":"自定义模块","moduleType":"diyModule",
"components":[],"uiSize":"726","islive":"true","id":"81e06f3c-6567-41ea-be79-4b05c687aefd","ruler":[]}
let len1 = con1.list.length;
con.width = con1.pageProps.w;
con.height = con1.pageProps.h;
con.bC = con1.pageProps.backgroundColor;
for(let i = 0; i < len1; i++){
let itt = con1.list[i];
if(itt.type == 'image'){
con.components.push({"type":"img","name":"图片"+(i+1),"width":itt.publicProps.w,"height":itt.publicProps.h,"left":itt.publicProps.x,"top":itt.publicProps.y,"src":itt.privateProps.src})
}else if(itt.type == 'hotarea'){
con.components.push({"type":"area","name":"热区"+(i+1),"width":itt.publicProps.w,"height":itt.publicProps.h,"left":itt.publicProps.x,"top":itt.publicProps.y,"url":itt.privateProps.link})
}else if(itt.type == 'video'){
con.components.push({"type":"video","name":"视频"+(i+1),"width":itt.publicProps.w,"height":itt.publicProps.h,"left":itt.publicProps.x,"top":itt.publicProps.y,"mutedbtm":50,"mutedleft":27,"mutedpic1":"https://img.alicdn.com/imgextra/i2/907349826/O1CN01IPxXfK2MSMbvqJtfK_!!907349826.png","mutedpic2":"https://img.alicdn.com/imgextra/i4/907349826/O1CN01ltVt1D2MSMbvujTOn_!!907349826.png","content":itt.privateProps.src,"poster":itt.privateProps.poster || "https://img.alicdn.com/imgextra/i1/1734086020/TB2QPnMl3vD8KJjSsplXXaIEFXa-1734086020.jpg","auto":"true","muted":"true","loop":"true","controls":"false","showbtn":"false"})
}else if(itt.type == "kaichangAnimation"){
let imgan = {"type":"imgan","name":"单图动画1","width":itt.publicProps.w,"height":itt.publicProps.h,"left":itt.publicProps.x,"top":itt.publicProps.y,"tx":0,"ty":"30","ops":"0","ope":"1","tss":"","tse":"","td":"0.5","ttf":"linear","ttr":"","delay":"","antype":"fadeIn","bI":"","config":{"bC":"","bI":"","components":[],"ruler":[]},"an":{"txy":1},"imageType":"diy"}
if(con1.customs[itt.id]){
let list2 = con1.customs[itt.id];
for(let ii = 0; ii < list2.length; ii++){
let ittt = list2[ii];
if(ittt.type == 'image'){
imgan.config.components.push({"type":"img","name":"图片"+(i+1),"width":ittt.publicProps.w,"height":ittt.publicProps.h,"left":ittt.publicProps.x,"top":ittt.publicProps.y,"src":ittt.privateProps.src})
}else if(ittt.type == 'hotarea'){
imgan.config.components.push({"type":"area","name":"热区"+(i+1),"width":ittt.publicProps.w,"height":ittt.publicProps.h,"left":ittt.publicProps.x,"top":ittt.publicProps.y,"url":ittt.privateProps.link})
}else if(ittt.type == 'video'){
imgan.config.components.push({"type":"video","name":"视频"+(i+1),"width":ittt.publicProps.w,"height":ittt.publicProps.h,"left":ittt.publicProps.x,"top":ittt.publicProps.y,"mutedbtm":50,"mutedleft":27,"mutedpic1":"https://img.alicdn.com/imgextra/i2/907349826/O1CN01IPxXfK2MSMbvqJtfK_!!907349826.png","mutedpic2":"https://img.alicdn.com/imgextra/i4/907349826/O1CN01ltVt1D2MSMbvujTOn_!!907349826.png","content":ittt.privateProps.src,"poster":ittt.privateProps.poster || "https://img.alicdn.com/imgextra/i1/1734086020/TB2QPnMl3vD8KJjSsplXXaIEFXa-1734086020.jpg","auto":"true","muted":"true","loop":"true","controls":"false","showbtn":"false"})
}
}
}
con.components.push(imgan)
}
}
zqitem.content = JSON.stringify(con);
zhdata.tab2.jsonarray.push(zqitem)
})
$("#zhh").val(JSON.stringify(zhdata));
}
})
</script>
</html>