Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
groupPurchase-miniapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭佳妮(贵阳日报)
groupPurchase-miniapp
Commits
82f29c96
Commit
82f29c96
authored
Aug 06, 2024
by
石建新(贵阳日报)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
店铺距离
parent
9a1a518e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
30 deletions
+86
-30
shop.vue
src/pages/shop/shop.vue
+86
-30
No files found.
src/pages/shop/shop.vue
View file @
82f29c96
...
...
@@ -311,6 +311,8 @@ const shopInfo = ref({});
const
shopSwiperList
=
ref
([]);
// 当前位置的经纬度-// 店铺的经纬度
const
currentLatitudeAndLongitude
=
ref
({
latitude
:
0
,
longitude
:
0
});
// 店铺经纬度
const
shopLocation
=
ref
({
lat
:
0
,
lon
:
0
});
// 团购商品列表
const
listOfGroupBuyingProducts
=
ref
([]);
// 商家优惠券
...
...
@@ -331,24 +333,77 @@ const commentTotal = ref(0);
const
recommendedTypesOfPeripherals
=
ref
([]);
// 商户id
const
shopId
=
ref
(
''
);
const
tagList2
=
ref
([{
name
:
'免费停车'
,
id
:
1
}]);
// 周边推荐-商家列表
const
recommendedListOfPeripherals
=
ref
([]);
onLoad
((
options
)
=>
{
// onLoad((options) => {
// params.value.shopId = options.shopId;
// getStoreInformationFn(options.shopId).then(() => {
// peripheryRecomFn();
// });
// groupBuyListFn(options.shopId);
// shopId.value = options.shopId;
// couponShopListFn(options.shopId);
// getEvaluationPageFn();
// });
// onShow(() => {
// getStoreInformationFn(params.value.shopId).then(() => {
// // 获取位置
// getLocationFn().then((res) => {
// const distance = getDistance(
// res.lat,
// res.lon,
// shopLocation.value.lat,
// shopLocation.value.lon,
// 1,
// );
// shopInfo.value.distance = distance;
// });
// });
// });
onLoad
(
async
(
options
)
=>
{
params
.
value
.
shopId
=
options
.
shopId
;
getStoreInformationFn
(
options
.
shopId
).
then
(()
=>
{
peripheryRecomFn
();
});
groupBuyListFn
(
options
.
shopId
);
shopId
.
value
=
options
.
shopId
;
couponShopListFn
(
options
.
shopId
);
// 使用 Promise.all 并行请求,提升性能
await
Promise
.
all
([
getStoreInformationFn
(
options
.
shopId
),
groupBuyListFn
(
options
.
shopId
),
couponShopListFn
(
options
.
shopId
),
]);
// 获取周边推荐信息
peripheryRecomFn
();
// 获取评价信息
getEvaluationPageFn
();
// 获取位置并计算距离
calculateDistance
();
});
onShow
(()
=>
{
// 获取位置
getLocationFn
();
onShow
(
async
()
=>
{
await
getStoreInformationFn
(
params
.
value
.
shopId
);
// 获取位置并计算距离
calculateDistance
();
});
const
value
=
ref
(
5
);
// 计算距离的函数封装
async
function
calculateDistance
()
{
try
{
const
res
=
await
getLocationFn
();
const
distance
=
getDistance
(
res
.
lat
,
res
.
lon
,
shopLocation
.
value
.
lat
,
shopLocation
.
value
.
lon
,
1
,
);
shopInfo
.
value
.
distance
=
distance
;
console
.
log
(
'distance'
,
distance
,
shopLocation
.
value
.
lat
,
shopLocation
.
value
.
lon
);
}
catch
(
error
)
{
console
.
error
(
'Error calculating distance:'
,
error
);
}
}
const
handleClick
=
(
e
)
=>
{
const
{
index
}
=
e
;
const
imgSrc
=
shopSwiperList
.
value
[
index
];
...
...
@@ -369,9 +424,9 @@ function scroll(e) {
*/
function
peripheryRecomFn
()
{
// 维度
const
lat
=
currentLatitudeAndLongitude
.
value
.
latitude
;
const
lat
=
shopLocation
.
value
.
lat
;
// 经度
const
lon
=
currentLatitudeAndLongitude
.
value
.
longitude
;
const
lon
=
shopLocation
.
value
.
lon
;
peripheryRecom
({
lat
,
lon
,
distance
:
10
}).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
recommendedTypesOfPeripherals
.
value
=
res
.
data
;
...
...
@@ -406,27 +461,27 @@ function sgyrddShopPageFn(categoryIds, lat, lon) {
.
filter
((
item
)
=>
{
return
item
!==
''
;
});
console
.
log
(
'res.data.content'
,
res
.
data
.
content
);
recommendedListOfPeripherals
.
value
=
res
.
data
.
content
;
xma
.
hideLoading
();
}
});
}
function
getLocationFn
()
{
xma
.
getLocation
({
type
:
'wgs84'
,
isHighAccuracy
:
true
,
success
:
function
(
res
)
{
// 经纬度
console
.
log
(
'res.latitude, res.longitude'
,
res
.
latitude
,
res
.
longitude
);
// 店铺的经纬度
const
myLatitude
=
currentLatitudeAndLongitude
.
value
.
latitude
;
const
myLongitude
=
currentLatitudeAndLongitude
.
value
.
longitude
;
const
distance
=
getDistance
(
res
.
latitude
,
res
.
longitude
,
myLatitude
,
myLongitude
,
1
);
shopInfo
.
value
.
distance
=
distance
;
},
fail
:
function
(
err
)
{
return
err
;
},
return
new
Promise
((
resolve
,
reject
)
=>
{
xma
.
getLocation
({
type
:
'wgs84'
,
isHighAccuracy
:
true
,
success
:
function
(
res
)
{
// 经纬度
console
.
log
(
'res.latitude, res.longitude'
,
res
.
latitude
,
res
.
longitude
);
resolve
({
lat
:
res
.
latitude
,
lon
:
res
.
longitude
});
},
fail
:
function
(
err
)
{
return
err
;
},
});
});
}
/**
...
...
@@ -475,8 +530,9 @@ const getStoreInformationFn = (id) => {
if
(
res
.
data
.
shop
.
labels
&&
res
.
data
.
shop
.
labels
!==
''
)
{
shopInfo
.
value
.
tagList
=
res
.
data
.
shop
.
labels
.
split
(
','
);
}
currentLatitudeAndLongitude
.
value
.
latitude
=
res
.
data
.
shop
.
location
.
lat
;
currentLatitudeAndLongitude
.
value
.
longitude
=
res
.
data
.
shop
.
location
.
lon
;
const
{
lat
,
lon
}
=
res
.
data
.
shop
.
location
;
shopLocation
.
value
.
lat
=
lat
;
shopLocation
.
value
.
lon
=
lon
;
resolve
();
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment