mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-10-16 23:43:44 +08:00
修复首次安装程序报错问题
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
<title>程序安装</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<style>
|
||||
.logo1 {
|
||||
width: 180px !important;
|
||||
}
|
||||
.logo1 {
|
||||
width: 180px !important;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 30px !important;
|
||||
@@ -124,32 +124,27 @@
|
||||
// 监听提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
const field = data.field;
|
||||
// 提交表单
|
||||
fetch('/install/install', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(field)
|
||||
}).then(res => {
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
}
|
||||
throw new Error('数据库配置错误');
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, {
|
||||
time: 1000,
|
||||
end: () => {
|
||||
window.location.href = '/User/login';
|
||||
}
|
||||
});
|
||||
(async () => {
|
||||
const saveRes = await fetch('/install/install', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(field) });
|
||||
const saveJson = await saveRes.json();
|
||||
if (saveJson.code == 0) {
|
||||
const initRes = await fetch('/install/init', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(field) });
|
||||
if (initRes.status != 200) { layer.msg('初始化失败,请检查配置'); return; }
|
||||
const initJson = await initRes.json();
|
||||
if (initJson.code == 0) {
|
||||
layer.msg(initJson.msg, {
|
||||
time: 1000,
|
||||
end: () => {
|
||||
window.location.href = '/User/login';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(initJson.msg);
|
||||
}
|
||||
} else {
|
||||
layer.msg(res.msg);
|
||||
layer.msg(json.msg);
|
||||
}
|
||||
}).catch(err => {
|
||||
layer.msg(err.message);
|
||||
})
|
||||
})()
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user