This commit is contained in:
2024-01-24 08:53:20 +08:00
parent 99e84d6617
commit 28e6df56ab

View File

@ -60,7 +60,6 @@
data() { data() {
return { return {
phonecode: undefined, phonecode: undefined,
logincode: undefined,
timer: undefined, timer: undefined,
cityCode: null, cityCode: null,
SOCKETURL: '', SOCKETURL: '',
@ -74,14 +73,6 @@
this.getAddress() this.getAddress()
} }
this.phonecode = undefined this.phonecode = undefined
this.logincode = undefined
let that = this
wx.login({
provider: 'weixin',
success: function(loginRes) {
that.logincode = loginRes.code
}
});
// this.scenenurseStationId = uni.getStorageSync('scenenurseStationId'); // this.scenenurseStationId = uni.getStorageSync('scenenurseStationId');
}, },
methods: { methods: {
@ -153,51 +144,54 @@
} }
}, },
login() { login() {
let that = this;
wx.login({ wx.login({
provider: 'weixin', provider: 'weixin',
success: function(loginRes) { success: function(loginRes) {
that.logincode = loginRes.code isRegistered(loginRes.code, that.phonecode).then(resp => {
} if (resp.data.openid && resp.data.phone) {
}); uni.setStorageSync("openid", resp.data.openid)
let that = this; uni.setStorageSync("phone", resp.data.phone)
// console.log(that.logincode, that.phonecode) }
isRegistered(that.logincode, that.phonecode).then(resp => { if (resp.data.code == '0') {
if (resp.data.openid && resp.data.phone) {
uni.setStorageSync("openid", resp.data.openid)
uni.setStorageSync("phone", resp.data.phone)
}
if (resp.data.code == '0') {
that.$refs.uToast.show({
title: '未注册,请先注册',
type: 'error',
duration: '1500',
})
if (that.timer) {
learTimeout(that.timer)
}
that.timer = setTimeout(() => {
uni.redirectTo({
url: '/pages/register/register',
})
}, 1500)
} else if (resp.data.code == '2') {
that.$refs.uToast.show({
title: '已被其他人注册',
type: 'error',
duration: '1500',
})
} else if (resp.data.code == '1') {
getCurrentUser(resp.data.openid).then(res => {
if (res.code == 200) {
if (res.data) {
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data);
that.scoket();
}
that.$refs.uToast.show({ that.$refs.uToast.show({
title: '登录成功', title: '未注册,请先注册',
type: 'success', type: 'error',
back: 1 duration: '1500',
})
if (that.timer) {
learTimeout(that.timer)
}
that.timer = setTimeout(() => {
uni.redirectTo({
url: '/pages/register/register',
})
}, 1500)
} else if (resp.data.code == '2') {
that.$refs.uToast.show({
title: '已被其他人注册',
type: 'error',
duration: '1500',
})
} else if (resp.data.code == '1') {
getCurrentUser(resp.data.openid).then(res => {
if (res.code == 200) {
if (res.data) {
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data);
that.scoket();
}
that.$refs.uToast.show({
title: '登录成功',
type: 'success',
back: 1
})
} else {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
}
}) })
} else { } else {
that.$refs.uToast.show({ that.$refs.uToast.show({
@ -207,7 +201,7 @@
} }
}) })
} }
}) });
}, },
pwdlogin() { pwdlogin() {
var that = this var that = this