|
|
@ -1,57 +1,14 @@ |
|
|
<template> |
|
|
<template> |
|
|
<view class="login"> |
|
|
<view> |
|
|
<!-- 主要内容区域 --> |
|
|
|
|
|
<view class="content"> |
|
|
|
|
|
<!-- Logo和标题区域 --> |
|
|
|
|
|
<view class="header"> |
|
|
|
|
|
<view class="title">欢迎登录</view> |
|
|
|
|
|
<view class="subtitle">登录您的账号,开启聊天之旅</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 表单区域 --> |
|
|
|
|
|
<view class="form-container"> |
|
|
|
|
|
<view class="form"> |
|
|
|
|
|
<view class="form-item" :class="{'focused': userNameFocused}"> |
|
|
|
|
|
<view class="icon-wrapper"> |
|
|
|
|
|
<view class="icon iconfont icon-username"></view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<input class="input" type="text" v-model="dataForm.userName" placeholder="用户名" |
|
|
|
|
|
@focus="userNameFocused = true" @blur="userNameFocused = false" /> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="form-item" :class="{'focused': passwordFocused}"> |
|
|
|
|
|
<view class="icon-wrapper"> |
|
|
|
|
|
<view class="icon iconfont icon-pwd"></view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<input class="input" :type="isShowPwd?'text':'password'" v-model="dataForm.password" |
|
|
|
|
|
placeholder="密码" @focus="passwordFocused = true" @blur="passwordFocused = false" /> |
|
|
|
|
|
<view class="icon-suffix iconfont" :class="isShowPwd?'icon-pwd-show':'icon-pwd-hide'" |
|
|
|
|
|
@click="onSwitchShowPwd"></view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 登录按钮 --> |
|
|
|
|
|
<button class="submit-btn" @click="submit" type="primary"> |
|
|
|
|
|
<view class="btn-content"> |
|
|
|
|
|
<text class="btn-text">立即登录</text> |
|
|
|
|
|
</view> |
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 底部导航 --> |
|
|
|
|
|
<view class="nav-tool-bar"> |
|
|
|
|
|
<view class="nav-register"> |
|
|
|
|
|
<navigator url="/pages/register/register" class="register-link"> |
|
|
|
|
|
<text class="register-text">没有账号?</text> |
|
|
|
|
|
<text class="register-highlight">立即注册</text> |
|
|
|
|
|
</navigator> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import UNI_APP from '@/.env.js'; |
|
|
import UNI_APP from '@/.env.js'; |
|
|
|
|
|
|
|
|
|
|
|
// 【全局唯一锁】整个APP只执行一次,无论多少个页面实例 |
|
|
|
|
|
let GLOBAL_AUTO_LOGIN_LOCK = false; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
@ -67,18 +24,7 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
async submit() { |
|
|
<<<<<<< HEAD |
|
|
if (!this.dataForm.userName) { |
|
|
|
|
|
return uni.showToast({ |
|
|
|
|
|
title: "请输入您的账号", |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if (!this.dataForm.password) { |
|
|
|
|
|
return uni.showToast({ |
|
|
|
|
|
title: "请输入您的密码", |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
autoLogin() { |
|
|
autoLogin() { |
|
|
// ======================== |
|
|
// ======================== |
|
|
// 全局锁:这辈子只跑一次 |
|
|
// 全局锁:这辈子只跑一次 |
|
|
@ -100,12 +46,7 @@ export default { |
|
|
}) |
|
|
}) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
this.getIp(); |
|
|
await this.getIp(); |
|
|
|
|
|
|
|
|
|
|
|
console.log("登录参数:", this.dataForm); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 无账号密码 → 不登录 |
|
|
// 无账号密码 → 不登录 |
|
|
// if (!userName || !password) { |
|
|
// if (!userName || !password) { |
|
|
// console.log("无缓存账号密码,不自动登录"); |
|
|
// console.log("无缓存账号密码,不自动登录"); |
|
|
@ -123,7 +64,7 @@ export default { |
|
|
}).then(loginInfo => { |
|
|
}).then(loginInfo => { |
|
|
uni.setStorageSync("isAgree", this.isAgree); |
|
|
uni.setStorageSync("isAgree", this.isAgree); |
|
|
uni.setStorageSync("loginInfo", loginInfo); |
|
|
uni.setStorageSync("loginInfo", loginInfo); |
|
|
|
|
|
|
|
|
getApp().$vm.init() |
|
|
getApp().$vm.init() |
|
|
console.log("loginInfo", loginInfo); |
|
|
console.log("loginInfo", loginInfo); |
|
|
this.$http({ |
|
|
this.$http({ |
|
|
@ -147,11 +88,10 @@ export default { |
|
|
console.log("自动登录失败", err); |
|
|
console.log("自动登录失败", err); |
|
|
}); |
|
|
}); |
|
|
// uni.navigateTo({ url: "/pages/chat/chat-box?chatIdx=0" }); |
|
|
// uni.navigateTo({ url: "/pages/chat/chat-box?chatIdx=0" }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
async getIp() { |
|
|
async getIp() { |
|
|
// 获取本机ip |
|
|
// 获取本机ip |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
@ -172,19 +112,18 @@ export default { |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onSwitchShowPwd() { |
|
|
onSwitchShowPwd() { |
|
|
this.isShowPwd = !this.isShowPwd; |
|
|
this.isShowPwd = !this.isShowPwd; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
onLoad() { |
|
|
onLoad() { |
|
|
|
|
|
|
|
|
// 延迟执行,彻底避开双加载 |
|
|
// 延迟执行,彻底避开双加载 |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
this.autoLogin(); |
|
|
this.autoLogin(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, 50); |
|
|
}, 50); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|