fix: H5本地运行白屏及登录获取验证码去除安全验证弹窗
- manifest.json: H5 devServer 关闭 https,修复本地开发 WDS 断连问题 - App.vue: 大屏跳转 pc.html 时动态推导路径前缀,兼容本地(/)和部署(/h5/)两种场景 - static/html/pc.html: iframe src 根据当前页面路径动态计算,修复本地白屏问题 - login/index.vue: 获取验证码直接调用接口,跳过前端安全验证弹窗(后端已注释校验) Made-with: Cursor
This commit is contained in:
@@ -95,7 +95,11 @@
|
|||||||
success(e) {
|
success(e) {
|
||||||
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
|
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
|
||||||
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
|
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
|
||||||
window.location.pathname = '/h5/static/html/pc.html';
|
const p = (window.location.pathname || '/').replace(/\/$/, '') || '/';
|
||||||
|
if (p.endsWith('/static/html/pc.html')) return;
|
||||||
|
/* 与 manifest h5.router.base 一致:根路径为 / 或子路径 /h5/ */
|
||||||
|
const h5Base = p.startsWith('/h5/') || p === '/h5' ? '/h5' : '';
|
||||||
|
window.location.pathname = `${h5Base}/static/html/pc.html`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name" : "黄精粉",
|
"name" : "范氏国香",
|
||||||
"appid" : "__UNI__6691FE3",
|
"appid" : "__UNI__6691FE3",
|
||||||
"description" : "黄精粉商城",
|
"description" : "范氏国香商城",
|
||||||
"versionName" : "3.5.1",
|
"versionName" : "3.5.1",
|
||||||
"versionCode" : 351,
|
"versionCode" : 351,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
},
|
},
|
||||||
"h5" : {
|
"h5" : {
|
||||||
"devServer" : {
|
"devServer" : {
|
||||||
"https" : true
|
"https" : false
|
||||||
},
|
},
|
||||||
"router" : {
|
"router" : {
|
||||||
"mode" : "history",
|
"mode" : "history",
|
||||||
|
|||||||
@@ -396,45 +396,44 @@
|
|||||||
this.keyCode +
|
this.keyCode +
|
||||||
Date.parse(new Date());
|
Date.parse(new Date());
|
||||||
},
|
},
|
||||||
success(data) {
|
success(data) {
|
||||||
this.$refs.verify.hide()
|
if (this.$refs.verify) this.$refs.verify.hide()
|
||||||
getCodeApi()
|
getCodeApi()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.keyCode = res.data.key;
|
this.keyCode = res.data.key;
|
||||||
this.getCode(data);
|
this.getCode(data);
|
||||||
})
|
})
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
this.$util.Tips({
|
this.$util.Tips({
|
||||||
title: res
|
title: res
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
code() {
|
},
|
||||||
let that = this
|
code() {
|
||||||
if (!that.protocol) {
|
let that = this
|
||||||
this.inAnimation = true
|
if (!that.protocol) {
|
||||||
return that.$util.Tips({
|
this.inAnimation = true
|
||||||
title: '请先阅读并同意协议'
|
return that.$util.Tips({
|
||||||
|
title: '请先阅读并同意协议'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!that.account) return that.$util.Tips({
|
||||||
|
title: '请填写手机号码'
|
||||||
|
});
|
||||||
|
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
|
||||||
|
title: '请输入正确的手机号码'
|
||||||
|
});
|
||||||
|
getCodeApi()
|
||||||
|
.then(res => {
|
||||||
|
that.keyCode = res.data.key;
|
||||||
|
that.getCode({ captchaVerification: '' });
|
||||||
|
})
|
||||||
|
.catch(res => {
|
||||||
|
that.$util.Tips({
|
||||||
|
title: res
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (!that.account) return that.$util.Tips({
|
|
||||||
title: '请填写手机号码'
|
|
||||||
});
|
});
|
||||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
|
},
|
||||||
title: '请输入正确的手机号码'
|
|
||||||
});
|
|
||||||
// getCodeApi()
|
|
||||||
// .then(res => {
|
|
||||||
// that.keyCode = res.data.key;
|
|
||||||
// that.getCode();
|
|
||||||
// })
|
|
||||||
// .catch(res => {
|
|
||||||
// that.$util.Tips({
|
|
||||||
// title: res
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
this.$refs.verify.show()
|
|
||||||
},
|
|
||||||
async getLogoImage() {
|
async getLogoImage() {
|
||||||
let that = this;
|
let that = this;
|
||||||
getLogo(2).then(res => {
|
getLogo(2).then(res => {
|
||||||
@@ -568,12 +567,12 @@
|
|||||||
});
|
});
|
||||||
that.sendCode();
|
that.sendCode();
|
||||||
})
|
})
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
this.$refs.verify.refresh()
|
if (this.$refs.verify) this.$refs.verify.refresh()
|
||||||
that.$util.Tips({
|
that.$util.Tips({
|
||||||
title: res
|
title: res
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
|||||||
@@ -35,21 +35,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="text/javascript">
|
|
||||||
window.isPC = true;
|
|
||||||
|
|
||||||
window.onload = function(){
|
|
||||||
/* 监听电脑浏览器窗口尺寸改变 */
|
|
||||||
window.onresize = function(){
|
|
||||||
/* 窗口宽度 小于或等于420px 时,跳转回H5页面 */
|
|
||||||
if(window.innerWidth <= 420){
|
|
||||||
window.location.pathname = '/h5/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<iframe src="/h5/?type=1"></iframe>
|
<iframe id="app-frame"></iframe>
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.isPC = true;
|
||||||
|
/* 根据当前地址推导 H5 根路径:本地 dev 多为 /,线上部署多为 /h5/ */
|
||||||
|
function h5AppRootPathname() {
|
||||||
|
var path = (window.location.pathname || '/').replace(/\/$/, '') || '/';
|
||||||
|
var marker = '/static/html/pc.html';
|
||||||
|
if (path.endsWith(marker)) {
|
||||||
|
var root = path.slice(0, -marker.length);
|
||||||
|
if (!root) root = '/';
|
||||||
|
return root === '/' ? '/' : (root + '/');
|
||||||
|
}
|
||||||
|
return '/';
|
||||||
|
}
|
||||||
|
var H5_ROOT = h5AppRootPathname();
|
||||||
|
document.getElementById('app-frame').src = H5_ROOT + '?type=1';
|
||||||
|
window.onresize = function(){
|
||||||
|
if (window.innerWidth <= 420) {
|
||||||
|
var target = H5_ROOT.replace(/\/$/, '');
|
||||||
|
window.location.pathname = target || '/';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user