Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
闫晓茹 2023-10-16 14:19:33 +08:00
commit f4fcbdaf46
2 changed files with 44 additions and 18 deletions

View File

@ -25,18 +25,18 @@
return { return {
phonecode: undefined, phonecode: undefined,
logincode: undefined, logincode: undefined,
code: undefined,
timer: undefined, timer: undefined,
cityCode: '1', cityCode: null,
openid: '',
// scenenurseStationId: undefined, // scenenurseStationId: undefined,
}; };
}, },
onShow() { onShow() {
this.getAddress(); let location = uni.getStorageSync('location')
if (!location) {
this.getAddress()
}
this.phonecode = undefined this.phonecode = undefined
this.logincode = undefined this.logincode = undefined
this.code = undefined
// this.scenenurseStationId = uni.getStorageSync('scenenurseStationId'); // this.scenenurseStationId = uni.getStorageSync('scenenurseStationId');
}, },
methods: { methods: {
@ -85,14 +85,10 @@
}); });
} }
}, },
login() { login() {
let that = this; let that = this;
// getWeChatUser(that.logincode).then(res => {
// if (res.code == 200) {
isRegistered(that.logincode, that.phonecode).then(resp => { isRegistered(that.logincode, that.phonecode).then(resp => {
uni.setStorageSync("openid", resp.data.openid) uni.setStorageSync("openid", resp.data.openid)
that.openid = resp.data.openid
if (resp.data.code == '0') { if (resp.data.code == '0') {
that.$refs.uToast.show({ that.$refs.uToast.show({
title: '未注册,请先注册', title: '未注册,请先注册',
@ -101,9 +97,7 @@
url: '/pages/register/register', url: '/pages/register/register',
}) })
} else if (resp.data.code == '1') { } else if (resp.data.code == '1') {
that.cityCode = '1' getCurrentUser(resp.data.openid, resp.data.cityCode).then(res => {
console.log(that.openid)
getCurrentUser(that.openid, that.cityCode).then(res => {
if (res.code == 200) { if (res.code == 200) {
that.$refs.uToast.show({ that.$refs.uToast.show({
title: '登录成功', title: '登录成功',
@ -112,10 +106,10 @@
}) })
uni.setStorageSync('patientId', res.data.id); uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data); uni.setStorageSync('userinfo', res.data);
if (this.timer) { if (that.timer) {
clearTimeout(this.timer) clearTimeout(that.timer)
} }
this.timer = setTimeout(e => { that.timer = setTimeout(e => {
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
@ -130,12 +124,10 @@
}) })
} }
}) })
}, },
pwdlogin() { pwdlogin() {
var that = this var that = this
uni.clearStorageSync(); uni.clearStorageSync();
that.login() that.login()
// createMobileToken().then(res => { // createMobileToken().then(res => {
// uni.setStorageSync("token", res.data.token) // uni.setStorageSync("token", res.data.token)

View File

@ -42,6 +42,7 @@
}, },
onShow() { onShow() {
var that = this var that = this
this.getAddress();
createMobileToken().then(res => { createMobileToken().then(res => {
uni.setStorageSync("token", res.data.token) uni.setStorageSync("token", res.data.token)
}) })
@ -51,7 +52,40 @@
}); });
}, 2000); }, 2000);
}, },
methods: {}, methods: {
//
getAddress() {
let that = this;
uni.getLocation({
type: 'wgs84',
success: (res) => {
let location = res.latitude + ',' + res.longitude
//
uni.request({
url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=location', //
data: {
location: location,
'key': "Q4DBZ-UIMC2-B63UX-CUZ6A-S3UT7-TBF3V", //Key
},
method: "GET",
success(res) {
uni.setStorageSync('location', res.data.result.address_component.city)
},
fail: res => {
console.log(res.errMsg, '解析失败返回的错误信息');
}
})
},
//
fail: (res) => {
uni.showToast({
icon: 'none',
title: '获取地址失败,请打开定位',
})
}
})
},
},
} }
</script> </script>