From 2437d21cc4e88f7283d96ea4172b4ddd298999b9 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Mon, 1 Dec 2025 18:05:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/reservation/index.vue | 67 +++++++++++-------- unpackage/dist/build/web/index.html | 2 +- .../{index.c970d746.js => index.14b82f73.js} | 2 +- .../js/pages-reservation-index.206014f9.js | 1 - .../js/pages-reservation-index.52621408.js | 1 + 5 files changed, 42 insertions(+), 31 deletions(-) rename unpackage/dist/build/web/static/js/{index.c970d746.js => index.14b82f73.js} (99%) delete mode 100644 unpackage/dist/build/web/static/js/pages-reservation-index.206014f9.js create mode 100644 unpackage/dist/build/web/static/js/pages-reservation-index.52621408.js diff --git a/pages/reservation/index.vue b/pages/reservation/index.vue index 5ec02e5..bb833b1 100644 --- a/pages/reservation/index.vue +++ b/pages/reservation/index.vue @@ -125,13 +125,17 @@ export default { this.isWeixinBrowser = /MicroMessenger/i.test(navigator.userAgent) // #endif }, - onShow() { - this.fetchDirectionEnum().then(() => { - this.fetchShipTypeEnum().then(() => { - this.fetchShipList(); - }); - }); - // 进入页面先提示需要获取位置信息,用户确认后再获取 + async onShow() { + // 先拉取方向、船型和可用船舶信息,如果没有可用船舶,则直接返回,不再进行后续操作(如获取位置信息等) + await this.fetchDirectionEnum(); + await this.fetchShipTypeEnum(); + const hasShip = await this.fetchShipList(); + if (!hasShip) { + // 已在 fetchShipList 内部给出提示并跳转 + return; + } + + // 有可用船舶时,再弹出获取位置信息的提示 uni.showModal({ title: '提示', content: '预约前需要先获取您的位置信息', @@ -150,8 +154,9 @@ export default { } } }); + + // 最后再拉取每日预约截止时间并设置默认日期 this.fetchDailyReservationDeadline(); - }, methods: { // 获取用户位置 @@ -493,7 +498,10 @@ export default { }, async fetchShipList() { const token = uni.getStorageSync('token'); - if (!token) return; + if (!token) { + uni.showToast({ title: '请先登录', icon: 'none' }); + return false; + } try { const res = await new Promise((resolve, reject) => { uni.request({ @@ -505,28 +513,31 @@ export default { }); if (res.data && res.data.errcode === 0) { - - if (!res.data.data) { - uni.showToast({ title: '暂无船舶信息', icon: 'none' }); - setTimeout(() => { - uni.navigateBack(); - uni.navigateTo({ url: '/pages/index/ship_manage' }); - }, 1000); - return; - } + if (!res.data.data) { + uni.showToast({ title: '暂无船舶信息', icon: 'none', duration: 1500 }); + setTimeout(() => { + uni.redirectTo({ url: '/pages/index/ship_manage' }); + }, 1000); + return false; + } - this.currentShip = { - id: res.data.data.id, - total_length: res.data.data.total_length, - total_width: res.data.data.total_width, - molded_depth: res.data.data.molded_depth, - ship_number: res.data.data.ship_number, - total_tonnage: res.data.data.total_tonnage, - ship_type: res.data.data.ship_type - }; + this.currentShip = { + id: res.data.data.id, + total_length: res.data.data.total_length, + total_width: res.data.data.total_width, + molded_depth: res.data.data.molded_depth, + ship_number: res.data.data.ship_number, + total_tonnage: res.data.data.total_tonnage, + ship_type: res.data.data.ship_type + }; + return true; + } else { + uni.showToast({ title: (res.data && res.data.errmsg) || '获取船舶信息失败', icon: 'none' }); + return false; } } catch (e) { - // 可选:错误处理 + uni.showToast({ title: '网络错误', icon: 'none' }); + return false; } }, async fetchDirectionEnum() { diff --git a/unpackage/dist/build/web/index.html b/unpackage/dist/build/web/index.html index 19037dc..21a2498 100644 --- a/unpackage/dist/build/web/index.html +++ b/unpackage/dist/build/web/index.html @@ -1,2 +1,2 @@