a3ab5d87 by lttnew

去支付

1 parent 10c86415
......@@ -1705,8 +1705,10 @@ export function goPay(params) {
export function payForOrder(params) {
let url = `/common/order/payForOrder/${params.id}`
const queryParams = []
if (params.id) queryParams.push(`id=${params.id}`)
if (params.payType) queryParams.push(`payType=${params.payType}`)
if (params.id) queryParams.push(`id=${encodeURIComponent(params.id)}`)
if (params.payType) queryParams.push(`payType=${encodeURIComponent(params.payType)}`)
if (params.contactPerson) queryParams.push(`contactPerson=${encodeURIComponent(params.contactPerson)}`)
if (params.contactTel) queryParams.push(`contactTel=${encodeURIComponent(params.contactTel)}`)
if (queryParams.length > 0) {
url += '?' + queryParams.join('&')
}
......
// dev
const baseUrl_api = 'http://192.168.1.134:8787'
const baseUrl_api = 'http://192.168.1.222:8787'
// const baseUrl_api = 'http://47.98.186.233:8787'
// const baseUrl_api = 'https://tk001.wxjylt.com/stage-api/'
const loginImage_api = 'https://tk001.wxjylt.com/stage-api'
......
<template>
<view class="pay-order-container">
<!-- 页面头部 -->
<view class="page-header">
<text class="title">确认并支付</text>
</view>
<!-- 订单核心信息 -->
<view class="order-info">
<view class="info-item">
<text class="label">缴费单位:</text>
<text class="value normal">{{ displayPayName }}</text>
</view>
<view class="info-item">
<text class="label">所属协会:</text>
<text class="value normal">{{ displayAssoName }}</text>
</view>
<view class="info-item">
<text class="label">人数合计:</text>
<text class="value red">{{ formData.all ?? 0 }}</text>
</view>
......@@ -30,13 +34,13 @@
<view class="section-title">选择支付方式</view>
<view class="payment-methods">
<radio-group @change="handlePayTypeChange">
<label :class="{ selected: payType === '1' }" class="payment-item">
<label :class="{ selected: payType === '0' }" class="payment-item">
<radio :checked="payType =='0'" value="0"/>
<image :src="config.baseUrl_api + '/fs/static/min.png'" class="icon ml10" mode="widthFix"></image>
<text class="pay-name ml10">民生付</text>
</label>
<label :class="{ selected: payType === '3' }" class="payment-item">
<radio :checked="payType === '3'" value="1"/>
<radio :checked="payType === '3'" value="3"/>
<image :src="config.baseUrl_api + '/fs/static/min.png'" class="icon ml10" mode="widthFix"></image>
<text class="pay-name ml10">对公转账</text>
</label>
......@@ -65,6 +69,7 @@
<script setup>
import {
computed,
ref
} from 'vue'
import {
......@@ -77,32 +82,118 @@ import {minShengPay} from "@/common/pay";
// 核心数据
const formData = ref({}) // 订单统计数据
const rangeId = ref('') // 核心业务ID
const orderId = ref('') // common/order 订单ID,用于订单列表再次支付
const payName = ref('')
const assoName = ref('')
const payType = ref('0') // 支付方式(默认0=民生付)
const payLoading = ref(false) // 支付按钮加载状态
const form = ref({
contactPerson: '',
contactTel: ''
})
const app = getApp()
const memberInfo = app.globalData?.memberInfo || {}
const deptInfo = app.globalData?.dept || app.globalData?.userInfo?.dept || {}
const pickFirst = (...values) => {
const value = values.find(item => item !== undefined && item !== null && String(item).trim() !== '')
return value ? String(value) : ''
}
const displayPayName = computed(() => {
return pickFirst(
memberInfo.name,
memberInfo.deptName,
deptInfo.deptName,
formData.value.orderName,
formData.value.payDeptName,
formData.value.payMemName,
formData.value.memberName,
payName.value,
formData.value.memName
) || '-'
})
const displayAssoName = computed(() => {
return pickFirst(
deptInfo.aname,
deptInfo.associateName,
memberInfo.aname,
memberInfo.associateName,
memberInfo.assoName,
formData.value.assoName,
formData.value.associateName,
formData.value.associationName,
formData.value.aname,
formData.value.parentName,
assoName.value
) || '-'
})
// 页面加载接收参数
onLoad(async (options) => {
console.log('订单ID:', options.rangeId)
console.log('缴费范围ID:', options.rangeId, '订单ID:', options.orderId)
payName.value = decodeURIComponent(options.payName || '')
assoName.value = decodeURIComponent(options.assoName || '')
if (options.orderId) {
orderId.value = options.orderId
}
if (options.rangeId) {
rangeId.value = options.rangeId
await getCount()
}
if (options.orderId) {
await getOrderDetail()
}
})
async function getCount() {
try {
const res = await api.getNewCountByRangeId(rangeId.value)
formData.value = res.data || {
formData.value = {
...formData.value,
...(res.data || {
all: 0,
new: 0,
old: 0
})
}
} catch (e) {
formData.value = {
...formData.value,
all: 0,
new: 0,
old: 0
}
}
}
async function getOrderDetail() {
try {
const res = await api.orderDetail(orderId.value)
const data = res.data || {}
let content = {}
if (data.content) {
try {
content = typeof data.content === 'string' ? JSON.parse(data.content) : data.content
} catch (e) {
content = {}
}
}
formData.value = {
...formData.value,
...data,
...content,
all: content.allPersonCount ?? data.allCount ?? data.all ?? 0,
new: content.newPersonCount ?? data.newCount ?? data.new ?? 0,
old: content.renewPersonCount ?? data.oldCount ?? data.old ?? 0,
price: data.price ?? content.price ?? 0
}
payName.value = pickFirst(data.orderName, content.orderName, data.payDeptName, data.payMemName, content.payDeptName, content.payMemName, data.memberName, content.memberName, payName.value)
assoName.value = pickFirst(data.assoName, data.associateName, data.associationName, data.aname, data.parentName, content.assoName, content.associateName, content.associationName, content.aname, content.parentName, assoName.value)
} catch (e) {
formData.value = {
...formData.value,
all: 0,
new: 0,
old: 0
......@@ -112,7 +203,7 @@ async function getCount() {
// 支付方式切换
function handlePayTypeChange(e) {
payType.value = e.detail.value == '0' ? '0' : '3'
payType.value = e.detail.value
console.log('支付方式:', payType.value)
if (payType.value === '3') {
form.value.contactPerson = ''
......@@ -123,7 +214,7 @@ function handlePayTypeChange(e) {
// 立即支付核心逻辑
async function handlePay() {
// 基础校验
if (!rangeId.value || rangeId.value === '-1') {
if ((!rangeId.value && !orderId.value) || rangeId.value === '-1') {
return uni.showToast({
title: '订单ID异常',
icon: 'none'
......@@ -153,7 +244,7 @@ async function handlePay() {
// 构建请求参数
const params = {
id: rangeId.value,
id: orderId.value || rangeId.value,
payType: payType.value
}
if (payType.value === '3') {
......@@ -161,7 +252,7 @@ async function handlePay() {
params.contactTel = form.value.contactTel
}
const res = await api.goPay(params)
const res = orderId.value ? await api.payForOrder(params) : await api.goPay(params)
const resData = res.data
// 对公转账 - 跳转转账信息页面
......@@ -230,6 +321,8 @@ async function handlePay() {
// 订单信息区域
.order-info {
margin-bottom: 60rpx;
border-top: 1px solid #f5f5f5;
border-bottom: 1px solid #f5f5f5;
.info-item {
display: flex;
......@@ -241,11 +334,19 @@ async function handlePay() {
.label {
color: #666;
flex-shrink: 0;
}
.value {
font-weight: 600;
font-size: 34rpx;
text-align: right;
word-break: break-all;
}
.normal {
color: #111;
font-size: 30rpx;
}
.red {
......
......@@ -17,7 +17,7 @@
v-model="queryParams.wfCode"
:input-border="false"
class="search-input"
placeholder="输入订单编号/名称/单位/日期"
placeholder="输入缴费编号查询"
placeholderStyle="font-size:28rpx;color:#999"
prefixIcon="search"
@blur="handelSearch"
......@@ -229,31 +229,15 @@
</view>
</view>
</view>
<!-- 缴费方式 -->
<!-- <view class="pay-way-row">
<text class="pay-way-label">缴费方式:</text>
<text class="pay-way-value">{{ item.payType == '3' ? '对公转账' : '民生付' }}</text>
</view> -->
<!-- 按钮组:靠右展示 -->
<view class="btn-group">
<!-- 已缴费:申请开票/已开票(需要审核通过才能开票) -->
<template v-if="item.payStatus == 1 && item.invoiceStatus != 1&& item.auditStatus == 2 &&item.price>0">
<button :disabled="item.invoiceStatus === 1" class="btn btn-view-invoice"
@click.stop="makeInvoiceFN(item)">
申请开票
</button>
</template>
<!-- 已申请票据:查看票据 -->
<template v-if="item.invoiceStatus == 1">
<button class="btn btn-invoice" @click.stop="viewInvoice(item)">查看票据</button>
<button :class="{ disabled: isPayDisabled(item) }" :disabled="isPayDisabled(item)" class="btn btn-pay" @click.stop="handlePay(item)">支付</button>
<button :class="{ disabled: isCancelDisabled(item) }" :disabled="isCancelDisabled(item)" class="btn btn-cancel" @click.stop="handleCancel(item)">取消订单</button>
<template v-if="!hasInvoice(item)">
<button :class="{ disabled: isInvoiceDisabled(item) }" :disabled="isInvoiceDisabled(item)" class="btn btn-view-invoice" @click.stop="makeInvoiceFN(item)">申请开票</button>
</template>
<!-- 未缴费:去缴费 + 取消订单 -->
<template v-if="item.payStatus == 0">
<!-- 支付按钮:仅 auditStatus==='0' && payStatus==='0' 时可点 -->
<button :disabled="!(item.auditStatus == '0' && item.payStatus == 0)" class="btn btn-pay" @click.stop="handlePay(item)">去支付</button>
<button :disabled="item.payStatus != 0" class="btn btn-cancel" @click.stop="handleCancel(item)">取消订单</button>
<template v-else>
<button class="btn btn-invoice" @click.stop="viewInvoice(item)">查看发票</button>
</template>
</view>
</view>
......@@ -542,6 +526,46 @@ const filterType = (row) => {
if (row == 4) return '越位考试办理'
}
const getRowType = (item) => String(item?.type ?? currentTab.value)
const isPersonalOrder = (item) => getRowType(item) === '0'
const isGroupOrder = (item) => getRowType(item) === '1'
const isPayDisabled = (item) => {
if (isPersonalOrder(item)) return String(item?.auditStatus) !== '9'
if (String(item?.payStatus) !== '0') return true
return String(item?.auditStatus) !== '0'
}
const isCancelDisabled = (item) => {
if (isPersonalOrder(item)) return String(item?.auditStatus) !== '9'
if (String(item?.payStatus) !== '0') return true
return false
}
const hasInvoice = (item) => String(item?.invoiceStatus) === '1'
const isInvoiceDisabled = (item) => {
if (hasInvoice(item)) return true
if (isPersonalOrder(item)) return String(item?.auditStatus) !== '2'
return String(item?.payStatus) !== '1' || String(item?.auditStatus) !== '2' || Number(item?.price || 0) <= 0
}
const encodeQueryValue = (value) => encodeURIComponent(value || '')
const getPayName = (item) => {
return item?.orderName || item?.content?.orderName || item?.payDeptName || item?.payMemName || item?.content?.payDeptName || item?.content?.payMemName || item?.memberName || item?.content?.memberName || ''
}
const getAssoName = (item) => {
return item?.assoName || item?.associateName || item?.associationName || item?.aname || item?.parentName || item?.content?.assoName || item?.content?.associateName || item?.content?.associationName || item?.content?.aname || item?.content?.parentName || ''
}
const buildPayInfoQuery = (item) => {
return `payName=${encodeQueryValue(getPayName(item))}&assoName=${encodeQueryValue(getAssoName(item))}`
}
// 数据请求核心方法
const initData = async () => {
......@@ -617,7 +641,7 @@ const confirmDel = async () => {
const goToDetail = (item) => {
const form = encodeURIComponent(JSON.stringify(item))
switch (currentTab.value) {
switch (getRowType(item)) {
case '1':
uni.navigateTo({url: `/group/groupOrderDetail?form=${form}`});
break;
......@@ -641,13 +665,27 @@ const closeDelPopup = () => {
currentOrder.value = null;
};
// 去缴费 - 跳转到单位会员支付页面
// 去支付:个人会员订单走 payOrder,再次支付携带 common/order 的 id;单位会员订单走 goPay。
const handlePay = async (item) => {
if (item.payStatus !== 0) return;
// 跳转到单位会员支付页面
if (isPayDisabled(item)) return;
const payInfoQuery = buildPayInfoQuery(item)
if (isPersonalOrder(item)) {
const rangeId = item.sourceId || item.rangId || ''
uni.navigateTo({
url: `/myCenter/goPay?orderId=${item.id}&renewYear=${item.content?.yearCount || 1}`
url: `/myCenter/payOrder?orderId=${item.id}&rangeId=${rangeId}&${payInfoQuery}`
});
return;
}
if (isGroupOrder(item)) {
uni.navigateTo({
url: `/myCenter/goPay?orderId=${item.id}&renewYear=${item.content?.yearCount || 1}&${payInfoQuery}`
});
return;
}
uni.navigateTo({url: `/pages/rank/applyDetail?examId=${item.sourceId || item.id}&type=${getRowType(item)}`});
};
// 申请开票
......@@ -715,7 +753,7 @@ const closeInvoiceWebview = () => {
// 取消订单
const handleCancel = (item) => {
currentOrder.value = item;
cancelModalContent.value = `是否确认取消订单编号为"${item.tradeNo}"的订单?`;
cancelModalContent.value = `是否确认取消缴费编号为"${item.wfCode}"的订单?`;
showCancelPopup.value = true;
isPopupOpen.value = true;
};
......@@ -1205,8 +1243,12 @@ const onTabSwitch = (index, url) => {
border: 1rpx solid #c30d23;
}
&:disabled {
opacity: 0.6;
&.disabled,
&[disabled] {
background: #f5f5f5 !important;
color: #b8b8b8 !important;
border: 1rpx solid #e1e1e1 !important;
opacity: 1;
pointer-events: none;
}
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!