From 2cd31915236257e325b49f2e86f6912512e1f7ce Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 02 十一月 2025 14:27:15 +0800
Subject: [PATCH] fix:app 用户登录,默认不勾选用户协议
---
app/pages/task/create-emergency.vue | 203 +++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 165 insertions(+), 38 deletions(-)
diff --git a/app/pages/task/create-emergency.vue b/app/pages/task/create-emergency.vue
index a056049..21fa1c0 100644
--- a/app/pages/task/create-emergency.vue
+++ b/app/pages/task/create-emergency.vue
@@ -78,7 +78,7 @@
<view class="form-item">
- <view class="form-label">杞繍鏃堕棿</view>
+ <view class="form-label required">杞繍鏃堕棿</view>
<uni-datetime-picker
v-model="taskForm.transferTime"
type="datetime"
@@ -443,7 +443,7 @@
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
import { addTask } from "@/api/task"
import { listAvailableVehicles, getUserBoundVehicle } from "@/api/vehicle"
-import { calculateDistance } from "@/api/map"
+import { calculateDistance, baiduDistanceByAddress } from "@/api/map"
import { searchHospitals } from "@/api/hospital"
import { listUser } from "@/api/system/user"
import { searchIcd10 } from "@/api/icd10"
@@ -560,6 +560,9 @@
}
},
onLoad(options) {
+ // 璁剧疆榛樿杞繍鏃堕棿涓哄綋鍓嶆椂闂�
+ this.setDefaultTransferTime()
+
// 鍏堝姞杞借溅杈嗗垪琛紝鐒跺悗鍔犺浇缁戝畾杞﹁締淇℃伅
this.getAvailableVehicles().then(() => {
this.getUserBoundVehicleInfo()
@@ -785,25 +788,67 @@
this.taskForm.hospitalIn.departmentId = selected.id // 淇濆瓨绉戝ID
},
- // 鍔犺浇榛樿鍖洪櫌鍒楄〃锛堝墠100鏉★級
+ // 鍔犺浇榛樿鍖婚櫌鍒楄〃锛堝墠100鏉★級
loadDefaultHospitals() {
- // 浼犲叆绌哄瓧绗︿覆鎴栫壒娈婃爣璇嗚幏鍙栧墠100鏉★紝鍚屾椂浼犲叆鍦板煙杩囨护
+ // 杞嚭鍖婚櫌锛氬彧鍔犺浇褰撳墠鍖哄煙鐨勫尰闄紙甯﹀湴鍩熻繃婊わ級
searchHospitals('', this.selectedRegion).then(response => {
- this.defaultHospitals = response.data || []
- // 鍚屾椂鍒濆鍖栦袱涓悳绱㈢粨鏋滀负榛樿鏁版嵁
- this.hospitalOutResults = [...this.defaultHospitals]
- this.hospitalInResults = [...this.defaultHospitals]
+ this.hospitalOutResults = response.data || []
+ console.log('鍔犺浇杞嚭鍖婚櫌锛堝綋鍓嶅尯鍩燂級:', this.selectedRegion, '鏁伴噺:', this.hospitalOutResults.length)
}).catch(error => {
- console.error('鍔犺浇榛樿鍖洪櫌鍒楄〃澶辫触:', error)
- this.defaultHospitals = []
+ console.error('鍔犺浇杞嚭鍖婚櫌鍒楄〃澶辫触:', error)
+ this.hospitalOutResults = []
})
+
+ // 杞叆鍖婚櫌锛氬姞杞芥墍鏈夊尰闄紙涓嶅甫鍦板煙杩囨护锛屽悗缁細鎸夊湴鍩熸帓搴忥級
+ searchHospitals('', this.selectedRegion).then(response => {
+ const allHospitals = response.data || []
+ // 灏嗗尰闄㈡寜鍦板煙鎺掑簭锛氭湰鍦板尯鍩熶紭鍏�
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ console.log('鍔犺浇杞叆鍖婚櫌锛堝叏閮ㄥ尯鍩燂級:', '鏁伴噺:', this.hospitalInResults.length)
+ }).catch(error => {
+ console.error('鍔犺浇杞叆鍖婚櫌鍒楄〃澶辫触:', error)
+ this.hospitalInResults = []
+ })
+ },
+
+ // 鎸夊湴鍩熸帓搴忓尰闄細鏈湴鍖哄煙浼樺厛
+ sortHospitalsByRegion(hospitals) {
+ if (!this.selectedRegion || !hospitals || hospitals.length === 0) {
+ return hospitals
+ }
+
+ const region = this.selectedRegion
+ const localHospitals = []
+ const otherHospitals = []
+
+ hospitals.forEach(hospital => {
+ // 鍒ゆ柇鍖婚櫌鏄惁鍦ㄦ湰鍦板尯鍩燂紙鐪併�佸競銆佸尯浠讳竴鍖呭惈鍦板煙鍏抽敭璇嶏級
+ const isLocal =
+ (hospital.hopsProvince && hospital.hopsProvince.includes(region)) ||
+ (hospital.hopsCity && hospital.hopsCity.includes(region)) ||
+ (hospital.hopsArea && hospital.hopsArea.includes(region))
+
+ if (isLocal) {
+ localHospitals.push(hospital)
+ } else {
+ otherHospitals.push(hospital)
+ }
+ })
+
+ // 鏈湴鍖婚櫌鍦ㄥ墠锛屽叾浠栧尰闄㈠湪鍚�
+ return [...localHospitals, ...otherHospitals]
},
// 杞嚭鍖婚櫌杈撳叆妗嗚幏寰楃劍鐐�
onHospitalOutFocus() {
- // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず榛樿鐨�100鏉℃暟鎹�
+ // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鍙樉绀哄綋鍓嶅尯鍩熺殑鍖婚櫌
if (!this.hospitalOutSearchKeyword || this.hospitalOutSearchKeyword.trim() === '') {
- this.hospitalOutResults = [...this.defaultHospitals]
+ searchHospitals('', this.selectedRegion).then(response => {
+ this.hospitalOutResults = response.data || []
+ }).catch(error => {
+ console.error('鍔犺浇杞嚭鍖婚櫌澶辫触:', error)
+ this.hospitalOutResults = []
+ })
}
this.showHospitalOutResults = true
},
@@ -818,27 +863,33 @@
clearTimeout(this.searchTimer)
}
- // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず榛樿100鏉�
+ // 濡傛灉鍏抽敭璇嶄负绌猴紝鍙樉绀哄綋鍓嶅尯鍩熺殑鍖婚櫌
if (!keyword || keyword.trim() === '') {
- this.hospitalOutResults = [...this.defaultHospitals]
+ searchHospitals('', this.selectedRegion).then(response => {
+ this.hospitalOutResults = response.data || []
+ }).catch(error => {
+ console.error('鍔犺浇杞嚭鍖婚櫌澶辫触:', error)
+ this.hospitalOutResults = []
+ })
this.showHospitalOutResults = true
return
}
- // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储
+ // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储锛堜粎闄愬綋鍓嶅尯鍩燂級
this.searchTimer = setTimeout(() => {
this.searchHospitalOut(keyword)
}, 300)
},
- // 鎼滅储杞嚭鍖婚櫌
+ // 鎼滅储杞嚭鍖婚櫌锛堜粎闄愬綋鍓嶅尯鍩燂級
searchHospitalOut(keyword) {
- // 浼犲叆鍏抽敭璇嶅拰鍦板煙杩囨护
+ // 浼犲叆鍏抽敭璇嶅拰鍦板煙杩囨护锛屽彧鎼滅储褰撳墠鍖哄煙鐨勫尰闄�
searchHospitals(keyword, this.selectedRegion).then(response => {
this.hospitalOutResults = response.data || []
this.showHospitalOutResults = true
+ console.log('鎼滅储杞嚭鍖婚櫌:', keyword, '鍖哄煙:', this.selectedRegion, '缁撴灉鏁�:', this.hospitalOutResults.length)
}).catch(error => {
- console.error('鎼滅储鍖婚櫌澶辫触:', error)
+ console.error('鎼滅储杞嚭鍖婚櫌澶辫触:', error)
this.hospitalOutResults = []
})
},
@@ -854,23 +905,27 @@
this.showHospitalOutResults = false
this.hospitalOutResults = []
- // 濡傛灉鏈塆PS鍧愭爣锛屼繚瀛樹笅鏉�
- // 娉ㄦ剰锛欻ospData琛ㄤ腑鍙兘娌℃湁GPS鍧愭爣锛岄渶瑕佹牴鎹湴鍧�杩涜鍦扮悊缂栫爜
- // 杩欓噷鍏堢疆涓簄ull锛屽悗缁彲浠ラ�氳繃鍦板潃瑙f瀽鑾峰彇
- this.addressCoordinates.hospitalOutAddress = null
+ // 淇濆瓨杞嚭鍖婚櫌鐨勫煄甯備俊鎭�
+ this.taskForm.hospitalOut.city = hospital.hopsCity || ''
// 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
if (this.taskForm.hospitalIn.address) {
- // 杩欓噷鍙互璋冪敤鍦板潃瑙f瀽鍜岃窛绂昏绠�
- // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+ this.calculateHospitalDistance()
}
},
// 杞叆鍖婚櫌杈撳叆妗嗚幏寰楃劍鐐�
onHospitalInFocus() {
- // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず榛樿鐨�100鏉℃暟鎹�
+ // 濡傛灉娌℃湁鎼滅储鍏抽敭璇嶏紝鏄剧ず鎵�鏈夊尰闄紙鏈湴鍖哄煙浼樺厛锛�
if (!this.hospitalInSearchKeyword || this.hospitalInSearchKeyword.trim() === '') {
- this.hospitalInResults = [...this.defaultHospitals]
+ searchHospitals('', '').then(response => {
+ const allHospitals = response.data || []
+ // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ }).catch(error => {
+ console.error('鍔犺浇杞叆鍖婚櫌澶辫触:', error)
+ this.hospitalInResults = []
+ })
}
this.showHospitalInResults = true
},
@@ -885,27 +940,37 @@
clearTimeout(this.searchTimer)
}
- // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず榛樿100鏉�
+ // 濡傛灉鍏抽敭璇嶄负绌猴紝鏄剧ず鎵�鏈夊尰闄紙鏈湴鍖哄煙浼樺厛锛�
if (!keyword || keyword.trim() === '') {
- this.hospitalInResults = [...this.defaultHospitals]
+ searchHospitals('', '').then(response => {
+ const allHospitals = response.data || []
+ // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
+ }).catch(error => {
+ console.error('鍔犺浇杞叆鍖婚櫌澶辫触:', error)
+ this.hospitalInResults = []
+ })
this.showHospitalInResults = true
return
}
- // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储
+ // 鏈夊叧閿瘝鏃讹紝鍘绘湇鍔$鎼滅储锛堜笉闄愬尯鍩燂紝浣嗙粨鏋滄寜鍦板煙鎺掑簭锛�
this.searchTimer = setTimeout(() => {
this.searchHospitalIn(keyword)
}, 300)
},
- // 鎼滅储杞叆鍖婚櫌
+ // 鎼滅储杞叆鍖婚櫌锛堜笉闄愬尯鍩燂紝浣嗘湰鍦板尯鍩熶紭鍏堬級
searchHospitalIn(keyword) {
- // 浼犲叆鍏抽敭璇嶅拰鍦板煙杩囨护
- searchHospitals(keyword, this.selectedRegion).then(response => {
- this.hospitalInResults = response.data || []
+ // 浼犲叆鍏抽敭璇嶏紝涓嶄紶鍦板煙杩囨护锛堟悳绱㈡墍鏈夊尯鍩燂級
+ searchHospitals(keyword, '').then(response => {
+ const allHospitals = response.data || []
+ // 鎸夊湴鍩熸帓搴忥細鏈湴鍖哄煙浼樺厛
+ this.hospitalInResults = this.sortHospitalsByRegion(allHospitals)
this.showHospitalInResults = true
+ console.log('鎼滅储杞叆鍖婚櫌:', keyword, '缁撴灉鏁�:', this.hospitalInResults.length)
}).catch(error => {
- console.error('鎼滅储鍖婚櫌澶辫触:', error)
+ console.error('鎼滅储杞叆鍖婚櫌澶辫触:', error)
this.hospitalInResults = []
})
},
@@ -921,13 +986,12 @@
this.showHospitalInResults = false
this.hospitalInResults = []
- // 濡傛灉鏈塆PS鍧愭爣锛屼繚瀛樹笅鏉�
- this.addressCoordinates.hospitalInAddress = null
+ // 淇濆瓨杞叆鍖婚櫌鐨勫煄甯備俊鎭�
+ this.taskForm.hospitalIn.city = hospital.hopsCity || ''
// 濡傛灉涓や釜鍖婚櫌閮藉凡閫夋嫨锛岃嚜鍔ㄨ绠楄窛绂�
if (this.taskForm.hospitalOut.address) {
- // 杩欓噷鍙互璋冪敤鍦板潃瑙f瀽鍜岃窛绂昏绠�
- // 鏆傛椂鐣欑┖锛岀敱鐢ㄦ埛鎵嬪姩杈撳叆璺濈
+ this.calculateHospitalDistance()
}
},
@@ -1206,6 +1270,20 @@
this.selectedDiseases.splice(index, 1)
},
+ // 璁剧疆榛樿杞繍鏃堕棿涓哄綋鍓嶆椂闂�
+ setDefaultTransferTime() {
+ const now = new Date()
+ const year = now.getFullYear()
+ const month = String(now.getMonth() + 1).padStart(2, '0')
+ const day = String(now.getDate()).padStart(2, '0')
+ const hours = String(now.getHours()).padStart(2, '0')
+ const minutes = String(now.getMinutes()).padStart(2, '0')
+ const seconds = String(now.getSeconds()).padStart(2, '0')
+
+ // 鏍煎紡鍖栦负 YYYY-MM-DD HH:mm:ss
+ this.taskForm.transferTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
+ },
+
validateForm() {
if (!this.selectedVehicleId) {
this.$modal.showToast('璇烽�夋嫨浠诲姟杞﹁締')
@@ -1219,6 +1297,11 @@
if (!this.selectedDocumentType) {
this.$modal.showToast('璇烽�夋嫨鍗曟嵁绫诲瀷')
+ return false
+ }
+
+ if (!this.taskForm.transferTime) {
+ this.$modal.showToast('璇烽�夋嫨杞繍鏃堕棿')
return false
}
@@ -1382,6 +1465,50 @@
parts.push(hospital.hospAddress)
}
return parts.join('')
+ },
+
+ // 鑷姩璁$畻涓や釜鍖婚櫌涔嬮棿鐨勮窛绂�
+ calculateHospitalDistance() {
+ const fromAddress = this.taskForm.hospitalOut.address
+ const fromCity = this.taskForm.hospitalOut.city
+ const toAddress = this.taskForm.hospitalIn.address
+ const toCity = this.taskForm.hospitalIn.city
+
+ if (!fromAddress || !toAddress) {
+ console.log('鍦板潃淇℃伅涓嶅畬鏁达紝鏃犳硶璁$畻璺濈')
+ return
+ }
+
+ console.log('寮�濮嬭绠楄窛绂�:', fromAddress, '->', toAddress)
+
+ // 鏄剧ず鍔犺浇鎻愮ず
+ uni.showLoading({
+ title: '璁$畻璺濈涓�...'
+ })
+
+ // 璋冪敤鐧惧害鍦板浘API璁$畻璺濈
+ baiduDistanceByAddress(fromAddress, fromCity, toAddress, toCity)
+ .then(response => {
+ uni.hideLoading()
+
+ if (response.code === 200 && response.data) {
+ const distanceInMeters = response.data.distance
+ // 杞崲涓哄叕閲岋紝淇濈暀1浣嶅皬鏁�
+ const distanceInKm = (distanceInMeters / 1000).toFixed(1)
+ this.taskForm.transferDistance = distanceInKm
+
+ console.log('璺濈璁$畻鎴愬姛:', distanceInKm, 'km')
+ // this.$modal.showToast(`璺濈璁$畻鎴愬姛: ${distanceInKm}鍏噷`)
+ } else {
+ console.error('璺濈璁$畻澶辫触:', response.msg)
+ this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+ }
+ })
+ .catch(error => {
+ uni.hideLoading()
+ console.error('璺濈璁$畻澶辫触:', error)
+ this.$modal.showToast('璺濈璁$畻澶辫触锛岃鎵嬪姩杈撳叆')
+ })
}
}
}
--
Gitblit v1.9.1