增加内网设备绑定

This commit is contained in:
xuli3099
2025-08-20 09:43:00 +08:00
parent 8f849cda40
commit b2b0c11966
4 changed files with 52 additions and 8 deletions

View File

@@ -4,5 +4,5 @@ export const AGREEWELCOME_KEY="agreewelcome";
// clientId 默认写2
export const CLIENT_ID="2";
// #区分内外网 //1-内网2-外网
export const NETWORK_ENV=2;
export const NETWORK_ENV=1;

View File

@@ -6,13 +6,26 @@
<view :style="{height: navBarPaddingTop + 'px'}"></view>
<view class="auth-title">
<image src="@/static/images/icon-lock@2x.png"/>
<text>设备授权</text>
<text>{{networkEnv==1?'内网':''}}设备授权</text>
</view>
<view class="login-con">
<!-- 登录 -->
<block v-if="!bindStatus">
<view class="login-form">
<view class="login-form" :class="{network1:networkEnv==1}">
<uni-forms ref="form2" :model="formData2" :rules="rules2" label-position="top">
<!-- networkEnv -->
<uni-forms-item label="设备标识" required name="uniqCode" v-if="networkEnv==1">
<view class="code-con code-device">
<uni-easyinput prefixIcon="person" :inputBorder="false"
v-model="formData2.uniqCode" placeholder="请输入设备标识"
>
<!-- <template #prefixIcon> -->
<!-- <image src="@/static/images/login-biaoshi.png" style="width: 20px; height: 20px;" /> -->
<!-- </template> -->
</uni-easyinput>
</view>
</uni-forms-item>
<uni-forms-item label="用户名" required name="username">
<view class="code-con">
<uni-easyinput prefixIcon="person" :inputBorder="false"
@@ -96,7 +109,7 @@ let deviceId = ref(undefined);
let clientId = `${proxy.$CLIENT_ID || 2}`;
let networkEnv = ref(proxy.$NETWORK_ENV);//1-内网 2-外网
onLoad(async(opt) => {
console.log("deviceAuth=>onLoad",clientId,networkEnv);
console.log("deviceAuth=>onLoad",clientId,networkEnv.value);
uni.setStorageSync('page_cache',true);
// uni.preloadPage({url: "/pages/login/login"});
// uni.preloadPage({url: "/pages/home/home"});
@@ -187,11 +200,17 @@ let refreshBindStatus = async ()=>{
// 账号登录
const form2 = ref(null);
const formData2 = ref({
uniqCode:'',
username: '',
password: ''
});
const rules2 = {
uniqCode:{
rules: [
{ required: true, errorMessage: '请输入设备标识' },
]
},
username: {
rules: [
{ required: true, errorMessage: '请输入用户名' },
@@ -212,8 +231,8 @@ const submitForm = async() => {
form2.value.validate().then(async param => {
btnLoading.value = true;
//1-内网2-外网
if(networkEnv==1){
deviceId.value = form2.value.uniqCode;
if(networkEnv.value==1){
deviceId.value = param.uniqCode;
}else{
deviceId.value = uuidv4(); //2-外网 生成的设备唯一标识
}
@@ -450,6 +469,31 @@ const handleSubmit=()=>{
content: "\e66c" !important;
}
/* 加设备ID样式 */
.container .login-form.network1{
padding-bottom:50rpx;
}
.container .login-form.network1 .code-con{
padding:0 0 3rpx;
}
.container .login-form.network1 :deep(.uni-forms-item){
margin-bottom:10px !important
}
.container .login-form.network1 :deep(.uni-easyinput__content-input){
height: 30px !important;
}
.container .login-form .code-con.code-device :deep(.uni-easyinput__content .uniui-person){
background: url('@/static/images/login-biaoshi.png') 15rpx no-repeat;
background-size:25rpx 30rpx;
width: 25rpx;
height: 30rpx;
margin-right:10rpx;
}
.container .login-form .code-con.code-device :deep(.uniui-person:before){
display: none;
}
.btn-submit{
width:496rpx;
height:88rpx;

View File

@@ -14,9 +14,9 @@
>
<!-- #ifdef APP-PLUS -->
<!-- 删除设备ID--测试用 -->
<!-- <view class="del-cache" @click="handleDelete">
<view class="del-cache" @click="handleDelete">
<uni-icons type="minus" size="30" color="#ffffff"></uni-icons>
</view> -->
</view>
<!-- #endif -->
<!-- 待办内容 -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B