|
|
@@ -9,6 +9,7 @@
|
|
|
class="swiper-item-1"
|
|
|
style="width: 100%"
|
|
|
:list="state.swiperList"
|
|
|
+ @click="handleBannerClick"
|
|
|
previousMargin="30"
|
|
|
nextMargin="30"
|
|
|
circular
|
|
|
@@ -17,11 +18,11 @@
|
|
|
bgColor="#ffffff">
|
|
|
</uv-swiper>
|
|
|
</view>
|
|
|
-<!--
|
|
|
- <view class="w100">
|
|
|
- <uv-notice-bar mode="closable" speed="50" url="/pages/coupon/index" :text="state.notice"></uv-notice-bar>
|
|
|
- </view>
|
|
|
--->
|
|
|
+ <!--
|
|
|
+ <view class="w100">
|
|
|
+ <uv-notice-bar mode="closable" speed="50" url="/pages/coupon/index" :text="state.notice"></uv-notice-bar>
|
|
|
+ </view>
|
|
|
+ -->
|
|
|
|
|
|
<view class="w100 gap"></view>
|
|
|
|
|
|
@@ -38,7 +39,7 @@
|
|
|
<view class="w100 gap"></view>
|
|
|
|
|
|
<!-- 站点清单 start-->
|
|
|
- <view class="w100 content_station" >
|
|
|
+ <view class="w100 content_station">
|
|
|
<WashStation v-for="item in state.stationList" :key="item.id" :item="item"></WashStation>
|
|
|
<WashStation v-for="item in state.stationList" :key="item.id" :item="item"></WashStation>
|
|
|
<WashStation v-for="item in state.stationList" :key="item.id" :item="item"></WashStation>
|
|
|
@@ -57,13 +58,13 @@
|
|
|
</view>
|
|
|
<!-- 站点清单 end-->
|
|
|
|
|
|
-<!-- <cover-view class="login_bar">
|
|
|
- <login-bar class="w100 text-center"></login-bar>
|
|
|
- </cover-view>-->
|
|
|
-<!-- <cover-view class="login_bar" v-show="!isLogin">-->
|
|
|
- <login-bar class="w100 text-center"></login-bar>
|
|
|
-<!-- </cover-view>-->
|
|
|
- <tab-bar :index="0" ></tab-bar>
|
|
|
+ <!-- <cover-view class="login_bar">
|
|
|
+ <login-bar class="w100 text-center"></login-bar>
|
|
|
+ </cover-view>-->
|
|
|
+ <!-- <cover-view class="login_bar" v-show="!isLogin">-->
|
|
|
+ <login-bar class="w100 text-center"></login-bar>
|
|
|
+ <!-- </cover-view>-->
|
|
|
+ <tab-bar :index="0"></tab-bar>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -85,6 +86,7 @@ const change = () => {
|
|
|
}
|
|
|
|
|
|
const initState = () => ({
|
|
|
+ bannerList: [],
|
|
|
swiperList: [
|
|
|
'https://cdn.uviewui.com/uview/swiper/swiper3.png',
|
|
|
'https://cdn.uviewui.com/uview/swiper/swiper2.png',
|
|
|
@@ -122,29 +124,30 @@ onLoad((e: any) => {
|
|
|
let query = decodeURIComponent(e);
|
|
|
let scanTime = e.scancode_time;
|
|
|
console.log(e)
|
|
|
-/* if (query) {
|
|
|
- uni.showToast({
|
|
|
- title: query,
|
|
|
- duration: 5000
|
|
|
- })
|
|
|
- }*/
|
|
|
+ /* if (query) {
|
|
|
+ uni.showToast({
|
|
|
+ title: query,
|
|
|
+ duration: 5000
|
|
|
+ })
|
|
|
+ }*/
|
|
|
|
|
|
})
|
|
|
|
|
|
onShow(() => {
|
|
|
const userData = getApp<any>().globalData.user;
|
|
|
- if (userData&&userData.id) {
|
|
|
+ if (userData && userData.id) {
|
|
|
isLogin.value = true;
|
|
|
}
|
|
|
- console.log("show index>>>>",isLogin.value,state.stationList,state.location)
|
|
|
- let locationData = getApp<any>().globalData.location;
|
|
|
- if(!locationData||!locationData.longitude){
|
|
|
|
|
|
- loadCurrentLocation();
|
|
|
- }else{
|
|
|
+ console.log("show index>>>>", isLogin.value, state.stationList, state.location)
|
|
|
+ let locationData = getApp<any>().globalData.location;
|
|
|
+ if (!locationData || !locationData.longitude) {
|
|
|
+ loadCurrentLocation();
|
|
|
+ } else {
|
|
|
state.location = locationData;
|
|
|
loadWashStationList();
|
|
|
}
|
|
|
+ loadBannerList();
|
|
|
uni.$on('loginEvent', function (data) {
|
|
|
isLogin.value = data.isLogin;
|
|
|
})
|
|
|
@@ -155,18 +158,32 @@ onHide(() => {
|
|
|
Object.assign(state, initState());
|
|
|
})
|
|
|
|
|
|
-const handleMenuClick = (menu:any) => {
|
|
|
- checkLogin().then((res)=>{
|
|
|
- if(menu.title==='洗车'){
|
|
|
- uni.navigateTo({
|
|
|
- url:'/pages-wash/scan/index'
|
|
|
- })
|
|
|
- }else if(menu.title==='充值'){
|
|
|
- uni.navigateTo({
|
|
|
- url:'/pages-user/wallet/recharge'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+const loadBannerList = () => {
|
|
|
+ get(`/banner`).then((res: any) => {
|
|
|
+ state.bannerList = res;
|
|
|
+ state.swiperList = res.map(k => k.bannerUrl);
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const handleBannerClick = (index: number) => {
|
|
|
+ let ele = state.bannerList[index];
|
|
|
+ if (ele && ele.linkUrl) {
|
|
|
+ uni.navigateTo({url: ele.linkUrl})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleMenuClick = (menu: any) => {
|
|
|
+ checkLogin().then((res) => {
|
|
|
+ if (menu.title === '洗车') {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages-wash/scan/index'
|
|
|
+ })
|
|
|
+ } else if (menu.title === '充值') {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages-user/wallet/recharge'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -179,12 +196,12 @@ const loadCurrentLocation = () => {
|
|
|
uni.getLocation({
|
|
|
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
|
|
|
success: res => {
|
|
|
- let location = {
|
|
|
+ let location = {
|
|
|
latitude: res.latitude,
|
|
|
longitude: res.longitude
|
|
|
}
|
|
|
- getApp<any>().globalData.location = location;
|
|
|
- state.location = location
|
|
|
+ getApp<any>().globalData.location = location;
|
|
|
+ state.location = location
|
|
|
loadWashStationList();
|
|
|
console.log("loadCurrentLocation location", res)
|
|
|
}
|
|
|
@@ -205,14 +222,14 @@ const loadWashStationList = () => {
|
|
|
list.forEach((station: any) => {
|
|
|
if (station.location) {
|
|
|
let stationLocation = JSON.parse(station.location);
|
|
|
- station.distance = calcMapDistance(state.location.latitude,state.location.longitude,stationLocation.stationLat,stationLocation.stationLng);
|
|
|
+ station.distance = calcMapDistance(state.location.latitude, state.location.longitude, stationLocation.stationLat, stationLocation.stationLng);
|
|
|
}
|
|
|
})
|
|
|
state.stationList = list;
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const handleNavMap = (station:any) => {
|
|
|
+const handleNavMap = (station: any) => {
|
|
|
let location = JSON.parse(station.location)
|
|
|
uni.openLocation({
|
|
|
latitude: location.stationLat,
|
|
|
@@ -226,7 +243,7 @@ const handleNavMap = (station:any) => {
|
|
|
const handleNavStation = (station: any) => {
|
|
|
getApp<any>().globalData.pageData = {station}
|
|
|
uni.navigateTo({
|
|
|
- url: '/pages-wash/station/index?id='+station.id
|
|
|
+ url: '/pages-wash/station/index?id=' + station.id
|
|
|
})
|
|
|
console.log(station)
|
|
|
}
|
|
|
@@ -275,9 +292,10 @@ const handleNavStation = (station: any) => {
|
|
|
margin-bottom: 10rpx;
|
|
|
}
|
|
|
|
|
|
-.swiper-content{
|
|
|
+.swiper-content {
|
|
|
height: 200rpx;
|
|
|
}
|
|
|
+
|
|
|
.guide-content {
|
|
|
text-align: center;
|
|
|
}
|
|
|
@@ -287,8 +305,8 @@ const handleNavStation = (station: any) => {
|
|
|
bottom: 20rpx;
|
|
|
}
|
|
|
|
|
|
-.content_station{
|
|
|
- height: calc(100vh - 600rpx );
|
|
|
+.content_station {
|
|
|
+ height: calc(100vh - 600rpx);
|
|
|
overflow: scroll;
|
|
|
}
|
|
|
</style>
|