diff --git a/src/api/index.js b/src/api/index.js
index dab3a8f..22064ca 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -5,15 +5,14 @@ const host1 = `http://192.168.31.137:9000/`
const uploadURL = "http://39.108.250.202:9000/";
export default {
- host,
-
- // 登录
logins: `${host1}users/users/user/login`,
verification: `${host1}users/users/user/captcha`,// 验证码图片
logoDetail: `occupationlab/sys/logo/detail`, //查看系统设置信息
isClient: `${host1}users/users/user/isClient`,
sendPhoneVerificationCode: `${host1}users/users/user/sendPhoneVerificationCode`,
getToken: `${host1}users/users/user/getToken`,
+ getOtherAccountByPhone: `${host1}users/users/user/getOtherAccountByPhone`,
+ unbindAccounts: `${host1}users/users/user/getOtherAccountunbindAccountsByPhone`,
platformLogList: `nakadai/log/platformLogList`,
logNotification: `nakadai/log/logNotification`,
diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue
index b1e1ca2..a16c55f 100644
--- a/src/pages/account/login/index.vue
+++ b/src/pages/account/login/index.vue
@@ -14,9 +14,6 @@
-
- 设置为默认学校
-
@@ -73,6 +70,9 @@
+
+ 设置为默认学校
+
登录
@@ -83,12 +83,12 @@
-
+
- {{ phoneBtnText }}
+ {{ phoneBtnText }}
@@ -174,12 +174,15 @@ export default {
phoneCode: '',
phoneDisabled: false,
phoneTimer: null,
+ phoneOpener: '',
phoneBtnText: '发送验证码',
selectVisible: false,
selectedRole: '',
token: '',
userVisible: false,
- users: []
+ users: [],
+ accountIds: [],
+ binding: true
};
},
components: {
@@ -370,12 +373,37 @@ export default {
sendPhoneCodeLogin() {
const phone = this.form.account
if (!this.verifyPhone(phone)) return false
- this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phone}`).then(({ message }) => {
+ this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phone}&loginOrBind=0`).then(({ message }) => {
util.successMsg(message)
this.phoneCountdownLogin()
}).catch(res => {})
},
-
+ // 手机号失去焦点回调
+ phoneChange() {
+ this.$post(`${this.api.getOtherAccountByPhone}?phone=${this.phone}&platform=${Setting.platformId}`).then(({ userAccounts }) => {
+ const list = userAccounts
+ if (list) {
+ const msg = []
+ list.map(e => {
+ msg.push(`${e.userName}(${e.schoolName},学号${e.workNumber})`)
+ })
+ this.accountIds = list.map(e => e.id)
+ this.$confirm(`该手机号已与${msg.join(';')}的用户绑定,是否为本人?选择否,则解绑以上用户信息,并授权手机号绑定新用户信息。`, '提示', {
+ type: 'warning',
+ confirmButtonText: '是',
+ cancelButtonText: '否'
+ }).then(() => {
+ debugger
+ this.binding = true
+ this.sendPhoneCode(1)
+ }).catch(() => {
+ debugger
+ this.binding = false
+ this.sendPhoneCode(0)
+ })
+ }
+ }).catch(res => {})
+ },
// 验证码倒计时
phoneCountdown() {
let count = 60
@@ -395,41 +423,66 @@ export default {
}
},
// 发送验证码
- sendPhoneCode() {
+ sendPhoneCode(bind) {
const { phone } = this
if (!this.verifyPhone(phone)) return false
- this.$post(this.api.sendPhoneOrEmailCode, {
- platform: Setting.platformId,
- phone,
- types: 2
- }).then(({ message }) => {
- if (message.opener) {
+ // 不解绑发送验证码
+ if (bind) {
+ this.$post(this.api.sendPhoneOrEmailCode, {
+ platform: Setting.platformId,
+ phone,
+ types: 2
+ }).then(({ message }) => {
+ if (message.opener) {
+ this.phoneCountdown()
+ this.phoneOpener = message.opener
+ } else {
+ util.errorMsg(message)
+ }
+ }).catch(res => {})
+ } else {
+ this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phone}&loginOrBind=1`).then(({ message }) => {
this.phoneCountdown()
- this.phoneOpener = message.opener
- } else {
- util.errorMsg(message)
- }
+ }).catch(res => {})
+ }
+ },
+ // 解绑
+ unbind() {
+ const { password, platform, schoolId, type, workNumber } = this.form
+ this.$post(this.api.unbindAccounts, {
+ accountIds: this.accountIds,
+ code: this.phoneCode,
+ password,
+ phone: this.phone,
+ platform,
+ schoolId,
+ type,
+ workNumber,
+ }).then(({ token }) => {
+ this.token = token
+ this.setLogin()
}).catch(res => {})
},
// 绑定手机号
phoneSubmit() {
const { phone, phoneCode } = this
if (!this.verifyPhone(phone)) return false
- if (!phoneCode) return util.warningMsg("请输入验证码")
- this.$post(this.api.bindPhoneOrEmail, {
- phone,
- types: 2,
- code: phoneCode,
- opener: this.phoneOpener,
- platform: Setting.platformId,
- account: this.form.workNumber
- }).then(({ token }) => {
- util.successMsg("绑定成功")
- this.form.phone = this.phone
- this.phoneVisible = false
- this.token = token
- this.setLogin()
- }).catch(res => {})
+ if (!phoneCode) return util.warningMsg('请输入验证码')
+ if (this.binding) {
+ this.$post(this.api.bindPhoneOrEmail, {
+ phone,
+ types: 2,
+ code: phoneCode,
+ opener: this.phoneOpener,
+ platform: Setting.platformId,
+ account: this.form.workNumber
+ }).then(({ token }) => {
+ this.token = token
+ this.setLogin()
+ }).catch(res => {})
+ } else {
+ this.unbind()
+ }
}
}
};
@@ -500,9 +553,6 @@ export default {
border: 1px solid #E1E6F2;
border-radius: 4px !important;
}
- .school-select {
- // margin-bottom: 10px;
- }
.default-check {
text-align: right;
}
diff --git a/src/pages/setting/person/info.vue b/src/pages/setting/person/info.vue
index d91f001..f0a113d 100644
--- a/src/pages/setting/person/info.vue
+++ b/src/pages/setting/person/info.vue
@@ -1,6 +1,6 @@