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 = [];
d1.data.forEach((item, index)=>{
let mrdata1 = {tab1:{}};
if(item.moduleInstantsName == '悬浮'){
let mitem = item.moduleData;
mrdata1.tab1.pic = mitem.fixpic;
mrdata1.tab1.url = mitem.url;
mrdata1.tab1.gotop = mitem.gotop;
mrdata1.tab1.heng = mitem.heng;
mrdata1.tab1.zong = mitem.zong;
mrdata1.tab1.url = mitem.url;
mrdata1.tab1.picw = mitem.fix_width || 138;
mrdata1.tab1.pich = mitem.fix_height || 138;
mrdata1.tab1.fix_top = mitem.fix_top;
mrdata1.tab1.fix_left = mitem.fix_left;
mrdata1.moduleType = 'lhzxuanfumod';
}else if(item.moduleInstantsName == '图片模块'){
let mitem = item.moduleData;
let jsonarray = mitem.jsonarray;
let h = 0;
let jsonarray2 = [];
for(let i = 0; i < jsonarray.length; i++){
let jitem1 = jsonarray[i];
let jitem = {pic:{width:jitem1.width,height:jitem1.height, pic:jitem1.pic}};
h+=jitem1.height;
if(jitem1.marB){
jitem.marB = jitem1.marB;
h+=parseInt(jitem1.marB)
}
jsonarray2.push(jitem)
}
mrdata1.height = h;
mrdata1.moduleType = 'lhzpicmod';
mrdata1.tab1.jsonarray = jsonarray2;
}
let mata2 = {init_data:mrdata1};
mata2.title = item.moduleInstantsName;
mata2.ident = mrdata1.moduleType;
zhdata.push(mata2)
})
$("#zhh").val(JSON.stringify(zhdata));
}
})
</script>
</html>