develop
xiaozhiyong 11 months ago
parent d3c8010b61
commit 4fd0b3eed1
  1. 2
      src/App.vue
  2. 2
      src/manifest.json
  3. 84
      src/subPackages/site/details/index.vue

@ -6,7 +6,7 @@ export default {
latitude: 39.5426, latitude: 39.5426,
longitude: 116.23292, longitude: 116.23292,
}, },
appId: "wxed3e2914d6aa4d52", appId: "wx9995c9f495efa82e",
hasLocationAuth: true, hasLocationAuth: true,
}, },
onLaunch: function () { onLaunch: function () {

@ -57,7 +57,7 @@
/* */ /* */
}, },
"mp-weixin": { "mp-weixin": {
/* */ "appid": "wxed3e2914d6aa4d52", /* */ "appid": "wx9995c9f495efa82e",
"setting": { "setting": {
"urlCheck": false "urlCheck": false
}, },

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

Loading…
Cancel
Save