增加扫码页/增加环境配置
This commit is contained in:
@@ -1,19 +1,34 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function(options) {
|
||||
console.log('App Launch')
|
||||
|
||||
// #ifdef H5
|
||||
// 解析 URL 路径中的设备编号(如 /A1036)
|
||||
const path = window.location.pathname;
|
||||
const segments = path.split('/').filter(Boolean);
|
||||
if (segments.length > 0) {
|
||||
const last = segments[segments.length - 1];
|
||||
// 匹配设备编号格式:大写字母开头 + 大写字母/数字
|
||||
if (/^[A-Z][A-Z0-9]+$/.test(last)) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/index/index?device_id=' + last
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import '@/uni_modules/uni-scss/index.scss';
|
||||
/* #ifndef APP-NVUE */
|
||||
@@ -28,5 +43,5 @@
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user