补充招生数据获取
This commit is contained in:
parent
b112065efe
commit
535e7954c3
|
|
@ -1,97 +1,109 @@
|
|||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
// #ifndef H5
|
||||
"navigationStyle": "custom",
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
"navigationBarTitleText": "首页"
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/user",
|
||||
"style": {
|
||||
// #ifndef H5
|
||||
"navigationStyle": "custom",
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
"navigationBarTitleText": "个人中心"
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录"
|
||||
},
|
||||
"meta": {
|
||||
"white": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/register/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册"
|
||||
},
|
||||
"meta": {
|
||||
"white": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/pre_registration/pre_registration",
|
||||
"style": {
|
||||
"navigationBarTitleText": "预报名"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/submit_success/submit_success",
|
||||
"style": {
|
||||
"navigationBarTitleText": "提交成功"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/my_recruitment/my_recruitment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的招生",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user_data/user_data",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/change_password/change_password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/payment/payment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "缴费"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "商城",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F8F8F8",
|
||||
"h5": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
"easycom": {
|
||||
"custom": {
|
||||
"router-navigate": "uniapp-router-next/components/router-navigate/router-navigate.vue",
|
||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue",
|
||||
"^w-(.*)": "@/components/widgets/$1/$1.vue"
|
||||
}
|
||||
}
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
// #ifndef H5
|
||||
"navigationStyle": "custom",
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
"navigationBarTitleText": "首页"
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/user",
|
||||
"style": {
|
||||
// #ifndef H5
|
||||
"navigationStyle": "custom",
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
"navigationBarTitleText": "个人中心"
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录"
|
||||
},
|
||||
"meta": {
|
||||
"white": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/register/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册"
|
||||
},
|
||||
"meta": {
|
||||
"white": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/pre_registration/pre_registration",
|
||||
"style": {
|
||||
"navigationBarTitleText": "预报名"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/submit_success/submit_success",
|
||||
"style": {
|
||||
"navigationBarTitleText": "提交成功"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/my_recruitment/my_recruitment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的招生",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user_data/user_data",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/change_password/change_password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/payment/payment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "缴费"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/payment_result/payment_result",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付结果"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/webview/webview",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "商城",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F8F8F8",
|
||||
"h5": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
"easycom": {
|
||||
"custom": {
|
||||
"router-navigate": "uniapp-router-next/components/router-navigate/router-navigate.vue",
|
||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue",
|
||||
"^w-(.*)": "@/components/widgets/$1/$1.vue"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,11 +205,12 @@ const getStats = async () => {
|
|||
if (teacherId) {
|
||||
console.log('首页获取招生统计,teacherId:', teacherId)
|
||||
const res = await getEnrollmentStatistical(teacherId)
|
||||
if (res && res.totalEnrollCount !== undefined) {
|
||||
console.log('招生统计接口返回:', res)
|
||||
if (res && res.total_enroll_count !== undefined) {
|
||||
stats.value = {
|
||||
total: res.totalEnrollCount,
|
||||
today: res.todayEnrollCount,
|
||||
week: res.weekEnrollCount
|
||||
total: res.total_enroll_count,
|
||||
today: res.today_enroll_count,
|
||||
week: res.week_enroll_count
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -65,14 +65,21 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, shallowRef } from 'vue'
|
||||
import { ref, shallowRef, computed } from 'vue'
|
||||
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 { ensureStorageConfig } from '@/utils/configUtils'
|
||||
|
||||
const list = ref<any[]>([])
|
||||
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'))
|
||||
|
|
@ -87,10 +94,17 @@ const initImageSources = async () => {
|
|||
const queryList = async (pageNo: number, pageSize: number) => {
|
||||
console.log('=== queryList 开始执行 ===', pageNo, pageSize)
|
||||
try {
|
||||
const teacherId = currentTeacherId.value
|
||||
if (!teacherId) {
|
||||
console.log('未找到 teacherId,跳过获取招生列表')
|
||||
paging.value.complete([])
|
||||
return
|
||||
}
|
||||
const params = {
|
||||
page: pageNo,
|
||||
limit: pageSize,
|
||||
studentStatus: -1
|
||||
studentStatus: -1,
|
||||
recruitmentTeacherId: teacherId
|
||||
}
|
||||
console.log('请求参数:', params)
|
||||
const res = await getPreRegistrationList(params)
|
||||
|
|
@ -112,8 +126,24 @@ const goBack = () => {
|
|||
uni.navigateBack()
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
onLoad(async () => {
|
||||
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)
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -312,21 +312,59 @@ const alipayJspayPay = async () => {
|
|||
amountFen: Math.round(parseFloat(String(amount.value)) * 100),
|
||||
body: remark.value || '缴费支付',
|
||||
studentId: Number(studentId.value),
|
||||
buyerLogonId: '',
|
||||
buyerLogonId: userStore.userInfo?.mobile || '',
|
||||
includeRawResponse: false
|
||||
})
|
||||
|
||||
// 检查返回结果(后端 AjaxResult.data 为驼峰字段)
|
||||
if (res && res.status === '0' && res.resultCode === '0') {
|
||||
outTradeNo.value = res.outTradeNo || ''
|
||||
// #ifdef H5
|
||||
if (res.payUrl) {
|
||||
window.location.href = res.payUrl
|
||||
// 检查返回结果(后端 AjaxResult 包装,实际数据在 data 字段)
|
||||
console.log('支付接口响应:', res)
|
||||
// 后端返回格式: { code: 1, msg: "成功", data: { status: "0", resultCode: "0", ... } }
|
||||
const payData = res.code === 1 && res.data ? res.data : res
|
||||
console.log('支付数据:', payData)
|
||||
|
||||
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
|
||||
}
|
||||
// #endif
|
||||
|
||||
const payInfo = JSON.parse(res.payInfo || '{}')
|
||||
const payInfo = JSON.parse(payData.payInfo || '{}')
|
||||
console.log('payInfo:', payInfo)
|
||||
|
||||
if (payInfo.tradeNO) {
|
||||
// #ifdef APP-PLUS
|
||||
|
|
@ -345,6 +383,24 @@ const alipayJspayPay = async () => {
|
|||
})
|
||||
// #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
|
||||
if (typeof AlipayJSBridge !== 'undefined') {
|
||||
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) => {
|
||||
uni.redirectTo({
|
||||
|
|
|
|||
|
|
@ -480,6 +480,7 @@ onMounted(() => {
|
|||
onLoad((options: any) => {
|
||||
console.log('=== 预报名页面 onLoad 被触发 ===')
|
||||
console.log('options:', options)
|
||||
console.log('【调试】二维码参数:', { teacherId: options.teacherId, id: options.id, invitationCode: options.invitationCode, scene: options.scene })
|
||||
|
||||
if (options.teacherId) {
|
||||
getTeacherData(options.teacherId)
|
||||
|
|
|
|||
|
|
@ -313,17 +313,17 @@ const getStats = async (teacherId?: number) => {
|
|||
console.log('正在调用 getEnrollmentStatistical, teacherId:', teacherId)
|
||||
const res = await getEnrollmentStatistical(teacherId)
|
||||
console.log('接口返回结果:', res)
|
||||
// 接口直接返回数据对象,没有 code 包装
|
||||
if (res && res.totalEnrollCount !== undefined) {
|
||||
console.log('totalEnrollCount:', res.totalEnrollCount)
|
||||
console.log('todayEnrollCount:', res.todayEnrollCount)
|
||||
console.log('weekEnrollCount:', res.weekEnrollCount)
|
||||
console.log('monthEnrollCount:', res.monthEnrollCount)
|
||||
// 接口返回数据对象
|
||||
if (res && res.total_enroll_count !== undefined) {
|
||||
console.log('total_enroll_count:', res.total_enroll_count)
|
||||
console.log('today_enroll_count:', res.today_enroll_count)
|
||||
console.log('week_enroll_count:', res.week_enroll_count)
|
||||
console.log('month_enroll_count:', res.month_enroll_count)
|
||||
recruitmentStats.value = {
|
||||
total: res.totalEnrollCount,
|
||||
today: res.todayEnrollCount,
|
||||
week: res.weekEnrollCount,
|
||||
month: res.monthEnrollCount
|
||||
total: res.total_enroll_count,
|
||||
today: res.today_enroll_count,
|
||||
week: res.week_enroll_count,
|
||||
month: res.month_enroll_count
|
||||
}
|
||||
console.log('更新后的 recruitmentStats:', recruitmentStats.value)
|
||||
} else {
|
||||
|
|
@ -338,9 +338,14 @@ const getStats = async (teacherId?: number) => {
|
|||
const openQrcodeModal = async () => {
|
||||
showQrcodeModal.value = true
|
||||
if (!qrcodeUrl.value) {
|
||||
console.log('openQrcodeModal: 使用默认 teacherId = 8 获取二维码')
|
||||
const defaultTeacherId = 8
|
||||
await getQrcode(defaultTeacherId)
|
||||
const teacherId = currentTeacherId.value || userInfo.value?.teacherId
|
||||
if (teacherId) {
|
||||
console.log('openQrcodeModal: 使用 teacherId =', teacherId, '获取二维码')
|
||||
await getQrcode(teacherId)
|
||||
} else {
|
||||
console.log('openQrcodeModal: 未找到 teacherId,无法获取二维码')
|
||||
uni.$u.toast('无法获取二维码,请先登录')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue