Compare commits
1 Commits
master
...
d3c8010b61
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3c8010b61 |
@@ -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();
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<view style="opacity: 1"
|
||||
>加100升约省{{
|
||||
item.oilSitePrice | conserveFilter(item.sitePrice)
|
||||
}}</view
|
||||
}}元</view
|
||||
>
|
||||
<view @click.stop="openMap(item)">
|
||||
<image src="/static/index/home/nav.png" mode="" />
|
||||
@@ -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;
|
||||
|
||||
@@ -45,7 +45,8 @@ export default {
|
||||
onPullDownRefresh() {
|
||||
if (this.currentTab === "home") {
|
||||
this.$bus.$emit("pullDownRefresh");
|
||||
} else {
|
||||
}
|
||||
if (this.currentTab === "user") {
|
||||
setTimeout(() => {
|
||||
uni.stopPullDownRefresh();
|
||||
}, 500);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
}}</text
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
>本单优惠¥{{
|
||||
orderInfo.discountAmount | preferential(orderInfo.serviceCharge)
|
||||
}}</view
|
||||
>
|
||||
<view>本单优惠¥{{ orderInfo.discountAmount }}</view>
|
||||
</view>
|
||||
|
||||
<view class="info">
|
||||
@@ -81,11 +77,16 @@
|
||||
<view class="term">
|
||||
<view>
|
||||
<text>直降优惠:</text>
|
||||
<text>{{ orderInfo.discountAmount }}</text>
|
||||
<text
|
||||
>-¥{{
|
||||
orderInfo.discountAmount
|
||||
| preferential(orderInfo.platformCommission)
|
||||
}}</text
|
||||
>
|
||||
</view>
|
||||
<view>
|
||||
<text>服务费:</text>
|
||||
<text>{{ orderInfo.serviceCharge }}</text>
|
||||
<text>+¥{{ orderInfo.platformCommission }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="total">
|
||||
@@ -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: {},
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
<view class="tip"
|
||||
>请告知加油员,已成功支付,如需发票,请联系加油站开票</view
|
||||
>
|
||||
<view class="button details" @click="jumpDetails">订单详情</view>
|
||||
<view
|
||||
v-if="orderInfo.orderSerialNumber"
|
||||
class="button details"
|
||||
@click="jumpDetails"
|
||||
>订单详情</view
|
||||
>
|
||||
<view class="button home" @click="jumpHome">返回首页</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view>{{ siteInfo.address }}</view>
|
||||
<view>距您{{ siteInfo.juli }}km</view>
|
||||
<view>距您{{ siteInfo.juli | distanceFilter }}km</view>
|
||||
<view class="nav" @click="openMap">
|
||||
<image src="../static/details/nav.png" mode="" />
|
||||
<view>导航</view>
|
||||
@@ -27,8 +27,8 @@
|
||||
>/L
|
||||
</view>
|
||||
<view>
|
||||
<view>油站价 ¥{{ params.oilSitePrice }}/L</view>
|
||||
<view>指导价 ¥{{ params.marketPrice }}/L</view>
|
||||
<view>油站价 ¥{{ params.oilSitePrice || "--" }}/L</view>
|
||||
<view>指导价 ¥{{ params.marketPrice || "--" }}/L</view>
|
||||
</view>
|
||||
<view
|
||||
>享油站价<text>直降¥{{ priceDiff }}/L</text></view
|
||||
@@ -54,7 +54,7 @@
|
||||
<text>¥</text>
|
||||
<input
|
||||
v-model="params.sitePriceAmount"
|
||||
type="numeric"
|
||||
type="number"
|
||||
maxlength="4"
|
||||
placeholder="输入金额,实时计算优惠"
|
||||
placeholder-class="placeholder-class"
|
||||
@@ -170,11 +170,25 @@ export default {
|
||||
return;
|
||||
}
|
||||
this.getById(JSON.parse(siteInfo));
|
||||
this.hasLocationAuthHandle(() => {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
// ();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user