修改
This commit is contained in:
parent
f250d0438b
commit
a94dc0b6b8
@ -25,53 +25,17 @@
|
||||
return {
|
||||
phonecode: undefined,
|
||||
logincode: undefined,
|
||||
code: undefined,
|
||||
timer: undefined,
|
||||
cityCode: '1',
|
||||
openid: '',
|
||||
cityCode: null,
|
||||
// scenenurseStationId: undefined,
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.getAddress();
|
||||
this.phonecode = undefined
|
||||
this.logincode = undefined
|
||||
this.code = undefined
|
||||
// this.scenenurseStationId = uni.getStorageSync('scenenurseStationId');
|
||||
},
|
||||
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: '获取地址失败,请打开定位',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
getPhoneNumberp(val) {
|
||||
let that = this;
|
||||
if (val.detail.code) {
|
||||
@ -85,14 +49,10 @@
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
login() {
|
||||
let that = this;
|
||||
// getWeChatUser(that.logincode).then(res => {
|
||||
// if (res.code == 200) {
|
||||
isRegistered(that.logincode, that.phonecode).then(resp => {
|
||||
uni.setStorageSync("openid", resp.data.openid)
|
||||
that.openid = resp.data.openid
|
||||
if (resp.data.code == '0') {
|
||||
that.$refs.uToast.show({
|
||||
title: '未注册,请先注册',
|
||||
@ -101,9 +61,7 @@
|
||||
url: '/pages/register/register',
|
||||
})
|
||||
} else if (resp.data.code == '1') {
|
||||
that.cityCode = '1'
|
||||
console.log(that.openid)
|
||||
getCurrentUser(that.openid, that.cityCode).then(res => {
|
||||
getCurrentUser(resp.data.openid, resp.data.cityCode).then(res => {
|
||||
if (res.code == 200) {
|
||||
that.$refs.uToast.show({
|
||||
title: '登录成功',
|
||||
@ -112,10 +70,10 @@
|
||||
})
|
||||
uni.setStorageSync('patientId', res.data.id);
|
||||
uni.setStorageSync('userinfo', res.data);
|
||||
if (this.timer) {
|
||||
clearTimeout(this.timer)
|
||||
if (that.timer) {
|
||||
clearTimeout(that.timer)
|
||||
}
|
||||
this.timer = setTimeout(e => {
|
||||
that.timer = setTimeout(e => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
@ -130,12 +88,10 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
pwdlogin() {
|
||||
var that = this
|
||||
uni.clearStorageSync();
|
||||
|
||||
that.login()
|
||||
// createMobileToken().then(res => {
|
||||
// uni.setStorageSync("token", res.data.token)
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
},
|
||||
onShow() {
|
||||
var that = this
|
||||
this.getAddress();
|
||||
createMobileToken().then(res => {
|
||||
uni.setStorageSync("token", res.data.token)
|
||||
})
|
||||
@ -51,7 +52,40 @@
|
||||
});
|
||||
}, 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>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user