增加密码错误的异常捕获和oa自动登录
This commit is contained in:
@@ -6,69 +6,31 @@
|
|||||||
<view class="title">欢迎使用德迅,福安德信息科技有限公司内部交流平台</view>
|
<view class="title">欢迎使用德迅,福安德信息科技有限公司内部交流平台</view>
|
||||||
</view>
|
</view>
|
||||||
<u-tabs :list="list" @click="click"></u-tabs>
|
<u-tabs :list="list" @click="click"></u-tabs>
|
||||||
<u-form
|
<u-form class="loginForm" labelPosition="top" :model="loginInfo" :labelStyle="{
|
||||||
class="loginForm"
|
|
||||||
labelPosition="top"
|
|
||||||
:model="loginInfo"
|
|
||||||
:labelStyle="{
|
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
marginTop: '20rpx',
|
marginTop: '20rpx',
|
||||||
width: 'max-content',
|
width: 'max-content',
|
||||||
}"
|
}" ref="loginForm">
|
||||||
ref="loginForm"
|
|
||||||
>
|
|
||||||
<u-form-item v-if="active === 0" label="" prop="phoneNumber">
|
<u-form-item v-if="active === 0" label="" prop="phoneNumber">
|
||||||
<u-input
|
<u-input v-model="loginInfo.phoneNumber" border="surround" placeholder="请输入手机号码" clearable>
|
||||||
v-model="loginInfo.phoneNumber"
|
<view slot="prefix" class="phoneNumber_areacode" @click="showPicker">
|
||||||
border="surround"
|
|
||||||
placeholder="请输入手机号码"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<view
|
|
||||||
slot="prefix"
|
|
||||||
class="phoneNumber_areacode"
|
|
||||||
@click="showPicker"
|
|
||||||
>
|
|
||||||
<text class="areacode_content">+{{ loginInfo.areaCode }}</text>
|
<text class="areacode_content">+{{ loginInfo.areaCode }}</text>
|
||||||
<u-icon class="arrow_down" name="arrow-down"></u-icon>
|
<u-icon class="arrow_down" name="arrow-down"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
</u-input>
|
</u-input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item v-if="active === 1" label="" prop="email">
|
<u-form-item v-if="active === 1" label="" prop="email">
|
||||||
<u-input
|
<u-input v-model="loginInfo.email" border="surround" placeholder="请输入您的邮箱" clearable>
|
||||||
v-model="loginInfo.email"
|
|
||||||
border="surround"
|
|
||||||
placeholder="请输入您的邮箱"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
</u-input>
|
</u-input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item v-if="active > 1 || isPwdLogin" label="" prop="password">
|
<u-form-item v-if="active > 1 || isPwdLogin" label="" prop="password">
|
||||||
<u-input
|
<u-input v-model="loginInfo.password" border="surround" placeholder="请输入密码" :password="!eying" clearable>
|
||||||
v-model="loginInfo.password"
|
<u-icon @click="updateEye" slot="suffix" :name="eying ? 'eye-off' : 'eye'">
|
||||||
border="surround"
|
|
||||||
placeholder="请输入密码"
|
|
||||||
:password="!eying"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<u-icon
|
|
||||||
@click="updateEye"
|
|
||||||
slot="suffix"
|
|
||||||
:name="eying ? 'eye-off' : 'eye'"
|
|
||||||
>
|
|
||||||
</u-icon>
|
</u-icon>
|
||||||
</u-input>
|
</u-input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item
|
<u-form-item v-if="active <= 1 && !isPwdLogin" label="" prop="verificationCode">
|
||||||
v-if="active <= 1 && !isPwdLogin"
|
<u-input v-model="loginInfo.verificationCode" border="surround" placeholder="请输入验证码">
|
||||||
label=""
|
|
||||||
prop="verificationCode"
|
|
||||||
>
|
|
||||||
<u-input
|
|
||||||
v-model="loginInfo.verificationCode"
|
|
||||||
border="surround"
|
|
||||||
placeholder="请输入验证码"
|
|
||||||
>
|
|
||||||
<view class="code_btn" slot="suffix" @click="getCode">
|
<view class="code_btn" slot="suffix" @click="getCode">
|
||||||
{{ count !== 0 ? `${count} s` : "获取验证码" }}
|
{{ count !== 0 ? `${count} s` : "获取验证码" }}
|
||||||
</view>
|
</view>
|
||||||
@@ -80,12 +42,7 @@
|
|||||||
<text class="forget" @click="toggleLoginMethod">{{ isPwdLogin ? "验证码登录" : "密码登录" }}</text>
|
<text class="forget" @click="toggleLoginMethod">{{ isPwdLogin ? "验证码登录" : "密码登录" }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="login-btn">
|
<view class="login-btn">
|
||||||
<u-button
|
<u-button :loading="loading" type="primary" @click="startLogin" :disabled="!canLogin">
|
||||||
:loading="loading"
|
|
||||||
type="primary"
|
|
||||||
@click="startLogin"
|
|
||||||
:disabled="!canLogin"
|
|
||||||
>
|
|
||||||
登录
|
登录
|
||||||
</u-button>
|
</u-button>
|
||||||
</view>
|
</view>
|
||||||
@@ -186,7 +143,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
async startLogin() {
|
async startLogin() {
|
||||||
// this.$refs.loginForm.validate().then(async (valid) => {
|
try {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.saveLoginInfo();
|
this.saveLoginInfo();
|
||||||
let data = {};
|
let data = {};
|
||||||
@@ -200,6 +157,9 @@ export default {
|
|||||||
});
|
});
|
||||||
console.log("data: " + JSON.stringify(data));
|
console.log("data: " + JSON.stringify(data));
|
||||||
const { imToken, userID } = data;
|
const { imToken, userID } = data;
|
||||||
|
if (!imToken || !userID) {
|
||||||
|
throw new Error("登录失败")
|
||||||
|
}
|
||||||
await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), {
|
await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), {
|
||||||
userID,
|
userID,
|
||||||
token: imToken,
|
token: imToken,
|
||||||
@@ -216,75 +176,18 @@ export default {
|
|||||||
this.$store.dispatch("contact/getSentFriendApplications");
|
this.$store.dispatch("contact/getSentFriendApplications");
|
||||||
this.$store.dispatch("contact/getRecvGroupApplications");
|
this.$store.dispatch("contact/getRecvGroupApplications");
|
||||||
this.$store.dispatch("contact/getSentGroupApplications");
|
this.$store.dispatch("contact/getSentGroupApplications");
|
||||||
// 登录成功后,绑定deviceId与imId
|
await getSMSCodeFromOa(this.loginInfo.phoneNumber);
|
||||||
// 获取设备cid,调用云函数
|
const info = await loginOaByPhone(this.loginInfo.phoneNumber)
|
||||||
// const cid = uni.getStorageSync('cid');
|
this.loginInfo.password = "";
|
||||||
// uniCloud.callFunction({
|
this.loading = false;
|
||||||
// name: 'bindingIm',
|
|
||||||
// data: {
|
|
||||||
// deviceId: cid,
|
|
||||||
// imId: userID
|
|
||||||
// },
|
|
||||||
// success: (res) => {
|
|
||||||
// if (res.result.code === 200) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: res.result.msg,
|
|
||||||
// icon: 'success'
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: res.result.msg,
|
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// fail: (err) => {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '云函数调用失败',
|
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
// console.error(err);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: "/pages/conversation/conversationList/index",
|
url: "/pages/conversation/conversationList/index",
|
||||||
});
|
});
|
||||||
await getSMSCodeFromOa(this.loginInfo.phoneNumber);
|
} catch (error) {
|
||||||
const info = await loginOaByPhone(this.loginInfo.phoneNumber)
|
console.error(error);
|
||||||
// console.log('用户信息', info)
|
uni.$u.toast("登录失败");
|
||||||
// const oaUserId = info.userInfo.userId;
|
|
||||||
|
|
||||||
// uniCloud.callFunction({
|
|
||||||
// name: 'binding',
|
|
||||||
// data: {
|
|
||||||
// oaId: oaUserId,
|
|
||||||
// deviceId: cid
|
|
||||||
// },
|
|
||||||
// success: (res) => {
|
|
||||||
// if (res.result.code === 200) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: res.result.msg,
|
|
||||||
// icon: 'success'
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: res.result.msg,
|
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// fail: (err) => {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '云函数调用失败',
|
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
// console.error(err);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
this.loginInfo.password = "";
|
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
// });
|
}
|
||||||
},
|
},
|
||||||
saveLoginProfile(data) {
|
saveLoginProfile(data) {
|
||||||
const { imToken, chatToken, userID } = data;
|
const { imToken, chatToken, userID } = data;
|
||||||
@@ -371,11 +274,9 @@ export default {
|
|||||||
.login {
|
.login {
|
||||||
color: #0c1c33;
|
color: #0c1c33;
|
||||||
padding: 10vh 80rpx 0;
|
padding: 10vh 80rpx 0;
|
||||||
background: linear-gradient(
|
background: linear-gradient(180deg,
|
||||||
180deg,
|
|
||||||
rgba(0, 137, 255, 0.1) 0%,
|
rgba(0, 137, 255, 0.1) 0%,
|
||||||
rgba(255, 255, 255, 0) 100%
|
rgba(255, 255, 255, 0) 100%);
|
||||||
);
|
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
|
|||||||
@@ -3,21 +3,13 @@
|
|||||||
<view class="self_info_row"></view>
|
<view class="self_info_row"></view>
|
||||||
|
|
||||||
<view class="info_card">
|
<view class="info_card">
|
||||||
<my-avatar
|
<my-avatar :src="selfInfo.faceURL || '/static/images/default_avatar.png'" :desc="selfInfo.nickname" size="46" />
|
||||||
:src="selfInfo.faceURL || '/static/images/default_avatar.png'"
|
|
||||||
:desc="selfInfo.nickname"
|
|
||||||
size="46"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<view class="id_row">
|
<view class="id_row">
|
||||||
<text class="nickname">{{ selfInfo.nickname }}</text>
|
<text class="nickname">{{ selfInfo.nickname }}</text>
|
||||||
<view class="id_row_copy" @click="copy">
|
<view class="id_row_copy" @click="copy">
|
||||||
<text class="id">{{ selfInfo.userID }}</text>
|
<text class="id">{{ selfInfo.userID }}</text>
|
||||||
<image
|
<image style="width: 32rpx; height: 32rpx" src="@/static/images/id_copy.png" mode="" />
|
||||||
style="width: 32rpx; height: 32rpx"
|
|
||||||
src="@/static/images/id_copy.png"
|
|
||||||
mode=""
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -28,12 +20,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="action_box">
|
<view class="action_box">
|
||||||
<view
|
<view @click="profileMenuClick(item)" class="profile_menu_item" v-for="item in profileMenus" :key="item.idx">
|
||||||
@click="profileMenuClick(item)"
|
|
||||||
class="profile_menu_item"
|
|
||||||
v-for="item in profileMenus"
|
|
||||||
:key="item.idx"
|
|
||||||
>
|
|
||||||
<view class="menu_left">
|
<view class="menu_left">
|
||||||
<image style="width: 48rpx; height: 48rpx" :src="item.icon" mode="" />
|
<image style="width: 48rpx; height: 48rpx" :src="item.icon" mode="" />
|
||||||
<text>{{ item.title }}</text>
|
<text>{{ item.title }}</text>
|
||||||
@@ -83,6 +70,11 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
idx: 6,
|
idx: 6,
|
||||||
|
title: "清理缓存",
|
||||||
|
icon: require("static/images/profile_menu_about.png"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
idx: 7,
|
||||||
title: "退出登录",
|
title: "退出登录",
|
||||||
icon: require("static/images/profile_menu_logout.png"),
|
icon: require("static/images/profile_menu_logout.png"),
|
||||||
},
|
},
|
||||||
@@ -162,6 +154,9 @@ export default {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
this.clearCache();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: "确定要退出当前账号吗?",
|
content: "确定要退出当前账号吗?",
|
||||||
@@ -206,7 +201,7 @@ export default {
|
|||||||
success: (modalRes) => {
|
success: (modalRes) => {
|
||||||
if (modalRes.confirm) {
|
if (modalRes.confirm) {
|
||||||
uni.$updateManager.clearIgnoredVersion();
|
uni.$updateManager.clearIgnoredVersion();
|
||||||
uni.showToast({title: '已清除忽略版本设置'});
|
uni.showToast({ title: '已清除忽略版本设置' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -218,6 +213,82 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
clearCache() {
|
||||||
|
uni.showModal({
|
||||||
|
title: "清理缓存",
|
||||||
|
content: "确定要清理应用缓存吗?清理后需要重新登录。",
|
||||||
|
confirmText: "确认清理",
|
||||||
|
cancelText: "取消",
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '清理中...'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清理本地存储
|
||||||
|
const clearStorageKeys = [
|
||||||
|
'IMToken',
|
||||||
|
'BusinessToken',
|
||||||
|
'userInfo',
|
||||||
|
'conversationList',
|
||||||
|
'messageList',
|
||||||
|
'contactList'
|
||||||
|
];
|
||||||
|
|
||||||
|
clearStorageKeys.forEach(key => {
|
||||||
|
try {
|
||||||
|
uni.removeStorageSync(key);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`清理缓存失败: ${key}`, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清理文件缓存
|
||||||
|
uni.getSavedFileList({
|
||||||
|
success: (fileRes) => {
|
||||||
|
if (fileRes.fileList && fileRes.fileList.length > 0) {
|
||||||
|
fileRes.fileList.forEach(file => {
|
||||||
|
uni.removeSavedFile({
|
||||||
|
filePath: file.filePath,
|
||||||
|
success: () => {
|
||||||
|
console.log('文件缓存清理成功:', file.filePath);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.log('文件缓存清理失败:', file.filePath, err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.log('获取文件列表失败:', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清理图片缓存
|
||||||
|
uni.getImageInfo({
|
||||||
|
src: '/static/images/default_avatar.png',
|
||||||
|
success: () => {
|
||||||
|
// 这里可以添加更多图片缓存清理逻辑
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: '缓存清理完成',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清理完成后跳转到登录页
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.$u.route("/pages/login/index");
|
||||||
|
}, 1500);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const request = config => {
|
|||||||
data: config.data,
|
data: config.data,
|
||||||
header: config.header,
|
header: config.header,
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).then(response => {
|
}).then(async response => {
|
||||||
let [error, res] = response
|
let [error, res] = response
|
||||||
// 打印返回值
|
// 打印返回值
|
||||||
console.log('[oaRequest] 返回值:', res)
|
console.log('[oaRequest] 返回值:', res)
|
||||||
@@ -59,6 +59,12 @@ const request = config => {
|
|||||||
try {
|
try {
|
||||||
await getSMSCodeFromOa(phoneNumber)
|
await getSMSCodeFromOa(phoneNumber)
|
||||||
await loginOaByPhone(phoneNumber)
|
await loginOaByPhone(phoneNumber)
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const page = pages[pages.length - 1];
|
||||||
|
// 重新加载当前页面
|
||||||
|
if (page && page.onLoad) {
|
||||||
|
page.onLoad(page.options || {});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('OA自动登录失败', e)
|
console.log('OA自动登录失败', e)
|
||||||
toast('OA自动登录失败')
|
toast('OA自动登录失败')
|
||||||
@@ -66,10 +72,6 @@ const request = config => {
|
|||||||
} else {
|
} else {
|
||||||
toast('无法获取手机号,OA自动登录失败')
|
toast('无法获取手机号,OA自动登录失败')
|
||||||
}
|
}
|
||||||
// 登录
|
|
||||||
// store.dispatch('LogOut').then(res => {
|
|
||||||
// uni.reLaunch({ url: '/pages/login' })
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
reject('无效的会话,或者会话已过期,请重新登录。')
|
reject('无效的会话,或者会话已过期,请重新登录。')
|
||||||
|
|||||||
Reference in New Issue
Block a user