补充招生数据获取
This commit is contained in:
parent
b112065efe
commit
535e7954c3
|
|
@ -76,6 +76,18 @@
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "缴费"
|
"navigationBarTitleText": "缴费"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/payment_result/payment_result",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "支付结果"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/webview/webview",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "支付"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
|
|
||||||
|
|
@ -205,11 +205,12 @@ const getStats = async () => {
|
||||||
if (teacherId) {
|
if (teacherId) {
|
||||||
console.log('首页获取招生统计,teacherId:', teacherId)
|
console.log('首页获取招生统计,teacherId:', teacherId)
|
||||||
const res = await getEnrollmentStatistical(teacherId)
|
const res = await getEnrollmentStatistical(teacherId)
|
||||||
if (res && res.totalEnrollCount !== undefined) {
|
console.log('招生统计接口返回:', res)
|
||||||
|
if (res && res.total_enroll_count !== undefined) {
|
||||||
stats.value = {
|
stats.value = {
|
||||||
total: res.totalEnrollCount,
|
total: res.total_enroll_count,
|
||||||
today: res.todayEnrollCount,
|
today: res.today_enroll_count,
|
||||||
week: res.weekEnrollCount
|
week: res.week_enroll_count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,21 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, shallowRef } from 'vue'
|
import { ref, shallowRef, computed } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { getPreRegistrationList } from '@/api/app'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { getPreRegistrationList, getTeacherInfo } from '@/api/app'
|
||||||
import { getAliyunImageUrl } from '@/utils/imageUtils'
|
import { getAliyunImageUrl } from '@/utils/imageUtils'
|
||||||
import { ensureStorageConfig } from '@/utils/configUtils'
|
import { ensureStorageConfig } from '@/utils/configUtils'
|
||||||
|
|
||||||
const list = ref<any[]>([])
|
const list = ref<any[]>([])
|
||||||
const paging = shallowRef()
|
const paging = shallowRef()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const { userInfo } = storeToRefs(userStore)
|
||||||
|
|
||||||
|
// 获取当前老师的ID
|
||||||
|
const currentTeacherId = ref<number | undefined>(undefined)
|
||||||
|
|
||||||
// 初始化图片源
|
// 初始化图片源
|
||||||
const recruitmentBgImageSrc = ref(getAliyunImageUrl('static/yubaoming/recruitment_3.png'))
|
const recruitmentBgImageSrc = ref(getAliyunImageUrl('static/yubaoming/recruitment_3.png'))
|
||||||
|
|
@ -87,10 +94,17 @@ const initImageSources = async () => {
|
||||||
const queryList = async (pageNo: number, pageSize: number) => {
|
const queryList = async (pageNo: number, pageSize: number) => {
|
||||||
console.log('=== queryList 开始执行 ===', pageNo, pageSize)
|
console.log('=== queryList 开始执行 ===', pageNo, pageSize)
|
||||||
try {
|
try {
|
||||||
|
const teacherId = currentTeacherId.value
|
||||||
|
if (!teacherId) {
|
||||||
|
console.log('未找到 teacherId,跳过获取招生列表')
|
||||||
|
paging.value.complete([])
|
||||||
|
return
|
||||||
|
}
|
||||||
const params = {
|
const params = {
|
||||||
page: pageNo,
|
page: pageNo,
|
||||||
limit: pageSize,
|
limit: pageSize,
|
||||||
studentStatus: -1
|
studentStatus: -1,
|
||||||
|
recruitmentTeacherId: teacherId
|
||||||
}
|
}
|
||||||
console.log('请求参数:', params)
|
console.log('请求参数:', params)
|
||||||
const res = await getPreRegistrationList(params)
|
const res = await getPreRegistrationList(params)
|
||||||
|
|
@ -112,8 +126,24 @@ const goBack = () => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(async () => {
|
||||||
initImageSources()
|
initImageSources()
|
||||||
|
|
||||||
|
// 获取当前登录老师的 teacherId
|
||||||
|
if (userInfo.value?.teacherId) {
|
||||||
|
currentTeacherId.value = userInfo.value.teacherId
|
||||||
|
} else if (userInfo.value?.account) {
|
||||||
|
try {
|
||||||
|
const teacherRes = await getTeacherInfo({ teacherCode: userInfo.value.account })
|
||||||
|
if (teacherRes && teacherRes.code === 1 && teacherRes.data) {
|
||||||
|
currentTeacherId.value = teacherRes.data.teacherId
|
||||||
|
userInfo.value.teacherId = teacherRes.data.teacherId
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取教师信息失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
queryList(1, 10)
|
queryList(1, 10)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -312,21 +312,59 @@ const alipayJspayPay = async () => {
|
||||||
amountFen: Math.round(parseFloat(String(amount.value)) * 100),
|
amountFen: Math.round(parseFloat(String(amount.value)) * 100),
|
||||||
body: remark.value || '缴费支付',
|
body: remark.value || '缴费支付',
|
||||||
studentId: Number(studentId.value),
|
studentId: Number(studentId.value),
|
||||||
buyerLogonId: '',
|
buyerLogonId: userStore.userInfo?.mobile || '',
|
||||||
includeRawResponse: false
|
includeRawResponse: false
|
||||||
})
|
})
|
||||||
|
|
||||||
// 检查返回结果(后端 AjaxResult.data 为驼峰字段)
|
// 检查返回结果(后端 AjaxResult 包装,实际数据在 data 字段)
|
||||||
if (res && res.status === '0' && res.resultCode === '0') {
|
console.log('支付接口响应:', res)
|
||||||
outTradeNo.value = res.outTradeNo || ''
|
// 后端返回格式: { code: 1, msg: "成功", data: { status: "0", resultCode: "0", ... } }
|
||||||
// #ifdef H5
|
const payData = res.code === 1 && res.data ? res.data : res
|
||||||
if (res.payUrl) {
|
console.log('支付数据:', payData)
|
||||||
window.location.href = res.payUrl
|
|
||||||
|
if (payData && payData.status === '0' && payData.resultCode === '0') {
|
||||||
|
outTradeNo.value = payData.outTradeNo || ''
|
||||||
|
|
||||||
|
// 如果有 payUrl,优先使用 payUrl 跳转
|
||||||
|
console.log('payUrl:', payData.payUrl)
|
||||||
|
if (payData.payUrl) {
|
||||||
|
const payUrlStr = String(payData.payUrl).trim()
|
||||||
|
console.log('准备跳转 payUrl:', payUrlStr)
|
||||||
|
|
||||||
|
// 关闭 loading
|
||||||
|
uni.hideLoading()
|
||||||
|
|
||||||
|
// 微信小程序环境:使用 web-view 页面打开支付链接
|
||||||
|
console.log('微信小程序环境,使用 web-view 打开')
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/webview/webview?url=${encodeURIComponent(payUrlStr)}`,
|
||||||
|
success: () => {
|
||||||
|
console.log('打开 web-view 成功')
|
||||||
|
startPayStatusCheck()
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('打开 web-view 失败:', err)
|
||||||
|
// 降级:复制链接
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: payUrlStr,
|
||||||
|
success: () => {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '支付链接已复制,请在浏览器中打开完成支付',
|
||||||
|
showCancel: false,
|
||||||
|
success: () => {
|
||||||
|
startPayStatusCheck()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// #endif
|
|
||||||
|
|
||||||
const payInfo = JSON.parse(res.payInfo || '{}')
|
const payInfo = JSON.parse(payData.payInfo || '{}')
|
||||||
|
console.log('payInfo:', payInfo)
|
||||||
|
|
||||||
if (payInfo.tradeNO) {
|
if (payInfo.tradeNO) {
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
|
|
@ -345,6 +383,24 @@ const alipayJspayPay = async () => {
|
||||||
})
|
})
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef MP-ALIPAY
|
||||||
|
// 支付宝小程序支付
|
||||||
|
my.tradePay({
|
||||||
|
tradeNO: payInfo.tradeNO,
|
||||||
|
success: (result: any) => {
|
||||||
|
if (result.resultCode === '9000') {
|
||||||
|
checkPayResult()
|
||||||
|
} else {
|
||||||
|
goToResult(false)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
console.error('支付宝小程序支付失败:', err)
|
||||||
|
goToResult(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (typeof AlipayJSBridge !== 'undefined') {
|
if (typeof AlipayJSBridge !== 'undefined') {
|
||||||
AlipayJSBridge.call(
|
AlipayJSBridge.call(
|
||||||
|
|
@ -553,6 +609,60 @@ const fallbackCheckPayResult = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 开始轮询检查支付状态(用于微信小程序外部浏览器支付场景)
|
||||||
|
let payStatusCheckTimer: any = null
|
||||||
|
const startPayStatusCheck = () => {
|
||||||
|
// 清除之前的定时器
|
||||||
|
if (payStatusCheckTimer) {
|
||||||
|
clearInterval(payStatusCheckTimer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 每3秒检查一次支付状态,最多检查20次(60秒)
|
||||||
|
let checkCount = 0
|
||||||
|
const maxCheckCount = 20
|
||||||
|
|
||||||
|
payStatusCheckTimer = setInterval(async () => {
|
||||||
|
checkCount++
|
||||||
|
console.log(`第${checkCount}次检查支付状态`)
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!outTradeNo.value) {
|
||||||
|
clearInterval(payStatusCheckTimer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await bankFeeTradeQuery({ outTradeNo: outTradeNo.value })
|
||||||
|
|
||||||
|
if (res && res.status === '0' && res.resultCode === '0') {
|
||||||
|
const tradeState = res.tradeState
|
||||||
|
|
||||||
|
if (tradeState === 'SUCCESS') {
|
||||||
|
// 支付成功
|
||||||
|
clearInterval(payStatusCheckTimer)
|
||||||
|
goToResult(true)
|
||||||
|
} else if (tradeState === 'CLOSED' || tradeState === 'REVOKED' || tradeState === 'PAYERROR') {
|
||||||
|
// 支付失败或关闭
|
||||||
|
clearInterval(payStatusCheckTimer)
|
||||||
|
goToResult(false)
|
||||||
|
}
|
||||||
|
// NOTPAY 或 USERPAYING 继续轮询
|
||||||
|
}
|
||||||
|
|
||||||
|
// 达到最大检查次数
|
||||||
|
if (checkCount >= maxCheckCount) {
|
||||||
|
clearInterval(payStatusCheckTimer)
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '支付检查超时,请手动查询支付结果',
|
||||||
|
showCancel: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('检查支付状态失败:', error)
|
||||||
|
}
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
|
|
||||||
// 跳转到结果页
|
// 跳转到结果页
|
||||||
const goToResult = (success: boolean) => {
|
const goToResult = (success: boolean) => {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,7 @@ onMounted(() => {
|
||||||
onLoad((options: any) => {
|
onLoad((options: any) => {
|
||||||
console.log('=== 预报名页面 onLoad 被触发 ===')
|
console.log('=== 预报名页面 onLoad 被触发 ===')
|
||||||
console.log('options:', options)
|
console.log('options:', options)
|
||||||
|
console.log('【调试】二维码参数:', { teacherId: options.teacherId, id: options.id, invitationCode: options.invitationCode, scene: options.scene })
|
||||||
|
|
||||||
if (options.teacherId) {
|
if (options.teacherId) {
|
||||||
getTeacherData(options.teacherId)
|
getTeacherData(options.teacherId)
|
||||||
|
|
|
||||||
|
|
@ -313,17 +313,17 @@ const getStats = async (teacherId?: number) => {
|
||||||
console.log('正在调用 getEnrollmentStatistical, teacherId:', teacherId)
|
console.log('正在调用 getEnrollmentStatistical, teacherId:', teacherId)
|
||||||
const res = await getEnrollmentStatistical(teacherId)
|
const res = await getEnrollmentStatistical(teacherId)
|
||||||
console.log('接口返回结果:', res)
|
console.log('接口返回结果:', res)
|
||||||
// 接口直接返回数据对象,没有 code 包装
|
// 接口返回数据对象
|
||||||
if (res && res.totalEnrollCount !== undefined) {
|
if (res && res.total_enroll_count !== undefined) {
|
||||||
console.log('totalEnrollCount:', res.totalEnrollCount)
|
console.log('total_enroll_count:', res.total_enroll_count)
|
||||||
console.log('todayEnrollCount:', res.todayEnrollCount)
|
console.log('today_enroll_count:', res.today_enroll_count)
|
||||||
console.log('weekEnrollCount:', res.weekEnrollCount)
|
console.log('week_enroll_count:', res.week_enroll_count)
|
||||||
console.log('monthEnrollCount:', res.monthEnrollCount)
|
console.log('month_enroll_count:', res.month_enroll_count)
|
||||||
recruitmentStats.value = {
|
recruitmentStats.value = {
|
||||||
total: res.totalEnrollCount,
|
total: res.total_enroll_count,
|
||||||
today: res.todayEnrollCount,
|
today: res.today_enroll_count,
|
||||||
week: res.weekEnrollCount,
|
week: res.week_enroll_count,
|
||||||
month: res.monthEnrollCount
|
month: res.month_enroll_count
|
||||||
}
|
}
|
||||||
console.log('更新后的 recruitmentStats:', recruitmentStats.value)
|
console.log('更新后的 recruitmentStats:', recruitmentStats.value)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -338,9 +338,14 @@ const getStats = async (teacherId?: number) => {
|
||||||
const openQrcodeModal = async () => {
|
const openQrcodeModal = async () => {
|
||||||
showQrcodeModal.value = true
|
showQrcodeModal.value = true
|
||||||
if (!qrcodeUrl.value) {
|
if (!qrcodeUrl.value) {
|
||||||
console.log('openQrcodeModal: 使用默认 teacherId = 8 获取二维码')
|
const teacherId = currentTeacherId.value || userInfo.value?.teacherId
|
||||||
const defaultTeacherId = 8
|
if (teacherId) {
|
||||||
await getQrcode(defaultTeacherId)
|
console.log('openQrcodeModal: 使用 teacherId =', teacherId, '获取二维码')
|
||||||
|
await getQrcode(teacherId)
|
||||||
|
} else {
|
||||||
|
console.log('openQrcodeModal: 未找到 teacherId,无法获取二维码')
|
||||||
|
uni.$u.toast('无法获取二维码,请先登录')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue