首页登录

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({ return request({
url: `/applet/register/getCurrentResident/${openid}/${cityCode}`, url: `/applet/register/getCurrentResident/${openid}`,
method: 'GET', method: 'GET',
header: { header: {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token') Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')

View File

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

View File

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

View File

@ -399,14 +399,13 @@
if (valid) { if (valid) {
registerdata(that.query).then(res => { registerdata(that.query).then(res => {
if (res.code == 200) { 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('patientId', res.data.id);
uni.setStorageSync('patientName', res.data.patientName); uni.setStorageSync('patientName', res.data.patientName);
uni.setStorageSync("userinfo", res.data) uni.setStorageSync("userinfo", res.data)
that.$refs.uToast.show({ that.$refs.uToast.show({
title: '注册成功', title: '注册成功',
type: 'success', type: 'success',
duration: '1000',
back: 1, back: 1,
}) })
}) })