修复审核不通过的代码

This commit is contained in:
zhouyanli
2026-07-24 08:36:00 +08:00
parent 0cd2323bc2
commit ace7d969ac
7 changed files with 339 additions and 293 deletions

View File

@@ -90,16 +90,11 @@ const handleBtnClick = () => {
if (currentStep.value < 2) {
currentStep.value++;
} else {
// 立即体验,跳转首页
// 1. 记录引导已完成
// 立即体验,直接进入首页(不强制登录 — 仅在需要身份的功能上才要求登录)
uni.setStorageSync('hasShowGuide', true);
// 2. 跳转首页
uni.navigateTo({
url: "/pageSubPack/loginSub/pwd-login"
})
// uni.switchTab({
// url: '/pages/index/index'
// });
uni.switchTab({
url: '/pages/paymentIndex/paymentIndex'
});
}
};
</script>

View File

@@ -1,7 +1,6 @@
<template>
<view class="contentStyle" style="">
<view class="status-bar"></view>
<!-- left-icon="left" @clickLeft="goBack" -->
<uni-nav-bar title="生活缴费" backgroundColor="transparent" :border="false">
</uni-nav-bar>
<view class="topbox">
@@ -10,8 +9,15 @@
</view>
<scroll-view class="page" scroll-y="true">
<view class="container">
<!-- 已缴费/欠费列表 -->
<view class="bill-list" v-if="paymentList.length != 0">
<!-- 未登录提示条 -->
<view class="login-tip" v-if="!isLogin" @click="handleLoginPrompt">
<image class="login-tip-icon" src="https://wuyeadmin.bugtc.com/images/login/phone.png"></image>
<text class="login-tip-text">登录后可查看缴费账单</text>
<text class="login-tip-link">去登录</text>
</view>
<!-- 账单列表(仅登录后显示) -->
<view class="bill-list" v-if="isLogin && paymentList.length > 0">
<view class="bill-item" @click="goToBill(item)" v-for="item,index in paymentList" :key="index">
<image class="billIcon" src="https://wuyeadmin.bugtc.com/images/propertyImgs/water.png"
@@ -25,7 +31,6 @@
</view>
<view class="bill-desc">{{item.villageName+"-"+item.buildingName+'-'+formatAddress(item.fullAddress)}}</view>
</view>
<view class="arrow"></view>
</view>
</view>
@@ -38,26 +43,15 @@
</view>
<view class="grid-list">
<view class="grid-item" v-for="(item, index) in addList" :key="index" @click="goToAdd(item)">
<view class="icon-box" :class="item.iconClass">
<image class="iconStyle" :src="item.icon"></image>
</view>
<!-- <text class="item-name">{{ item.name +'费'}}</text> -->
<text class="item-name">{{ item.name}}</text>
</view>
</view>
</view>
<!-- 开启通知按钮 -->
<!-- v-if="subscribeAuth !== 'accepted'" -->
<!-- <view class="subscribe-btn" @click="requestSubscribeMessageClick">
<text class="subscribe-btn-text">开启缴费通知</text>
</view> -->
<!-- <button class="subscribe-btn" @tap="handleWaterElecSubscribe" open-type="subscribeMessage">
开启订单状态通知
</button> -->
<view style="width: 100%;height: 30rpx;"></view>
</view>
</scroll-view>
@@ -65,216 +59,155 @@
</template>
<script setup>
import {
ref,
onMounted,
computed
import { ref } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { getTopUpSelectByResident, getopenIdByCode, postInsertOpenId } from '/pageSubPack/api/apiSub.js'
import { isLoggedIn, requireAuth } from '/pageSubPack/api/auth.js'
} from 'vue'
import {
onShow,
onReady,
onReachBottom,
onLoad,
onUnload,
onPullDownRefresh
} from '@dcloudio/uni-app'
import {
getTopUpSelectByResident,
getopenIdByCode,
postInsertOpenId,
postSubscribeAuth
} from '/pageSubPack/api/apiSub.js'
// 响应式数据
const statusBarHeight = ref(20)
// const subscribeAuth = ref(uni.getStorageSync('subscribeAuth') || '')
const paymentList = ref([
// {
// id: 1,
// name: '物业费',
// status: '已欠费',
// address: '桂花园(别墅)2号楼2层',
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/property.png",
// },
// {
// id: 2,
// name: '暖气费',
// status: '',
// address: '山东省日照市东港区桂花园(别墅)2号楼2层',
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/heating.png",
// },
// {
// id: 3,
// name: '电表',
// status: '已欠费',
// address: '山东省日照市东港区桂花园(别墅)2号楼2层',
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png",
// }
])
const isLogin = ref(false)
const paymentList = ref([])
const addList = ref([
// {
// name: "燃气",
// type: "gas",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/gas.png",
// iconClass: "gas"
// },
{
name: "水表",
type: "water",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/water.png",
iconClass: "water"
},
// {
// name: "物业",
// type: "property",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/property.png",
// iconClass: "property"
// },
// {
// name: "电表",
// type: "electric",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png",
// iconClass: "electric"
// },
// {
// name: "车位",
// type: "parking",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/parkingIcon.png",
// iconClass: "parking"
// }
])
// ===== 刷新登录状态 =====
const refreshLoginState = () => {
isLogin.value = isLoggedIn();
if (!isLogin.value) {
// 未登录时清空账单数据
paymentList.value = [];
}
};
// ===== openid 相关(仅登录后) =====
const postOpenId = async () => {
// 获取 openid
if (!isLogin.value) return;
try {
const loginRes = await wx.login()
if (!loginRes.code) {
uni.hideLoading()
uni.showToast({
title: '登录失败',
icon: 'none'
})
console.error('wx.login 失败')
return
}
// 用 code 换 openid
const openIdRes = await getopenIdByCode({
code: loginRes.code
})
const openIdRes = await getopenIdByCode({ code: loginRes.code })
if (openIdRes.code !== 200 || !openIdRes.data) {
uni.hideLoading()
uni.showToast({
title: '获取openid失败',
icon: 'none'
})
console.error('获取openid失败')
return
}
const openid = openIdRes.data
uni.setStorageSync('openid', openid)
uni.setStorageSync('openid', openIdRes.data)
await postInsertOpenId({
openid: uni.getStorageSync('openid'),
openid: openIdRes.data,
residentUserId: uni.getStorageSync('userId')
})
} catch (err) {
uni.showToast({
title: err.msg,
icon: 'none'
})
console.error('列表接口报错:', err)
console.error('postOpenId 报错:', err)
}
}
onShow(() => {
// 不再自动请求订阅消息,改为用户点击触发
})
// 生命周期
onReady(() => {})
onLoad(() => {
postOpenId()
uni.hideTabBar({
animation: false // 关闭动画,更稳定
});
getPayList()
})
};
// ===== 获取缴费列表 =====
const getPayList = async () => {
// 防重复请求
if (!isLogin.value) return;
try {
const res = await getTopUpSelectByResident({
residentUserId: uni.getStorageSync('userId')
})
const data = res.data
paymentList.value = data
paymentList.value = res.data || []
} catch (err) {
uni.showToast({
title: err.msg,
icon: 'none'
})
console.error('列表接口报错:', err)
} finally {
}
}
// 方法
};
// ===== 生命周期 =====
onLoad(() => {
refreshLoginState();
uni.hideTabBar({ animation: false });
if (isLogin.value) {
postOpenId();
getPayList();
}
});
onShow(() => {
refreshLoginState();
if (isLogin.value) {
getPayList();
}
});
// ===== 点击事件(统一用 isLogin 判断) =====
// 点击"去登录"提示条
const handleLoginPrompt = () => {
if (isLogin.value) return;
requireAuth({
title: '查看缴费账单',
onLoggedIn: () => {
refreshLoginState();
getPayList();
}
});
};
// 点击账单明细
const goToBill = (item) => {
if (!isLogin.value) {
requireAuth({
title: '查看缴费详情',
onLoggedIn: () => {
refreshLoginState();
goToBill(item);
}
});
return;
}
uni.setStorageSync('arrearsPayment', item)
// if (item.balance < 0) {
// uni.redirectTo({
// url: '/pageSubPack/payment-list/arrearsPayment'
// })
// } else {
// uni.redirectTo({
// url: '/pageSubPack/payment-list/noArrearsPayment'
// })
// }
uni.redirectTo({
url: '/pageSubPack/payment-list/arrearsPayment'
})
}
uni.redirectTo({ url: '/pageSubPack/payment-list/arrearsPayment' })
};
// 点击缴费记录
const goToRecord = () => {
uni.redirectTo({
url: '/pageSubPack/payment-list/paymentRecord'
})
}
if (!isLogin.value) {
requireAuth({
title: '查看缴费记录',
onLoggedIn: () => {
refreshLoginState();
goToRecord();
}
});
return;
}
uni.redirectTo({ url: '/pageSubPack/payment-list/paymentRecord' })
};
// 点击新增缴费(水表/电表等)
const goToAdd = (type) => {
if (!isLogin.value) {
requireAuth({
title: '新增缴费',
onLoggedIn: () => {
refreshLoginState();
goToAdd(type);
}
});
return;
}
if (type.name == '燃气' || type.name == '暖气') {
uni.redirectTo({
url: '/pageSubPack/payment-list/selectPaymentEntity'
})
uni.redirectTo({ url: '/pageSubPack/payment-list/selectPaymentEntity' })
} else if (type.name == '水表' || type.name == '电表') {
uni.redirectTo({
url: '/pageSubPack/payment-list/addHydropower'
})
uni.redirectTo({ url: '/pageSubPack/payment-list/addHydropower' })
}
uni.setStorageSync('addPaymentType', type.name)
}
};
const formatAddress = (addr) => {
if (!addr) return ''
return addr.replace(/\d+[层楼]\s*/g, '').replace(/单元\s*/g, '-').replace(/\s+/g, '')
}
const goBack = () => {
console.log(uni.getStorageSync('sourcePage'))
if (uni.getStorageSync('sourcePage') == 'serviceIndex') {
uni.switchTab({
url: '/pages/serviceIndex/serviceIndex'
})
} else if (uni.getStorageSync('sourcePage') == 'index') {
uni.switchTab({
url: '/pages/index/index'
})
}
uni.removeStorageSync('sourcePage')
}
if (!addr) return ''
return addr.replace(/\d+[层楼]\s*/g, '').replace(/单元\s*/g, '-').replace(/\s+/g, '')
};
</script>
<style lang="scss">
@@ -320,7 +253,31 @@
bottom: -140rpx;
}
.container {}
/* ===== 未登录提示条 ===== */
.login-tip {
display: flex;
align-items: center;
background-color: #fff;
padding: 24rpx 30rpx;
border-radius: 10rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
}
.login-tip-icon {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
}
.login-tip-text {
flex: 1;
font-size: 28rpx;
color: #666;
}
.login-tip-link {
font-size: 28rpx;
color: #1677ff;
font-weight: 500;
}
.bill-list {
margin-bottom: 40rpx;
@@ -329,22 +286,6 @@
border-radius: 10rpx;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
color: #ccc;
}
.empty-text {
font-size: 32rpx;
color: #999;
margin-top: 20rpx;
margin-bottom: 10rpx;
}
.bill-item {
display: flex;
align-items: center;
@@ -478,22 +419,8 @@
color: #333;
}
.subscribe-btn {
margin-top: 20rpx;
background-color: #1677ff;
padding: 24rpx;
border-radius: 10rpx;
text-align: center;
}
.subscribe-btn-text {
color: #fff;
font-size: 32rpx;
font-weight: 600;
}
.status-bar {
width: 100vw;
height: 46px;
}
</style>
</style>