295 lines
7.4 KiB
JavaScript
295 lines
7.4 KiB
JavaScript
var orgId = localStorage.getItem("orgId");
|
||
var postName = localStorage.getItem("postName");
|
||
localStorage.setItem("flage", 0);
|
||
|
||
$(function () {
|
||
//alert(postName)
|
||
/* if(postName.indexOf("检验") != -1){
|
||
orgId = 6;
|
||
}*/
|
||
|
||
/* if(postName.indexOf("客服") != -1){
|
||
orgId = 2;
|
||
}*/
|
||
|
||
/* if(postName.indexOf("维修") != -1){
|
||
orgId = 5;
|
||
}*/
|
||
});
|
||
|
||
mui.back = function () {
|
||
window.location.href = './login.html';
|
||
}
|
||
//跳转至登录页------二维码扫描
|
||
function qrCodeBinding() {
|
||
if (postName.indexOf("检验") != -1) {
|
||
window.location.href = 'qrCodeBinding/qrCodeBinding.html';
|
||
} else {
|
||
alert("当前账户不是检验员");
|
||
}
|
||
}
|
||
|
||
function rfidBinding() {
|
||
window.location.href = 'rfid/rfidBinding.html';
|
||
}
|
||
|
||
/*//跳转至领料页
|
||
function lease() {
|
||
window.location.href = 'lease/machinesCollar.html';
|
||
}*/
|
||
//跳转至检验/出库页
|
||
|
||
function lease() {
|
||
/*if(orgId != 6) {
|
||
alert("当前账户不是检验员");
|
||
} else {
|
||
window.location.href = 'lease/machinesOutStorageInspectionList.html';
|
||
}
|
||
if(orgId != 2) {
|
||
alert("当前账户不是客服代表员");
|
||
} else {
|
||
window.location.href = 'lease/machinesOutStorageList.html';
|
||
}*/
|
||
if (postName.indexOf("客服") != -1) {
|
||
window.location.href = 'lease/machinesOutStorageList.html';
|
||
} else {
|
||
alert("当前账户不是客服代表员");
|
||
}
|
||
}
|
||
//跳转至入库页
|
||
function putInStorage() {
|
||
if (postName.indexOf("客服") != -1) {
|
||
localStorage.setItem("postName", postName);
|
||
window.location.href = 'newInput/newRepairInput.html';
|
||
} else {
|
||
alert("当前账户不是客服代表员");
|
||
}
|
||
}
|
||
|
||
//跳转退料界面
|
||
function reBackLib() {
|
||
if (postName.indexOf("检验") != -1) {
|
||
window.location.href = 'rm/returnMaterialTask.html';
|
||
} else {
|
||
alert("当前账户不是检验员");
|
||
|
||
}
|
||
}
|
||
|
||
function scan() {
|
||
|
||
window.location.href = 'rfid/rfidBinding.html';
|
||
|
||
}
|
||
|
||
function partApply() {
|
||
|
||
checkLogin();
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
function checkLogin() {
|
||
var loginName = localStorage.getItem("loginName");
|
||
var name = localStorage.getItem("name");
|
||
var password = localStorage.getItem("password");
|
||
|
||
$.ajax({
|
||
type: "post",
|
||
url: "http://10.1.0.142:1999/login/userLogin",
|
||
data: {
|
||
username: loginName,
|
||
password: $.md5(password)
|
||
},
|
||
success: function (data) {
|
||
var apiUrl = "http://10.1.0.142:1999/";
|
||
localStorage.setItem("apiUrl", apiUrl);
|
||
if (data.code == "200") {
|
||
localStorage.setItem("token", data.token);
|
||
localStorage.setItem("name", name);
|
||
window.location.href = 'part/partIndex.html';
|
||
|
||
} else {
|
||
alert("没有权限!");
|
||
window.location.href = 'part/partIndex.html';
|
||
}
|
||
|
||
},
|
||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||
alert("未连接到服务器,请检查网络!" + XMLHttpRequest.status);
|
||
}
|
||
});
|
||
}
|
||
|
||
//跳转维修任务列表
|
||
function machinesRepair() {
|
||
if (postName.indexOf("维修") != -1) {
|
||
window.location.href = 'repair/repairItem.html';
|
||
//window.location.href = 'repair/repairTaskList.html';
|
||
} else {
|
||
alert("当前账户不是维修人员");
|
||
|
||
}
|
||
}
|
||
|
||
//跳转报废任务列表
|
||
function machineScrap() {
|
||
if (postName.indexOf("检验") != -1) {
|
||
window.location.href = 'scrap/scrapTaskNewList.html';
|
||
} else {
|
||
alert("当前账户不是检验员");
|
||
|
||
}
|
||
}
|
||
|
||
//跳转维修明细界面
|
||
function repairDetailList() {
|
||
window.location.href = 'repairDetailList.html';
|
||
}
|
||
|
||
//维修明细界面跳转至维修设备展示界面
|
||
function repairMachineList() {
|
||
window.location.href = 'repairMachineList.html';
|
||
}
|
||
|
||
//选择维修合格,添加维修配件等信息
|
||
function repairOperation() {
|
||
window.location.href = 'repairOperation.html';
|
||
}
|
||
|
||
//选择报废,添加报废信息
|
||
function scrapOperation() {
|
||
window.location.href = 'scrapOperation.html';
|
||
}
|
||
|
||
//计数机具选择维修合格,添加维修配件等信息
|
||
function repairNumsOperation() {
|
||
window.location.href = 'repairNumsOperation.html';
|
||
}
|
||
|
||
//计数机具选择报废,添加报废信息
|
||
function scrapNumsOperation() {
|
||
window.location.href = 'scrapNumsOperation.html';
|
||
}
|
||
|
||
|
||
//跳转至维修检验任务界面
|
||
function checkOutLib() {
|
||
if (postName.indexOf("检验") != -1) {
|
||
localStorage.setItem("flageInspect", 0);
|
||
window.location.href = 'repairInspect/newInspectTaskList.html';
|
||
} else {
|
||
alert("当前账户不是检验员");
|
||
}
|
||
}
|
||
|
||
//跳转至检验任务明细界面
|
||
function inspectDetailList() {
|
||
window.location.href = 'inspectDetailList.html';
|
||
}
|
||
|
||
//跳转至检验设备展示界面
|
||
function inspectMachineList() {
|
||
window.location.href = 'inspectMachineList.html';
|
||
}
|
||
|
||
////跳转至数量检验操作界面
|
||
//function inspectNumsOperation(){
|
||
// window.location.href='inspectNumsOperation.html';
|
||
//}
|
||
|
||
//跳转至数量检验操作界面
|
||
function inspectNumsOperation() {
|
||
|
||
window.location.href = 'newInspectNumsOperation.html';
|
||
}
|
||
|
||
// 安全用品需求计划管理 - 需求申请
|
||
function safetyPlanApply() {
|
||
checkLoginAndNavigate('safetyPlan/safetyPlanIndex.html');
|
||
}
|
||
|
||
// 安全用品需求计划管理 - 需求审核
|
||
function safetyPlanReview() {
|
||
checkLoginAndNavigate('safetyPlan/safetyPlanIndex.html');
|
||
}
|
||
|
||
// 安全用品需求计划管理 - 需求发货
|
||
function safetyPlanShipment() {
|
||
// checkLoginAndNavigate('safetyPlan/safetyPlanIndex.html');
|
||
checkLoginAndNavigate('safetyPlan/safetyPlanShipment.html');
|
||
}
|
||
|
||
// 检查登录并获取安全模块token,然后导航
|
||
function checkLoginAndNavigate(targetUrl) {
|
||
var loginName = localStorage.getItem("loginName");
|
||
var password = localStorage.getItem("password");
|
||
var safetyToken = localStorage.getItem("safetyToken");
|
||
|
||
console.log('========== pageController.js - checkLoginAndNavigate ==========');
|
||
console.log('目标URL:', targetUrl);
|
||
console.log('登录用户名:', loginName);
|
||
console.log('安全模块Token是否存在:', safetyToken ? '是' : '否');
|
||
console.log('安全模块Token值:', safetyToken);
|
||
|
||
// 如果安全模块token已存在,直接导航
|
||
if (safetyToken) {
|
||
console.log('✅ 安全模块Token已存在,直接导航');
|
||
window.location.href = targetUrl;
|
||
return;
|
||
}
|
||
|
||
// 否则先获取安全模块token
|
||
console.log('⏳ 安全模块Token不存在,正在获取...');
|
||
console.log('调用安全模块登陆接口: http://10.1.0.142:1999/gz_aqgqj/login/userLogin');
|
||
|
||
$.ajax({
|
||
type: "post",
|
||
url: "http://10.1.0.142:1999/gz_aqgqj/login/userLogin",
|
||
data: {
|
||
username: loginName,
|
||
password: $.md5(password)
|
||
},
|
||
success: function (data) {
|
||
console.log('✅ 安全模块登录API响应成功');
|
||
console.log('完整响应:', JSON.stringify(data, null, 2));
|
||
if (data.code == "200" || data.code == 200) {
|
||
console.log('✅ 安全模块登录成功,保存token');
|
||
localStorage.setItem("safetyToken", data.token);
|
||
console.log('安全模块Token已保存:', data.token);
|
||
window.location.href = targetUrl;
|
||
} else {
|
||
console.error('❌ 安全模块登录失败,code:', data.code);
|
||
alert("安全模块登录失败,请重新登录!");
|
||
}
|
||
},
|
||
error: function (xhr, textStatus, errorThrown) {
|
||
console.error('❌ 安全模块登录API请求失败');
|
||
console.error('状态码:', xhr.status);
|
||
console.error('错误信息:', errorThrown);
|
||
console.error('响应文本:', xhr.responseText);
|
||
alert("未连接到服务器,请检查网络!");
|
||
}
|
||
});
|
||
}
|
||
|
||
$.ajaxSetup({
|
||
cache: false,
|
||
headers: {
|
||
"companyId": localStorage.getItem("companyId")
|
||
}
|
||
});
|
||
|
||
mui.back = function () {
|
||
layer.open({
|
||
content: '您确定要退出当前系统吗?',
|
||
style: 'font-size:1.1em',
|
||
btn: ['确定', '取消'],
|
||
yes: function (index) {
|
||
plus.runtime.quit();
|
||
}
|
||
});
|
||
} |