增加密码错误的异常捕获和oa自动登录
This commit is contained in:
@@ -6,69 +6,31 @@
|
||||
<view class="title">欢迎使用德迅,福安德信息科技有限公司内部交流平台</view>
|
||||
</view>
|
||||
<u-tabs :list="list" @click="click"></u-tabs>
|
||||
<u-form
|
||||
class="loginForm"
|
||||
labelPosition="top"
|
||||
:model="loginInfo"
|
||||
:labelStyle="{
|
||||
fontSize: '14px',
|
||||
marginTop: '20rpx',
|
||||
width: 'max-content',
|
||||
}"
|
||||
ref="loginForm"
|
||||
>
|
||||
<u-form class="loginForm" labelPosition="top" :model="loginInfo" :labelStyle="{
|
||||
fontSize: '14px',
|
||||
marginTop: '20rpx',
|
||||
width: 'max-content',
|
||||
}" ref="loginForm">
|
||||
<u-form-item v-if="active === 0" label="" prop="phoneNumber">
|
||||
<u-input
|
||||
v-model="loginInfo.phoneNumber"
|
||||
border="surround"
|
||||
placeholder="请输入手机号码"
|
||||
clearable
|
||||
>
|
||||
<view
|
||||
slot="prefix"
|
||||
class="phoneNumber_areacode"
|
||||
@click="showPicker"
|
||||
>
|
||||
<u-input v-model="loginInfo.phoneNumber" border="surround" placeholder="请输入手机号码" clearable>
|
||||
<view slot="prefix" class="phoneNumber_areacode" @click="showPicker">
|
||||
<text class="areacode_content">+{{ loginInfo.areaCode }}</text>
|
||||
<u-icon class="arrow_down" name="arrow-down"></u-icon>
|
||||
</view>
|
||||
</u-input>
|
||||
</u-form-item>
|
||||
<u-form-item v-if="active === 1" label="" prop="email">
|
||||
<u-input
|
||||
v-model="loginInfo.email"
|
||||
border="surround"
|
||||
placeholder="请输入您的邮箱"
|
||||
clearable
|
||||
>
|
||||
<u-input v-model="loginInfo.email" border="surround" placeholder="请输入您的邮箱" clearable>
|
||||
</u-input>
|
||||
</u-form-item>
|
||||
<u-form-item v-if="active > 1 || isPwdLogin" label="" prop="password">
|
||||
<u-input
|
||||
v-model="loginInfo.password"
|
||||
border="surround"
|
||||
placeholder="请输入密码"
|
||||
:password="!eying"
|
||||
clearable
|
||||
>
|
||||
<u-icon
|
||||
@click="updateEye"
|
||||
slot="suffix"
|
||||
:name="eying ? 'eye-off' : 'eye'"
|
||||
>
|
||||
<u-input v-model="loginInfo.password" border="surround" placeholder="请输入密码" :password="!eying" clearable>
|
||||
<u-icon @click="updateEye" slot="suffix" :name="eying ? 'eye-off' : 'eye'">
|
||||
</u-icon>
|
||||
</u-input>
|
||||
</u-form-item>
|
||||
<u-form-item
|
||||
v-if="active <= 1 && !isPwdLogin"
|
||||
label=""
|
||||
prop="verificationCode"
|
||||
>
|
||||
<u-input
|
||||
v-model="loginInfo.verificationCode"
|
||||
border="surround"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<u-form-item v-if="active <= 1 && !isPwdLogin" label="" prop="verificationCode">
|
||||
<u-input v-model="loginInfo.verificationCode" border="surround" placeholder="请输入验证码">
|
||||
<view class="code_btn" slot="suffix" @click="getCode">
|
||||
{{ count !== 0 ? `${count} s` : "获取验证码" }}
|
||||
</view>
|
||||
@@ -80,12 +42,7 @@
|
||||
<text class="forget" @click="toggleLoginMethod">{{ isPwdLogin ? "验证码登录" : "密码登录" }}</text>
|
||||
</view>
|
||||
<view class="login-btn">
|
||||
<u-button
|
||||
:loading="loading"
|
||||
type="primary"
|
||||
@click="startLogin"
|
||||
:disabled="!canLogin"
|
||||
>
|
||||
<u-button :loading="loading" type="primary" @click="startLogin" :disabled="!canLogin">
|
||||
登录
|
||||
</u-button>
|
||||
</view>
|
||||
@@ -120,9 +77,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
list: [{
|
||||
name: '手机号',
|
||||
name: '手机号',
|
||||
}, {
|
||||
name: '邮箱',
|
||||
name: '邮箱',
|
||||
}],
|
||||
loginInfo: {
|
||||
email: "",
|
||||
@@ -144,7 +101,7 @@ export default {
|
||||
},
|
||||
canLogin() {
|
||||
return (
|
||||
(this.loginInfo.phoneNumber || this.loginInfo.email) &&
|
||||
(this.loginInfo.phoneNumber || this.loginInfo.email) &&
|
||||
(this.loginInfo.password || this.loginInfo.verificationCode)
|
||||
);
|
||||
},
|
||||
@@ -186,105 +143,51 @@ export default {
|
||||
});
|
||||
},
|
||||
async startLogin() {
|
||||
// this.$refs.loginForm.validate().then(async (valid) => {
|
||||
try {
|
||||
this.loading = true;
|
||||
this.saveLoginInfo();
|
||||
let data = {};
|
||||
data = await businessLogin({
|
||||
phoneNumber: this.loginInfo.phoneNumber,
|
||||
email: this.loginInfo.email,
|
||||
areaCode: `+${this.loginInfo.areaCode}`,
|
||||
password: this.isPwdLogin ? md5(this.loginInfo.password) : "",
|
||||
platform: uni.$u.os() === "ios" ? 1 : 2,
|
||||
verifyCode: this.loginInfo.verificationCode,
|
||||
});
|
||||
console.log("data: " + JSON.stringify(data));
|
||||
const { imToken, userID } = data;
|
||||
await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), {
|
||||
userID,
|
||||
token: imToken,
|
||||
});
|
||||
this.saveLoginProfile(data);
|
||||
this.$store.commit("user/SET_AUTH_DATA", data);
|
||||
this.$store.dispatch("user/getSelfInfo");
|
||||
this.$store.dispatch("conversation/getConversationList");
|
||||
this.$store.dispatch("conversation/getUnReadCount");
|
||||
this.$store.dispatch("contact/getFriendList");
|
||||
this.$store.dispatch("contact/getGrouplist");
|
||||
this.$store.dispatch("contact/getBlacklist");
|
||||
this.$store.dispatch("contact/getRecvFriendApplications");
|
||||
this.$store.dispatch("contact/getSentFriendApplications");
|
||||
this.$store.dispatch("contact/getRecvGroupApplications");
|
||||
this.$store.dispatch("contact/getSentGroupApplications");
|
||||
// 登录成功后,绑定deviceId与imId
|
||||
// 获取设备cid,调用云函数
|
||||
// const cid = uni.getStorageSync('cid');
|
||||
// uniCloud.callFunction({
|
||||
// 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({
|
||||
url: "/pages/conversation/conversationList/index",
|
||||
});
|
||||
await getSMSCodeFromOa(this.loginInfo.phoneNumber);
|
||||
const info = await loginOaByPhone(this.loginInfo.phoneNumber)
|
||||
// console.log('用户信息', info)
|
||||
// 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 = "";
|
||||
|
||||
data = await businessLogin({
|
||||
phoneNumber: this.loginInfo.phoneNumber,
|
||||
email: this.loginInfo.email,
|
||||
areaCode: `+${this.loginInfo.areaCode}`,
|
||||
password: this.isPwdLogin ? md5(this.loginInfo.password) : "",
|
||||
platform: uni.$u.os() === "ios" ? 1 : 2,
|
||||
verifyCode: this.loginInfo.verificationCode,
|
||||
});
|
||||
console.log("data: " + JSON.stringify(data));
|
||||
const { imToken, userID } = data;
|
||||
if (!imToken || !userID) {
|
||||
throw new Error("登录失败")
|
||||
}
|
||||
await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), {
|
||||
userID,
|
||||
token: imToken,
|
||||
});
|
||||
this.saveLoginProfile(data);
|
||||
this.$store.commit("user/SET_AUTH_DATA", data);
|
||||
this.$store.dispatch("user/getSelfInfo");
|
||||
this.$store.dispatch("conversation/getConversationList");
|
||||
this.$store.dispatch("conversation/getUnReadCount");
|
||||
this.$store.dispatch("contact/getFriendList");
|
||||
this.$store.dispatch("contact/getGrouplist");
|
||||
this.$store.dispatch("contact/getBlacklist");
|
||||
this.$store.dispatch("contact/getRecvFriendApplications");
|
||||
this.$store.dispatch("contact/getSentFriendApplications");
|
||||
this.$store.dispatch("contact/getRecvGroupApplications");
|
||||
this.$store.dispatch("contact/getSentGroupApplications");
|
||||
await getSMSCodeFromOa(this.loginInfo.phoneNumber);
|
||||
const info = await loginOaByPhone(this.loginInfo.phoneNumber)
|
||||
this.loginInfo.password = "";
|
||||
this.loading = false;
|
||||
// });
|
||||
uni.switchTab({
|
||||
url: "/pages/conversation/conversationList/index",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
uni.$u.toast("登录失败");
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
saveLoginProfile(data) {
|
||||
const { imToken, chatToken, userID } = data;
|
||||
@@ -371,11 +274,9 @@ export default {
|
||||
.login {
|
||||
color: #0c1c33;
|
||||
padding: 10vh 80rpx 0;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 137, 255, 0.1) 0%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
background: linear-gradient(180deg,
|
||||
rgba(0, 137, 255, 0.1) 0%,
|
||||
rgba(255, 255, 255, 0) 100%);
|
||||
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
|
||||
Reference in New Issue
Block a user