map更新
This commit is contained in:
parent
44cd1efde2
commit
13938e14cd
4
acdr-ui/env/.env
vendored
4
acdr-ui/env/.env
vendored
@ -7,8 +7,8 @@ VITE_WX_APPID = 'wxf2c6d4b7361366b4'
|
|||||||
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
||||||
VITE_APP_PUBLIC_BASE=/acdr/
|
VITE_APP_PUBLIC_BASE=/acdr/
|
||||||
|
|
||||||
VITE_SERVER_BASEURL = 'http://127.0.0.1:28184/api'
|
VITE_SERVER_BASEURL = 'http://47.99.70.12:28184/api'
|
||||||
VITE_UPLOAD_BASEURL = 'http://127.0.0.1:28184'
|
VITE_UPLOAD_BASEURL = 'http://47.99.70.12:28184'
|
||||||
VITE_OSS_BASEURL = 'http://116.204.119.171:9000/linghe'
|
VITE_OSS_BASEURL = 'http://116.204.119.171:9000/linghe'
|
||||||
|
|
||||||
# h5是否需要配置代理
|
# h5是否需要配置代理
|
||||||
|
@ -123,7 +123,12 @@ export default defineManifestConfig({
|
|||||||
setting: {
|
setting: {
|
||||||
urlCheck: false,
|
urlCheck: false,
|
||||||
},
|
},
|
||||||
requiredPrivateInfos: ["getLocation"],
|
requiredPrivateInfos: ["getLocation","chooseLocation"],
|
||||||
|
permission: {
|
||||||
|
"scope.userLocation": {
|
||||||
|
"desc": "你的位置信息将用于定位效果展示"
|
||||||
|
}
|
||||||
|
},
|
||||||
usingComponents: true,
|
usingComponents: true,
|
||||||
lazyCodeLoading: 'requiredComponents',
|
lazyCodeLoading: 'requiredComponents',
|
||||||
// __usePrivacyCheck__: true,
|
// __usePrivacyCheck__: true,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
layout: "default",
|
layout: "default",
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: "地图组件",
|
navigationBarTitleText: "地图组件",
|
||||||
// 隐藏该组件的头部;
|
// 隐藏该组件的头部
|
||||||
navigationStyle: "custom",
|
navigationStyle: "custom",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -18,56 +18,41 @@
|
|||||||
</u-row>
|
</u-row>
|
||||||
<u-row class="myInfoRow">
|
<u-row class="myInfoRow">
|
||||||
<u-col span="12">
|
<u-col span="12">
|
||||||
<textarea
|
<textarea v-show="geocode" disabled="true" :value="position" placeholder="未加载出位置信息"></textarea>
|
||||||
v-show="geocode"
|
|
||||||
disabled="true"
|
|
||||||
:value="position"
|
|
||||||
placeholder="未加载出位置信息"
|
|
||||||
></textarea>
|
|
||||||
</u-col>
|
</u-col>
|
||||||
</u-row>
|
</u-row>
|
||||||
<u-row>
|
<u-row>
|
||||||
<u-col span="6">
|
<u-col span="6">
|
||||||
<u-button type="success" shape="square" @click="changePosition"
|
<u-button type="success" shape="square" @click="changePosition">刷新当前位置</u-button>
|
||||||
>刷新当前位置</u-button
|
|
||||||
>
|
|
||||||
</u-col>
|
</u-col>
|
||||||
<u-col span="6">
|
<u-col span="6">
|
||||||
<u-button type="success" shape="square" @click="returnPosition"
|
<u-button type="success" shape="square" @click="returnPosition">返回定位位置</u-button>
|
||||||
>返回定位位置</u-button
|
|
||||||
>
|
|
||||||
</u-col>
|
</u-col>
|
||||||
</u-row>
|
</u-row>
|
||||||
<br />
|
<br />
|
||||||
<u-row>
|
<u-row>
|
||||||
<!-- style内嵌标签的写法才能让app端地图全屏展示 -->
|
<!-- style内嵌标签的写法才能让app端地图全屏展示 -->
|
||||||
<u-col span="12">
|
<u-col span="12">
|
||||||
<map
|
<map id="myMap" ref="myMap" :longitude="longitude" :latitude="latitude" :scale="scale" @tap="clickmap"
|
||||||
id="myMap"
|
:markers="covers" style="width: 100vw; height: 100vh"></map>
|
||||||
ref="myMap"
|
|
||||||
:longitude="longitude"
|
|
||||||
:latitude="latitude"
|
|
||||||
:scale="scale"
|
|
||||||
@tap="clickmap"
|
|
||||||
:markers="covers"
|
|
||||||
style="width: 100%; height: 100vh"
|
|
||||||
></map>
|
|
||||||
</u-col>
|
</u-col>
|
||||||
</u-row>
|
</u-row>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted } from "vue";
|
import { toast } from "@/utils/commUtils"
|
||||||
|
import { ref, reactive, onMounted } from "vue"
|
||||||
|
|
||||||
const longitude = ref(0); // 记录实时点击位置
|
const longitude = ref(0) // 记录实时点击位置
|
||||||
const latitude = ref(0);
|
const latitude = ref(0)
|
||||||
const originalLongitude = ref(0); // 记录用户当前真实位置随时返回
|
const originalLongitude = ref(0) // 记录用户当前真实位置随时返回
|
||||||
const originalLatitude = ref(0);
|
const originalLatitude = ref(0)
|
||||||
const scale = ref("16");
|
const scale = ref("16")
|
||||||
const geocode = ref(true);
|
const geocode = ref(true)
|
||||||
const position = ref(""); // 获取的地址信息
|
const position = ref("") // 获取的地址信息
|
||||||
const originalPosition = ref(""); // 记录用户当前真实位置随时返回
|
const originalPosition = ref("") // 记录用户当前真实位置随时返回
|
||||||
|
|
||||||
const covers = reactive([
|
const covers = reactive([
|
||||||
{
|
{
|
||||||
@ -82,91 +67,96 @@ const covers = reactive([
|
|||||||
color: "#FB3109",
|
color: "#FB3109",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
|
|
||||||
const clickmap = () => {
|
const clickmap = () => {
|
||||||
uni.chooseLocation({
|
uni.chooseLocation({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
position.value = "位置名称:" + res.name + " 详细地址:" + res.address;
|
position.value = "位置名称:" + res.name + " 详细地址:" + res.address
|
||||||
longitude.value = res.longitude;
|
longitude.value = res.longitude
|
||||||
latitude.value = res.latitude;
|
latitude.value = res.latitude
|
||||||
covers[0].longitude = res.longitude;
|
covers[0].longitude = res.longitude
|
||||||
covers[0].latitude = res.latitude;
|
covers[0].latitude = res.latitude
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
uni.showToast({
|
console.log(err)
|
||||||
title: "获取位置失败",
|
toast("获取位置失败")
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
const returnPosition = () => {
|
const returnPosition = () => {
|
||||||
position.value = originalPosition.value;
|
position.value = originalPosition.value
|
||||||
longitude.value = originalLongitude.value;
|
longitude.value = originalLongitude.value
|
||||||
latitude.value = originalLatitude.value;
|
latitude.value = originalLatitude.value
|
||||||
covers[0].longitude = originalLongitude.value;
|
covers[0].longitude = originalLongitude.value
|
||||||
covers[0].latitude = originalLatitude.value;
|
covers[0].latitude = originalLatitude.value
|
||||||
};
|
}
|
||||||
|
|
||||||
const changePosition = () => {
|
const changePosition = () => {
|
||||||
console.log("坐标刷新成功");
|
console.log("坐标刷新成功")
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "坐标刷新成功",
|
title: "坐标刷新成功",
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
const getLocation = () => {
|
const getLocation = () => {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "正在获取定位",
|
title: "正在获取定位",
|
||||||
});
|
})
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: "gcj02",
|
type: "gcj02",
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
geocode: geocode.value,
|
geocode: geocode.value,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("@@@@", res);
|
uni.hideLoading()
|
||||||
uni.hideLoading();
|
longitude.value = res.longitude
|
||||||
longitude.value = res.longitude;
|
latitude.value = res.latitude
|
||||||
latitude.value = res.latitude;
|
originalLongitude.value = res.longitude
|
||||||
originalLongitude.value = res.longitude;
|
originalLatitude.value = res.latitude
|
||||||
originalLatitude.value = res.latitude;
|
covers[0].longitude = res.longitude
|
||||||
covers[0].longitude = res.longitude;
|
covers[0].latitude = res.latitude
|
||||||
covers[0].latitude = res.latitude;
|
|
||||||
|
|
||||||
const { address } = res;
|
// const { address } = res
|
||||||
const { country, province, city, district, street, streetNum, poiName } = address;
|
// const { country, province, city, district, street, streetNum, poiName } = address
|
||||||
const myPosition = `${country}-${province}-${city}-${district}-${street}-${streetNum}-${poiName}`;
|
// const myPosition = `${country}-${province}-${city}-${district}-${street}-${streetNum}-${poiName}`
|
||||||
position.value = myPosition;
|
// position.value = myPosition
|
||||||
originalPosition.value = myPosition;
|
// originalPosition.value = myPosition
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.log(err);
|
console.log(err)
|
||||||
uni.hideLoading();
|
uni.hideLoading()
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: "位置信息获取失败(请确定定位功能是否打开)",
|
content: "位置信息获取失败(请确定定位功能是否打开)",
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getLocation();
|
getLocation()
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
#myMap {
|
.objView {
|
||||||
width: 750rpx;
|
width: 100% height: 100%
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#myMap {
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
/* 信息栏高度 */
|
/* 信息栏高度 */
|
||||||
.myInfoRow {
|
.myInfoRow {
|
||||||
height: 50px;
|
height: 50px
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 让地址栏通栏展示 */
|
/* 让地址栏通栏展示 */
|
||||||
textarea {
|
textarea {
|
||||||
width: 100%;
|
width: 100%
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -89,8 +89,14 @@
|
|||||||
},
|
},
|
||||||
"usingComponents": true,
|
"usingComponents": true,
|
||||||
"requiredPrivateInfos": [
|
"requiredPrivateInfos": [
|
||||||
"getLocation"
|
"getLocation",
|
||||||
|
"chooseLocation"
|
||||||
],
|
],
|
||||||
|
"permission": {
|
||||||
|
"scope.userLocation": {
|
||||||
|
"desc": "你的位置信息将用于定位效果展示"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lazyCodeLoading": "requiredComponents"
|
"lazyCodeLoading": "requiredComponents"
|
||||||
},
|
},
|
||||||
"mp-alipay": {
|
"mp-alipay": {
|
||||||
|
@ -17,4 +17,8 @@
|
|||||||
import Map from '@/components/Map.vue';
|
import Map from '@/components/Map.vue';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped>
|
||||||
|
.root {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -10,24 +10,14 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="my-page-container">
|
<view class="my-page-container">
|
||||||
<view
|
<view class="background" :style="{ backgroundImage: `url(${imgUrl('@/static/my/my-bg.png')})` }"></view>
|
||||||
class="background"
|
|
||||||
:style="{ backgroundImage: `url(${imgUrl('@/static/my/my-bg.png')})` }"
|
|
||||||
></view>
|
|
||||||
<image :src="imgUrl('@/static/my/cat-dog.png')" class="cat-dog"></image>
|
<image :src="imgUrl('@/static/my/cat-dog.png')" class="cat-dog"></image>
|
||||||
<view class="bg"></view>
|
<view class="bg"></view>
|
||||||
<view class="my-avatar">
|
<view class="my-avatar">
|
||||||
<wd-img
|
<wd-img :width="100" :height="100" round mode="aspectFill" :src="userInfo.avatar == ''
|
||||||
:width="100"
|
|
||||||
:height="100"
|
|
||||||
round
|
|
||||||
mode="aspectFill"
|
|
||||||
:src="
|
|
||||||
userInfo.avatar == ''
|
|
||||||
? imgUrl('@/static/my/avatar.jpg')
|
? imgUrl('@/static/my/avatar.jpg')
|
||||||
: baseUrl + userInfo.avatar
|
: baseUrl + userInfo.avatar
|
||||||
"
|
"></wd-img>
|
||||||
></wd-img>
|
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="name">{{ userInfo.nickname }}</view>
|
<view class="name">{{ userInfo.nickname }}</view>
|
||||||
<view class="description">爱猫猫,爱狗狗</view>
|
<view class="description">爱猫猫,爱狗狗</view>
|
||||||
@ -42,27 +32,11 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="services-container card">
|
<view class="services-container card">
|
||||||
<view
|
<view class="service-item" v-for="(service, index) in services" @click="toPath(service.path)" :key="index">
|
||||||
class="service-item"
|
|
||||||
v-for="(service, index) in services"
|
|
||||||
@click="toPath(service.path)"
|
|
||||||
:key="index"
|
|
||||||
>
|
|
||||||
<view class="service-box">
|
<view class="service-box">
|
||||||
<wd-img
|
<wd-img v-if="service.label == '我的服务'" :width="42" :height="40" :src="imgUrl(service.icon)"
|
||||||
v-if="service.label == '我的服务'"
|
class="service-icon" />
|
||||||
:width="42"
|
<wd-img v-else :width="38" :height="40" :src="imgUrl(service.icon)" class="service-icon" />
|
||||||
:height="40"
|
|
||||||
:src="imgUrl(service.icon)"
|
|
||||||
class="service-icon"
|
|
||||||
/>
|
|
||||||
<wd-img
|
|
||||||
v-else
|
|
||||||
:width="38"
|
|
||||||
:height="40"
|
|
||||||
:src="imgUrl(service.icon)"
|
|
||||||
class="service-icon"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="service-label">{{ service.label }}</view>
|
<view class="service-label">{{ service.label }}</view>
|
||||||
</view>
|
</view>
|
||||||
@ -78,12 +52,7 @@
|
|||||||
<view class="pets-container card">
|
<view class="pets-container card">
|
||||||
<view class="pets-title">我的宠物</view>
|
<view class="pets-title">我的宠物</view>
|
||||||
<view class="pets-list scroll-x overflow-x-auto" scroll-x>
|
<view class="pets-list scroll-x overflow-x-auto" scroll-x>
|
||||||
<view
|
<view class="pet-item" v-for="(pet, index) in pets" @click="editPet(pet)" :key="index">
|
||||||
class="pet-item"
|
|
||||||
v-for="(pet, index) in pets"
|
|
||||||
@click="editPet(pet)"
|
|
||||||
:key="index"
|
|
||||||
>
|
|
||||||
<wd-img :width="60" :height="60" round :src="pet.icon" class="pet-avatar" />
|
<wd-img :width="60" :height="60" round :src="pet.icon" class="pet-avatar" />
|
||||||
<view class="pet-label">{{ pet.name }}</view>
|
<view class="pet-label">{{ pet.name }}</view>
|
||||||
</view>
|
</view>
|
||||||
@ -98,12 +67,7 @@
|
|||||||
|
|
||||||
<view class="settings-container card">
|
<view class="settings-container card">
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view
|
<view class="list-item" v-for="(item, index) in items" @click="toPath(item.to)" :key="index">
|
||||||
class="list-item"
|
|
||||||
v-for="(item, index) in items"
|
|
||||||
@click="toPath(item.to)"
|
|
||||||
:key="index"
|
|
||||||
>
|
|
||||||
<view class="icon">
|
<view class="icon">
|
||||||
<image :src="imgUrl(item.icon)" class="item-icon" />
|
<image :src="imgUrl(item.icon)" class="item-icon" />
|
||||||
</view>
|
</view>
|
||||||
@ -118,52 +82,74 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue"
|
||||||
import { useUserStore } from "@/store/user";
|
import { useUserStore } from "@/store/user"
|
||||||
import { baseUrl, imgUrl } from "@/utils/commUtils";
|
import { baseUrl, imgUrl, toast } from "@/utils/commUtils"
|
||||||
import { httpGet } from "@/utils/http"; // 假设你已经封装好了这个方法
|
import { httpGet } from "@/utils/http" // 假设你已经封装好了这个方法
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const userInfo = userStore.userInfo;
|
const userInfo = userStore.userInfo
|
||||||
|
|
||||||
const stats = [
|
const stats = ref(
|
||||||
|
[
|
||||||
{ number: 0, label: "粉丝" },
|
{ number: 0, label: "粉丝" },
|
||||||
{ number: 0, label: "关注" },
|
{ number: 0, label: "关注" },
|
||||||
{ number: 0, label: "收藏" },
|
{ number: 0, label: "收藏" },
|
||||||
{ number: 0, label: "获赞" },
|
{ number: 0, label: "获赞" },
|
||||||
];
|
]
|
||||||
|
)
|
||||||
|
|
||||||
const services = [
|
const services = [
|
||||||
{ icon: "@/static/my/order.png", label: "我的订单", path: "/pages/order/index" },
|
{ icon: "@/static/my/order.png", label: "我的订单", path: "/pages/order/index" },
|
||||||
{ icon: "@/static/my/pet.png", label: "我的服务", path: "/pages/service/my-service" },
|
{ icon: "@/static/my/pet.png", label: "我的服务", path: "/pages/service/my-service" },
|
||||||
{ icon: "@/static/my/wash.png", label: "我的评价", path: "/pages/order/index" },
|
{ icon: "@/static/my/wash.png", label: "我的评价", path: "/pages/order/index" },
|
||||||
{ icon: "@/static/my/service.png", label: "售后服务", path: "/pages/order/index" },
|
{ icon: "@/static/my/service.png", label: "售后服务", path: "/pages/order/index" },
|
||||||
];
|
]
|
||||||
|
|
||||||
const pets = ref([]);
|
const pets = ref([])
|
||||||
|
|
||||||
onShow(() => {
|
onShow(async () => {
|
||||||
fetchPets();
|
await fetchActivities()
|
||||||
});
|
await fetchPets()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取社区活动的信息
|
||||||
|
const fetchActivities = async () => {
|
||||||
|
try {
|
||||||
|
const response = await httpGet("/posts/community")
|
||||||
|
if (response.code == 200) {
|
||||||
|
let index = 0
|
||||||
|
for (const key in response.data) {
|
||||||
|
if (response.data[key]) {
|
||||||
|
stats.value[index] = { number: response.data[key], label: key }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(response)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const fetchPets = async () => {
|
const fetchPets = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await httpGet("/petInfo/select", { userId: userStore.userInfo.id });
|
const response = await httpGet("/petInfo/select", { userId: userStore.userInfo.id })
|
||||||
pets.value = response.records.map((pet) => ({
|
pets.value = response.records.map((pet) => ({
|
||||||
...pet,
|
...pet,
|
||||||
icon: baseUrl + pet.profileUrl,
|
icon: baseUrl + pet.profileUrl,
|
||||||
}));
|
}))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({ title: "网络错误,请重试", icon: "error" });
|
uni.showToast({ title: "网络错误,请重试", icon: "error" })
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const editPet = (pet) => {
|
const editPet = (pet) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/pet/pet-add-page?id=${pet.id}&name=${pet.name}&icon=${pet.icon}&breed=${pet.breed}&color=${pet.color}&birthday=${pet.birthday}&gender=${pet.gender}&userId=${pet.userId}`,
|
url: `/pages/pet/pet-add-page?id=${pet.id}&name=${pet.name}&icon=${pet.icon}&breed=${pet.breed}&color=${pet.color}&birthday=${pet.birthday}&gender=${pet.gender}&userId=${pet.userId}`,
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
{ icon: "@/static/my/send.png", label: "我的发布", to: "/pages/publish/index" },
|
{ icon: "@/static/my/send.png", label: "我的发布", to: "/pages/publish/index" },
|
||||||
@ -185,13 +171,13 @@ const items = [
|
|||||||
{ icon: "@/static/my/address.png", label: "我的地址", to: "/pages/address/index" },
|
{ icon: "@/static/my/address.png", label: "我的地址", to: "/pages/address/index" },
|
||||||
{ icon: "@/static/my/settings.png", label: "设置", to: "/pages/settings/index" },
|
{ icon: "@/static/my/settings.png", label: "设置", to: "/pages/settings/index" },
|
||||||
{ icon: "@/static/my/address.png", label: "地址", to: "/pages/map/index" },
|
{ icon: "@/static/my/address.png", label: "地址", to: "/pages/map/index" },
|
||||||
];
|
]
|
||||||
|
|
||||||
const toPath = (path) => {
|
const toPath = (path) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: path,
|
url: path,
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
60
acdr-ui/src/service/mapService.js
Normal file
60
acdr-ui/src/service/mapService.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { toast } from "@/utils/commUtils";
|
||||||
|
import { httpGet } from "@/utils/http";
|
||||||
|
|
||||||
|
// 通过高德地图api获取详细位置
|
||||||
|
const getReverseGeocoding = async (longitude, latitude) => {
|
||||||
|
try {
|
||||||
|
const res = await uni.request({
|
||||||
|
url: `https://restapi.amap.com/v3/geocode/regeo?location=${longitude},${latitude}&key=${config.AMapKey}`
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res[1].data.status === "1" && res[1].data.regeocode) {
|
||||||
|
const address = res[1].data.regeocode.formatted_address;
|
||||||
|
return address; // 返回详细地址信息
|
||||||
|
} else {
|
||||||
|
throw new Error("无法获取详细地址");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("逆地理编码请求失败:", err);
|
||||||
|
throw err; // 抛出错误以便调用者处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通过后端服务器获取详细位置
|
||||||
|
const getMapDetailAddress = async (longitude, latitude) => {
|
||||||
|
try {
|
||||||
|
const res = await httpGet("/map/detail", {
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
})
|
||||||
|
if (res.code == 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
} catch (err) {
|
||||||
|
console.error("获取详细地址信息失败:", err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前经纬度信息
|
||||||
|
const getLocation = async () => {
|
||||||
|
try {
|
||||||
|
const res = await new Promise((resolve, reject) => {
|
||||||
|
uni.chooseLocation({
|
||||||
|
success: (res) => {
|
||||||
|
resolve(res); // 成功时返回结果
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
reject(err); // 失败时抛出错误
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return res; // 返回获取到的地理位置信息
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
toast("获取位置失败");
|
||||||
|
throw err; // 抛出错误,供调用者处理
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,10 @@
|
|||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.yskj.acdr.master.address.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.yskj.acdr.common.response.GlobalResponse;
|
||||||
|
import com.yskj.acdr.master.address.service.ServiceAddressService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller("/map")
|
||||||
|
public class ServiceAddressController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ServiceAddressController.class);
|
||||||
|
@Resource
|
||||||
|
private ServiceAddressService addressService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param longitude 经度
|
||||||
|
* @param latitude 纬度
|
||||||
|
* @return {
|
||||||
|
* "addressComponent": {
|
||||||
|
* "city": "深圳市",
|
||||||
|
* "province": "广东省",
|
||||||
|
* "adcode": "440304",
|
||||||
|
* "district": "福田区",
|
||||||
|
* "towncode": "440304008000",
|
||||||
|
* "streetNumber": {
|
||||||
|
* "number": "218号",
|
||||||
|
* "location": "114.059260,22.542982",
|
||||||
|
* "direction": "西",
|
||||||
|
* "distance": "33.663",
|
||||||
|
* "street": "福中路"
|
||||||
|
* },
|
||||||
|
* "country": "中国",
|
||||||
|
* "township": "莲花街道",
|
||||||
|
* "businessAreas": [
|
||||||
|
* []
|
||||||
|
* ],
|
||||||
|
* "building": {
|
||||||
|
* "name": [],
|
||||||
|
* "type": []
|
||||||
|
* },
|
||||||
|
* "neighborhood": {
|
||||||
|
* "name": [],
|
||||||
|
* "type": []
|
||||||
|
* },
|
||||||
|
* "citycode": "0755"
|
||||||
|
* },
|
||||||
|
* "formatted_address": "广东省深圳市福田区莲花街道福中三路深圳市民中心"
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public GlobalResponse<JSONObject> mapDetail(double longitude, double latitude) {
|
||||||
|
try {
|
||||||
|
return GlobalResponse.success(addressService.getReverseGeocoding(longitude, latitude));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return GlobalResponse.failure("获取地址失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.yskj.acdr.master.address.service;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ServiceAddressService {
|
||||||
|
|
||||||
|
@Value("${map.amapkey}")
|
||||||
|
private String amap;
|
||||||
|
|
||||||
|
public JSONObject getReverseGeocoding(double longitude, double latitude) throws Exception {
|
||||||
|
String url = String.format("https://restapi.amap.com/v3/geocode/regeo?location=%f,%f&key=%s", longitude, latitude, amap);
|
||||||
|
|
||||||
|
// 发送HTTP请求
|
||||||
|
HttpResponse response = HttpUtil.createGet(url).execute();
|
||||||
|
|
||||||
|
// 解析返回的JSON数据
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response.body());
|
||||||
|
String status = jsonObject.getString("status");
|
||||||
|
|
||||||
|
if ("1".equals(status)) {
|
||||||
|
JSONObject regeocode = jsonObject.getJSONObject("regeocode");
|
||||||
|
if (regeocode != null) {
|
||||||
|
return regeocode; // 返回详细地址信息
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("无法获取详细地址");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -532,5 +532,42 @@ public class CommunityController {
|
|||||||
|
|
||||||
return GlobalResponse.success(result);
|
return GlobalResponse.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取用户的社交信息
|
||||||
|
@GetMapping("/community")
|
||||||
|
public GlobalResponse<Map<Object, Object>> social() {
|
||||||
|
long userId = StpUtil.getLoginIdAsLong();
|
||||||
|
// 获取被关注的信息
|
||||||
|
Long fans = followsMapper.selectCount(
|
||||||
|
new LambdaQueryWrapper<Follows>()
|
||||||
|
.eq(Follows::getFollowingId, userId)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 关注已关注的信息
|
||||||
|
Long follow = followsMapper.selectCount(
|
||||||
|
new LambdaQueryWrapper<Follows>()
|
||||||
|
.eq(Follows::getFollowerId, userId)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取收藏的信息数量
|
||||||
|
Long collection = favoritesMapper.selectCount(
|
||||||
|
new LambdaQueryWrapper<Favorites>()
|
||||||
|
.eq(Favorites::getUserId, userId)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取被点赞的信息数量
|
||||||
|
Long likes = likesMapper.selectCount(
|
||||||
|
new LambdaQueryWrapper<Likes>()
|
||||||
|
.eq(Likes::getUserId, userId)
|
||||||
|
);
|
||||||
|
|
||||||
|
return GlobalResponse.success(
|
||||||
|
MapUtil.builder()
|
||||||
|
.put("粉丝",fans)
|
||||||
|
.put("关注",follow)
|
||||||
|
.put("收藏",collection)
|
||||||
|
.put("获赞",likes).map()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,30 @@
|
|||||||
package com.yskj.acdr.master.community.entity;
|
package com.yskj.acdr.master.community.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import io.swagger.annotations.ApiModel;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import lombok.Getter;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import lombok.Setter;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import lombok.ToString;
|
||||||
import java.io.Serializable;
|
import lombok.experimental.Accessors;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import java.io.Serializable;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import java.time.LocalDateTime;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 林河
|
* @author 林河
|
||||||
* @since 2024-08-12
|
* @since 2024-08-12
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("acdr_favorites")
|
@TableName("acdr_favorites")
|
||||||
@ApiModel(value = "Favorites对象", description = "")
|
@ApiModel(value = "Favorites对象", description = "")
|
||||||
public class Favorites implements Serializable {
|
public class Favorites implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import jakarta.annotation.Resource;
|
|||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -35,6 +36,9 @@ public class UserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private GlobalRedisCache<String> redisCache;
|
private GlobalRedisCache<String> redisCache;
|
||||||
|
|
||||||
|
@Value("${is-starter-shop:false}")
|
||||||
|
private Boolean isStarterShop;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取验证码
|
* 获取验证码
|
||||||
@ -66,7 +70,7 @@ public class UserController {
|
|||||||
GlobalResponse<String> login = usersService.login(phone, code);
|
GlobalResponse<String> login = usersService.login(phone, code);
|
||||||
String userShop;
|
String userShop;
|
||||||
UserShopInfo userShopInfo = null;
|
UserShopInfo userShopInfo = null;
|
||||||
if (StrUtil.isNotBlank(login.getData())) {
|
if (StrUtil.isNotBlank(login.getData()) && isStarterShop) {
|
||||||
// 登录商城账户
|
// 登录商城账户
|
||||||
userShop = usersService.loginShop(phone);
|
userShop = usersService.loginShop(phone);
|
||||||
userShopInfo = JSONUtil.parse(userShop).toBean(UserShopInfo.class);
|
userShopInfo = JSONUtil.parse(userShop).toBean(UserShopInfo.class);
|
||||||
|
@ -104,6 +104,8 @@ management:
|
|||||||
exposure:
|
exposure:
|
||||||
include: '*'
|
include: '*'
|
||||||
|
|
||||||
|
is-starter-shop: false
|
||||||
|
|
||||||
# 自定义配置
|
# 自定义配置
|
||||||
path:
|
path:
|
||||||
home: D:\system\acdr\
|
home: D:\system\acdr\
|
||||||
|
@ -2,6 +2,7 @@ package com.yskj.acdr;
|
|||||||
|
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.yskj.acdr.master.address.service.ServiceAddressService;
|
||||||
import com.yskj.acdr.master.user.entity.AuthenticationResponse;
|
import com.yskj.acdr.master.user.entity.AuthenticationResponse;
|
||||||
import com.yskj.acdr.master.user.service.AuthenticationService;
|
import com.yskj.acdr.master.user.service.AuthenticationService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -18,6 +19,9 @@ public class AcdrTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AuthenticationService service;
|
private AuthenticationService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ServiceAddressService addressService;
|
||||||
|
|
||||||
// 测试实名认证
|
// 测试实名认证
|
||||||
@Test
|
@Test
|
||||||
void TestAuthenticationService() {
|
void TestAuthenticationService() {
|
||||||
@ -62,4 +66,9 @@ public class AcdrTest {
|
|||||||
|
|
||||||
log.info(post);
|
log.info(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void map() throws Exception {
|
||||||
|
System.out.println(addressService.getReverseGeocoding(114.05956, 22.54286));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user