|
|
@@ -3,9 +3,11 @@ import chargeSearch from '../components/search.vue'
|
|
|
import chargeFooter from '../components/charge-tab.vue'
|
|
|
import router from '@/router'
|
|
|
import { StaticUrl } from '@/config'
|
|
|
+import { createGlobalLoadingMiddleware } from '@/api/core/middleware'
|
|
|
|
|
|
-const { statusBarHeight, MenuButtonHeight, opcity, userInfo } = storeToRefs(useSysStore())
|
|
|
-const swiperList = ['https://www.keaitupian.cn/cjpic/frombd/2/253/1659552792/3869332496.jpg']
|
|
|
+const { statusBarHeight, MenuButtonHeight, opcity } = storeToRefs(useSysStore())
|
|
|
+const { token, userInfo } = storeToRefs(useUserStore())
|
|
|
+const { Location } = storeToRefs(useAddressStore())
|
|
|
definePage({
|
|
|
name: 'charge-index',
|
|
|
islogin: false,
|
|
|
@@ -15,29 +17,53 @@ definePage({
|
|
|
backgroundColorBottom: '#fff',
|
|
|
},
|
|
|
})
|
|
|
+const activeFilter = ref<number>(1)
|
|
|
const filterOptions = [
|
|
|
- { key: 'nearest', label: '离我最近', widthClass: 'w-152rpx' },
|
|
|
- { key: 'most-available', label: '空闲最多', widthClass: '' },
|
|
|
- { key: 'lowest-price', label: '电费最低', widthClass: '' },
|
|
|
+ { key: 1, label: '离我最近', widthClass: 'w-152rpx' },
|
|
|
+ { key: 2, label: '空闲最多', widthClass: '' },
|
|
|
+ { key: 3, label: '电费最低', widthClass: '' },
|
|
|
]
|
|
|
-const activeFilter = ref('nearest')
|
|
|
|
|
|
+/**
|
|
|
+ * 获取充电站列表
|
|
|
+ */
|
|
|
+const { data: stationList, isLastPage, page, refresh, reload } = usePagination((pageNum, pageSize) =>
|
|
|
+ Apis.charge.getStationInfoPage({ data: { pageNum, pageSize, sortType: activeFilter.value, longitude: Location.value.longitude || 106.620256, latitude: Location.value.latitude || 26.648327, userId: userInfo.value.id } }), {
|
|
|
+ data: resp => resp.data?.list,
|
|
|
+ initialData: [],
|
|
|
+ initialPage: 1,
|
|
|
+ initialPageSize: 10,
|
|
|
+ append: true,
|
|
|
+ immediate: true,
|
|
|
+ middleware: createGlobalLoadingMiddleware(),
|
|
|
+})
|
|
|
+onMounted(() => {
|
|
|
+ getUserAccountInfo()
|
|
|
+ opcity.value = 0
|
|
|
+})
|
|
|
+onShow(() => refresh())
|
|
|
+onPageScroll((e) => {
|
|
|
+ const calculatedOpacity = e.scrollTop / 100
|
|
|
+ opcity.value = Math.min(1, Math.max(0.1, calculatedOpacity))
|
|
|
+})
|
|
|
+onReachBottom(() => {
|
|
|
+ if (!isLastPage.value) {
|
|
|
+ page.value++
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取用户账户信息
|
|
|
+ */
|
|
|
+const userAccountInfo = ref()
|
|
|
+async function getUserAccountInfo() {
|
|
|
+ const res = await Apis.charge.getMemberInfo({})
|
|
|
+ userAccountInfo.value = res.data
|
|
|
+}
|
|
|
// 处理筛选项点击的方法
|
|
|
-function handleFilterClick(filterKey: string) {
|
|
|
+function handleFilterClick(filterKey: number) {
|
|
|
activeFilter.value = filterKey
|
|
|
- console.log(`选择了: ${filterKey}`)
|
|
|
- // 根据不同筛选类型执行相应操作
|
|
|
- switch (filterKey) {
|
|
|
- case 'nearest':
|
|
|
- // 执行距离排序逻辑
|
|
|
- break
|
|
|
- case 'most-available':
|
|
|
- // 执行空闲数量排序逻辑
|
|
|
- break
|
|
|
- case 'lowest-price':
|
|
|
- // 执行价格排序逻辑
|
|
|
- break
|
|
|
- }
|
|
|
+ reload()
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
@@ -57,7 +83,7 @@ function handleFilterClick(filterKey: string) {
|
|
|
</template>
|
|
|
</wd-navbar>
|
|
|
<view :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }" class="px24rpx">
|
|
|
- <charge-search />
|
|
|
+ <charge-search map-mode-text-value="地图模式" @map-mode-click="router.push({ name: 'charge-map' })" />
|
|
|
<view class="userInfo-card">
|
|
|
<view class="flex items-center gap-20rpx">
|
|
|
<image
|
|
|
@@ -68,9 +94,12 @@ function handleFilterClick(filterKey: string) {
|
|
|
<view class="text-32rpx text-#2B303A font-bold">
|
|
|
{{ userInfo?.nickName || '游客' }}
|
|
|
</view>
|
|
|
- <view class="text-24rpx text-#9ED605">
|
|
|
+ <view v-if="!token" class="text-24rpx text-#9ED605" @click="router.replace({ name: 'smqjh-login' })">
|
|
|
授权登录
|
|
|
</view>
|
|
|
+ <view v-else class="rounded-8rpx bg-#9ED605 px12rpx py4rpx text-24rpx text-#FFF opacity-70">
|
|
|
+ {{ userInfo.channelName }}
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="mt-20rpx flex items-center justify-between gap-18rpx">
|
|
|
@@ -79,16 +108,18 @@ function handleFilterClick(filterKey: string) {
|
|
|
<view>我的积分</view>
|
|
|
<view>可用充电余额</view>
|
|
|
</view>
|
|
|
- <view class="mt-24rpx flex items-center gap-30rpx text-40rpx text-#9ED605 font-bold">
|
|
|
+ <view class="mt-24rpx flex items-center gap-30rpx text-28rpx text-#9ED605 font-500">
|
|
|
<view class="flex items-center gap-20rpx">
|
|
|
- <text>896</text>
|
|
|
- <image class="h-48rpx w-48rpx" :src="`${StaticUrl}/charge-acc.png`" />
|
|
|
+ <text class="w-120rpx overflow-hidden truncate whitespace-nowrap">
|
|
|
+ {{ userAccountInfo?.availablePoints || '--' }}
|
|
|
+ </text>
|
|
|
+ <image class="h-30rpx w-30rpx" :src="`${StaticUrl}/charge-acc.png`" />
|
|
|
</view>
|
|
|
- <view>
|
|
|
- <text class="text-28rpx">
|
|
|
+ <view class="w-120rpx overflow-hidden truncate whitespace-nowrap">
|
|
|
+ <text class="text-20rpx">
|
|
|
¥
|
|
|
</text>
|
|
|
- 89.6
|
|
|
+ {{ userAccountInfo?.balance || '--' }}
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -97,7 +128,7 @@ function handleFilterClick(filterKey: string) {
|
|
|
<view class="text-28rpx font-bold">
|
|
|
充电订单
|
|
|
</view>
|
|
|
- <view class="mt-24rpx text-40rpx text-#9ED605 font-bold">
|
|
|
+ <view class="mt-24rpx text-28rpx text-#9ED605 font-500">
|
|
|
956
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -105,9 +136,9 @@ function handleFilterClick(filterKey: string) {
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="mt-24rpx">
|
|
|
+ <!-- <view class="mt-24rpx">
|
|
|
<wd-swiper :list="swiperList" :height="100" :indicator="false" value-key="advertImg" />
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
<view class="mt-24rpx flex items-center gap-20rpx">
|
|
|
<view
|
|
|
v-for="option in filterOptions"
|
|
|
@@ -122,16 +153,16 @@ function handleFilterClick(filterKey: string) {
|
|
|
</view>
|
|
|
</view>
|
|
|
<view>
|
|
|
- <view class="relative mt-24rpx rounded-16rpx bg-#FFFFFF p-24rpx">
|
|
|
+ <view v-for="item in stationList" :key="item.stationId" class="relative mt-24rpx rounded-16rpx bg-#FFFFFF p-24rpx" @click="router.push({ name: 'charge-site-detail', params: { stationId: String(item.stationId) } })">
|
|
|
<image
|
|
|
class="absolute right-0 top-0 h-52rpx w-186rpx"
|
|
|
:src="`${StaticUrl}/charge-firm-tag.png`"
|
|
|
/>
|
|
|
<view class="text-32rpx text-#2B303A font-bold">
|
|
|
- 贵阳花果园购物中心充电站
|
|
|
+ {{ item.stationName }}
|
|
|
</view>
|
|
|
<view class="mt-20rpx text-24rpx text-#aaa">
|
|
|
- 充电减免2小时停车费,超出部分按每小时3元计算
|
|
|
+ {{ item.tips || '暂无提示' }}
|
|
|
</view>
|
|
|
<view class="mt-24rpx flex items-center rounded-16rpx bg-[linear-gradient(90deg,rgba(170,255,235,0.3)_0%,rgba(175,247,252,0.2)_43.57%,rgba(139,232,252,0)_100%)] p-20rpx">
|
|
|
<view class="flex items-center gap-16rpx">
|
|
|
@@ -140,10 +171,7 @@ function handleFilterClick(filterKey: string) {
|
|
|
</view>
|
|
|
<view class="flex items-center">
|
|
|
<text class="text-32rpx font-bold">
|
|
|
- 12
|
|
|
- </text>
|
|
|
- <text class="text-24rpx text-#AAAAAA">
|
|
|
- /12
|
|
|
+ {{ item.fastCharging }}
|
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -153,10 +181,7 @@ function handleFilterClick(filterKey: string) {
|
|
|
</view>
|
|
|
<view class="flex items-center">
|
|
|
<text class="text-32rpx font-bold">
|
|
|
- 12
|
|
|
- </text>
|
|
|
- <text class="text-24rpx text-#AAAAAA">
|
|
|
- /12
|
|
|
+ {{ item.slowCharging }}
|
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -165,15 +190,15 @@ function handleFilterClick(filterKey: string) {
|
|
|
<wd-icon name="location" size="16px" color="#FFF" />
|
|
|
</view>
|
|
|
<view class="text-24rpx text-#3EB6F8">
|
|
|
- 1.55km
|
|
|
+ {{ item.distance }}km
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="mt-28rpx flex items-center justify-between">
|
|
|
+ <view v-if="!item.enterprisePrice" class="mt-28rpx flex items-center justify-between">
|
|
|
<view class="relative flex">
|
|
|
<view class="absolute left-30rpx z-10 flex items-center -top-26rpx">
|
|
|
<text class="text-40rpx text-#FF6464 font-bold">
|
|
|
- 1.0026
|
|
|
+ {{ item.platformPrice }}
|
|
|
</text>
|
|
|
<text class="w-100rpx text-24rpx">
|
|
|
元/度
|
|
|
@@ -185,11 +210,32 @@ function handleFilterClick(filterKey: string) {
|
|
|
/>
|
|
|
</view>
|
|
|
<view class="text-24rpx text-#2B303A">
|
|
|
- 峰:10:00-13:00
|
|
|
+ {{ item.peakValue }}:{{ item.peakTime }}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view v-else class="mt-20rpx flex items-center justify-between">
|
|
|
+ <view class="flex items-center">
|
|
|
+ <view class="flex items-center -mt-10rpx">
|
|
|
+ <text class="text-40rpx text-#FF6464 font-bold">
|
|
|
+ {{ item.platformPrice }}
|
|
|
+ </text>
|
|
|
+ <text class="w-100rpx text-24rpx">
|
|
|
+ 元/度
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="h-52rpx w-212rpx text-center" :style="{ backgroundImage: `url(${StaticUrl}/charge-firm.png)`, backgroundSize: 'cover', backgroundPosition: 'center' }">
|
|
|
+ <text class="ml-70rpx text-28rpx text-#FF6464">
|
|
|
+ {{ item.enterprisePrice }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="text-24rpx text-#2B303A">
|
|
|
+ {{ item.peakValue }}:{{ item.peakTime }}
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="h-160rpx" />
|
|
|
</view>
|
|
|
<chargeFooter />
|
|
|
</view>
|