丢弃报错的银联插件

This commit is contained in:
zhouyanli
2026-06-08 17:16:46 +08:00
parent d26bd4e86b
commit ebdfa8d95e
23 changed files with 228 additions and 706 deletions

View File

@@ -200,7 +200,7 @@
} catch (err) {
uni.hideLoading()
uni.showToast({
title: `${err}`,
title: err.msg || '网络异常',
icon: 'none'
})
console.error('绑定设备失败:', err)
@@ -215,7 +215,7 @@
// 跳转成功页
const goNext = () => {
uni.redirectTo({
url: '/pageSubPack/payment-list/addPaymentSuccess'
url: '/pageSubPack/payment-list/addPaymentSuccess?type=bind'
})
}

View File

@@ -1,7 +1,7 @@
<template>
<view class="contentStyle" style="">
<view class="status-bar"></view>
<uni-nav-bar :title="'新增'+paymentType+'缴费'" left-icon="left" @clickLeft="goBack" backgroundColor="transparent"
<uni-nav-bar :title="navTitle" left-icon="left" @clickLeft="goBack" backgroundColor="transparent"
:border="false">
</uni-nav-bar>
@@ -11,20 +11,18 @@
<!-- 成功图标 -->
<view class="success-icon">
<text class="icon-check"></text>
<!-- <image src="https://wuyeadmin.bugtc.com/images/home/bingo.png" ></image> -->
</view>
<!-- 主标题 -->
<view class="title">绑定成功</view>
<view class="title">{{ pageTitle }}</view>
<!-- 提示文案 -->
<view class="desc">
恭喜您绑定成功费用将在24小时内更新<br>
请您按时查看避免造成费用欠费
</view>
<view class="desc" v-html="descText"></view>
<!-- 操作按钮 -->
<view class="btn-wrap">
<button class="btn-back" @click="goBack">返回生活缴费</button>
<button class="btn-back" @click="handlePrimaryClick">{{ btnText }}</button>
</view>
</view>
</scroll-view>
@@ -50,8 +48,40 @@
// 响应式数据
const statusBarHeight = ref(20)
const paymentType = ref(uni.getStorageSync('addPaymentType'))
const pageType = ref('bind') // 'bind' | 'pay'
// 页面配置:根据类型返回对应文案和跳转
const pageConfig = computed(() => {
const configs = {
bind: {
navTitle: '新增' + paymentType.value + '缴费',
pageTitle: '绑定成功',
descText: '恭喜您绑定成功费用将在24小时内更新<br>请您按时查看,避免造成费用欠费',
btnText: '返回生活缴费',
backUrl: '/pageSubPack/payment-list/paymentIndex'
},
pay: {
navTitle: '缴费支付',
pageTitle: '支付成功',
descText: '恭喜您支付成功,感谢您的使用',
btnText: '返回生活缴费',
backUrl: '/pageSubPack/payment-list/paymentIndex' // TODO: 如有缴费记录页请修改
}
}
return configs[pageType.value] || configs.bind
})
const navTitle = computed(() => pageConfig.value.navTitle)
const pageTitle = computed(() => pageConfig.value.pageTitle)
const descText = computed(() => pageConfig.value.descText)
const btnText = computed(() => pageConfig.value.btnText)
// 生命周期
onLoad((options) => {
if (options?.type) {
pageType.value = options.type
}
})
onShow(() => {})
onMounted(() => {})
onReady(() => {})
@@ -60,6 +90,11 @@
const goBack = () => {
uni.redirectTo({ url: '/pageSubPack/payment-list/paymentIndex' });
}
const handlePrimaryClick = () => {
const url = pageConfig.value.backUrl
uni.redirectTo({ url });
}
</script>
<style lang="scss">

View File

@@ -161,7 +161,7 @@
})
} catch (err) {
uni.showToast({
title: `${err}`,
title: err.msg || '网络异常',
icon: 'none'
})
console.error('列表接口报错:', err)

View File

@@ -1,56 +1,60 @@
<template>
<view class="container">
<!-- 状态栏 -->
<view class="status-bar"></view>
<!-- 顶部导航 -->
<uni-nav-bar title="支付收银台" left-icon="left" @clickLeft="goBack" />
<uni-nav-bar
title="支付收银台"
left-icon="left"
@clickLeft="goBack"
background-color="#F5F6F9"
color="#000"
/>
<!-- 金额区域 -->
<view class="amount-box">
<text class="amount">¥{{ amount }}</text>
<text class="countdown">剩余支付时间{{ countdownTime }}</text>
<!-- 内容区域 -->
<view class="content">
<!-- 金额区域 -->
<view class="amount-box">
<view class="amount-text">缴费金额</view>
<text class="amount"> <text style="font-size: 32rpx;"> ¥ </text>{{ amount }}</text>
<view class="countdown-wrap">
<text class="countdown">剩余支付时间 {{ countdownTime }}</text>
</view>
</view>
<!-- 支付方式列表 -->
<view class="tip">请选择支付方式</view>
<view class="pay-list">
<view class="pay-item" @click="selectPayType('wx')">
<view class="left">
<image src="https://wuyeadmin.bugtc.com/images/home/wechat.png" class="icon" mode="widthFix" />
<view class="pay-info">
<text class="pay-name">微信</text>
</view>
</view>
<view class="radio" :class="{ active: selectedType === 'wx' }" />
</view>
<view class="pay-item" @click="selectPayType('alipay')">
<view class="left">
<image src="https://wuyeadmin.bugtc.com/images/home/alipay.png" class="icon" mode="widthFix" />
<view class="pay-info">
<text class="pay-name">支付宝</text>
</view>
</view>
<view class="radio" :class="{ active: selectedType === 'alipay' }" />
</view>
</view>
</view>
<!-- 支付方式列表 -->
<view class="pay-list">
<view class="pay-item" @click="selectPayType('wx')">
<view class="left">
<image src="/static/wechat.png" class="icon" mode="widthFix" />
<view class="pay-info">
<text class="pay-name">微信支付</text>
<text class="pay-desc">微信快捷支付</text>
</view>
</view>
<view class="radio" :class="{ active: selectedType === 'wx' }" />
</view>
<view class="pay-item" @click="selectPayType('alipay')">
<view class="left">
<image src="/static/alipay.png" class="icon" mode="widthFix" />
<view class="pay-info">
<text class="pay-name">支付宝支付</text>
<text class="pay-desc">支付宝快捷支付</text>
</view>
</view>
<view class="radio" :class="{ active: selectedType === 'alipa··y' }" />
</view>
<view class="pay-item" @click="selectPayType('union')">
<view class="left">
<image src="/static/union.png" class="icon" mode="widthFix" />
<view class="pay-info">
<text class="pay-name">银联支付</text>
<text class="pay-desc">云闪付/银行卡</text>
</view>
</view>
<view class="radio" :class="{ active: selectedType === 'union' }" />
</view>
</view>
<view class="tip">请选择支付方式完成缴费</view>
<!-- 底部支付按钮 -->
<view class="pay-btn" @click="handlePayClick">
<text class="btn-text">立即支付 {{ amount }} </text>
<view class="btn-wrap">
<view class="pay-btn" @click="handlePayClick">
<text class="btn-text">立即支付 {{ amount }} </text>
</view>
</view>
</view>
</template>
@@ -61,16 +65,13 @@
import { getUnionPayTn } from '/pageSubPack/api/apiSub.js'
import { getPushSingle } from '/pageSubPack/api/api.js'
// #ifdef APP
import { startPay, checkWalletInstalled } from '@/uni_modules/unionpay-full'
// #endif
// 支付宝和微信支付
const amount = ref('0.00')
const countdownTime = ref('29:57')
const countdownTime = ref('10:00')
let timer = null
const payData = ref({})
// 读取支付数据
onLoad(() => {
const data = uni.getStorageSync('payData')
if (data) {
@@ -101,37 +102,39 @@
}, 1000)
}
// 选中的支付类型(默认微信)
const selectedType = ref('wx')
// 返回
const goBack = () => uni.navigateBack()
// 选择支付方式
const selectPayType = (type) => {
selectedType.value = type
// #ifndef APP-HARMONY
uni.vibrateShort({ type: 'light' })
// #endif
}
// 点击底部支付按钮
const handlePayClick = () => {
handlePay()
}
// ==================== 统一支付入口 ====================
const handlePay = async () => {
try {
uni.showLoading({ title: '发起支付中' })
const payTypeMap = { wx: '0', alipay: '1' }
const backendPayType = payTypeMap[selectedType.value] || '1'
// 向后端请求获取支付参数
const res = await getUnionPayTn({
amount: amount.value,
orderDesc: (payData.value.type || '缴费') + '缴费',
residentUserId: uni.getStorageSync('userId'),
devicecode: payData.value.deviceCode || '',
deviceType: '2'
payType: backendPayType,
deviceCode: payData.value.deviceCode || '',
deviceType: '2',
chargeTypeId: payData.value.chargeTypeId,
chargeItemId: payData.value.chargeItemId,
billId: payData.value.billId,
houseId: payData.value.houseId
})
console.log('支付接口返回:', JSON.stringify(res.data))
console.log('支付接口返回:', JSON.stringify(res.data))
uni.hideLoading()
if (res.code !== 200 || !res.data) {
@@ -142,16 +145,10 @@
const payType = selectedType.value
const data = res.data
// 根据支付方式调起对应 SDK
if (payType === 'union') {
// 银联UMS SDK
invokeUmsPay('unionpay', data.union?.tn || data.union || data)
} else if (payType === 'wx') {
// 微信plus.payment等申请微信SDK后切到UMS
if (payType === 'wx') {
invokeWxPay(data.wx || data.wxPayInfo || data)
} else if (payType === 'alipay') {
// 支付宝UMS SDK
invokeUmsPay('alipay', data.alipay || data.aliPayInfo || data)
invokeAlipay(data.alipay || data.aliPayInfo || data)
}
} catch (err) {
@@ -161,60 +158,6 @@
}
}
// ==================== UMS 统一支付(银联/支付宝)====================
const invokeUmsPay = (channel, data) => {
// #ifdef APP
const tn = typeof data === 'string' ? data : (data.tn || JSON.stringify(data))
// 银联渠道检查是否安装云闪付
if (channel === 'unionpay') {
const installed = checkWalletInstalled()
if (!installed) {
uni.showModal({
title: '未安装云闪付',
content: '请先下载安装云闪付App后再进行支付',
showCancel: false,
confirmText: '知道了'
})
return
}
}
// 调起 UMS 支付
startPay({
channel: channel,
tn: tn,
mode: '00',
callback: (result) => {
console.log('UMS支付结果[' + channel + ']', JSON.stringify(result))
const code = result?.code
if (code === 0) {
paySuccess()
} else if (code === 1) {
uni.showModal({
title: '支付处理中',
content: '银行正在处理支付结果,请勿重复支付。您可在「缴费记录」中查看最终状态。',
showCancel: false,
confirmText: '我知道了',
success: () => {
uni.redirectTo({ url: '/pageSubPack/payment-list/paymentIndex' })
}
})
} else if (code === -2) {
uni.showToast({ title: '支付已取消', icon: 'none' })
} else {
uni.showToast({ title: result?.msg || '支付失败', icon: 'none' })
}
}
})
// #endif
// #ifndef APP
uni.showToast({ title: '支付仅支持App端', icon: 'none' })
// #endif
}
// ==================== 微信支付uni.requestPayment====================
const invokeWxPay = (data) => {
const orderInfo = {
appid: data.appId,
@@ -240,10 +183,8 @@
})
}
// ==================== 支付宝支付uni.requestPayment====================
const invokeAlipay = (data) => {
const orderInfo = data.orderInfo || data
uni.requestPayment({
provider: 'alipay',
orderInfo: orderInfo,
@@ -258,19 +199,17 @@
})
}
// ==================== 支付成功 ====================
const paySuccess = () => {
sendPaySuccessPush()
uni.showToast({ title: '支付成功', icon: 'success' })
uni.setStorageSync('paySuccess', true)
setTimeout(() => {
uni.redirectTo({
url: '/pageSubPack/payment-list/arrearsPayment'
url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay'
})
}, 1500)
}
// 缴费成功推送通知
const sendPaySuccessPush = () => {
const userId = uni.getStorageSync('userId')
if (userId) {
@@ -285,48 +224,78 @@
</script>
<style scoped>
/* 全局容器 */
/* 全局背景 */
.container {
width: 100%;
height: 100vh;
background-color: #f5f5f5;
display: flex;
flex-direction: column;
width: 100%;
min-height: 100vh;
background-color: #F5F6F9;
padding: 0 30rpx;
box-sizing: border-box;
}
/* 金额区域 */
/* 状态栏 */
.status-bar {
width: 100%;
height: var(--status-bar-height);
}
/* 内容区域 */
.content {
/* flex: 1; */
}
/* 金额卡片 */
.amount-box {
background: #2F77FD;
color: #fff;
padding: 60rpx 20rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 50rpx 0;
text-align: center;
margin: 30rpx 0;
}
.amount {
font-size: 72rpx;
font-weight: bold;
display: block;
.amount-text {
font-size: 28rpx;
color: #666;
margin-bottom: 16rpx;
}
.countdown {
font-size: 26rpx;
opacity: 0.9;
.amount {
display: block;
font-size: 52rpx;
font-weight: bold;
color: #333;
}
/* 支付方式列表 */
/* 倒计时样式 */
.countdown-wrap {
display: inline-block;
margin-top: 24rpx;
padding: 8rpx 24rpx;
background: #F4F4F4;
border-radius: 30rpx;
}
.countdown {
font-size: 28rpx;
color: #000;
}
/* 支付方式卡片 */
.pay-list {
margin-top: 20rpx;
background-color: #fff;
padding: 0 20rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 0 30rpx;
margin-bottom: 30rpx;
}
.pay-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx 20rpx;
border-bottom: 1rpx solid #f0f0f0;
padding: 36rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.pay-item:last-child {
@@ -341,13 +310,7 @@
.icon {
width: 56rpx;
height: 56rpx;
margin-right: 20rpx;
border-radius: 8rpx;
}
.pay-info {
display: flex;
flex-direction: column;
margin-right: 24rpx;
}
.pay-name {
@@ -356,65 +319,58 @@
font-weight: 500;
}
.pay-desc {
font-size: 24rpx;
color: #999;
margin-top: 4rpx;
}
/* 单选按钮 — 对勾样式 */
.radio {
width: 36rpx;
height: 36rpx;
width: 44rpx;
height: 44rpx;
border-radius: 50%;
border: 2rpx solid #ccc;
border: 3rpx solid #d0d0d0;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
box-sizing: border-box;
}
.radio.active {
border-color: #2F77FD;
background-color: #2F77FD;
border-color: #2F77FD;
}
.radio.active::after {
content: '';
width: 10rpx;
height: 18rpx;
border: 3rpx solid #fff;
border-left: none;
border-top: none;
width: 12rpx;
height: 22rpx;
border: 4rpx solid #fff;
border-left: 0;
border-top: 0;
transform: rotate(45deg) translate(-2rpx, -2rpx);
}
/* 底部提示 */
/* 提示 */
.tip {
font-size: 24rpx;
color: #999;
text-align: center;
padding: 30rpx 0;
margin-bottom: 120rpx;
font-size: 32rpx;
color: #333;
font-weight: 500;
text-align: left;
padding: 20rpx 0;
}
/* 底部按钮 — 圆角胶囊 */
/* 底部按钮区域 */
.btn-wrap {
padding: 30rpx 0 60rpx;
}
/* 底部支付按钮 */
.pay-btn {
position: fixed;
bottom: 40rpx;
left: 30rpx;
right: 30rpx;
height: 90rpx;
line-height: 90rpx;
width: 100%;
height: 96rpx;
line-height: 96rpx;
background: #2F77FD;
color: #fff;
text-align: center;
font-size: 32rpx;
font-size: 34rpx;
font-weight: bold;
border-radius: 45rpx;
border-radius: 8rpx;
box-shadow: 0 6rpx 20rpx rgba(47, 119, 253, 0.3);
}
.status-bar {
width: 100vw;
height: 46px;
}
</style>
</style>