首页登录

This commit is contained in:
shidongli 2023-11-10 15:56:33 +08:00
parent c1c9243f30
commit dc3f3dd978
4 changed files with 40 additions and 14 deletions

View File

@ -12,9 +12,9 @@ export function getOpenId(code) {
}
// 获取当前注册居民
export function getCurrentUser(openid, cityCode) {
export function getCurrentUser(openid) {
return request({
url: `/applet/register/getCurrentResident/${openid}/${cityCode}`,
url: `/applet/register/getCurrentResident/${openid}`,
method: 'GET',
header: {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
@ -42,4 +42,4 @@ export function checkSignApply(identity) {
region: uni.getStorageSync('region'),
},
})
}
}

View File

@ -169,10 +169,12 @@
goonline() {
if (!this.userinfo) {
this.gologin();
} else {
} else if(this.userinfo){
if (this.region == 3) {
this.family()
} else {
console.log(this.userinfo,'0900')
if (this.region == 1 || this.region == 2) {
if (this.checkSign == "0") {
this.$refs.uToast.show({

View File

@ -96,15 +96,27 @@
getPhoneNumberp(val) {
let that = this;
if (val.detail.code) {
that.phonecode = val.detail.code
that.login();
}
},
login() {
wx.login({
provider: 'weixin',
success: function(loginRes) {
that.logincode = loginRes.code
}
});
let that = this;
// console.log(that.logincode, that.phonecode)
isRegistered(that.logincode, that.phonecode).then(resp => {
uni.setStorageSync("openid", resp.data.openid)
uni.setStorageSync("phone", resp.data.phone)
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: '未注册,请先注册',
@ -112,18 +124,31 @@
duration: '1500',
})
if (that.timer) {
clearTimeout(that.timer)
learTimeout(that.timer)
}
that.timer = setTimeout(() => {
uni.redirectTo({
url: '/pages/register/register',
})
}, 1500)
} else if (resp.data.code == '1') {
getCurrentUser(resp.data.openid, resp.data.cityCode).then(res => {
} 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) {
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data);
console.log(res,'000')
if(res.data){
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data);
}
that.$refs.uToast.show({
title: '登录成功',
type: 'success',

View File

@ -399,14 +399,13 @@
if (valid) {
registerdata(that.query).then(res => {
if (res.code == 200) {
getCurrentUser(that.query.openid, that.query.cityCode).then(res => {
getCurrentUser(that.query.openid).then(res => {
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('patientName', res.data.patientName);
uni.setStorageSync("userinfo", res.data)
that.$refs.uToast.show({
title: '注册成功',
type: 'success',
duration: '1000',
back: 1,
})
})
@ -902,4 +901,4 @@
/deep/ .u-form-item__message {
padding-left: 0 !important;
}
</style>
</style>