|
|
|
@ -201,39 +201,16 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
hasLocationAuthHandle(callback = () => {}) { |
|
|
|
|
const appInstance = getApp(); |
|
|
|
|
let { hasLocationAuth } = appInstance.globalData; |
|
|
|
|
if (!hasLocationAuth) { |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: "未打开小程序定位", |
|
|
|
|
content: "需获取您的地理位置才可以继续加油", |
|
|
|
|
confirmText: "开启定位", |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
uni.openSetting({ |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.authSetting["scope.userLocation"]) { |
|
|
|
|
callback(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
serviceIllustrate() { |
|
|
|
|
this.$refs.popupIllustrate.open("bottom"); |
|
|
|
|
}, |
|
|
|
|
createCOrder() { |
|
|
|
|
async createCOrder() { |
|
|
|
|
let isHas = this.hasLocationAuthHandle(() => { |
|
|
|
|
this.getById(this.siteInfo); |
|
|
|
|
}); |
|
|
|
|
if (!isHas) return; |
|
|
|
|
if (!this.beyondDistance()) return; |
|
|
|
|
let isBeyond = await this.beyondDistance(); |
|
|
|
|
if (!isBeyond) return; |
|
|
|
|
if (!this.checkParams()) return; |
|
|
|
|
serve |
|
|
|
|
.createCOrder({ |
|
|
|
@ -251,17 +228,24 @@ export default { |
|
|
|
|
this.wxPay(res.data); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
beyondDistance() { |
|
|
|
|
let { juli, siteName } = this.siteInfo; |
|
|
|
|
if (juli > 10000) { |
|
|
|
|
// 定位权限是否开启检测 |
|
|
|
|
hasLocationAuthHandle(callback = () => {}) { |
|
|
|
|
const appInstance = getApp(); |
|
|
|
|
let { hasLocationAuth } = appInstance.globalData; |
|
|
|
|
if (!hasLocationAuth) { |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: siteName, |
|
|
|
|
content: "您与加油站距离较远,请到达加油站与加油员确认金额后付款", |
|
|
|
|
confirmText: "导航到站", |
|
|
|
|
cancelText: "我知道了", |
|
|
|
|
title: "未打开小程序定位", |
|
|
|
|
content: "需获取您的地理位置才可以继续加油", |
|
|
|
|
confirmText: "开启定位", |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
this.openMap(); |
|
|
|
|
uni.openSetting({ |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.authSetting["scope.userLocation"]) { |
|
|
|
|
callback(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
@ -269,6 +253,36 @@ export default { |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
// 距离检测 |
|
|
|
|
async beyondDistance() { |
|
|
|
|
let { juli, siteName, siteId, id } = this.siteInfo; |
|
|
|
|
if (juli > 10000) { |
|
|
|
|
let firstRes = await this.$utils.obtainLocationHandle(); |
|
|
|
|
let { latitude, longitude } = firstRes; |
|
|
|
|
let secondRes = await serve.getById({ |
|
|
|
|
id: siteId || id, |
|
|
|
|
latitude, |
|
|
|
|
longitude, |
|
|
|
|
}); |
|
|
|
|
if (secondRes.code !== 20000) return false; |
|
|
|
|
if (secondRes.data.juli > 10000) { |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: siteName, |
|
|
|
|
content: "您与加油站距离较远,请到达加油站与加油员确认金额后付款", |
|
|
|
|
confirmText: "导航到站", |
|
|
|
|
cancelText: "我知道了", |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
this.openMap(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
checkParams() { |
|
|
|
|
if (!this.params.oilsBar) { |
|
|
|
|
uni.showToast({ |
|
|
|
@ -385,7 +399,7 @@ export default { |
|
|
|
|
marketPrice: item.marketPrice, |
|
|
|
|
sitePriceId: item.priceId, |
|
|
|
|
}); |
|
|
|
|
// item.oilsBars数据结构为['','',''] 此处不适用 转化下为[{},{},{}] |
|
|
|
|
// item.oilsBars数据结构为['','',''] 此处不适用 转化为[{},{},{}] |
|
|
|
|
spear[item.oilProductCode] = item.oilsBars.reduce((prev, item) => { |
|
|
|
|
prev.push({ |
|
|
|
|
label: item, |
|
|
|
|