From 97db9d11ff425583d2dece82a842a7766bb5e7e4 Mon Sep 17 00:00:00 2001 From: wlzboy <66905212@qq.com> Date: 星期五, 26 九月 2025 21:43:39 +0800 Subject: [PATCH] feat: 添加map --- app/pages/task/create.vue | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 154 insertions(+), 7 deletions(-) diff --git a/app/pages/task/create.vue b/app/pages/task/create.vue index 1cf4741..0970acd 100644 --- a/app/pages/task/create.vue +++ b/app/pages/task/create.vue @@ -475,16 +475,37 @@ </view> </view> </view> + + <!-- 鍦板浘閫夋嫨鍣ㄥ脊绐� --> + <uni-popup ref="mapPopup" type="bottom" :mask-click="false"> + <view class="map-popup-container"> + <view class="popup-header"> + <view class="popup-title">閫夋嫨鍦板潃</view> + <view class="close-btn" @click="closeMapSelector"> + <uni-icons type="closeempty" size="20" color="#999"></uni-icons> + </view> + </view> + <map-selector + :initial-address="getInitialAddress()" + @addressSelected="onAddressSelected" + ></map-selector> + </view> + </uni-popup> </scroll-view> </template> <script> import { mapState } from 'vuex' import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue' + import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue' + import { getUserProfile } from "@/api/system/user" + import MapSelector from '@/components/map-selector.vue' export default { components: { - uniDatetimePicker + uniDatetimePicker, + uniPopup, + MapSelector }, data() { return { @@ -492,6 +513,10 @@ selectedVehicle: '', selectedOrganization: '', selectedEmergencyTaskType: '', + boundVehicle: '', // 鐢ㄦ埛缁戝畾鐨勮溅杈� + // 鍦板浘閫夋嫨鐩稿叧 + showMapSelector: false, + mapSelectorType: '', // 鏍囪瘑褰撳墠閫夋嫨鐨勬槸鍝釜鍦板潃瀛楁 taskForm: { description: '', startLocation: '', @@ -575,9 +600,34 @@ }) }) }, + onLoad() { + // 鑾峰彇鐢ㄦ埛缁戝畾鐨勮溅杈嗕俊鎭� + this.getUserBoundVehicle() + }, methods: { + // 鑾峰彇鐢ㄦ埛缁戝畾鐨勮溅杈嗕俊鎭� + getUserBoundVehicle() { + getUserProfile().then(response => { + // 杩欓噷妯℃嫙浠庣敤鎴蜂俊鎭腑鑾峰彇缁戝畾杞﹁締锛屽疄闄呴」鐩腑搴旇浠巖esponse.data涓幏鍙� + // 鍋囪鐢ㄦ埛淇℃伅涓湁boundVehicle瀛楁 + this.boundVehicle = '绮12345' // 妯℃嫙鍊硷紝瀹為檯搴斾粠response.data.boundVehicle鑾峰彇 + + // 濡傛灉鏈夌粦瀹氳溅杈嗭紝鍒欓粯璁ら�変腑 + if (this.boundVehicle) { + this.selectedVehicle = this.boundVehicle + } + }).catch(() => { + // 鑾峰彇鐢ㄦ埛淇℃伅澶辫触鏃朵娇鐢ㄩ粯璁ゅ�� + this.boundVehicle = '' + }) + }, + selectTaskCategory(category) { this.selectedTaskCategory = category + // 褰撻�夋嫨浠诲姟绫诲瀷鏃讹紝濡傛灉鏄櫘閫氫换鍔′笖鐢ㄦ埛鏈夌粦瀹氳溅杈嗭紝鍒欓粯璁ら�変腑缁戝畾杞﹁締 + if (category.type === 'normal' && this.boundVehicle) { + this.selectedVehicle = this.boundVehicle + } }, backToCategory() { @@ -596,28 +646,94 @@ this.selectedEmergencyTaskType = this.emergencyTaskTypes[e.detail.value] }, + // 鏄剧ず鍦板浘閫夋嫨鍣� - 浠诲姟鍑哄彂鍦� selectStartLocation() { - this.$modal.showToast('閫夋嫨鍑哄彂鍦板姛鑳藉紑鍙戜腑') + this.mapSelectorType = 'startLocation' + this.$refs.mapPopup.open() }, + // 鏄剧ず鍦板浘閫夋嫨鍣� - 浠诲姟鐩殑鍦� selectEndLocation() { - this.$modal.showToast('閫夋嫨鐩殑鍦板姛鑳藉紑鍙戜腑') + this.mapSelectorType = 'endLocation' + this.$refs.mapPopup.open() }, + // 鏄剧ず鍦板浘閫夋嫨鍣� - 杞嚭鍖婚櫌鍦板潃 selectHospitalOutAddress() { - this.$modal.showToast('閫夋嫨杞嚭鍖婚櫌鍦板潃鍔熻兘寮�鍙戜腑') + this.mapSelectorType = 'hospitalOutAddress' + this.$refs.mapPopup.open() }, + // 鏄剧ず鍦板浘閫夋嫨鍣� - 杞叆鍖婚櫌鍦板潃 selectHospitalInAddress() { - this.$modal.showToast('閫夋嫨杞叆鍖婚櫌鍦板潃鍔熻兘寮�鍙戜腑') + this.mapSelectorType = 'hospitalInAddress' + this.$refs.mapPopup.open() }, + // 鏄剧ず鍦板浘閫夋嫨鍣� - 绂忕杞﹀嚭鍙戝湴鍧� selectStartAddress() { - this.$modal.showToast('閫夋嫨鍑哄彂鍦板潃鍔熻兘寮�鍙戜腑') + this.mapSelectorType = 'startAddress' + this.$refs.mapPopup.open() }, + // 鏄剧ず鍦板浘閫夋嫨鍣� - 绂忕杞︾洰鐨勫湴鍧� selectEndAddress() { - this.$modal.showToast('閫夋嫨鐩殑鍦板潃鍔熻兘寮�鍙戜腑') + this.mapSelectorType = 'endAddress' + this.$refs.mapPopup.open() + }, + + // 鑾峰彇鍒濆鍦板潃鐢ㄤ簬鍦板浘鎼滅储 + getInitialAddress() { + switch (this.mapSelectorType) { + case 'startLocation': + return this.taskForm.startLocation + case 'endLocation': + return this.taskForm.endLocation + case 'hospitalOutAddress': + return this.taskForm.hospitalOut.address + case 'hospitalInAddress': + return this.taskForm.hospitalIn.address + case 'startAddress': + return this.taskForm.startAddress + case 'endAddress': + return this.taskForm.endAddress + default: + return '' + } + }, + + // 鍦板浘閫夋嫨鍣ㄥ湴鍧�閫夋嫨鍥炶皟 + onAddressSelected(address) { + // 鏍规嵁涓嶅悓鐨勫湴鍧�绫诲瀷璁剧疆瀵瑰簲鐨勮〃鍗曞瓧娈� + switch (this.mapSelectorType) { + case 'startLocation': + this.taskForm.startLocation = address.title + ' - ' + address.address + break + case 'endLocation': + this.taskForm.endLocation = address.title + ' - ' + address.address + break + case 'hospitalOutAddress': + this.taskForm.hospitalOut.address = address.title + ' - ' + address.address + break + case 'hospitalInAddress': + this.taskForm.hospitalIn.address = address.title + ' - ' + address.address + break + case 'startAddress': + this.taskForm.startAddress = address.title + ' - ' + address.address + break + case 'endAddress': + this.taskForm.endAddress = address.title + ' - ' + address.address + break + } + + // 鍏抽棴鍦板浘閫夋嫨鍣� + this.closeMapSelector() + }, + + // 鍏抽棴鍦板浘閫夋嫨鍣� + closeMapSelector() { + this.$refs.mapPopup.close() + this.mapSelectorType = '' }, addStaff() { @@ -852,5 +968,36 @@ } } } + + // 鍦板浘閫夋嫨鍣ㄥ脊绐楁牱寮� + .map-popup-container { + height: 80vh; + background-color: white; + border-top-left-radius: 20rpx; + border-top-right-radius: 20rpx; + overflow: hidden; + + .popup-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 20rpx 30rpx; + border-bottom: 1rpx solid #f0f0f0; + + .popup-title { + font-size: 32rpx; + font-weight: bold; + color: #333; + } + + .close-btn { + width: 50rpx; + height: 50rpx; + display: flex; + align-items: center; + justify-content: center; + } + } + } } </style> \ No newline at end of file -- Gitblit v1.9.1