Files
2025-07-13 19:37:38 +08:00

167 lines
6.9 KiB
JavaScript
Executable File

//用户检测
const User = checkUser();
/*————————vue预定义————————*/
var vm = new Vue({
el: '#offCanvasWrapper', //该ID元素必须被包含于body以内
data: {
ctms: params.ctms,
version: params.version,
Company:params.Company,
Page:{
title:'客户资料',
menus: menus
},
search:{
carno:'',
phone:'',
city:''
}
},
methods:{
TestFunc(){
console.log('测试下添加个自定义函数方法')
}
},
created:function(o){ //实例创建完成时
// console.log(o)
},
mounted:function(o){ //页面初始化方法
// console.log(o)
},
destroyed:function(o){ //实例销毁方法
console.log(o)
}
});
/*————————MUI操作————————*/
mui.init();
//侧滑容器父节点
var offCanvasWrapper = mui('#offCanvasWrapper');
//主界面容器
var offCanvasInner = offCanvasWrapper[0].querySelector('.mui-inner-wrap');
//菜单容器
var offCanvasSide = document.getElementById("offCanvasSide");
if (!mui.os.android) {
var spans = document.querySelectorAll('.android-only');
for (var i = 0, len = spans.length; i < len; i++) {
spans[i].style.display = "none";
}
}
//移动效果是否为整体移动
var moveTogether = false;
//主界面‘显示侧滑菜单’按钮的点击事件
document.getElementById('offCanvasShow').addEventListener('tap', function() {
offCanvasWrapper.offCanvas('show');
});
//菜单界面,‘关闭侧滑菜单’按钮的点击事件
document.getElementById('offCanvasHide').addEventListener('tap', function() {
offCanvasWrapper.offCanvas('close');
});
//主界面和侧滑菜单界面均支持区域滚动;
mui('#offCanvasSideScroll').scroll();
mui('#offCanvasContentScroll').scroll();
//实现ios平台原生侧滑关闭页面;
if (mui.os.plus && mui.os.ios) {
mui.plusReady(function() { //5+ iOS暂时无法屏蔽popGesture时传递touch事件,故该demo直接屏蔽popGesture功能
plus.webview.currentWebview().setStyle({
'popGesture': 'none'
});
});
}
document.getElementById("alertBtnHelp").addEventListener('tap', function() {
mui.toast('感谢使用,请查看页面中的使用说明');
});
/*————————其他事件响应——————————*/
function checkOrder(formid){
var form = document.getElementById(formid);
var url = apis.domain+apis.JiaocheSearch;
var data = vm.search;
mui.post(url,{search:data,pid:apis.pid},function(res){
console.log(res);
if(res){
switch(res.code){
case 200 :
//将查询结果缓存在本地
var orders = res.data.data.orders;
var o = JSON.stringify(orders);
console.log(o);
localStorage.setItem('JiaocheList',o);
//跳转到列表页
mui.openWindow({
url:'list.html',
id:'JiaocheList',
styles:{
top:44, //新页面顶部位置
bottom:0, //新页面底部位置
width:'100%', //新页面宽度,默认为100%
height:'100%' //新页面高度,默认为100%
},
extras:{
orders:res.data.data.orders ,//自定义扩展参数,可以用来处理页面间传值
},
createNew:false,//是否重复创建同样id的webview,默认为false:不重复创建,直接显示
show:{
autoShow:true,//页面loaded事件发生后自动显示,默认为true
aniShow:'slide-in-right',//页面显示动画,默认为”slide-in-right“;
duration:200//页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
},
waiting:{
autoShow:true,//自动显示等待框,默认为true
title:'正在加载...',//等待对话框上显示的提示内容
options:{
width:'100%',//等待框背景区域宽度,默认根据内容自动计算合适宽度
height:'100%',//等待框背景区域高度,默认根据内容自动计算合适高度
}
}
});
break;
case 400:
default:
document.getElementById('pagename').innerText = '未查询到结果!';
break;
}
}else{
document.getElementById('pagename').innerText = '查询失败!';
document.getElementById('PrintError').innerText = '您好,系统查询失败。如果可以,请您将此页截屏发送给我们(微信: sanyabaike ),以帮助我们找到问题并改进,感谢您的支持!' + res ;
let classAtr = document.getElementById("PrintError").getAttribute("class");
let newClass = classAtr.replace("mui-hidden","");
document.getElementById("PrintError").setAttribute("class",newClass);
}
},'json');
return false;
}
function openUrl(url,title){
mui.openWindow({
url: url,
id: encodeURI(url),
styles: { // 窗口参数 参考5+规范中的WebviewStyle,也就是说WebviewStyle下的参数都可以在此设置
// titleNView: { // 窗口的标题栏控件
// titleText:"", // 标题栏文字,当不设置此属性时,默认加载当前页面的标题,并自动更新页面的标题
// titleColor:"#000000", // 字体颜色,颜色值格式为"#RRGGBB",默认值为"#000000"
// titleSize:"17px", // 字体大小,默认17px
// backgroundColor:"#F7F7F7", // 控件背景颜色,颜色值格式为"#RRGGBB",默认值为"#F7F7F7"
// progress:{ // 标题栏控件的进度条样式
// color:"#00FF00", // 进度条颜色,默认值为"#00FF00"
// height:"2px" // 进度条高度,默认值为"2px"
// },
// splitLine:{ // 标题栏控件的底部分割线,类似borderBottom
// color:"#CCCCCC", // 分割线颜色,默认值为"#CCCCCC"
// height:"1px" // 分割线高度,默认值为"2px"
// }
// }
}
});
}
mui('body').on("tap",'a',function(e){
var url = e.target.href;
var title = e.target.innerHTML;
openUrl(url,title);
});