diff --git a/src/App.vue b/src/App.vue
index 4c4cf06..f90c767 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -5,9 +5,9 @@ export default {
location: {
latitude: 39.5426,
longitude: 116.23292,
- test: 1,
},
appId: "wxed3e2914d6aa4d52",
+ hasLocationAuth: true,
},
onLaunch: function () {
let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
diff --git a/src/pages.json b/src/pages.json
index 36c6d61..c5f970e 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -1,12 +1,12 @@
{
"pages": [
- {
- "path": "pages/index/index",
- "style": { "enablePullDownRefresh": true }
- },
{
"path": "pages/startPage/index",
"style": {}
+ },
+ {
+ "path": "pages/index/index",
+ "style": { "enablePullDownRefresh": true }
}
],
"subPackages": [
diff --git a/src/pages/index/home/components/options.vue b/src/pages/index/home/components/options.vue
index 3588f6a..412e784 100644
--- a/src/pages/index/home/components/options.vue
+++ b/src/pages/index/home/components/options.vue
@@ -33,7 +33,7 @@ export default {
params: {
sort: "juli",
oilProductCode: "0#",
- distance: 5000,
+ distance: 15000,
siteBrand: "",
},
list: [
@@ -83,6 +83,7 @@ export default {
{ name: "5km", id: 5000 },
{ name: "15km", id: 15000 },
{ name: "30km", id: 30000 },
+ { name: "50km", id: 50000 },
],
};
this.list.forEach((item) => {
diff --git a/src/pages/index/home/index.vue b/src/pages/index/home/index.vue
index 5950a3a..9cf8535 100644
--- a/src/pages/index/home/index.vue
+++ b/src/pages/index/home/index.vue
@@ -44,7 +44,7 @@
加100升约省{{
item.oilSitePrice | conserveFilter(item.sitePrice)
- }}
@@ -82,7 +82,7 @@ export default {
params: {
sort: "juli",
oilProductCode: "0#",
- distance: 5000,
+ distance: 15000,
siteBrand: "",
},
},
@@ -112,13 +112,7 @@ export default {
this.paramter.currentPage = 1;
this.isReachBottom = false;
- wx.getSetting({
- success: (res) => {
- if (res.authSetting["scope.userLocation"]) {
- this.findBSiteInfoByPage();
- } else this.obtainLocation();
- },
- });
+ this.obtainLocation();
});
},
methods: {
@@ -136,50 +130,18 @@ export default {
});
},
obtainLocation() {
- uni.getLocation({
- type: "wgs84",
- success: (res) => {
- console.log(res);
- if (res.errMsg === "getLocation:ok") {
- let { latitude, longitude } = res;
- this.paramter.params.latitude = latitude;
- this.paramter.params.longitude = longitude;
-
- let appInstance = getApp();
- appInstance.globalData.location.latitude = latitude;
- appInstance.globalData.location.longitude = longitude;
- }
- },
- fail: (err) => {
- if (err.errMsg === "getLocation:fail auth deny") {
- uni.showModal({
- title: "提示",
- content: "您已拒绝获取位置信息,请重新授权",
- confirmText: "开启定位",
- success: (res) => {
- if (res.confirm) {
- uni.openSetting({
- success: (res) => {
- if (res.authSetting["scope.userLocation"])
- this.obtainLocation();
- },
- });
- } else {
- uni.showToast({
- title:
- "因您拒绝获取位置信息,默认为您查询北京天安门附近油站",
- icon: "none",
- duration: 2000,
- });
- }
- },
- });
- }
- },
- complete: () => {
+ let appInstance = getApp();
+ this.$utils
+ .obtainLocationHandle(appInstance)
+ .then((res) => {
+ let { latitude, longitude } = res;
+ this.paramter.params.latitude = latitude;
+ this.paramter.params.longitude = longitude;
this.findBSiteInfoByPage();
- },
- });
+ })
+ .catch(() => {
+ this.findBSiteInfoByPage();
+ });
},
findBSiteInfoByPage() {
if (this.isReachBottom) return;
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 326e2f0..e782a5b 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -45,7 +45,8 @@ export default {
onPullDownRefresh() {
if (this.currentTab === "home") {
this.$bus.$emit("pullDownRefresh");
- } else {
+ }
+ if (this.currentTab === "user") {
setTimeout(() => {
uni.stopPullDownRefresh();
}, 500);
diff --git a/src/pages/startPage/index.vue b/src/pages/startPage/index.vue
index 9f8a596..e1b2482 100644
--- a/src/pages/startPage/index.vue
+++ b/src/pages/startPage/index.vue
@@ -38,10 +38,11 @@ export default {
methods: {
initFn() {
- uni.reLaunch({
- url: "/pages/index/index",
- });
- setTimeout(() => {}, 500);
+ setTimeout(() => {
+ uni.reLaunch({
+ url: "/pages/index/index",
+ });
+ }, 1000);
return;
let interstitialAd = null;
diff --git a/src/subPackages/order/details/index.vue b/src/subPackages/order/details/index.vue
index 39340fe..973c498 100644
--- a/src/subPackages/order/details/index.vue
+++ b/src/subPackages/order/details/index.vue
@@ -19,11 +19,7 @@
}}
- 本单优惠¥{{
- orderInfo.discountAmount | preferential(orderInfo.serviceCharge)
- }}
+ 本单优惠¥{{ orderInfo.discountAmount }}
@@ -81,11 +77,16 @@
直降优惠:
- {{ orderInfo.discountAmount }}
+ -¥{{
+ orderInfo.discountAmount
+ | preferential(orderInfo.platformCommission)
+ }}
服务费:
- {{ orderInfo.serviceCharge }}
+ +¥{{ orderInfo.platformCommission }}
@@ -111,9 +112,9 @@ export default {
this.orderInfo = JSON.parse(orderInfo);
},
filters: {
- preferential(discountAmount, serviceCharge) {
- if (!discountAmount || !serviceCharge) return "0.00";
- return (discountAmount * 10000 - serviceCharge * 10000) / 10000;
+ preferential(discountAmount, platformCommission) {
+ if (!discountAmount || !platformCommission) return "0.00";
+ return (discountAmount * 10000 + platformCommission * 10000) / 10000;
},
},
methods: {},
diff --git a/src/subPackages/order/paymentResult/index.vue b/src/subPackages/order/paymentResult/index.vue
index 3698e28..8db7122 100644
--- a/src/subPackages/order/paymentResult/index.vue
+++ b/src/subPackages/order/paymentResult/index.vue
@@ -8,7 +8,12 @@
请告知加油员,已成功支付,如需发票,请联系加油站开票
- 订单详情
+ 订单详情
返回首页
diff --git a/src/subPackages/site/details/index.vue b/src/subPackages/site/details/index.vue
index d116507..5cfa68d 100644
--- a/src/subPackages/site/details/index.vue
+++ b/src/subPackages/site/details/index.vue
@@ -11,7 +11,7 @@
{{ siteInfo.address }}
- 距您{{ siteInfo.juli }}km
+ 距您{{ siteInfo.juli | distanceFilter }}km
导航
@@ -27,8 +27,8 @@
>/L
- 油站价 ¥{{ params.oilSitePrice }}/L
- 指导价 ¥{{ params.marketPrice }}/L
+ 油站价 ¥{{ params.oilSitePrice || "--" }}/L
+ 指导价 ¥{{ params.marketPrice || "--" }}/L
享油站价直降¥{{ priceDiff }}/L¥
{
+ this.$utils.obtainLocationHandle(appInstance).then(() => {
+ this.getById(JSON.parse(siteInfo));
+ });
+ });
},
filters: {
preferential(discountAmount, serviceCharge) {
if (!discountAmount) return "0.00";
- return (discountAmount * 10000 - serviceCharge * 10000) / 10000;
+ return (
+ (discountAmount * 100000 - serviceCharge * 100000) /
+ 100000
+ ).toFixed(2);
+ },
+ distanceFilter(value) {
+ if (value) {
+ return (value / 1000).toFixed(2);
+ }
+ return "0.00";
},
},
computed: {
@@ -183,14 +197,43 @@ export default {
if (oilSitePrice && sitePrice) {
return (oilSitePrice - sitePrice).toFixed(2);
}
- return "0.00";
+ return "--";
},
},
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() {
+ let isHas = this.hasLocationAuthHandle(() => {
+ this.getById(this.siteInfo);
+ });
+ if (!isHas) return;
+ if (!this.beyondDistance()) return;
if (!this.checkParams()) return;
serve
.createCOrder({
@@ -208,6 +251,24 @@ export default {
this.wxPay(res.data);
});
},
+ beyondDistance() {
+ let { juli, siteName } = this.siteInfo;
+ if (juli > 10000) {
+ uni.showModal({
+ title: siteName,
+ content: "您与加油站距离较远,请到达加油站与加油员确认金额后付款",
+ confirmText: "导航到站",
+ cancelText: "我知道了",
+ success: (res) => {
+ if (res.confirm) {
+ this.openMap();
+ }
+ },
+ });
+ return false;
+ }
+ return true;
+ },
checkParams() {
if (!this.params.oilsBar) {
uni.showToast({
@@ -297,10 +358,12 @@ export default {
});
},
getById(siteInfo) {
+ const appInstance = getApp();
+ let { latitude, longitude } = appInstance.globalData.location;
let params = {
- id: siteInfo.siteId,
- latitude: siteInfo.latitude,
- longitude: siteInfo.longitude,
+ id: siteInfo.siteId || siteInfo.id,
+ latitude: latitude,
+ longitude: longitude,
};
serve.getById(params).then((res) => {
if (res.code !== 20000) return;
@@ -585,7 +648,7 @@ export default {
// line-height: 100rpx;
}
> view {
- width: 170rpx;
+ width: 200rpx;
font-size: 28rpx;
color: #999;
}
diff --git a/src/utils/index.js b/src/utils/index.js
index 65dd1e2..ff9e1d1 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -1,3 +1,4 @@
+// 类型校验
export function typeJudgment(object) {
try {
let res = {}.__proto__.toString.call(object);
@@ -7,10 +8,10 @@ export function typeJudgment(object) {
return "";
}
}
+// 时间处理
function padZero(value, length = 2) {
return value.toString().padStart(length, "0");
}
-
export function dateTimeHandle(date) {
let dateTime;
@@ -53,3 +54,57 @@ export function dateTimeHandle(date) {
weekDay, // 0-6, with 0 being Sunday
};
}
+
+// uni.getLocation
+export function obtainLocationHandle(
+ appInstance = { globalData: { location: {} } }
+) {
+ return new Promise((resolve, reject) => {
+ uni.getLocation({
+ type: "wgs84",
+ success: (res) => {
+ if (res.errMsg === "getLocation:ok") {
+ appInstance.globalData.hasLocationAuth = true;
+ let { latitude, longitude } = res;
+ appInstance.globalData.location.latitude = latitude;
+ appInstance.globalData.location.longitude = longitude;
+ resolve(res);
+ }
+ },
+ fail: (err) => {
+ appInstance.globalData.hasLocationAuth = false;
+
+ if (err.errMsg === "getLocation:fail auth deny") {
+ uni.showModal({
+ title: "提示",
+ content: "您已拒绝获取位置信息,请重新授权",
+ confirmText: "开启定位",
+ success: (res) => {
+ if (res.confirm) {
+ uni.openSetting({
+ success: (res) => {
+ if (res.authSetting["scope.userLocation"])
+ obtainLocationHandle(appInstance).then((_res) =>
+ resolve(_res)
+ );
+ },
+ });
+ } else {
+ uni.showToast({
+ title: "因您拒绝获取位置信息,默认为您查询北京天安门附近油站",
+ icon: "none",
+ duration: 2000,
+ });
+ let i = setTimeout(() => {
+ clearTimeout(i);
+ reject();
+ }, 2000);
+ // ();
+ }
+ },
+ });
+ }
+ },
+ });
+ });
+}
diff --git a/src/utils/request.js b/src/utils/request.js
index 533d873..b90a180 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,10 +1,10 @@
import axios from "axios";
import axiosMiniprogramAdapter from "axios-miniprogram-adapter";
import utils from "@/utils/encode";
-
-let env = "test";
-// let env = "production";
-let testUrl = "http://192.168.110.230:38080";
+let env;
+env = "test";
+env = "production";
+let testUrl = "http://192.168.110.77:38080";
let productUrl = "http://uat.xingoil.com/guest-api";
// let productUrl = "https://www.xingoil.com/adminapi";