You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

754 lines
18 KiB

<template>
<view class="home-container" :class="{ 'wechat-browser': isWeixinBrowser }">
<!-- 顶部蓝色渐变背景及数据 -->
<view class="header-gradient">
<view class="header-title">胥口枢纽闸站状态</view>
<view class="header-info">
<view class="info-item">
2 weeks ago
<text class="info-label">今日太湖水位</text>
<text class="info-value">{{ statistics.water_level.taihu }}m</text>
</view>
<view class="info-item">
2 weeks ago
<text class="info-label">今日胥江水位</text>
<text class="info-value">{{ statistics.water_level.xujiang }}m</text>
</view>
</view>
<view class="batch-row-strict">
2 weeks ago
<block v-for="(item,index) in statistics.batches" :key="item.id">
<block v-if="index < 2">
<view class="batch-col">
<view class="batch-tag-strict orange">
2 weeks ago
<text class="tag-orange">{{ item.direction==='in'?'去胥江':'去太湖' }}</text>{{ item.name }}
</view>
</view>
2 weeks ago
<view v-if="index < 1" class="batch-divider-strict"></view>
</block>
</block>
</view>
</view>
<!-- 闸站流程 -->
<view class="process-card">
<view class="process-title-bar">
<text>闸站流程</text>
</view>
<view class="process-flow">
<view class="process-step">
<image class="icon" src="/static/icon_step_index1.png" mode="aspectFit" />
<text class="process-label">先预约</text>
</view>
<view class="arrow">&gt;</view>
<view class="process-step">
<image class="icon" src="/static/icon_step_index2.png" mode="aspectFit" />
6 months ago
<text class="process-label">再购票</text>
</view>
<view class="arrow">&gt;</view>
<view class="process-step">
<image class="icon" src="/static/icon_step_index3.png" mode="aspectFit" />
<text class="process-label">排队过闸</text>
</view>
</view>
</view>
<!-- 四个功能卡片 -->
<view class="card-grid">
<view class="func-card" @click="goReservation">
<image class="card-bg" src="/static/index_radius_green.png" mode="aspectFill" />
<view class="func-card-content">
<text class="func-title">过闸预约</text>
2 weeks ago
<text class="func-num">{{ statistics.total_count }}</text>
</view>
<view class="func-bg-icon clock"></view>
</view>
<view class="func-card" @click="goOrder">
<image class="card-bg" src="/static/index_radius_blue.png" mode="aspectFill" />
<view class="func-card-content">
6 months ago
<text class="func-title">在线付款</text>
2 weeks ago
<text class="func-num">{{ statistics.unpaid_count }}</text>
</view>
<view class="func-bg-icon ticket"></view>
</view>
<view class="func-card" @click="goWaitPass">
<image class="card-bg" src="/static/index_radius_orange.png" mode="aspectFill" />
<view class="func-card-content">
6 months ago
<text class="func-title">排队过闸</text>
2 weeks ago
<text class="func-num">{{ statistics.paid_count }}</text>
</view>
<view class="func-bg-icon ship"></view>
</view>
<view class="func-card" @click="goInvoiceManage">
<image class="card-bg" src="/static/index_radius_purple.png" mode="aspectFill" />
<view class="func-card-content">
2 weeks ago
<text class="func-title">我的开票</text>
<text class="func-num">{{ statistics.billed_count }}</text>
</view>
<view class="func-bg-icon invoice"></view>
</view>
</view>
<!-- 实时/公告信息 -->
2 weeks ago
<!-- <view class="info-list">
<view class="info-item-row">
<view class="info-tag realtime">
<text class="info-tag-text">实时</text>
</view>
<text class="info-text">北向南2025040102准备过闸</text>
</view>
<view class="info-item-row">
<view class="info-tag notice">
<text class="info-tag-text">公告</text>
</view>
<text class="info-text">北向南2025040102准备过闸</text>
</view>
2 weeks ago
</view> -->
<!-- 编辑信息弹窗 -->
<view v-if="showEditPopup" class="edit-popup-mask" @click="closeEditPopup">
<view class="edit-popup" @click.stop>
<view class="edit-popup-header">
<text>更新信息</text>
<text class="edit-popup-close" @click="closeEditPopup">×</text>
</view>
<view class="edit-popup-content">
<view class="edit-field">
<text class="edit-label">姓名</text>
<input class="edit-input" v-model="editForm.name" placeholder="请输入姓名" />
</view>
<view class="edit-field">
<text class="edit-label">交款人类型</text>
<view class="payer-type-group">
<view
class="payer-type-item"
:class="{ active: Number(editForm.payer_type) === 1 }"
@click="editForm.payer_type = 1"
>
个人
</view>
<view
class="payer-type-item"
:class="{ active: Number(editForm.payer_type) === 2 }"
@click="editForm.payer_type = 2"
>
单位
</view>
</view>
</view>
<view class="edit-field">
<text class="edit-label">手机号</text>
<input
class="edit-input"
v-model="editForm.phone"
type="number"
maxlength="11"
placeholder="请输入手机号"
/>
</view>
<view class="edit-field">
<text class="edit-label">证件号</text>
<input
class="edit-input"
v-model="editForm.id_card"
placeholder="请输入身份证号"
maxlength="18"
/>
</view>
</view>
<view class="edit-popup-footer">
<button class="edit-submit-btn" @click="submitUserInfo"></button>
</view>
</view>
</view>
</view>
</template>
<script>
2 weeks ago
import { API } from '@/config/index.js'
export default {
data() {
return {
2 weeks ago
isWeixinBrowser: false,
userInfo: null,
showEditPopup: false,
editForm: {
name: '',
payer_type: 1,
phone: '',
id_card: ''
},
statistics: {
water_level: {
taihu: '-',
xujiang: '-'
},
total_count: 0,
unpaid_count: 0,
paid_count: 0,
billed_count: 0
}
}
},
onLoad() {
// #ifdef H5
this.isWeixinBrowser = /MicroMessenger/i.test(navigator.userAgent)
// #endif
2 weeks ago
this.fetchUserInfo()
this.fetchStatistics()
},
methods: {
2 weeks ago
async fetchStatistics() {
const token = uni.getStorageSync('token')
if (!token) {
return
}
const res = await new Promise((resolve, reject) => {
uni.request({
url: `${API.STATISTICS}?token=${token}`,
method: 'get',
success: resolve,
fail: reject
})
})
if (res.data && res.data.errcode === 0) {
this.statistics = res.data.data
}
},
async fetchUserInfo() {
const token = uni.getStorageSync('token')
if (!token) {
this.userInfo = null
return
}
try {
const res = await new Promise((resolve, reject) => {
uni.request({
url: `${API.GET_USER_INFO}?token=${token}`,
method: 'POST',
success: resolve,
fail: reject
})
})
if (res.data) {
const data = res.data || {}
const payerType = Number(data.payer_type ?? data.payerType ?? 1)
this.userInfo = { ...data, payer_type: payerType }
this.editForm = {
name: data.name || '',
payer_type: payerType,
phone: data.phone || '',
id_card: data.id_card || ''
}
}
} catch (e) {
this.userInfo = null
}
},
requireUserInfoComplete() {
const u = this.userInfo || {}
const ok = !!(u.name && (u.payer_type ?? u.payerType) && u.phone && u.id_card)
return ok
},
openEditPopup() {
this.showEditPopup = true
},
closeEditPopup() {
this.showEditPopup = false
},
validateForm() {
if (!this.editForm.name) {
uni.showToast({ title: '请输入姓名', icon: 'none' })
return false
}
if (![1, 2].includes(Number(this.editForm.payer_type))) {
uni.showToast({ title: '请选择交款人类型', icon: 'none' })
return false
}
const phoneReg = /^1\d{10}$/
if (!phoneReg.test(this.editForm.phone)) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
return false
}
const idReg = /^(?:\d{15}|\d{17}[\dXx])$/
if (!idReg.test(this.editForm.id_card)) {
uni.showToast({ title: '请输入正确的证件号', icon: 'none' })
return false
}
return true
},
async submitUserInfo() {
if (!this.validateForm()) return
const token = uni.getStorageSync('token')
if (!token) {
uni.showToast({ title: '请先登录', icon: 'none' })
return
}
try {
uni.showLoading({ title: '提交中...' })
const res = await new Promise((resolve, reject) => {
uni.request({
url: `${API.UPDATE_USER_INFO}?token=${token}`,
method: 'POST',
data: {
name: this.editForm.name,
payer_type: Number(this.editForm.payer_type),
phone: this.editForm.phone,
id_card: this.editForm.id_card
},
success: resolve,
fail: reject
})
})
uni.hideLoading()
if (res.data && res.data.errcode === 0) {
uni.showToast({ title: '更新成功', icon: 'success' })
this.closeEditPopup()
await this.fetchUserInfo()
} else {
uni.showToast({ title: (res.data && res.data.errmsg) || '更新失败', icon: 'none' })
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '更新失败', icon: 'none' })
}
},
goReservation() {
2 weeks ago
const afterCheck = () => {
if (this.requireUserInfoComplete()) {
uni.navigateTo({ url: '/pages/reservation/index' });
} else {
uni.showModal({
title: '提示',
content: '为了后续流程的使用,请先完善个人信息',
confirmText: '去完善',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
this.openEditPopup()
}
}
})
}
}
if (!this.userInfo) {
this.fetchUserInfo().then(afterCheck).catch(afterCheck)
} else {
afterCheck()
}
},
6 months ago
goWaitPass() {
uni.navigateTo({ url: '/pages/order/pay_order_list?status=paid' });
},
goOrder() {
6 months ago
uni.navigateTo({ url: '/pages/order/pay_order_list?status=unpaid' });
},
goInvoiceManage() {
uni.navigateTo({ url: '/pages/index/invoice_manage' });
}
}
}
</script>
<style scoped>
.home-container {
background: #f6f8fc;
min-height: 100vh;
padding-bottom: 24rpx;
position: relative;
}
.wechat-browser {
margin-top: -88rpx;
}
.header-gradient {
background: linear-gradient(180deg, #2f50ff 0%, #28a8fa 100%);
border-bottom-left-radius: 20rpx;
border-bottom-right-radius: 20rpx;
padding: 0 0 36rpx 0;
color: #fff;
position: relative;
height: 630rpx;
min-height: 400rpx;
max-height: 650rpx;
}
.header-title {
text-align: center;
font-size: 36rpx;
font-weight: bold;
padding-top: 7vh;
letter-spacing: 2rpx;
}
.header-info {
display: flex;
justify-content: center;
align-items: flex-start;
width: fit-content;
margin: 5vh auto 0 auto; /* 水平居中 */
7 months ago
gap: 154rpx; /* 控制每组间距 */
}
.info-item {
display: flex;
flex-direction: column;
align-items: flex-start;
text-align: left;
}
.info-label {
font-size: 24rpx;
opacity: 0.95;
color: #e6eaff;
}
.info-value {
font-size: 32rpx;
font-weight: normal;
margin-top: 8rpx;
display: block;
color: #fff;
font-family: sans-serif;
}
.batch-row-strict {
display: flex;
align-items: flex-start;
justify-content: center;
margin: 4vh 48rpx 0 48rpx;
position: relative;
}
.batch-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.batch-divider-strict {
width: 2rpx;
height: 82rpx;
background: rgba(255, 255, 255, 0.2);
margin: 0 48rpx;
}
.batch-num-strict {
font-size: 32rpx;
font-weight: normal;
margin-bottom: 8rpx;
font-family: 'PangMenZhengDao', 'SourceHanSansCN', 'PingFang SC', 'Microsoft YaHei', sans-serif;
letter-spacing: 3rpx;
}
.batch-tag-strict {
2 weeks ago
font-size: 32rpx;
padding: 4rpx 12rpx;
border-radius: 20rpx;
background: #2b70ee;
display: flex;
align-items: center;
gap: 4rpx;
}
.tag-orange {
color: #FF9F43;
}
.tag-green {
color: #28C76F;
}
.tag-blue {
color: #4FC3FF;
}
.process-card {
background: #fff;
border-radius: 22rpx;
margin: 24rpx;
6 months ago
padding: 32rpx;
box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.08);
position: relative;
margin-top: -140rpx;
height: 138px;
}
.process-title-bar {
width: 60%;
margin: 0 auto;
6 months ago
position: relative;
top: -32rpx;
background: linear-gradient(180deg, #2f4dff 0%, #4b65ff 100%);
color: #fff;
font-size: 28rpx;
font-weight: bold;
border-radius: 0 0 20rpx 20rpx;
padding: 12rpx 0;
text-align: center;
box-shadow: 0 4rpx 16rpx rgba(59,124,255,0.12);
z-index: 2;
}
.process-flow {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 12rpx;
6 months ago
margin-top: 10rpx;
}
.process-step {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.icon {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background: linear-gradient(135deg, #2c51ff 0%, #2991fd 100%);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
/* 这里放svg或字体icon颜色为白色 */
}
.process-label {
color: #445fff;
font-size: 26rpx;
margin-top: 4rpx;
}
.arrow {
color: #B0B8C6;
font-size: 40rpx;
font-weight: bold;
margin: 0 12rpx;
margin-top: -30rpx;
}
.card-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 32rpx;
margin: 32rpx 24rpx 24rpx 24rpx;
}
.func-card {
position: relative;
border-radius: 32rpx;
height: 200rpx;
overflow: hidden;
box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.08);
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 32rpx 0 32rpx 32rpx;
}
.card-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.func-card-content {
z-index: 2;
position: relative;
display: flex;
flex-direction: column;
height: 100%;
justify-content: space-between;
}
.func-title {
font-size: 28rpx;
color: #fff;
font-weight: 500;
7 months ago
margin-bottom: 20rpx;
margin-top: 10rpx;
}
.func-num {
font-size: 58rpx;
font-weight: normal;
color: #fff;
font-family: 'PangMenZhengDao', 'SourceHanSansCN', 'PingFang SC', 'Microsoft YaHei', sans-serif;
letter-spacing: 5rpx;
}
.func-bg-icon {
position: absolute;
right: 12rpx;
bottom: 12rpx;
width: 100rpx;
height: 100rpx;
opacity: 0.18;
z-index: 1;
/* 这里放svg或字体icon */
}
2 weeks ago
.edit-popup-mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.45);
display: flex;
justify-content: center;
align-items: flex-end;
z-index: 9999;
}
.edit-popup {
background: #fff;
width: 100%;
border-top-left-radius: 24rpx;
border-top-right-radius: 24rpx;
padding: 32rpx;
box-sizing: border-box;
max-height: 80vh;
overflow-y: auto;
}
.edit-popup-header {
display: flex;
justify-content: center;
position: relative;
font-size: 32rpx;
font-weight: 600;
color: #222;
}
.edit-popup-close {
position: absolute;
right: 0;
top: 0;
font-size: 44rpx;
color: #999;
padding: 0 16rpx;
}
.edit-popup-content {
margin-top: 32rpx;
}
.edit-field {
margin-bottom: 28rpx;
}
.edit-label {
display: block;
font-size: 28rpx;
color: #666;
margin-bottom: 12rpx;
}
.edit-input {
width: 100%;
height: 80rpx;
border-radius: 12rpx;
border: 1rpx solid #e5e6eb;
padding: 0 24rpx;
font-size: 28rpx;
box-sizing: border-box;
background: #fafafa;
}
.payer-type-group {
display: flex;
gap: 20rpx;
}
.payer-type-item {
flex: 1;
height: 80rpx;
border-radius: 12rpx;
border: 1rpx solid #e5e6eb;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
color: #666;
}
.payer-type-item.active {
border-color: #3b7cff;
color: #3b7cff;
background: #edf3ff;
}
.edit-popup-footer {
margin-top: 12rpx;
}
.edit-submit-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
border-radius: 44rpx;
background: linear-gradient(90deg, #3b7cff 0%, #5bb6ff 100%);
color: #fff;
font-size: 32rpx;
font-weight: 500;
border: none;
}
.edit-submit-btn::after {
border: none;
}
.info-list {
background: #fff;
border-radius: 24rpx;
margin: 24rpx;
padding: 24rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
.info-item-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
padding: 12rpx 0;
}
.info-item-row:last-child {
margin-bottom: 0;
}
.info-tag {
font-size: 22rpx;
padding: 4rpx 18rpx;
border-radius: 8rpx;
margin-right: 12rpx;
white-space: nowrap;
color: #fff;
display: inline-block;
background: #e68c6e;
transform: skewX(-20deg);
font-weight: 500;
border: none;
margin-right: 32rpx;
}
.info-tag-text {
display: inline-block;
transform: skewX(20deg);
}
.notice {
background: linear-gradient(90deg, #2b70ee 0%, #4FC3FF 100%);
color: white;
}
.realtime {
background: linear-gradient(90deg, #e68d6e 0%, #ffb86c 100%);
color: white;
}
.info-text {
font-size: 26rpx;
color: #333;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>