|
|
@@ -1,8 +1,125 @@
|
|
|
<template>
|
|
|
<view class="container">
|
|
|
+ <navigation-bar @ready="handleNavReady"></navigation-bar>
|
|
|
+ <view class="dialog" v-if="styleData.dialog" :style="styleData.dialog">
|
|
|
+ <view class="height-88 flex-align-center bg-fff">
|
|
|
+ <view class="dialog_logo ml-24"></view>
|
|
|
+ <view class="dialog_search ml-24" @click.stop="toSearch"></view>
|
|
|
+ </view>
|
|
|
+ <!-- <view class="height-72 flex" style="background-color: #f9f9f9">
|
|
|
+ <view class="width-half flex-center" @click.stop="checkFilterDistance">
|
|
|
+ <view class="fs-26 color-000-6 mr-8">距离</view>
|
|
|
+ <view
|
|
|
+ class="width-20 height-20 br-round bg-000-08 lh-10 text-center transition"
|
|
|
+ :style="{
|
|
|
+ transform: filterDialog.distanceSelector ? 'rotate(180deg)' : '',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <uni-icons
|
|
|
+ type="bottom"
|
|
|
+ size="8"
|
|
|
+ color="rgba(0,0,0,0.4)"
|
|
|
+ ></uni-icons>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="width-half flex-center">
|
|
|
+ <view
|
|
|
+ class="width-32 height-32 br-round lh-20 text-center"
|
|
|
+ :style="{
|
|
|
+ border: filterDialog.discounts
|
|
|
+ ? '1px solid var(--color-primary)'
|
|
|
+ : '1px solid rgba(0, 0, 0, 0.4)',
|
|
|
+ backgroundColor: filterDialog.discounts
|
|
|
+ ? 'var(--color-primary)'
|
|
|
+ : '#fff',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <uni-icons
|
|
|
+ type="checkmarkempty"
|
|
|
+ size="10"
|
|
|
+ color="#ffffff"
|
|
|
+ ></uni-icons>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ :class="[
|
|
|
+ 'fs-26',
|
|
|
+ 'ml-8',
|
|
|
+ filterDialog.discounts ? 'color-primary' : 'color-000-6',
|
|
|
+ ]"
|
|
|
+ >支持省钱充电</view
|
|
|
+ >
|
|
|
+ </view>
|
|
|
+ </view> -->
|
|
|
+ <view
|
|
|
+ class="dialog_selector"
|
|
|
+ :style="{
|
|
|
+ height: filterDialog.distanceSelector ? '190rpx' : '0rpx',
|
|
|
+ borderTop: `1rpx solid rgba(0, 0, 0, ${
|
|
|
+ filterDialog.distanceSelector ? '0.1' : '0'
|
|
|
+ })`,
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <view class="flex-center flex-wrap pb-14">
|
|
|
+ <view
|
|
|
+ :class="[
|
|
|
+ 'type',
|
|
|
+ 'flex-shrink',
|
|
|
+ 'flex-center',
|
|
|
+ 'mt-20',
|
|
|
+ (index + 1) % 5 === 0 ? 'mr-0' : 'mr-20',
|
|
|
+ `type-${
|
|
|
+ item.value === filterDialog.options.distance ? 'active' : ''
|
|
|
+ }`,
|
|
|
+ ]"
|
|
|
+ v-for="(item, index) in filterDialog.distanceRange"
|
|
|
+ :key="index"
|
|
|
+ @click.stop="changeFilterDistance(index)"
|
|
|
+ style="width: 117rpx"
|
|
|
+ >{{ item.value }}km</view
|
|
|
+ >
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="dialog_event" v-if="ready && mapBanner.length > 0">
|
|
|
+ <swiper
|
|
|
+ class="swiper"
|
|
|
+ circular
|
|
|
+ :indicator-dots="true"
|
|
|
+ :autoplay="mapBanner.length > 1"
|
|
|
+ :interval="3000"
|
|
|
+ >
|
|
|
+ <swiper-item
|
|
|
+ class="swiper-item full-percent"
|
|
|
+ v-for="(item, index) in mapBanner"
|
|
|
+ :key="index"
|
|
|
+ @click="to(item.linkUrl)"
|
|
|
+ >
|
|
|
+ <view
|
|
|
+ class="full-percent"
|
|
|
+ :style="{
|
|
|
+ backgroundImage: `url(${item.bannerUrl})`,
|
|
|
+ }"
|
|
|
+ ></view>
|
|
|
+ </swiper-item>
|
|
|
+ </swiper>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ v-if="styleData.dialogPlaceHolderHeight"
|
|
|
+ :style="{ height: `${styleData.dialogPlaceHolderHeight}px` }"
|
|
|
+ ></view>
|
|
|
<map
|
|
|
+ v-if="ready"
|
|
|
id="map"
|
|
|
- style="width: 100%; height: 100%; z-index: 1"
|
|
|
+ :style="{
|
|
|
+ width: '100%',
|
|
|
+ height: styleData.dialogHeight
|
|
|
+ ? `calc(100vh - ${styleData.dialogHeight}px - ${
|
|
|
+ styleData.cardHeight - 24
|
|
|
+ }px)`
|
|
|
+ : '50vh',
|
|
|
+ zIndex: 1,
|
|
|
+ pointerEvents: loading || !mapMode ? 'none' : 'auto',
|
|
|
+ }"
|
|
|
:latitude="mapProps.latitude"
|
|
|
:longitude="mapProps.longitude"
|
|
|
:markers="markers"
|
|
|
@@ -14,118 +131,128 @@
|
|
|
@markertap="tapMarker"
|
|
|
:show-scale="true"
|
|
|
></map>
|
|
|
- <view class="card" v-if="ready">
|
|
|
- <swiper
|
|
|
- class="mt-68"
|
|
|
- :autoplay="false"
|
|
|
- @change="changeMarker"
|
|
|
- :current="markersIndex"
|
|
|
- >
|
|
|
- <block v-if="!empty">
|
|
|
- <swiper-item v-for="(item, index) in station" :key="index">
|
|
|
- <view class="station">
|
|
|
- <charge-station
|
|
|
- :title="item.stationName"
|
|
|
- :address="item.address"
|
|
|
- :price="item.totalFee"
|
|
|
- :fast="item.fastEquipmentInfos"
|
|
|
- :slow="item.slowEquipmentInfos"
|
|
|
- :sId="item.StationID"
|
|
|
- :distance="item.stationLatDistance"
|
|
|
- :latitude="item.location.stationLat"
|
|
|
- :longitude="item.location.stationLng"
|
|
|
- :fromMap="true"
|
|
|
- ></charge-station>
|
|
|
- </view>
|
|
|
- </swiper-item>
|
|
|
- </block>
|
|
|
- <block v-else>
|
|
|
- <swiper-item>
|
|
|
- <view class="station">
|
|
|
- <view class="station-empty flex-column flex-align-center pt-20">
|
|
|
- <image src="/static/images/map-empty.png" mode="widthFix" />
|
|
|
- <view class="fs-22 mt-14" style="color: rgba(0, 0, 0, 0.5)"
|
|
|
- >暂无充电站信息</view
|
|
|
- >
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </swiper-item>
|
|
|
- </block>
|
|
|
- </swiper>
|
|
|
- </view>
|
|
|
- <view class="icon-menu" v-if="menuStyle.menu1" :style="menuStyle.menu1">
|
|
|
- <view class="flex-center mt-40" @click="search" hover-class="hover">
|
|
|
- <image src="/static/images/map-search.png" mode="widthFix" />
|
|
|
- </view>
|
|
|
+ <block v-else>
|
|
|
<view
|
|
|
- class="flex-center mt-40"
|
|
|
- @click="toggleDialogVisible"
|
|
|
- hover-class="hover"
|
|
|
+ v-if="styleData.dialogHeight"
|
|
|
+ class="mock-map flex-center"
|
|
|
+ :style="{
|
|
|
+ height: `calc(100vh - ${styleData.dialogHeight}px - ${
|
|
|
+ styleData.cardHeight - 24
|
|
|
+ }px)`,
|
|
|
+ }"
|
|
|
>
|
|
|
- <image src="/static/images/map-filter.png" mode="widthFix" />
|
|
|
+ <image
|
|
|
+ src="/static/images/map-bg.jpg"
|
|
|
+ mode="widthFix"
|
|
|
+ style="width: 100%"
|
|
|
+ ></image>
|
|
|
+ <image
|
|
|
+ src="/static/images/map-current.png"
|
|
|
+ mode="widthFix"
|
|
|
+ class="absolute-center"
|
|
|
+ style="width: 34px"
|
|
|
+ ></image>
|
|
|
</view>
|
|
|
- </view>
|
|
|
- <view class="icon-menu" v-if="menuStyle.menu2" :style="menuStyle.menu2">
|
|
|
- <view class="flex-center" hover-class="hover" @click="resetLocation">
|
|
|
- <image src="/static/images/map-location.png" mode="widthFix" />
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ </block>
|
|
|
<view
|
|
|
- class="dialog"
|
|
|
- v-if="filterDialog.visible"
|
|
|
- @click="toggleDialogVisible"
|
|
|
+ class="card"
|
|
|
+ :style="{
|
|
|
+ height: mapMode
|
|
|
+ ? `${styleData.cardHeight}px`
|
|
|
+ : `calc(100vh - ${styleData.navHeight}px)`,
|
|
|
+ bottom: '0px',
|
|
|
+ borderRadius: mapMode ? '16rpx 16rpx 0px 0px' : '0px',
|
|
|
+ overflowY: mapMode ? 'visible' : 'auto',
|
|
|
+ }"
|
|
|
+ @touchstart.stop="touchCardStart"
|
|
|
+ @touchmove.stop="touchCardMove"
|
|
|
>
|
|
|
- <view class="filter-dialog" @click.stop="emptyTap">
|
|
|
- <view :style="filterDialog.style"></view>
|
|
|
- <view class="pl-40 pr-40">
|
|
|
- <view class="pt-20 pb-20">
|
|
|
- <text class="fs-30 fw-500">距离</text>
|
|
|
- </view>
|
|
|
- <view class="flex-wrap pb-14">
|
|
|
- <view
|
|
|
- :class="[
|
|
|
- 'type',
|
|
|
- 'flex-shrink',
|
|
|
- 'flex-center',
|
|
|
- 'mt-20',
|
|
|
- (index + 1) % 5 === 0 ? 'mr-0' : 'mr-20',
|
|
|
- `type-${
|
|
|
- item.value === filterDialog.options.distance ? 'active' : ''
|
|
|
- }`,
|
|
|
- ]"
|
|
|
- v-for="(item, index) in filterDialog.range"
|
|
|
- :key="index"
|
|
|
- @click.stop="changeFilterDistance(index)"
|
|
|
- style="width: 117rpx"
|
|
|
- >{{ item.value }}km</view
|
|
|
- >
|
|
|
- </view>
|
|
|
- <view class="fs-30 fw-500 pt-38 pb-20">充电状态</view>
|
|
|
- <view class="flex pb-30">
|
|
|
- <view
|
|
|
- :class="[
|
|
|
- 'type',
|
|
|
- 'flex-center',
|
|
|
- 'mr-20',
|
|
|
- `type-${index === filterDialog.options.status ? 'active' : ''}`,
|
|
|
- ]"
|
|
|
- v-for="(item, index) in filterDialog.status"
|
|
|
- :key="index"
|
|
|
- @click.stop="changeFilterStatus(index)"
|
|
|
- >{{ item.title }}</view
|
|
|
- >
|
|
|
+ <view
|
|
|
+ v-if="mapMode"
|
|
|
+ class="card_location height-64 width-64 bg-fff flex-center"
|
|
|
+ @touchstart.stop="resetLocation"
|
|
|
+ >
|
|
|
+ <image
|
|
|
+ src="/static/images/map-re-location.png"
|
|
|
+ mode="widthFix"
|
|
|
+ class="width-48"
|
|
|
+ ></image>
|
|
|
+ </view>
|
|
|
+ <block v-if="station.length">
|
|
|
+ <!-- 列表 -->
|
|
|
+ <block v-if="!mapMode">
|
|
|
+ <view class="station" v-for="(item, index) in station" :key="index">
|
|
|
+ <view v-if="index !== 0" class="card_line"></view>
|
|
|
+ <charge-station
|
|
|
+ :title="item.stationName"
|
|
|
+ :address="item.address"
|
|
|
+ :price="item.totalFee"
|
|
|
+ :fast="item.fastEquipmentInfos"
|
|
|
+ :slow="item.slowEquipmentInfos"
|
|
|
+ :sId="item.StationID"
|
|
|
+ :distance="item.stationLatDistance"
|
|
|
+ :latitude="item.location.stationLat"
|
|
|
+ :longitude="item.location.stationLng"
|
|
|
+ :fromMap="true"
|
|
|
+ ></charge-station>
|
|
|
</view>
|
|
|
- <view class="foot flex-align-center">
|
|
|
- <style-button size="small" @click.stop="resetFilter"
|
|
|
- >重置</style-button
|
|
|
- >
|
|
|
- <view style="width: 30rpx"></view>
|
|
|
- <style-button size="small" type="primary" @click.stop="submitFilter"
|
|
|
- >确定</style-button
|
|
|
- >
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <!-- 单个 -->
|
|
|
+ <view class="station">
|
|
|
+ <charge-station
|
|
|
+ :title="station[markersIndex].stationName"
|
|
|
+ :address="station[markersIndex].address"
|
|
|
+ :price="station[markersIndex].totalFee"
|
|
|
+ :fast="station[markersIndex].fastEquipmentInfos"
|
|
|
+ :slow="station[markersIndex].slowEquipmentInfos"
|
|
|
+ :sId="station[markersIndex].StationID"
|
|
|
+ :distance="station[markersIndex].stationLatDistance"
|
|
|
+ :latitude="station[markersIndex].location.stationLat"
|
|
|
+ :longitude="station[markersIndex].location.stationLng"
|
|
|
+ :fromMap="true"
|
|
|
+ ></charge-station>
|
|
|
</view>
|
|
|
+ </block>
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <view class="card_empty flex-column flex-align-center pt-20">
|
|
|
+ <view v-if="loading" class="mt-60 animation-loading"
|
|
|
+ ><uni-icons
|
|
|
+ type="spinner-cycle"
|
|
|
+ size="20"
|
|
|
+ color="rgba(0, 0, 0, 0.5)"
|
|
|
+ ></uni-icons
|
|
|
+ ></view>
|
|
|
+ <image
|
|
|
+ class="image"
|
|
|
+ v-else
|
|
|
+ src="/static/images/map-empty.png"
|
|
|
+ mode="widthFix"
|
|
|
+ />
|
|
|
+ <view class="fs-22 mt-14 color-000-5">{{
|
|
|
+ loading
|
|
|
+ ? "加载中"
|
|
|
+ : token
|
|
|
+ ? "暂无充电站信息"
|
|
|
+ : "登录后查看更多电站信息"
|
|
|
+ }}</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </block>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="charging flex-align-center"
|
|
|
+ v-if="charging"
|
|
|
+ @click="toCharging"
|
|
|
+ >
|
|
|
+ <image
|
|
|
+ class="width-64 ml-12"
|
|
|
+ src="/static/images/map-charging.png"
|
|
|
+ mode="widthFix"
|
|
|
+ ></image>
|
|
|
+ <view class="fs-26 color-fff ml-12">{{
|
|
|
+ charging.chargeStatus === 0 ? "已预约" : "充电中"
|
|
|
+ }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="login-mask" v-if="!token">
|
|
|
@@ -150,28 +277,33 @@ const pointSize = {
|
|
|
androidX: -14,
|
|
|
androidCurrentX: -20,
|
|
|
};
|
|
|
+import { fetchHomeBanner } from "@/api";
|
|
|
import { deCode } from "../../utils/code";
|
|
|
+import { rpxToPx } from "../../utils/device";
|
|
|
import { fetchToken, login, onLogin } from "@/api/auth";
|
|
|
-import { fetchStations } from "@/api/charge";
|
|
|
+import { fetchStations, fetchChargeStatus } from "@/api/charge";
|
|
|
import { fetchCollectList } from "@/api/user";
|
|
|
import { fetchLocation } from "@/utils/location";
|
|
|
-import { onLoad } from "@dcloudio/uni-app";
|
|
|
+import { to } from "@/utils/navigate";
|
|
|
+import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
|
import { ref } from "vue";
|
|
|
+
|
|
|
const isIOS = ref(false);
|
|
|
const token = ref<string>();
|
|
|
const ready = ref(false);
|
|
|
-const empty = ref(true);
|
|
|
-const mapProps = ref({
|
|
|
- latitude: 23.098994,
|
|
|
- longitude: 113.32252,
|
|
|
- selflatitude: 23.098994,
|
|
|
- selflongitude: 113.32252,
|
|
|
- scale: defaultScale,
|
|
|
+const loading = ref(false);
|
|
|
+const styleData = ref({
|
|
|
+ dialog: "",
|
|
|
+ dialogHeight: 0,
|
|
|
+ dialogPlaceHolderHeight: 0,
|
|
|
+ cardHeight: 0,
|
|
|
+ navHeight: 0
|
|
|
});
|
|
|
+
|
|
|
const filterDialog = ref({
|
|
|
- visible: false,
|
|
|
- style: {},
|
|
|
- range: [
|
|
|
+ discounts: false,
|
|
|
+ distanceSelector: false,
|
|
|
+ distanceRange: [
|
|
|
{
|
|
|
value: 1,
|
|
|
scale: defaultScale + 3,
|
|
|
@@ -229,18 +361,26 @@ const filterDialog = ref({
|
|
|
},
|
|
|
],
|
|
|
});
|
|
|
-const menuStyle = ref({
|
|
|
- menu1: {},
|
|
|
- menu2: {},
|
|
|
-});
|
|
|
+
|
|
|
const stationPage = ref({
|
|
|
page: 1,
|
|
|
pageSize: 6,
|
|
|
hasNext: false,
|
|
|
});
|
|
|
const station = ref<any[]>([]);
|
|
|
-const markersIndex = ref(0);
|
|
|
+const charging = ref<any>();
|
|
|
+
|
|
|
+const mapMode = ref(true);
|
|
|
+const mapProps = ref({
|
|
|
+ latitude: 23.098994,
|
|
|
+ longitude: 113.32252,
|
|
|
+ selflatitude: 23.098994,
|
|
|
+ selflongitude: 113.32252,
|
|
|
+ scale: defaultScale,
|
|
|
+});
|
|
|
+const markersIndex = ref(-1);
|
|
|
const markers = ref<any[]>([]);
|
|
|
+const mapBanner = ref<any[]>([]);
|
|
|
|
|
|
let isIgnoreChangeLocation = false;
|
|
|
|
|
|
@@ -323,9 +463,9 @@ const refreshStation = (location: any) => {
|
|
|
height: 34,
|
|
|
});
|
|
|
}
|
|
|
- isIgnoreChangeLocation = markers.value.length !== _markers.length
|
|
|
+ isIgnoreChangeLocation = markers.value.length !== _markers.length;
|
|
|
stationPage.value.hasNext = res.length >= stationPage.value.pageSize;
|
|
|
- empty.value = stationPage.value.page === 1 ? res.length <= 0 : false;
|
|
|
+ // empty.value = stationPage.value.page === 1 ? res.length <= 0 : false;
|
|
|
station.value =
|
|
|
stationPage.value.page === 1 ? res : [...station.value, ...res];
|
|
|
markersIndex.value = _markersIndex;
|
|
|
@@ -335,16 +475,19 @@ const refreshStation = (location: any) => {
|
|
|
};
|
|
|
|
|
|
const refresh = () => {
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
console.log("刷新电站");
|
|
|
uni.showLoading({
|
|
|
title: "加载中",
|
|
|
});
|
|
|
+ loading.value = true;
|
|
|
stationPage.value.page = 1;
|
|
|
stationPage.value.hasNext = false;
|
|
|
station.value = [];
|
|
|
markers.value = [];
|
|
|
markersIndex.value = 0;
|
|
|
- filterDialog.value.visible = false;
|
|
|
fetchLocation()
|
|
|
.then((res: any) => {
|
|
|
mapProps.value.latitude = res.latitude;
|
|
|
@@ -356,17 +499,41 @@ const refresh = () => {
|
|
|
})
|
|
|
.then(() => {
|
|
|
uni.hideLoading();
|
|
|
+ loading.value = false;
|
|
|
ready.value = true;
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.log(err);
|
|
|
uni.hideLoading();
|
|
|
+ loading.value = false;
|
|
|
uni.showModal({
|
|
|
content: `${err.errMsg},请重试`,
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const handleNavReady = (e: any) => {
|
|
|
+ console.log(e)
|
|
|
+ styleData.value.dialog = `padding-top:${e.detail.statusBarHeight - 6}px;`;
|
|
|
+ const searchHeight = rpxToPx(88);
|
|
|
+ const filterHeight = 0; // rpxToPx(72);
|
|
|
+ styleData.value.dialogHeight =
|
|
|
+ e.detail.statusBarHeight - 6 + searchHeight + filterHeight;
|
|
|
+ styleData.value.dialogPlaceHolderHeight =
|
|
|
+ styleData.value.dialogHeight - e.detail.navigationBarHeight;
|
|
|
+ styleData.value.cardHeight = rpxToPx(402) + e.detail.statusBarHeight;
|
|
|
+ styleData.value.navHeight = e.detail.navigationBarHeight;
|
|
|
+};
|
|
|
+
|
|
|
+const toSearch = () => {
|
|
|
+ if (!ready.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ uni.navigateTo({
|
|
|
+ url: "/pages-charge/search/search",
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
onLoad((query: any) => {
|
|
|
// 只为了打包进tab-bar使用
|
|
|
console.log(fetchToken, login, onLogin);
|
|
|
@@ -375,17 +542,9 @@ onLoad((query: any) => {
|
|
|
console.log("扫普通码", decodeURIComponent(query.q));
|
|
|
getApp<any>().globalData.normalCode = decodeURIComponent(query.q); // 获取到二维码原始链接内容
|
|
|
}
|
|
|
- const menu = uni.getMenuButtonBoundingClientRect();
|
|
|
- const window = uni.getWindowInfo();
|
|
|
const device = uni.getSystemInfoSync();
|
|
|
isIOS.value = device.osName === "ios";
|
|
|
- menuStyle.value.menu1 = `top:${menu.top + menu.height}px;right:${
|
|
|
- window.windowWidth - menu.right
|
|
|
- }px;`;
|
|
|
- menuStyle.value.menu2 = `bottom:420rpx;right:${
|
|
|
- window.windowWidth - menu.right
|
|
|
- }px;margin-bottom: constant(safe-area-inset-bottom);margin-bottom: env(safe-area-inset-bottom);`;
|
|
|
- filterDialog.value.style = `height:${menu.bottom + 6}px;`;
|
|
|
+
|
|
|
setTimeout(() => {
|
|
|
token.value = getApp<any>().globalData.token || "";
|
|
|
if (!token.value) {
|
|
|
@@ -415,6 +574,8 @@ onLoad((query: any) => {
|
|
|
token.value = _token;
|
|
|
fetchCollectList().then(() => {
|
|
|
refresh();
|
|
|
+ fetchCharging();
|
|
|
+ fetchBanner();
|
|
|
});
|
|
|
});
|
|
|
return;
|
|
|
@@ -426,37 +587,65 @@ onLoad((query: any) => {
|
|
|
deCode(code);
|
|
|
}
|
|
|
refresh();
|
|
|
+ fetchCharging();
|
|
|
+ fetchBanner();
|
|
|
});
|
|
|
}, 300);
|
|
|
});
|
|
|
|
|
|
-const toggleDialogVisible = () => {
|
|
|
- filterDialog.value.visible = !filterDialog.value.visible;
|
|
|
-};
|
|
|
-const changeFilterDistance = (index: number) => {
|
|
|
- filterDialog.value.options.distance = filterDialog.value.range[index].value;
|
|
|
+onShow(() => {
|
|
|
+ if (token.value) {
|
|
|
+ fetchBanner();
|
|
|
+ charging.value = undefined;
|
|
|
+ setTimeout(() => {
|
|
|
+ fetchCharging();
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const fetchCharging = () => {
|
|
|
+ fetchChargeStatus().then((res) => {
|
|
|
+ if (res && [0, 1, 2, 3].includes(res.chargeStatus)) {
|
|
|
+ charging.value = res;
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
-const changeFilterStatus = (index: number) => {
|
|
|
- filterDialog.value.options.status = index;
|
|
|
+
|
|
|
+const fetchBanner = () => {
|
|
|
+ fetchHomeBanner().then((res) => {
|
|
|
+ mapBanner.value = res.filter((item: any) => item.status === 1);
|
|
|
+ });
|
|
|
};
|
|
|
-const resetFilter = () => {
|
|
|
- filterDialog.value.options.distance = defaulDistance;
|
|
|
- filterDialog.value.options.status = 0;
|
|
|
- refresh();
|
|
|
+
|
|
|
+// const checkDiscounts = () => {
|
|
|
+// filterDialog.value.discounts = !filterDialog.value.discounts;
|
|
|
+// };
|
|
|
+
|
|
|
+const checkFilterDistance = () => {
|
|
|
+ if (isIgnoreChangeLocation) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!mapMode.value) {
|
|
|
+ mapMode.value = true;
|
|
|
+ }
|
|
|
+ filterDialog.value.distanceSelector = !filterDialog.value.distanceSelector;
|
|
|
};
|
|
|
-const submitFilter = () => {
|
|
|
- const findIndex = filterDialog.value.range.findIndex(
|
|
|
- (item) => item.value === filterDialog.value.options.distance
|
|
|
- );
|
|
|
- if (mapProps.value.scale === filterDialog.value.range[findIndex].scale) {
|
|
|
- filterDialog.value.visible = false;
|
|
|
+
|
|
|
+const changeFilterDistance = (index: number) => {
|
|
|
+ filterDialog.value.options.distance =
|
|
|
+ filterDialog.value.distanceRange[index].value;
|
|
|
+ if (mapProps.value.scale === filterDialog.value.distanceRange[index].scale) {
|
|
|
refresh();
|
|
|
return;
|
|
|
}
|
|
|
- filterDialog.value.visible = false;
|
|
|
- mapProps.value.scale = filterDialog.value.range[findIndex].scale;
|
|
|
+ mapProps.value.scale = filterDialog.value.distanceRange[index].scale;
|
|
|
+ checkFilterDistance();
|
|
|
};
|
|
|
+
|
|
|
const resetLocation = () => {
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// eslint-disable-next-line promise/catch-or-return
|
|
|
fetchLocation().then((res: any) => {
|
|
|
const mapCtx = uni.createMapContext("map");
|
|
|
@@ -468,6 +657,7 @@ const resetLocation = () => {
|
|
|
mapProps.value.scale = defaultScale;
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
const mapUpdated = (e: any) => {
|
|
|
// console.log('map updated', isIgnoreChangeLocation)
|
|
|
setTimeout(() => {
|
|
|
@@ -479,9 +669,9 @@ const mapChange = (e: any) => {
|
|
|
return;
|
|
|
}
|
|
|
if (e.type === "end" && markers.value.length) {
|
|
|
- console.log("map change end", {
|
|
|
- ...e.detail.centerLocation
|
|
|
- });
|
|
|
+ // console.log("map change end", {
|
|
|
+ // ...e.detail.centerLocation,
|
|
|
+ // });
|
|
|
const current = e.target.centerLocation;
|
|
|
const { latitude, longitude } = current;
|
|
|
stationPage.value.page = 1;
|
|
|
@@ -523,9 +713,6 @@ const _changeMarker = (current: number) => {
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
-const changeMarker = (e: any) => {
|
|
|
- _changeMarker(e.detail.current);
|
|
|
-};
|
|
|
const tapMarker = (e: any) => {
|
|
|
if (e.detail.markerId === -1) {
|
|
|
return;
|
|
|
@@ -537,19 +724,45 @@ const tapMarker = (e: any) => {
|
|
|
_changeMarker(findIndex);
|
|
|
}
|
|
|
};
|
|
|
-const search = () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: "/pages-charge/search/search",
|
|
|
- });
|
|
|
-};
|
|
|
const loginMask = (e: any) => {
|
|
|
login(e);
|
|
|
};
|
|
|
-const emptyTap = () => {};
|
|
|
+
|
|
|
+let startpageY = 0;
|
|
|
+const touchCardStart = (e: any) => {
|
|
|
+ if (loading.value || station.value.length <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (e.touches && e.touches.length) {
|
|
|
+ startpageY = e.touches[0].pageY;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const touchCardMove = (e: any) => {
|
|
|
+ if (!startpageY) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const threshold = 150;
|
|
|
+ if (e.touches && e.touches.length) {
|
|
|
+ if (mapMode.value && startpageY - e.touches[0].pageY > threshold) {
|
|
|
+ mapMode.value = false;
|
|
|
+ }
|
|
|
+ if (!mapMode.value && e.touches[0].pageY - startpageY > threshold) {
|
|
|
+ mapMode.value = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const toCharging = () => {
|
|
|
+ to(
|
|
|
+ charging.value.chargeStatus === 0
|
|
|
+ ? `/pages-charge/appointment/appointment?sn=${charging.value.connectorId}`
|
|
|
+ : `/pages-charge/ordering/ordering?sn=${charging.value.connectorId}&start=1`
|
|
|
+ );
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
-@import "../../styles/dialog.scss";
|
|
|
page {
|
|
|
background-color: #ffffff;
|
|
|
}
|
|
|
@@ -561,6 +774,13 @@ page {
|
|
|
background-color: #ffffff;
|
|
|
}
|
|
|
|
|
|
+.mock-map {
|
|
|
+ position: relative;
|
|
|
+ width: 100vw;
|
|
|
+ background-color: #ffffff;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+
|
|
|
.login-mask {
|
|
|
position: fixed;
|
|
|
left: 0;
|
|
|
@@ -576,31 +796,72 @@ page {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.icon-menu {
|
|
|
- position: absolute;
|
|
|
- z-index: 9;
|
|
|
+.dialog {
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ z-index: 1000;
|
|
|
|
|
|
- image {
|
|
|
- width: 60rpx;
|
|
|
+ &_logo {
|
|
|
+ width: 156rpx;
|
|
|
+ height: 100%;
|
|
|
+ background-position: center;
|
|
|
+ background-size: 100% auto;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-image: url("/static/images/map-logo.png");
|
|
|
}
|
|
|
|
|
|
- & > view {
|
|
|
- height: 96rpx;
|
|
|
- width: 96rpx;
|
|
|
- border-radius: 50%;
|
|
|
- background-color: #fff;
|
|
|
- box-shadow: 0px 8rpx 20rpx rgba(0, 0, 0, 0.2);
|
|
|
+ &_search {
|
|
|
+ width: 352rpx;
|
|
|
+ height: 100%;
|
|
|
+ background-position: center;
|
|
|
+ background-size: 100% auto;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-image: url("/static/images/map-input.png");
|
|
|
}
|
|
|
|
|
|
- .hover {
|
|
|
- box-shadow: none;
|
|
|
+ &_event {
|
|
|
+ margin-top: 20rpx;
|
|
|
+ padding: 0rpx 32rpx;
|
|
|
+ .swiper {
|
|
|
+ height: 160rpx;
|
|
|
+ width: 100%;
|
|
|
+ border-radius: 16rpx;
|
|
|
+ overflow: hidden;
|
|
|
+ .swiper-item {
|
|
|
+ border-radius: 16rpx;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ view {
|
|
|
+ background-position: center;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-.filter-dialog {
|
|
|
- background-color: #fff;
|
|
|
+ &_selector {
|
|
|
+ background-color: #f9f9f9;
|
|
|
+ transition: all 0.3s;
|
|
|
+ overflow: hidden;
|
|
|
+ .type {
|
|
|
+ width: 160rpx;
|
|
|
+ height: 60rpx;
|
|
|
+ background: var(--color-sec);
|
|
|
+ border-radius: 4rpx;
|
|
|
+ color: #666;
|
|
|
+ font-size: 26rpx;
|
|
|
+ border: 1px solid var(--color-sec);
|
|
|
+ }
|
|
|
+
|
|
|
+ .type-active {
|
|
|
+ border: 1px solid var(--color-primary);
|
|
|
+ color: var(--color-primary);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- .slider {
|
|
|
+ /* .slider {
|
|
|
position: relative;
|
|
|
height: 12rpx;
|
|
|
width: 100%;
|
|
|
@@ -637,61 +898,53 @@ page {
|
|
|
margin: 0;
|
|
|
opacity: 0;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- .type {
|
|
|
- width: 160rpx;
|
|
|
- height: 60rpx;
|
|
|
- background: var(--color-sec);
|
|
|
- border-radius: 4rpx;
|
|
|
- color: var(--color-gray);
|
|
|
- font-size: 26rpx;
|
|
|
- border: 1px solid var(--color-sec);
|
|
|
- }
|
|
|
-
|
|
|
- .type-active {
|
|
|
- border: 1px solid var(--color-primary);
|
|
|
- color: var(--color-primary);
|
|
|
- }
|
|
|
-
|
|
|
- .foot {
|
|
|
- height: 120rpx;
|
|
|
- border-top: 1rpx solid var(--color-sec);
|
|
|
- }
|
|
|
+ } */
|
|
|
}
|
|
|
|
|
|
.card {
|
|
|
- position: absolute;
|
|
|
+ position: fixed;
|
|
|
width: 100%;
|
|
|
- height: 450rpx;
|
|
|
left: 0px;
|
|
|
- bottom: 0rpx;
|
|
|
- z-index: 9;
|
|
|
- background: linear-gradient(180deg, rgba(87, 104, 133, 0) 0%, #576885 100%);
|
|
|
- padding-left: 10rpx;
|
|
|
- margin-bottom: constant(safe-area-inset-bottom);
|
|
|
- margin-bottom: env(safe-area-inset-bottom);
|
|
|
+ z-index: 1000;
|
|
|
+ transition: all 0.3s;
|
|
|
+ box-shadow: 0px 8rpx 20rpx rgba(0, 0, 0, 0.2);
|
|
|
+ background-color: #fff;
|
|
|
|
|
|
- swiper,
|
|
|
- swiper-item {
|
|
|
- width: 100%;
|
|
|
- height: 300rpx;
|
|
|
+ &_location {
|
|
|
+ position: absolute;
|
|
|
+ border-radius: 16rpx;
|
|
|
+ box-shadow: 0px 8rpx 20rpx 0px rgba(0, 0, 0, 0.2);
|
|
|
+ right: 20rpx;
|
|
|
+ top: -104rpx;
|
|
|
+ z-index: 99;
|
|
|
}
|
|
|
|
|
|
- .station {
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- padding: 0rpx 20rpx;
|
|
|
+ &_line {
|
|
|
+ height: 1rpx;
|
|
|
+ background-color: rgba(0, 0, 0, 0.1);
|
|
|
+ margin-left: 30rpx;
|
|
|
+ margin-right: 30rpx;
|
|
|
}
|
|
|
|
|
|
- .station-empty {
|
|
|
+ &_empty {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
- background-color: #fff;
|
|
|
- border-radius: 20rpx 20rpx 0 0;
|
|
|
- image {
|
|
|
+ .image {
|
|
|
width: 160rpx;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.charging {
|
|
|
+ position: fixed;
|
|
|
+ z-index: 1000;
|
|
|
+ right: 0;
|
|
|
+ bottom: 164rpx;
|
|
|
+ width: 186rpx;
|
|
|
+ height: 88rpx;
|
|
|
+ border-radius: 88rpx 0px 0px 88rpx;
|
|
|
+ background: linear-gradient(106deg, #34b6ff 15.97%, #347dff 72.38%);
|
|
|
+ margin-bottom: constant(safe-area-inset-bottom);
|
|
|
+ margin-bottom: env(safe-area-inset-bottom);
|
|
|
+}
|
|
|
</style>
|