2025-04-03 11:47:12 +08:00

170 lines
3.5 KiB
Vue

<template>
<view class="page-content">
<view class="title">您的门店地址</view>
<view class="inp flex align-center justify-start" @click="getMyLocation">
<text class="cuIcon-locationfill" style="font-size: 42rpx;"></text>
{{form.address}}
</view>
<view class="desc">
当前可变更次数2次
</view>
<view class="desc">
地址变更将影响您的扫码核销准确性,请谨慎操作
</view>
<view class="desc">
变更次数将在门店认证审核通过后重置为2次
</view>
<button class="cu-btn bg-zd add-btn" @click="saveAddress">保存</button>
</view>
</view>
</template>
<script>
import { updateAddress } from "@/api/user.js"
import {
getBarInfo
} from '@/api/bar.js'
export default {
data() {
return {
form: {
address: '',
latitude: '',
longitude: ''
}
};
},
onLoad(){
this.getBarInfoFun()
},
methods: {
// 获取酒吧信息
getBarInfoFun() {
getBarInfo().then(res => {
console.log(res,'1111&&&&')
this.form.address = res.data.address
this.form.latitude = res.data.latitude
this.form.longitude = res.data.longitude
})
},
// 保存地址
saveAddress() {
if(!this.form.address) {
uni.showToast({
title: '请选择地址',
icon: 'none',
})
return
}
updateAddress(this.form).then(res => {
uni.showToast({
title: '保存成功',
icon: 'none',
})
setTimeout(()=>{
uni.navigateBack()
},500)
})
},
// 获取位置
getMyLocation() {
uni.getSetting({
success: (res) => {
console.log(res)
if (!res.authSetting['scope.userLocation']) {
uni.authorize({
scope: 'scope.userLocation',
success: (res) => {},
fail: (err) => {
uni.showModal({
title: '提示',
content: '请先授权获取您的位置信息',
success: (res) => {
if (res.confirm) {
uni.openSetting({
success: (res) => {
if (res
.authSetting[
'scope.userLocation'
]) {
this.handleGetLocation()
}
}
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
} else {
this.handleGetLocation()
}
},
})
},
handleGetLocation() {
uni.getLocation({
type: "gcj02",
success: (res) => {
console.log(res)
uni.chooseLocation({
complete: (res) => {
console.log(res)
if (res.errMsg == 'chooseLocation:ok') {
this.form.address = res.address
this.form.latitude = res.latitude
this.form.longitude = res.longitude
}
}
})
},
fail: (err) => {
console.log(err)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.page-content {
background: #FDFDFD;
padding: 48rpx;
height: 100vh;
.title {
font-family: Roboto;
font-size: 28rpx;
font-weight: 500;
color: #32343E;
margin-bottom: 18rpx;
}
.inp {
border-radius: 20rpx;
height: 100rpx;
background: #F0F5FA;
margin-bottom: 36rpx;
padding: 0 24rpx;
}
.desc {
font-family: Roboto;
font-size: 20rpx;
font-weight: 500;
color: #979797;
margin-bottom: 24rpx;
}
.add-btn {
width: 654rpx;
height: 88rpx;
border-radius: 24rpx;
font-size: 28rpx;
font-weight: 500;
color: #0B0E26;
}
}
</style>