diff --git a/admin/src/api/index.js b/admin/src/api/index.js index c79000b..14aceae 100644 --- a/admin/src/api/index.js +++ b/admin/src/api/index.js @@ -808,7 +808,7 @@ export const deletePolicy = (id) => { */ export const getTourRoutePage = (current = 1, size = 10, keyword = '') => { return request({ - url: '/tourroute/admin/page', + url: '/tour/admin/page', method: 'get', params: { current, @@ -823,7 +823,7 @@ export const getTourRoutePage = (current = 1, size = 10, keyword = '') => { */ export const getTourRouteById = (id) => { return request({ - url: `/tourroute/${id}`, + url: `/tour/${id}`, method: 'get' }) } @@ -833,7 +833,7 @@ export const getTourRouteById = (id) => { */ export const addTourRoute = (data) => { return request({ - url: '/tourroute/admin/create', + url: '/tour/admin/create', method: 'post', data }) @@ -844,7 +844,7 @@ export const addTourRoute = (data) => { */ export const updateTourRoute = (id, data) => { return request({ - url: `/tourroute/admin/update/${id}`, + url: `/tour/admin/update/${id}`, method: 'put', data }) @@ -855,7 +855,7 @@ export const updateTourRoute = (id, data) => { */ export const deleteTourRoute = (id) => { return request({ - url: `/tourroute/admin/delete/${id}`, + url: `/tour/admin/delete/${id}`, method: 'delete' }) } \ No newline at end of file diff --git a/miniprogram/pages/filing/filing.vue b/miniprogram/pages/filing/filing.vue index d7160ba..ad342be 100644 --- a/miniprogram/pages/filing/filing.vue +++ b/miniprogram/pages/filing/filing.vue @@ -460,8 +460,13 @@ export default { const isSuccess = response.code === 200 || response.code === 0 if (isSuccess) { - // 新的响应格式:data直接是文件名 - const fileUrl = response.data + // 确保文件URL是字符串格式 + let fileUrl = response.data + if (typeof fileUrl === 'object') { + fileUrl = fileUrl.url || fileUrl.filename || fileUrl.path || JSON.stringify(fileUrl) + } + fileUrl = String(fileUrl) + // 根据field类型设置对应的后端字段 if (field === 'permit') { this.form.shootPermit = fileUrl @@ -518,7 +523,12 @@ export default { duration: 3000 }) } finally { - uni.hideLoading() + // 安全地隐藏loading,避免"toast can't be found"错误 + try { + uni.hideLoading() + } catch (e) { + console.warn('隐藏loading时出错:', e) + } } } else { console.error('3. 文件路径未找到,无法上传') @@ -614,13 +624,13 @@ export default { this.submitting = true try { - // 准备提交数据,使用后端期望的字段名 + // 准备提交数据,确保数据类型与后端匹配 const reportData = { name: this.form.name, type: this.form.type, genre: this.form.genre, - episodes: this.form.episodes, - investAmount: this.form.investAmount, + episodes: parseInt(this.form.episodes) || 0, + investAmount: parseFloat(this.form.investAmount) || 0, mainCreators: this.form.mainCreators, leadProducer: this.form.leadProducer, producerUnit: this.form.producerUnit, @@ -631,13 +641,13 @@ export default { phoneNumber: this.form.phoneNumber, crewPosition: this.form.crewPosition, status: this.reportId ? undefined : 'PENDING', // 新增报备设置为'PENDING',编辑时保持原状态 - // 使用后端期望的字段名 - shootPermit: this.form.shootPermit, - thumbShootPermit: this.form.thumbShootPermit, - approvalFile: this.form.approvalFile, - thumbApprovalFile: this.form.thumbApprovalFile, - shootApply: this.form.shootApply || '', - thumbShootApply: this.form.thumbShootApply || '' + // 确保文件字段都是字符串类型 + shootPermit: this.ensureString(this.form.shootPermit), + thumbShootPermit: this.ensureString(this.form.thumbShootPermit), + approvalFile: this.ensureString(this.form.approvalFile), + thumbApprovalFile: this.ensureString(this.form.thumbApprovalFile), + shootApply: this.ensureString(this.form.shootApply), + thumbShootApply: this.ensureString(this.form.thumbShootApply) } console.log('提交数据:', reportData) @@ -689,6 +699,19 @@ export default { this.submitting = false } }, + // 确保值为字符串类型 + ensureString(value) { + if (value === null || value === undefined) { + return '' + } + if (typeof value === 'string') { + return value + } + if (typeof value === 'object') { + return value.url || value.filename || value.path || JSON.stringify(value) + } + return String(value) + }, resetForm() { this.form = { name: '', diff --git a/miniprogram/pages/policy/policy.vue b/miniprogram/pages/policy/policy.vue index 8c7f305..ee0d330 100644 --- a/miniprogram/pages/policy/policy.vue +++ b/miniprogram/pages/policy/policy.vue @@ -134,8 +134,9 @@ export default { type: this.selectedType === '全部' ? undefined : this.selectedType }) - if (res.code === 200 && res.data) { - const newPolicies = res.data.map(item => ({ + // 处理游标分页响应格式 + if (res && res.records) { + const newPolicies = res.records.map(item => ({ id: item.id, title: item.title, type: item.type, @@ -150,16 +151,12 @@ export default { this.policies = [...this.policies, ...newPolicies] } - // 更新分页信息 - if (res.pagination) { - this.totalPages = res.pagination.totalPages - this.hasMore = this.currentPage < this.totalPages - } else { - this.hasMore = newPolicies.length >= this.pageSize - } + // 更新游标分页信息 + this.hasMore = res.hasMore || false } else { + console.error('政策数据格式错误:', res) uni.showToast({ - title: res.message || '加载失败', + title: '数据格式错误', icon: 'none' }) } diff --git a/miniprogram/pages/tourroute/tourroute.vue b/miniprogram/pages/tourroute/tourroute.vue index b34206f..bf1cf99 100644 --- a/miniprogram/pages/tourroute/tourroute.vue +++ b/miniprogram/pages/tourroute/tourroute.vue @@ -126,15 +126,7 @@ export default { } else { this.routes = [...this.routes, ...newRoutes] } - ] - - try { - const res = await getTourPage({ - current: this.currentPage, - size: this.pageSize, - keyword: this.keyword || undefined - }) - + this.nextCursor = res.nextCursor this.hasMore = res.hasMore || false } else { diff --git a/miniprogram/services/backend-api.ts b/miniprogram/services/backend-api.ts index 27b240e..e95d431 100644 --- a/miniprogram/services/backend-api.ts +++ b/miniprogram/services/backend-api.ts @@ -61,14 +61,14 @@ export const getDramaById = (id: number) => { * 获取旅游线路列表(分页) */ export const getTourPage = async (params: { - current?: number + cursor?: string size?: number keyword?: string }) => { try { - console.log('调用getTourPage API,URL: /tourroute/admin/page, 参数:', params) - const result = await http>({ - url: '/tourroute/admin/page', + console.log('调用getTourPage API,URL: /tour/page, 参数:', params) + const result = await http({ + url: '/tour/page', method: 'GET', data: params })