oil-station/gasStation-uni/pages/index/index.vue

648 lines
14 KiB
Vue
Raw Normal View History

2023-11-27 09:24:16 +08:00
<template>
<view class="content">
<view class="container">
<!--外层 -->
<!-- 顶部 -->
<view class="conttainer-top">
<!-- 标题 -->
<view class="top-title">
出行服务 优惠加油
</view>
<view class="lan-gang">
<view class="lsiez"> <uni-icons type="checkbox" color="#ffffff" size="10"></uni-icons> </view>
<view class="lsiez"> <uni-icons type="checkbox" color="#ffffff" size="10"></uni-icons> </view>
<view class="lsiez"> <uni-icons type="checkbox" color="#ffffff" size="10"></uni-icons> </view>
</view>
<!-- 金刚区 -->
<view class="conttainer-jg">
2023-12-01 17:43:20 +08:00
<view class="jg-box" @click="toQRcode">
2023-11-27 09:24:16 +08:00
<view class="jg-img">
<image src="../../static/imgs/viprwm.png" mode=""></image>
</view>
2023-11-28 14:43:36 +08:00
<view class="jg-size">二维码</view>
2023-11-27 09:24:16 +08:00
</view>
<view class="jg-box" @click="goActivity()">
<view class="jg-img">
<image src="../../static/imgs/bzhd.png" mode=""></image>
</view>
<view class="jg-size">本站活动</view>
</view>
2023-11-27 18:28:41 +08:00
<view class="jg-box" @click="goCard()">
2023-11-27 09:24:16 +08:00
<view class="jg-img">
<image src="../../static/imgs/ykcz.png" mode=""></image>
</view>
<view class="jg-size">油卡充值</view>
</view>
2023-11-27 18:28:41 +08:00
<view class="jg-box" @click="goMall()">
2023-11-27 09:24:16 +08:00
<view class="jg-img">
<image src="../../static/imgs/jfsc.png" mode=""></image>
</view>
<view class="jg-size">积分商城</view>
</view>
</view>
<!-- 金刚区结束 -->
</view>
<!-- 顶部结束 -->
<!-- centenr -->
<view class="conttainer-cetr">
<view class="conttainer-title">今日会员价</view>
<view class="conttainer-box">
<view class="c-box-box1" @click="show = true">
2023-11-30 14:28:12 +08:00
<view class="">{{oilInfo.oilName}}</view>
2023-11-27 09:24:16 +08:00
<view class="">
<u-icon name="arrow-down-fill"></u-icon>
</view>
</view>
<view class="c-box-box2">
<view class="xred">会员价</view>
2023-11-30 14:28:12 +08:00
<view class="dred"> <text class="xred"></text> {{oilInfo.oilPrice}}</view>
2023-11-27 09:24:16 +08:00
</view>
<view class="c-box-box3">
<view class="xblck">国际价</view>
2023-11-30 14:28:12 +08:00
<view class="dblck"> <text class="xblck"></text> {{oilInfo.oilPrice}}</view>
2023-11-27 09:24:16 +08:00
</view>
</view>
</view>
<!-- centenr结束 -->
<!-- 加油站卡片-->
<view class="station">
<view class="station-box">
2023-11-29 16:26:19 +08:00
<view class="station-title">
{{store.name}}{{store.description ? "("+store.description+")" : ""}}
2023-11-28 14:43:36 +08:00
</view><!--顺通石化加油站(工业南路站)-->
2023-11-27 18:28:41 +08:00
<view style="display: flex;">
2023-11-28 14:43:36 +08:00
<view class="bule-icon" v-if="welfare.length!=0" v-for="(item,index) in welfare" :key="index">
{{item}}
</view>
2023-11-27 18:28:41 +08:00
</view>
2023-11-27 09:24:16 +08:00
<view class="dis-bt">
<view class="">
2023-11-27 18:28:41 +08:00
<view class="hui1">{{ store.address }}</view>
2023-11-29 16:26:19 +08:00
<view class="hui2" v-if="distance!=''">{{ distance }}km</view>
</view>
2023-12-01 16:20:02 +08:00
<view class="lananniu" @click="goGoGo" v-if="distance!=''">
<uni-icons type="paperplane-filled" color="#195ADA" size="16"></uni-icons>
{{ distance || "0" }}KM
2023-11-27 09:24:16 +08:00
</view>
</view>
<!-- <scroll-view scroll-x="true">
<view class="scrollbox" >
<view style="margin: 0px 10px;" v-for="(item,index) in 13" :key="index">123123</view>
</view>
</scroll-view> -->
<u-swiper :list="list3" previousMargin="30" nextMargin="30" circular :autoplay="false" radius="5"
bgColor="#ffffff"></u-swiper>
2023-11-27 18:28:41 +08:00
<view class="juanniu" @click="goOil()">
2023-11-27 09:24:16 +08:00
<view class="">一键加油</view>
</view>
</view>
<view style="height: 88px; width: 100%;"></view>
</view>
<!-- 加油站卡片结束-->
2023-11-30 14:28:12 +08:00
<!-- <u-picker :show="show" :columns="columns" @confirm="confirm" @cancel="cancel"></u-picker> -->
2023-12-01 16:20:02 +08:00
<u-picker :columns="columns" @confirm="confirm" :show="show" @cancel="show = false"
keyName="label"></u-picker>
2023-11-30 14:28:12 +08:00
2023-11-27 09:24:16 +08:00
<!--外层结束 -->
<tabbar :msg="msg"></tabbar>
</view>
</view>
</template>
<script>
import tabbar from "../../components/tabbar/tabbar.vue"
2023-11-30 14:28:12 +08:00
import config from '@/config'
import request from '../../utils/request'
2023-11-27 09:24:16 +08:00
export default {
data() {
return {
msg: "1",
show: false,
title: '',
2023-11-30 14:28:12 +08:00
oilTypeList: '',
2023-11-27 09:24:16 +08:00
columns: [
2023-12-01 16:20:02 +08:00
2023-11-27 09:24:16 +08:00
],
2023-11-30 14:28:12 +08:00
oilInfo: {
2023-12-01 16:20:02 +08:00
oilName: '未添加',
oilPrice: '0',
gbPrice: '0'
2023-11-30 14:28:12 +08:00
},
2023-12-01 16:20:02 +08:00
2023-11-27 09:24:16 +08:00
list3: [
'http://47.95.206.185:83/topbj.png',
'http://47.95.206.185:83/centerbj.png',
'https://cdn.uviewui.com/uview/swiper/swiper1.png',
],
2023-11-27 18:28:41 +08:00
// 当前经度信息
2023-11-28 14:43:36 +08:00
longitude: "",
2023-11-27 18:28:41 +08:00
// 纬度
2023-11-28 14:43:36 +08:00
latitude: "",
2023-11-27 18:28:41 +08:00
// 店铺信息
2023-12-01 16:26:25 +08:00
store: {
2023-12-05 10:37:36 +08:00
name: "测试油站",
description: "济南分店",
address: "济南槐荫区"
2023-12-01 16:26:25 +08:00
},
2023-11-27 18:28:41 +08:00
// 店铺福利信息
2023-11-28 14:43:36 +08:00
welfare: [],
2023-11-27 18:28:41 +08:00
distance: "",
2023-11-28 16:40:05 +08:00
storeId: "",
staffId: "",
2023-11-29 16:26:19 +08:00
baseUrl: this.$baseUrl,
2023-11-27 09:24:16 +08:00
}
},
2023-11-28 16:40:05 +08:00
onLoad(query) {
const q = decodeURIComponent(query.q) // 获取到二维码原始链接内容
2023-12-01 16:20:02 +08:00
if (q == undefined) {
2023-11-28 18:33:35 +08:00
let str = q.split("?")[1];
let arr = str.split("&");
let storeId = "";
let staffId = "";
arr.forEach(item => {
2023-12-01 16:20:02 +08:00
if (item.includes("storeId")) {
2023-11-28 18:33:35 +08:00
storeId = item.split("=")[1]
2023-12-01 16:20:02 +08:00
} else {
2023-11-28 18:33:35 +08:00
staffId = item.split("=")[1]
}
})
2023-12-18 18:44:02 +08:00
uni.setStorageSync("storeId", storeId)
2023-12-01 16:20:02 +08:00
uni.setStorageSync("inviteStaffId", staffId)
2023-12-18 18:44:02 +08:00
this.storeId = uni.getStorageSync("storeId")
2023-11-29 16:26:19 +08:00
this.staffId = uni.getStorageSync("inviteStaffId")
2023-11-28 18:33:35 +08:00
}
2023-12-06 18:36:10 +08:00
// this.isExistStoreId();
2023-12-05 10:37:36 +08:00
2023-12-01 15:40:43 +08:00
this.getUserAuthority();
2023-12-05 10:37:36 +08:00
this.getOilType();
2023-11-27 18:28:41 +08:00
},
onShow() {
2023-12-01 15:40:43 +08:00
// this.isExistStoreId();
2023-11-27 09:24:16 +08:00
},
components: {
tabbar
},
methods: {
2023-12-01 16:20:02 +08:00
isExistStoreId() {
2023-12-18 18:44:02 +08:00
if (uni.getStorageSync("storeId") != "") {
this.getStore(uni.getStorageSync("storeId"));
2023-12-01 16:20:02 +08:00
} else {
2023-11-28 18:33:35 +08:00
this.getAddress();
}
},
2023-12-01 15:40:43 +08:00
// 获取定位信息
2023-12-01 16:20:02 +08:00
getUserAuthority() {
2023-12-01 15:40:43 +08:00
let _this = this;
2023-12-06 18:36:10 +08:00
// this.getAddress();
2023-12-08 16:16:52 +08:00
2023-12-01 15:40:43 +08:00
wx.getSetting({
2023-12-01 16:20:02 +08:00
success(res) {
if (!res.authSetting['scope.userLocation']) {
2023-12-01 15:40:43 +08:00
wx.authorize({
2023-12-01 16:20:02 +08:00
scope: 'scope.userLocation',
success() {
2023-12-01 15:40:43 +08:00
// 用户同意获取位置信息
_this.isExistStoreId()
},
fail() {
// 用户拒绝
}
})
2023-12-01 16:20:02 +08:00
} else {
2023-12-01 15:40:43 +08:00
// 用户同意获取位置信息
_this.isExistStoreId()
}
}
})
},
2023-11-28 16:40:05 +08:00
// 获取门店信息
2023-12-01 16:20:02 +08:00
getStore(id) {
2023-11-28 18:33:35 +08:00
let _this = this;
2023-12-01 15:40:43 +08:00
request({
url: "business/storeInformation/store/queryStoreById",
method: 'post',
2023-12-01 16:20:02 +08:00
data: {
"storeId": id
},
}).then((response) => {
2023-12-01 15:40:43 +08:00
_this.store = response.data
let welfare = response.data.welfare
2023-12-08 16:16:52 +08:00
uni.setStorageSync("storeId", response.data.id)
uni.setStorageSync("chainStoreId", response.data.chainStoreId)
2023-12-01 15:40:43 +08:00
if (welfare != undefined && welfare != null && welfare != "") {
if (welfare.includes(",")) {
_this.welfare = response.data.welfare.split(",")
} else {
_this.welfare.push(response.data.welfare)
2023-11-29 16:26:19 +08:00
}
2023-11-28 18:33:35 +08:00
}
2023-12-01 16:59:31 +08:00
}).catch((res) => {
uni.showLoading({
2023-12-05 10:37:36 +08:00
title: res + "---" + 1
2023-12-01 16:59:31 +08:00
})
2023-11-28 18:33:35 +08:00
})
2023-11-28 16:40:05 +08:00
},
2023-11-27 18:28:41 +08:00
// 获取当前位置
2023-11-28 14:43:36 +08:00
getAddress() {
2023-11-27 18:28:41 +08:00
let _this = this;
uni.getLocation({
// 谷歌使用wgs84 其他使用gcj02
2023-12-01 15:40:43 +08:00
type: 'gcj02', // 使用国测局坐标系
2023-11-27 18:28:41 +08:00
success: function(res) {
2023-11-28 14:43:36 +08:00
_this.longitude = res.longitude;
_this.latitude = res.latitude
2023-11-27 18:28:41 +08:00
// console.log('经度: ' + res.longitude);
// console.log('纬度: ' + res.latitude);
2023-12-01 15:40:43 +08:00
request({
url: 'business/storeInformation/store/recentlyStore',
method: 'post',
2023-11-27 18:28:41 +08:00
data: {
"lon": res.longitude,
"lat": res.latitude
},
2023-12-01 16:20:02 +08:00
}).then((response) => {
2023-12-01 15:40:43 +08:00
_this.distance = (Math.ceil(response.data.distance)).toFixed(1)
_this.store = response.data.store
2023-12-01 16:20:02 +08:00
uni.setStorageSync("storeId", response.data.store.id)
2023-12-08 16:16:52 +08:00
uni.setStorageSync("chainStoreId", response.data.store.chainStoreId)
2023-12-01 15:40:43 +08:00
let welfare = response.data.store.welfare
if (welfare != undefined && welfare != null && welfare != "") {
if (welfare.includes(",")) {
_this.welfare = response.data.store.welfare.split(",")
} else {
_this.welfare.push(response.data.store.welfare)
2023-11-27 18:28:41 +08:00
}
}
})
2023-12-08 16:16:52 +08:00
2023-12-06 18:36:10 +08:00
uni.showToast({
2023-12-08 16:16:52 +08:00
title: "获取位置信息成功",
icon: "none"
2023-12-06 18:36:10 +08:00
})
2023-11-27 18:28:41 +08:00
},
fail: function(err) {
2023-12-06 18:36:10 +08:00
_this.getStore(2);
uni.showToast({
2023-12-08 16:16:52 +08:00
title: "获取位置信息失败"
2023-12-06 18:36:10 +08:00
})
2023-11-27 18:28:41 +08:00
console.log('获取位置信息失败: ' + err.errMsg);
}
});
},
2023-12-01 16:20:02 +08:00
2023-11-30 14:28:12 +08:00
//获取油站的油号信息
getOilType() {
2023-12-05 10:37:36 +08:00
let params = {
storeId: uni.getStorageSync("storeId")
}
2023-11-30 14:28:12 +08:00
request({
url: 'business/petrolStationManagement/oilNumber/getList2',
method: 'get',
2023-12-05 10:37:36 +08:00
params: params
2023-12-01 16:20:02 +08:00
}).then((res) => {
if (res.code == 200) {
2023-11-30 14:28:12 +08:00
this.oilTypeList = res.data.records
2023-12-01 16:20:02 +08:00
console.log("aaabbb", this.oilTypeList)
2023-11-30 14:28:12 +08:00
if (this.oilTypeList.length > 0) {
this.oilInfo.oilName = this.oilTypeList[0].oilName,
2023-12-01 16:20:02 +08:00
this.oilInfo.oilPrice = this.oilTypeList[0].oilPrice,
this.oilInfo.gbPrice = this.oilTypeList[0].gbPrice
2023-11-30 14:28:12 +08:00
}
let oilData = []
this.oilTypeList.forEach(res => {
let data = {
2023-12-01 16:20:02 +08:00
id: res.numberId,
label: res.oilName,
oilPrice: res.oilPrice,
gbPrice: res.gbPrice
2023-11-30 14:28:12 +08:00
}
oilData.push(data)
})
2023-12-01 16:20:02 +08:00
2023-11-30 14:28:12 +08:00
this.columns = [oilData]
2023-12-01 16:20:02 +08:00
console.log("aaa", this.columns)
2023-11-30 14:28:12 +08:00
}
})
},
2023-11-27 09:24:16 +08:00
confirm(e) {
console.log('选中的油号', e);
2023-11-30 14:28:12 +08:00
this.oilInfo.oilName = e.value[0].label,
2023-12-01 16:20:02 +08:00
this.oilInfo.oilPrice = e.value[0].oilPrice,
this.oilInfo.gbPrice = e.value[0].gbPrice
2023-11-27 09:24:16 +08:00
this.show = false
},
cancel() {
this.show = false
},
goActivity() {
// 去活动页
uni.navigateTo({
url: '/pagesHome/Activity/index'
})
},
2023-11-27 18:28:41 +08:00
goCard() {
2023-11-27 09:24:16 +08:00
uni.navigateTo({
url: '/pagesHome/MyCard/MyCard'
})
},
2023-11-27 18:28:41 +08:00
goOil() {
2023-11-27 09:24:16 +08:00
uni.navigateTo({
url: '/pages/refuel/refuel'
})
},
2023-11-27 18:28:41 +08:00
goMall() {
2023-11-27 09:24:16 +08:00
uni.navigateTo({
url: '/pagesHome/PointsMall/PointsMall'
})
},
2023-12-05 10:37:36 +08:00
toQRcode() {
2023-12-01 17:43:20 +08:00
uni.navigateTo({
url: '/pagesHome/QRcode/QRcode'
})
},
2023-11-27 18:28:41 +08:00
goGoGo() {
2023-11-27 09:24:16 +08:00
uni.openLocation({
latitude: 36.651441,
longitude: 116.901224,
success: function() {
console.log('success');
},
complete: function(res) {
console.log(res);
}
});
},
}
}
</script>
<style scoped lang="scss">
.content {
background: #ebf5ff;
}
.container {
width: 100%;
height: 100vh;
}
.conttainer-top {
width: 100%;
height: 250px;
// background-color: #3da4df;
background: url('http://47.95.206.185:83/topbj.png')center no-repeat;
background-size: 100% 100%;
position: relative;
margin-bottom: 60px;
}
.top-title {
font-size: 26px;
color: white;
font-weight: bold;
color: #FFFFFF;
line-height: 25px;
text-shadow: 0px 2px 0px #2F64CD;
position: absolute;
top: 120px;
left: 20px;
}
.lan-gang {
width: 200px;
height: 22px;
background: #2F43F7;
border-radius: 11px;
align-items: center;
display: flex;
justify-content: space-around;
position: absolute;
top: 155px;
left: 20px;
color: white;
}
.lsiez {
font-size: 10px;
display: flex;
}
.conttainer-jg {
width: 95%;
border-radius: 6px;
background: white;
box-sizing: border-box;
padding: 10px;
height: 90px;
margin: 0px auto;
position: absolute;
transform: translate(-50%, -50%);
left: 50%;
bottom: -90px;
display: flex;
}
.conttainer-cetr {
width: 95%;
border-radius: 6px;
background: white;
box-sizing: border-box;
padding: 10px;
margin: 10px auto;
}
.jg-box {
width: 25%;
text-align: center;
}
.jg-img {
width: 38px;
height: 38px;
image {
width: 100%;
height: 100%;
}
margin: 5px auto;
}
.jg-size {
font-size: 14px;
}
.conttainer-title {
font-size: 16px;
font-weight: bold;
}
.conttainer-box {
width: 100%;
box-sizing: border-box;
padding: 15px;
background: #F3F6F9;
display: flex;
align-items: center;
justify-content: space-between;
border-radius: 8px;
margin-top: 10px;
}
.c-box-box1 {
width: 33%;
height: 44px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.c-box-box2 {
width: 33%;
height: 44px;
text-align: center;
border-left: 1px solid #DDDDDD;
border-right: 1px solid #DDDDDD;
}
.c-box-box3 {
width: 33%;
height: 44px;
text-align: center;
}
.xblck {
font-size: 14px;
color: #333333;
}
.dblck {
font-size: 20px;
color: #333333;
font-weight: bold;
}
.xred {
font-size: 14px;
color: #ED2828;
}
.dred {
font-size: 20px;
color: #ED2828;
font-weight: bold;
}
.station {
width: 100%;
height: 120px;
background: url('http://47.95.206.185:83/centerbj.png')center no-repeat;
background-size: 100% 100%;
box-sizing: border-box;
padding-top: 30px;
}
.station-box {
width: 95%;
background-color: white;
border-radius: 8px;
box-sizing: border-box;
padding: 15px;
margin: 0px auto;
}
.station-title {
font-size: 16px;
font-weight: bold;
}
.bule-icon {
2023-11-29 16:26:19 +08:00
width: 85px;
2023-11-27 09:24:16 +08:00
font-size: 12px;
color: #195ADA;
box-sizing: border-box;
padding: 2px 5px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #195ADA;
border-radius: 4px;
2023-11-27 18:28:41 +08:00
margin: 5px 3px;
2023-11-27 09:24:16 +08:00
}
.dis-bt {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.hui1 {
color: #666666;
font-size: 12px;
margin: 5px auto;
}
.hui2 {
color: #999999;
font-size: 12px;
margin: 5px auto;
}
.lananniu {
2023-12-01 16:20:02 +08:00
box-sizing: border-box;
padding: 3px 10px;
2023-11-27 09:24:16 +08:00
background: #DBE9FF;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
color: #195ADA;
}
.tabs {
width: 100%;
display: flex;
height: 44px;
}
.scrollbox {
display: flex;
}
.scrollbox-imgs {
width: 195px;
height: 100px;
border-radius: 4px;
background-color: #195ADA;
margin: 0px 10px;
}
.juanniu {
height: 36px;
background: linear-gradient(90deg, #FF7302 0%, #FF5210 100%);
border-radius: 42px;
justify-content: center;
display: flex;
align-items: center;
color: white;
margin-top: 20px;
}
2023-12-14 13:38:01 +08:00
</style>