diff --git a/pages/login/index.vue b/pages/login/index.vue
index 88ea34f..3698908 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -6,69 +6,31 @@
欢迎使用德迅,福安德信息科技有限公司内部交流平台
-
+
-
-
+
+
+{{ loginInfo.areaCode }}
-
+
-
-
+
+
-
-
+
+
{{ count !== 0 ? `${count} s` : "获取验证码" }}
@@ -80,12 +42,7 @@
{{ isPwdLogin ? "验证码登录" : "密码登录" }}
-
+
登录
@@ -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;
diff --git a/pages/profile/index/index.vue b/pages/profile/index/index.vue
index b27ed1d..3e29196 100644
--- a/pages/profile/index/index.vue
+++ b/pages/profile/index/index.vue
@@ -3,21 +3,13 @@
-
+
{{ selfInfo.nickname }}
{{ selfInfo.userID }}
-
+
@@ -28,12 +20,7 @@
-