|
...
|
...
|
@@ -12,9 +12,11 @@ Page({ |
|
|
|
detail: {},
|
|
|
|
exp_date: {},
|
|
|
|
resultCoupon: '', //0未领取 1已领取
|
|
|
|
seller: {},
|
|
|
|
distance: '',
|
|
|
|
},
|
|
|
|
myModal: '',
|
|
|
|
myToast :'',
|
|
|
|
myToast:'',
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
...
|
...
|
@@ -95,7 +97,7 @@ Page({ |
|
|
|
// 领券
|
|
|
|
getActivityCouponFun(type){
|
|
|
|
let detail = this.data.detail
|
|
|
|
detail.name = this.data.sellername;
|
|
|
|
detail.name = this.data.seller.sellername;
|
|
|
|
detail.oid = this.data.opt.oid;
|
|
|
|
App.Activity.SetActivityAsReserve({
|
|
|
|
aid: this.data.opt.id,
|
|
...
|
...
|
@@ -153,11 +155,60 @@ Page({ |
|
|
|
},
|
|
|
|
// 获取店铺名称
|
|
|
|
getSellerDetail() {
|
|
|
|
let that = this;
|
|
|
|
App.Customer.GetSellerDetail({
|
|
|
|
sid: this.data.opt.sid
|
|
|
|
}).then(res => {
|
|
|
|
let data = res.data;
|
|
|
|
let cateStr = []
|
|
|
|
if (data.cate && data.cate.length > 0) {
|
|
|
|
data.cate.some(cate => {
|
|
|
|
cateStr.push(cate);
|
|
|
|
if (cateStr.length > 2) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
cateStr = cateStr.join('/')
|
|
|
|
}
|
|
|
|
let latitude = '';
|
|
|
|
let longitude = '';
|
|
|
|
let distance = '';
|
|
|
|
let seller = {
|
|
|
|
cateStr,
|
|
|
|
sellername: data.sellername,
|
|
|
|
is_online_reserve: data.is_online_reserve,
|
|
|
|
seller_image: data.seller_image,
|
|
|
|
}
|
|
|
|
wx.getLocation({
|
|
|
|
type: 'wgs84', // 返回可以用于 wx.openLocation 的经纬度
|
|
|
|
success: function (res) {
|
|
|
|
latitude = res.latitude; // 纬度
|
|
|
|
longitude = res.longitude; // 经度
|
|
|
|
console.log(`当前的纬度: ${latitude}, 当前的经度: ${longitude}`);
|
|
|
|
if (latitude && longitude) {
|
|
|
|
distance = that.getDistance(latitude, longitude, data.lat, data.long);
|
|
|
|
distance = parseInt(distance)
|
|
|
|
if (distance > 1000) {
|
|
|
|
distance = (distance / 1000).toFixed(2) + 'km'
|
|
|
|
} else {
|
|
|
|
distance += 'm';
|
|
|
|
}
|
|
|
|
that.setData({
|
|
|
|
distance
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: function (err) {
|
|
|
|
console.error('获取位置失败:', err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
console.log({
|
|
|
|
...seller
|
|
|
|
});
|
|
|
|
this.setData({
|
|
|
|
sellername: res.data.sellername
|
|
|
|
seller: {
|
|
|
|
...seller
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
...
|
...
|
@@ -214,7 +265,7 @@ Page({ |
|
|
|
path += '&activity_id='+detail.activity_id
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
title: `送你${this.data.sellername}${detail.price}元代金券,点击查看详情,领取到卡包吧!`,
|
|
|
|
title: `送你${this.data.seller.sellername}${detail.price}元代金券,点击查看详情,领取到卡包吧!`,
|
|
|
|
path,
|
|
|
|
imageUrl: 'https://nosqn.colorcun.com/share_money.png',
|
|
|
|
}
|
|
...
|
...
|
@@ -243,7 +294,22 @@ Page({ |
|
|
|
this.getSellerDetail();
|
|
|
|
this.getCoupon()
|
|
|
|
},
|
|
|
|
|
|
|
|
// 计算2点之间的距离
|
|
|
|
getDistance(lat1, lon1, lat2, lon2) {
|
|
|
|
const R = 6371e3; // 地球半径(米)
|
|
|
|
// 将经纬度转换为弧度
|
|
|
|
const φ1 = lat1 * Math.PI / 180; // 纬度1
|
|
|
|
const φ2 = lat2 * Math.PI / 180; // 纬度2
|
|
|
|
const Δφ = (lat2 - lat1) * Math.PI / 180; // 纬度差
|
|
|
|
const Δλ = (lon2 - lon1) * Math.PI / 180; // 经度差
|
|
|
|
// Haversine 公式
|
|
|
|
const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
|
|
|
Math.cos(φ1) * Math.cos(φ2) *
|
|
|
|
Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
|
|
|
|
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
|
const distance = R * c; // 计算距离(米)
|
|
|
|
return distance; // 返回距离
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
...
|
...
|
|