var listDept = null;
var url;
var slider = mui(".mui-slider");
var data = {
"interfaceId": "5002",
"sign": "10002",
"outId": "10002",
"reqDateTime": new Date(),
"tokenAuth": "",
"data": {
"companyId": "",
"deptId":""
}
};
//手动侧滑
slider.slider({
interval: 10000
});
mui('.mui-scroll-wrapper').scroll({
indicators: false, //是否显示滚动条
deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
bounce: false, //是否启用回弹
deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
});
//主页切换到侧滑菜单
mui(".mui-off-canvas-wrap").on("tap", ".index-info button", function() {
mui('.mui-off-canvas-wrap').offCanvas().toggle();
});
//库区选择,并切换到主页面
mui(".mui-off-canvas-wrap").on("tap", ".ul-menu li a", function() {
mui('.mui-off-canvas-wrap').offCanvas().toggle();
var id = this.getAttribute("id");
var dept = listDept[id];
$("#deptName").html("所在库区:" + dept.deptName);
localStorage.setItem('selectDeptId', JSON.stringify(dept.deptId));
});
//渲染分库列表
function renderListDept() {
if (listDept) {
var html = '';
$.each(listDept, function(index, item) {
html += '
';
html += '' + item.deptName + '';
html += '';
html += '';
})
$("#listDept").html(html);
}
}
//获取库区列表
function getListDept() {
console.log(url)
console.log(JSON.stringify(data.data))
//请求
mui.ajax(url, {
type: "POST",
dataType: "json",
crossDomain: true,
contentType: "application/json;charset=utf-8",
data: JSON.stringify(data),
success: function(data) {
if (data.code == "0000") {
listDept = data.data;
renderListDept();
} else {
mui.toast("获取库区列表失败!");
}
},
error: function() {
mui.toast("系统繁忙,请重试!");
}
})
}
//底部菜单栏跳转
mui(".g-tabbar").on("tap", ".tabbar a", function() {
var id = this.getAttribute("id");
if (id) {
mui.openWindow({
url: id + ".html",
id: id
})
}else{
mui.alert('无权查看此功能!', '提示', ["确定"], function() {}, "div");
}
});
//功能模块跳转
mui(".mui-content").on("tap", ".mui-scroll ul li a", function() {
var id = this.getAttribute("id");
if (id) {
var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId'));
if(selectDeptId){
mui.openWindow({
url: id + ".html",
id: id
})
}else{
mui.alert('请先选择库区!', '提示', ["确定"], function() {}, "div");
}
}else{
mui.alert('无权查看此功能!', '提示', ["确定"], function() {}, "div");
}
});
// //跳转气象页面
// function getWeatherView() {
// mui.openWindow({
// url: "./weather.html?url=" +
// "https://widget-page.heweather.net/h5/index.html?md=03456&bg=1&lc=accu&key=3cb8c045697b43c2b858751a145464aa&demo=true&v=_1617326246190&demo=true",
// id: 'weather'
// })
// }
// //跳转设备操作页面
// function getDeviceView(tag, typeName) {
// mui.openWindow({
// url: "device-listDepot.html",
// id: "device-listDepot",
// extras: {
// tag: tag,
// typeName: typeName
// }
// })
// }