Commit fbca9085171298f416a76a28c56bb779d939d343
1 parent
177df08c
提交12-9
Showing
9 changed files
with
250 additions
and
935 deletions
Too many changes to show.
To preserve performance only 9 of 11 files are displayed.
garbage-removal/src/apis/order.js
| @@ -211,3 +211,12 @@ export async function insertRandomCopyByTypeAndOrderId(params) { | @@ -211,3 +211,12 @@ export async function insertRandomCopyByTypeAndOrderId(params) { | ||
| 211 | export async function selectGarOrderCar(orderNo) { | 211 | export async function selectGarOrderCar(orderNo) { |
| 212 | return await request.get(`/order/selectGarOrderCar/${orderNo}`); | 212 | return await request.get(`/order/selectGarOrderCar/${orderNo}`); |
| 213 | } | 213 | } |
| 214 | + | ||
| 215 | +export async function deleteDriverByOrderNo(orderNo, carCode) { | ||
| 216 | + return await request.post(`/order/deleteDriverByOrderNo`, null, { | ||
| 217 | + params: { | ||
| 218 | + orderNo, | ||
| 219 | + carCode | ||
| 220 | + } | ||
| 221 | + }); | ||
| 222 | +} |
garbage-removal/src/components/liu-delivery-time/liu-delivery-time.vue
| @@ -125,143 +125,69 @@ const getFutureDays = () => { | @@ -125,143 +125,69 @@ const getFutureDays = () => { | ||
| 125 | 125 | ||
| 126 | 126 | ||
| 127 | const getTimeList = () => { | 127 | const getTimeList = () => { |
| 128 | - const timeList = [{ | ||
| 129 | - time: '00:00-01:00', | ||
| 130 | - start: '00:00', | ||
| 131 | - end: '01:00', | ||
| 132 | - timeStr:'22-07' | ||
| 133 | - },{ | ||
| 134 | - time: '01:00-02:00', | ||
| 135 | - start: '01:00', | ||
| 136 | - end: '02:00', | ||
| 137 | - timeStr:'22-07' | ||
| 138 | - },{ | ||
| 139 | - time: '02:00-03:00', | ||
| 140 | - start: '02:00', | ||
| 141 | - end: '03:00', | ||
| 142 | - timeStr:'22-07' | ||
| 143 | - },{ | ||
| 144 | - time: '03:00-04:00', | ||
| 145 | - start: '03:00', | ||
| 146 | - end: '04:00', | ||
| 147 | - timeStr:'22-07' | ||
| 148 | - },{ | ||
| 149 | - time: '04:00-05:00', | ||
| 150 | - start: '04:00', | ||
| 151 | - end: '05:00', | ||
| 152 | - timeStr:'22-07' | ||
| 153 | - },{ | ||
| 154 | - time: '05:00-06:00', | ||
| 155 | - start: '05:00', | ||
| 156 | - end: '06:00', | ||
| 157 | - timeStr:'22-07' | ||
| 158 | - },{ | ||
| 159 | - time: '06:00-07:00', | ||
| 160 | - start: '06:00', | ||
| 161 | - end: '07:00', | ||
| 162 | - timeStr:'22-07' | ||
| 163 | - },{ | ||
| 164 | - time: '07:00-08:00', | ||
| 165 | - start: '07:00', | ||
| 166 | - end: '08:00', | ||
| 167 | - timeStr:'07-08' | ||
| 168 | - },{ | ||
| 169 | - time: '08:00-09:00', | ||
| 170 | - start: '08:00', | ||
| 171 | - end: '09:00', | ||
| 172 | - timeStr:'08-09' | ||
| 173 | - },{ | ||
| 174 | - time: '09:00-10:00', | ||
| 175 | - start: '09:00', | ||
| 176 | - end: '10:00', | ||
| 177 | - timeStr:'09-10' | ||
| 178 | - }, | ||
| 179 | - { | ||
| 180 | - time: '10:00-11:00', | ||
| 181 | - start: '10:00', | ||
| 182 | - end: '11:00', | ||
| 183 | - timeStr:'10-11' | ||
| 184 | - }, | ||
| 185 | - { | ||
| 186 | - time: '11:00-12:00', | ||
| 187 | - start: '11:00', | ||
| 188 | - end: '12:00', | ||
| 189 | - timeStr:'11-12' | ||
| 190 | - }, | ||
| 191 | - { | ||
| 192 | - time: '12:00-13:00', | ||
| 193 | - start: '12:00', | ||
| 194 | - end: '13:00', | ||
| 195 | - timeStr:'12-13' | ||
| 196 | - }, | ||
| 197 | - { | ||
| 198 | - time: '13:00-14:00', | ||
| 199 | - start: '13:00', | ||
| 200 | - end: '14:00', | ||
| 201 | - timeStr:'13-14' | ||
| 202 | - }, | ||
| 203 | - { | ||
| 204 | - time: '14:00-15:00', | ||
| 205 | - start: '14:00', | ||
| 206 | - end: '15:00', | ||
| 207 | - timeStr:'14-15' | ||
| 208 | - }, | ||
| 209 | - { | ||
| 210 | - time: '15:00-16:00', | ||
| 211 | - start: '15:00', | ||
| 212 | - end: '16:00', | ||
| 213 | - timeStr:'15-16' | ||
| 214 | - }, | ||
| 215 | - { | ||
| 216 | - time: '16:00-17:00', | ||
| 217 | - start: '16:00', | ||
| 218 | - end: '17:00', | ||
| 219 | - timeStr:'16-17' | ||
| 220 | - }, | ||
| 221 | - { | ||
| 222 | - time: '17:00-18:00', | ||
| 223 | - start: '17:00', | ||
| 224 | - end: '18:00', | ||
| 225 | - timeStr:'17-18' | ||
| 226 | - }, | ||
| 227 | - { | ||
| 228 | - time: '18:00-19:00', | ||
| 229 | - start: '18:00', | ||
| 230 | - end: '19:00', | ||
| 231 | - timeStr:'18-19' | ||
| 232 | - }, | ||
| 233 | - { | ||
| 234 | - time: '19:00-20:00', | ||
| 235 | - start: '19:00', | ||
| 236 | - end: '20:00', | ||
| 237 | - timeStr:'19-20' | ||
| 238 | - }, | ||
| 239 | - { | ||
| 240 | - time: '20:00-21:00', | ||
| 241 | - start: '20:00', | ||
| 242 | - end: '21:00', | ||
| 243 | - timeStr:'20-21' | ||
| 244 | - }, | ||
| 245 | - { | ||
| 246 | - time: '21:00-22:00', | ||
| 247 | - start: '21:00', | ||
| 248 | - end: '22:00', | ||
| 249 | - timeStr:'21-22' | ||
| 250 | - }, | ||
| 251 | - { | ||
| 252 | - time: '22:00-23:00', | ||
| 253 | - start: '22:00', | ||
| 254 | - end: '23:00', | ||
| 255 | - timeStr:'22-07' | ||
| 256 | - }, | ||
| 257 | - { | ||
| 258 | - time: '23:00-24:00', | ||
| 259 | - start: '23:00', | ||
| 260 | - end: '24:00', | ||
| 261 | - timeStr:'22-07' | ||
| 262 | - } | ||
| 263 | - ]; | ||
| 264 | - return timeList | 128 | + const timeList = [{ |
| 129 | + time: '00:00-02:00', | ||
| 130 | + start: '00:00', | ||
| 131 | + end: '02:00', | ||
| 132 | + timeStr:'22-07' | ||
| 133 | + },{ | ||
| 134 | + time: '02:00-04:00', | ||
| 135 | + start: '02:00', | ||
| 136 | + end: '04:00', | ||
| 137 | + timeStr:'22-07' | ||
| 138 | + },{ | ||
| 139 | + time: '04:00-06:00', | ||
| 140 | + start: '04:00', | ||
| 141 | + end: '06:00', | ||
| 142 | + timeStr:'22-07' | ||
| 143 | + },{ | ||
| 144 | + time: '06:00-08:00', | ||
| 145 | + start: '06:00', | ||
| 146 | + end: '08:00', | ||
| 147 | + timeStr:'22-07' | ||
| 148 | + },{ | ||
| 149 | + time: '08:00-10:00', | ||
| 150 | + start: '08:00', | ||
| 151 | + end: '10:00', | ||
| 152 | + timeStr:'07-08' | ||
| 153 | + },{ | ||
| 154 | + time: '10:00-12:00', | ||
| 155 | + start: '10:00', | ||
| 156 | + end: '12:00', | ||
| 157 | + timeStr:'10-11' | ||
| 158 | + },{ | ||
| 159 | + time: '12:00-14:00', | ||
| 160 | + start: '12:00', | ||
| 161 | + end: '14:00', | ||
| 162 | + timeStr:'12-13' | ||
| 163 | + },{ | ||
| 164 | + time: '14:00-16:00', | ||
| 165 | + start: '14:00', | ||
| 166 | + end: '16:00', | ||
| 167 | + timeStr:'14-15' | ||
| 168 | + },{ | ||
| 169 | + time: '16:00-18:00', | ||
| 170 | + start: '16:00', | ||
| 171 | + end: '18:00', | ||
| 172 | + timeStr:'16-17' | ||
| 173 | + },{ | ||
| 174 | + time: '18:00-20:00', | ||
| 175 | + start: '18:00', | ||
| 176 | + end: '20:00', | ||
| 177 | + timeStr:'18-19' | ||
| 178 | + },{ | ||
| 179 | + time: '20:00-22:00', | ||
| 180 | + start: '20:00', | ||
| 181 | + end: '22:00', | ||
| 182 | + timeStr:'20-21' | ||
| 183 | + },{ | ||
| 184 | + time: '22:00-24:00', | ||
| 185 | + start: '22:00', | ||
| 186 | + end: '24:00', | ||
| 187 | + timeStr:'22-07' | ||
| 188 | + } | ||
| 189 | + ]; | ||
| 190 | + return timeList | ||
| 265 | } | 191 | } |
| 266 | 192 | ||
| 267 | /** | 193 | /** |
| @@ -271,12 +197,15 @@ const getTimeList = () => { | @@ -271,12 +197,15 @@ const getTimeList = () => { | ||
| 271 | * @param {*} skip 跳过几个 | 197 | * @param {*} skip 跳过几个 |
| 272 | */ | 198 | */ |
| 273 | const getCurrentDayTimeList = (startTime, hours, skip) => { | 199 | const getCurrentDayTimeList = (startTime, hours, skip) => { |
| 274 | - const timeList = getTimeList(); | ||
| 275 | - // 因为从9点开始所以从9点开始截取 | ||
| 276 | - // let startIndex = startTime + skip; | ||
| 277 | - let abs = startTime > hours ? 1 : -1; | ||
| 278 | - let index = startTime - hours >= skip ? 0 : (startTime - hours) * abs + skip; | ||
| 279 | - return timeList.slice(index, timeList.length + 1) | 200 | + const timeList = getTimeList(); |
| 201 | + // 计算当前小时所属的时间段索引 | ||
| 202 | + // 每个时间段是2小时,从00:00-02:00开始 | ||
| 203 | + let index = Math.floor(hours / 2) + 1; // 加1是为了跳过已过期的时间段 | ||
| 204 | + // 确保不会超出数组范围 | ||
| 205 | + if (index >= timeList.length) { | ||
| 206 | + return []; // 如果没有可选时间段,返回空数组 | ||
| 207 | + } | ||
| 208 | + return timeList.slice(index, timeList.length) | ||
| 280 | } | 209 | } |
| 281 | const open = () => { | 210 | const open = () => { |
| 282 | isShow.value = true; | 211 | isShow.value = true; |
garbage-removal/src/manifest.json
| @@ -28,7 +28,14 @@ | @@ -28,7 +28,14 @@ | ||
| 28 | "<uses-permission android:name=\"android.permission.VIBRATE\"/>", | 28 | "<uses-permission android:name=\"android.permission.VIBRATE\"/>", |
| 29 | "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", | 29 | "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", |
| 30 | "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", | 30 | "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", |
| 31 | - "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", | 31 | + "<uses-feature android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", |
| 32 | + "<uses-feature android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", | ||
| 33 | + "<uses-feature android:name=\"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS\"/>", | ||
| 34 | + "<uses-feature android:name=\"android.hardware.location.gps\"/>", | ||
| 35 | + "<uses-feature android:name=\"android.hardware.location.network\"/>", | ||
| 36 | + "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", | ||
| 37 | + "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", | ||
| 38 | + "<uses-permission android:name=\"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS\"/>", | ||
| 32 | "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", | 39 | "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", |
| 33 | "<uses-permission android:name=\"android.permission.CAMERA\"/>", | 40 | "<uses-permission android:name=\"android.permission.CAMERA\"/>", |
| 34 | "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", | 41 | "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", |
| @@ -58,7 +65,7 @@ | @@ -58,7 +65,7 @@ | ||
| 58 | "appid" : "wx6c12c068d07c46f8", | 65 | "appid" : "wx6c12c068d07c46f8", |
| 59 | "permission" : { | 66 | "permission" : { |
| 60 | "scope.userLocation" : { | 67 | "scope.userLocation" : { |
| 61 | - "desc" : "你的位置信息将用于小程序位置接口的" | 68 | + "desc" : "为了给您提供准确的地址定位服务" |
| 62 | } | 69 | } |
| 63 | }, | 70 | }, |
| 64 | "libVersion" : "latest", | 71 | "libVersion" : "latest", |
| @@ -71,9 +78,13 @@ | @@ -71,9 +78,13 @@ | ||
| 71 | "router" : { | 78 | "router" : { |
| 72 | "mode" : "history" | 79 | "mode" : "history" |
| 73 | }, | 80 | }, |
| 74 | - "sdkConfigs" : { | ||
| 75 | - "maps" : {} | ||
| 76 | - } | 81 | + "sdkConfigs" : { |
| 82 | + "maps" : { | ||
| 83 | + "qqmap": { | ||
| 84 | + "key": "XICBZ-ALWKT-2KPXZ-VCBL7-XMRYO-2QFS4" | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + } | ||
| 77 | }, | 88 | }, |
| 78 | "mp-alipay" : { | 89 | "mp-alipay" : { |
| 79 | "usingComponents" : true | 90 | "usingComponents" : true |
garbage-removal/src/pages/change-password/index.vue
| @@ -5,17 +5,6 @@ | @@ -5,17 +5,6 @@ | ||
| 5 | <view class="title">修改密码</view> | 5 | <view class="title">修改密码</view> |
| 6 | 6 | ||
| 7 | <view class="input-wrapper"> | 7 | <view class="input-wrapper"> |
| 8 | - <u-icon name="account" size="36" color="#909399" class="input-icon"></u-icon> | ||
| 9 | - <input | ||
| 10 | - class="login-input" | ||
| 11 | - type="text" | ||
| 12 | - v-model="formData.phone" | ||
| 13 | - placeholder="请输入手机号" | ||
| 14 | - placeholder-class="placeholder-style" | ||
| 15 | - /> | ||
| 16 | - </view> | ||
| 17 | - | ||
| 18 | - <view class="input-wrapper"> | ||
| 19 | <u-icon name="lock" size="36" color="#909399" class="input-icon"></u-icon> | 8 | <u-icon name="lock" size="36" color="#909399" class="input-icon"></u-icon> |
| 20 | <input | 9 | <input |
| 21 | class="login-input" | 10 | class="login-input" |
| @@ -49,10 +38,6 @@ | @@ -49,10 +38,6 @@ | ||
| 49 | </view> | 38 | </view> |
| 50 | 39 | ||
| 51 | <button @tap="handleChangePassword" class="submit-btn">确认修改</button> | 40 | <button @tap="handleChangePassword" class="submit-btn">确认修改</button> |
| 52 | - | ||
| 53 | - <view class="back-to-login"> | ||
| 54 | - <text class="link" @click="backToLogin">返回登录</text> | ||
| 55 | - </view> | ||
| 56 | </view> | 41 | </view> |
| 57 | </view> | 42 | </view> |
| 58 | </template> | 43 | </template> |
| @@ -103,10 +88,6 @@ const getCaptcha = () => { | @@ -103,10 +88,6 @@ const getCaptcha = () => { | ||
| 103 | // 修改密码 | 88 | // 修改密码 |
| 104 | const handleChangePassword = () => { | 89 | const handleChangePassword = () => { |
| 105 | // 表单验证 | 90 | // 表单验证 |
| 106 | - if (!proxy.$u.test.mobile(formData.value.phone)) { | ||
| 107 | - proxy.$u.toast("请输入正确的手机号"); | ||
| 108 | - return; | ||
| 109 | - } | ||
| 110 | 91 | ||
| 111 | if (!formData.value.oldPassword) { | 92 | if (!formData.value.oldPassword) { |
| 112 | proxy.$u.toast("请输入原密码"); | 93 | proxy.$u.toast("请输入原密码"); |
| @@ -125,7 +106,6 @@ const handleChangePassword = () => { | @@ -125,7 +106,6 @@ const handleChangePassword = () => { | ||
| 125 | 106 | ||
| 126 | // 调用修改密码接口 | 107 | // 调用修改密码接口 |
| 127 | const params = { | 108 | const params = { |
| 128 | - tel: formData.value.phone, | ||
| 129 | oldPassword: formData.value.oldPassword, | 109 | oldPassword: formData.value.oldPassword, |
| 130 | newPassword: formData.value.newPassword, | 110 | newPassword: formData.value.newPassword, |
| 131 | }; | 111 | }; |
garbage-removal/src/pages/home-info/address/addSite.vue
| @@ -162,739 +162,99 @@ const submit = () => { | @@ -162,739 +162,99 @@ const submit = () => { | ||
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | /** | 164 | /** |
| 165 | - * 打开地图选择地址 | 165 | + * 打开地图选择地址(自动定位到当前位置,修复 startCompass:fail 问题) |
| 166 | */ | 166 | */ |
| 167 | const chooseAddressDetail = () => { | 167 | const chooseAddressDetail = () => { |
| 168 | - console.log('打开地图选择地址'); | ||
| 169 | - takeLocation(); | ||
| 170 | - | ||
| 171 | - // 创建选择方式的模态框 | ||
| 172 | - const choiceContainer = document.createElement('div'); | ||
| 173 | - choiceContainer.id = 'choiceContainer'; | ||
| 174 | - choiceContainer.style.cssText = ` position: fixed; | ||
| 175 | - top: 0; | ||
| 176 | - left: 0; | ||
| 177 | - width: 100%; | ||
| 178 | - height: 100%; | ||
| 179 | - background: rgba(0, 0, 0, 0.5); | ||
| 180 | - z-index: 9999; | ||
| 181 | - display: flex; | ||
| 182 | - justify-content: center; | ||
| 183 | - align-items: center; | ||
| 184 | - `; | ||
| 185 | - | ||
| 186 | - const choiceBox = document.createElement('div'); | ||
| 187 | - choiceBox.style.cssText = ` background: white; | ||
| 188 | - padding: 20px; | ||
| 189 | - border-radius: 8px; | ||
| 190 | - text-align: center; | ||
| 191 | - width: 80%; | ||
| 192 | - max-width: 300px; | ||
| 193 | - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 194 | - `; | ||
| 195 | - | ||
| 196 | - const title = document.createElement('h3'); | ||
| 197 | - title.innerText = '请选择地址输入方式'; | ||
| 198 | - title.style.cssText = ` margin-top: 0; | ||
| 199 | - color: #333; | ||
| 200 | - font-size: 18px; | ||
| 201 | - `; | ||
| 202 | - | ||
| 203 | - const mapBtn = document.createElement('button'); | ||
| 204 | - mapBtn.innerText = '地图选择'; | ||
| 205 | - mapBtn.style.cssText = ` display: block; | ||
| 206 | - width: 100%; | ||
| 207 | - padding: 12px; | ||
| 208 | - margin: 10px 0; | ||
| 209 | - background: #19a97c; | ||
| 210 | - color: white; | ||
| 211 | - border: none; | ||
| 212 | - border-radius: 4px; | ||
| 213 | - cursor: pointer; | ||
| 214 | - font-size: 16px; | ||
| 215 | - transition: background 0.3s; | ||
| 216 | - `; | ||
| 217 | - | ||
| 218 | - mapBtn.onmouseover = function() { | ||
| 219 | - mapBtn.style.background = '#13966a'; | ||
| 220 | - }; | ||
| 221 | - | ||
| 222 | - mapBtn.onmouseout = function() { | ||
| 223 | - mapBtn.style.background = '#19a97c'; | ||
| 224 | - }; | ||
| 225 | - | ||
| 226 | - const manualBtn = document.createElement('button'); | ||
| 227 | - manualBtn.innerText = '手动输入'; | ||
| 228 | - manualBtn.style.cssText = ` display: block; | ||
| 229 | - width: 100%; | ||
| 230 | - padding: 12px; | ||
| 231 | - margin: 10px 0; | ||
| 232 | - background: #409eff; | ||
| 233 | - color: white; | ||
| 234 | - border: none; | ||
| 235 | - border-radius: 4px; | ||
| 236 | - cursor: pointer; | ||
| 237 | - font-size: 16px; | ||
| 238 | - transition: background 0.3s; | ||
| 239 | - `; | ||
| 240 | - | ||
| 241 | - manualBtn.onmouseover = function() { | ||
| 242 | - manualBtn.style.background = '#3388e6'; | ||
| 243 | - }; | ||
| 244 | - | ||
| 245 | - manualBtn.onmouseout = function() { | ||
| 246 | - manualBtn.style.background = '#409eff'; | ||
| 247 | - }; | ||
| 248 | - | ||
| 249 | - const cancelBtn = document.createElement('button'); | ||
| 250 | - cancelBtn.innerText = '取消'; | ||
| 251 | - cancelBtn.style.cssText = ` display: block; | ||
| 252 | - width: 100%; | ||
| 253 | - padding: 12px; | ||
| 254 | - margin: 10px 0; | ||
| 255 | - background: #ff4d4f; | ||
| 256 | - color: white; | ||
| 257 | - border: none; | ||
| 258 | - border-radius: 4px; | ||
| 259 | - cursor: pointer; | ||
| 260 | - font-size: 16px; | ||
| 261 | - transition: background 0.3s; | ||
| 262 | - `; | ||
| 263 | - | ||
| 264 | - cancelBtn.onmouseover = function() { | ||
| 265 | - cancelBtn.style.background = '#e63939'; | ||
| 266 | - }; | ||
| 267 | - | ||
| 268 | - cancelBtn.onmouseout = function() { | ||
| 269 | - cancelBtn.style.background = '#ff4d4f'; | ||
| 270 | - }; | ||
| 271 | - | ||
| 272 | - choiceBox.appendChild(title); | ||
| 273 | - choiceBox.appendChild(mapBtn); | ||
| 274 | - choiceBox.appendChild(manualBtn); | ||
| 275 | - choiceBox.appendChild(cancelBtn); | ||
| 276 | - choiceContainer.appendChild(choiceBox); | ||
| 277 | - document.body.appendChild(choiceContainer); | ||
| 278 | - | ||
| 279 | - // 地图选择按钮事件 | ||
| 280 | - mapBtn.onclick = function() { | ||
| 281 | - document.body.removeChild(choiceContainer); | ||
| 282 | - | ||
| 283 | - // 地图选择方式 | ||
| 284 | - let coordinate = 'gcj02'; | ||
| 285 | - | ||
| 286 | - // 创建一个模态框来显示地图 | ||
| 287 | - const mapContainer = document.createElement('div'); | ||
| 288 | - mapContainer.id = 'mapContainerWrapper'; | ||
| 289 | - mapContainer.style.cssText = ` position: fixed; | ||
| 290 | - top: 0; | ||
| 291 | - left: 0; | ||
| 292 | - width: 100%; | ||
| 293 | - height: 100%; | ||
| 294 | - background: white; | ||
| 295 | - z-index: 9999; | ||
| 296 | - `; | ||
| 297 | - | ||
| 298 | - // 创建顶部工具栏 | ||
| 299 | - const toolbar = document.createElement('div'); | ||
| 300 | - toolbar.style.cssText = ` position: absolute; | ||
| 301 | - top: 0; | ||
| 302 | - left: 0; | ||
| 303 | - width: 100%; | ||
| 304 | - height: 50px; | ||
| 305 | - background: #fff; | ||
| 306 | - box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
| 307 | - z-index: 10000; | ||
| 308 | - display: flex; | ||
| 309 | - align-items: center; | ||
| 310 | - padding: 0 15px; | ||
| 311 | - box-sizing: border-box; | ||
| 312 | - `; | ||
| 313 | - | ||
| 314 | - const titleText = document.createElement('div'); | ||
| 315 | - titleText.innerText = '请选择地址'; | ||
| 316 | - titleText.style.cssText = ` flex: 1; | ||
| 317 | - text-align: center; | ||
| 318 | - font-size: 16px; | ||
| 319 | - font-weight: bold; | ||
| 320 | - color: #333; | ||
| 321 | - `; | ||
| 322 | - | ||
| 323 | - // 创建关闭按钮 | ||
| 324 | - const closeBtn = document.createElement('button'); | ||
| 325 | - closeBtn.innerText = '✕'; | ||
| 326 | - closeBtn.style.cssText = ` width: 30px; | ||
| 327 | - height: 30px; | ||
| 328 | - background: #ff4d4f; | ||
| 329 | - color: white; | ||
| 330 | - border: none; | ||
| 331 | - border-radius: 50%; | ||
| 332 | - cursor: pointer; | ||
| 333 | - font-size: 16px; | ||
| 334 | - display: flex; | ||
| 335 | - align-items: center; | ||
| 336 | - justify-content: center; | ||
| 337 | - `; | ||
| 338 | - | ||
| 339 | - toolbar.appendChild(titleText); | ||
| 340 | - toolbar.appendChild(closeBtn); | ||
| 341 | - | ||
| 342 | - // 创建地图容器 | ||
| 343 | - const mapElement = document.createElement('div'); | ||
| 344 | - mapElement.id = 'mapContainer'; | ||
| 345 | - mapElement.style.cssText = ` width: 100%; | ||
| 346 | - height: 100%; | ||
| 347 | - margin-top: 50px; | ||
| 348 | - `; | ||
| 349 | - | ||
| 350 | - mapContainer.appendChild(toolbar); | ||
| 351 | - mapContainer.appendChild(mapElement); | ||
| 352 | - document.body.appendChild(mapContainer); | ||
| 353 | - | ||
| 354 | - // 加载腾讯地图API | ||
| 355 | - const script = document.createElement('script'); | ||
| 356 | - script.src = 'https://map.qq.com/api/js?v=2.exp&key=XICBZ-ALWKT-2KPXZ-VCBL7-XMRYO-2QFS4&callback=initMap'; | ||
| 357 | - | ||
| 358 | - // 定义全局回调函数 | ||
| 359 | - window.initMap = function() { | ||
| 360 | - // 初始化地图,设置默认位置为长沙 | ||
| 361 | - const center = new qq.maps.LatLng(28.198265, 112.984353); // 长沙市坐标 | ||
| 362 | - const map = new qq.maps.Map(mapElement, { | ||
| 363 | - center: center, | ||
| 364 | - zoom: 15 | ||
| 365 | - }); | ||
| 366 | - window.currentMapInstance = map; | ||
| 367 | - // 地图初始化完成后自动获取当前位置 | ||
| 368 | - setTimeout(() => { | ||
| 369 | - takeLocation(); | ||
| 370 | - }, 500); | ||
| 371 | - | ||
| 372 | - // 添加点击事件监听器 | ||
| 373 | - qq.maps.event.addListener(map, 'click', function(event) { | ||
| 374 | - const lat = event.latLng.getLat(); | ||
| 375 | - const lng = event.latLng.getLng(); | ||
| 376 | - | ||
| 377 | - // 使用腾讯地图逆解析API获取地址信息 | ||
| 378 | - const key = "XICBZ-ALWKT-2KPXZ-VCBL7-XMRYO-2QFS4"; | ||
| 379 | - const url = `https://apis.map.qq.com/ws/geocoder/v1/?key=${key}&location=${lat},${lng}&output=jsonp`; | ||
| 380 | - | ||
| 381 | - // 创建script标签实现JSONP | ||
| 382 | - const jsonpScript = document.createElement('script'); | ||
| 383 | - const callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random()); | ||
| 384 | - | ||
| 385 | - // 定义全局回调函数 | ||
| 386 | - window[callbackName] = function(data) { | ||
| 387 | - // 清理 | ||
| 388 | - delete window[callbackName]; | ||
| 389 | - document.body.removeChild(jsonpScript); | ||
| 390 | - | ||
| 391 | - if (data.status === 0) { | ||
| 392 | - const component = data.result.address_component; | ||
| 393 | - const address = data.result.address; | ||
| 394 | - | ||
| 395 | - // 创建确认选择的模态框 | ||
| 396 | - const confirmContainer = document.createElement('div'); | ||
| 397 | - confirmContainer.style.cssText = ` position: fixed; | ||
| 398 | - top: 0; | ||
| 399 | - left: 0; | ||
| 400 | - width: 100%; | ||
| 401 | - height: 100%; | ||
| 402 | - background: rgba(0, 0, 0, 0.5); | ||
| 403 | - z-index: 10001; | ||
| 404 | - display: flex; | ||
| 405 | - justify-content: center; | ||
| 406 | - align-items: center; | ||
| 407 | - `; | ||
| 408 | - | ||
| 409 | - const confirmBox = document.createElement('div'); | ||
| 410 | - confirmBox.style.cssText = ` background: white; | ||
| 411 | - padding: 20px; | ||
| 412 | - border-radius: 8px; | ||
| 413 | - text-align: center; | ||
| 414 | - width: 80%; | ||
| 415 | - max-width: 300px; | ||
| 416 | - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 417 | - `; | ||
| 418 | - | ||
| 419 | - const confirmTitle = document.createElement('h3'); | ||
| 420 | - confirmTitle.innerText = '确认地址'; | ||
| 421 | - confirmTitle.style.cssText = ` margin-top: 0; | ||
| 422 | - color: #333; | ||
| 423 | - `; | ||
| 424 | - | ||
| 425 | - const confirmText = document.createElement('p'); | ||
| 426 | - confirmText.innerText = address; | ||
| 427 | - confirmText.style.cssText = ` color: #666; | ||
| 428 | - font-size: 14px; | ||
| 429 | - line-height: 1.5; | ||
| 430 | - margin: 10px 0; | ||
| 431 | - `; | ||
| 432 | - | ||
| 433 | - const confirmBtn = document.createElement('button'); | ||
| 434 | - confirmBtn.innerText = '确认'; | ||
| 435 | - confirmBtn.style.cssText = ` display: inline-block; | ||
| 436 | - width: 45%; | ||
| 437 | - padding: 10px; | ||
| 438 | - margin: 5px; | ||
| 439 | - background: #19a97c; | ||
| 440 | - color: white; | ||
| 441 | - border: none; | ||
| 442 | - border-radius: 4px; | ||
| 443 | - cursor: pointer; | ||
| 444 | - font-size: 14px; | ||
| 445 | - `; | ||
| 446 | - | ||
| 447 | - const cancelConfirmBtn = document.createElement('button'); | ||
| 448 | - cancelConfirmBtn.innerText = '取消'; | ||
| 449 | - cancelConfirmBtn.style.cssText = ` display: inline-block; | ||
| 450 | - width: 45%; | ||
| 451 | - padding: 10px; | ||
| 452 | - margin: 5px; | ||
| 453 | - background: #ff4d4f; | ||
| 454 | - color: white; | ||
| 455 | - border: none; | ||
| 456 | - border-radius: 4px; | ||
| 457 | - cursor: pointer; | ||
| 458 | - font-size: 14px; | ||
| 459 | - `; | ||
| 460 | - | ||
| 461 | - confirmBox.appendChild(confirmTitle); | ||
| 462 | - confirmBox.appendChild(confirmText); | ||
| 463 | - confirmBox.appendChild(confirmBtn); | ||
| 464 | - confirmBox.appendChild(cancelConfirmBtn); | ||
| 465 | - confirmContainer.appendChild(confirmBox); | ||
| 466 | - document.body.appendChild(confirmContainer); | ||
| 467 | - | ||
| 468 | - // 确认按钮事件 | ||
| 469 | - confirmBtn.onclick = function() { | ||
| 470 | - addressInfo.garLongitude = lng; | ||
| 471 | - addressInfo.garLatitude = lat; | ||
| 472 | - addressInfo.garCoordinate = coordinate; | ||
| 473 | - | ||
| 474 | - if (component.province == "湖南省") { | ||
| 475 | - addressInfo.addressDetail = address.replace(component.province + component.city + component.district, ""); | ||
| 476 | - addressInfo.addressArea = component.province + '-' + component.city + '-' + component.district; | ||
| 477 | - } else { | ||
| 478 | - addressInfo.addressDetail = address; | ||
| 479 | - } | ||
| 480 | - | ||
| 481 | - // 关闭所有模态框 | ||
| 482 | - document.body.removeChild(confirmContainer); | ||
| 483 | - document.body.removeChild(mapContainer); | ||
| 484 | - // 清理全局函数 | ||
| 485 | - delete window.initMap; | ||
| 486 | - }; | ||
| 487 | - | ||
| 488 | - // 取消确认按钮事件 | ||
| 489 | - cancelConfirmBtn.onclick = function() { | ||
| 490 | - document.body.removeChild(confirmContainer); | ||
| 491 | - }; | ||
| 492 | - } else { | ||
| 493 | - // 创建错误提示的模态框 | ||
| 494 | - const errorContainer = document.createElement('div'); | ||
| 495 | - errorContainer.style.cssText = ` position: fixed; | ||
| 496 | - top: 0; | ||
| 497 | - left: 0; | ||
| 498 | - width: 100%; | ||
| 499 | - height: 100%; | ||
| 500 | - background: rgba(0, 0, 0, 0.5); | ||
| 501 | - z-index: 10001; | ||
| 502 | - display: flex; | ||
| 503 | - justify-content: center; | ||
| 504 | - align-items: center; | ||
| 505 | - `; | ||
| 506 | - | ||
| 507 | - const errorBox = document.createElement('div'); | ||
| 508 | - errorBox.style.cssText = ` background: white; | ||
| 509 | - padding: 20px; | ||
| 510 | - border-radius: 8px; | ||
| 511 | - text-align: center; | ||
| 512 | - width: 80%; | ||
| 513 | - max-width: 300px; | ||
| 514 | - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 515 | - `; | ||
| 516 | - | ||
| 517 | - const errorTitle = document.createElement('h3'); | ||
| 518 | - errorTitle.innerText = '提示'; | ||
| 519 | - errorTitle.style.cssText = ` margin-top: 0; | ||
| 520 | - color: #333; | ||
| 521 | - `; | ||
| 522 | - | ||
| 523 | - const errorText = document.createElement('p'); | ||
| 524 | - errorText.innerText = '地址解析失败,请重新选择'; | ||
| 525 | - errorText.style.cssText = ` color: #666; | ||
| 526 | - font-size: 14px; | ||
| 527 | - margin: 10px 0; | ||
| 528 | - `; | ||
| 529 | - | ||
| 530 | - const okBtn = document.createElement('button'); | ||
| 531 | - okBtn.innerText = '确定'; | ||
| 532 | - okBtn.style.cssText = ` display: inline-block; | ||
| 533 | - width: 100%; | ||
| 534 | - padding: 10px; | ||
| 535 | - margin: 5px 0; | ||
| 536 | - background: #409eff; | ||
| 537 | - color: white; | ||
| 538 | - border: none; | ||
| 539 | - border-radius: 4px; | ||
| 540 | - cursor: pointer; | ||
| 541 | - font-size: 14px; | ||
| 542 | - `; | ||
| 543 | - | ||
| 544 | - errorBox.appendChild(errorTitle); | ||
| 545 | - errorBox.appendChild(errorText); | ||
| 546 | - errorBox.appendChild(okBtn); | ||
| 547 | - errorContainer.appendChild(errorBox); | ||
| 548 | - document.body.appendChild(errorContainer); | ||
| 549 | - | ||
| 550 | - // 确定按钮事件 | ||
| 551 | - okBtn.onclick = function() { | ||
| 552 | - document.body.removeChild(errorContainer); | ||
| 553 | - }; | ||
| 554 | - } | ||
| 555 | - }; | ||
| 556 | - | ||
| 557 | - // 设置错误处理 | ||
| 558 | - jsonpScript.onerror = function() { | ||
| 559 | - // 清理 | ||
| 560 | - delete window[callbackName]; | ||
| 561 | - document.body.removeChild(jsonpScript); | ||
| 562 | - | ||
| 563 | - // 创建错误提示的模态框 | ||
| 564 | - const errorContainer = document.createElement('div'); | ||
| 565 | - errorContainer.style.cssText = ` position: fixed; | ||
| 566 | - top: 0; | ||
| 567 | - left: 0; | ||
| 568 | - width: 100%; | ||
| 569 | - height: 100%; | ||
| 570 | - background: rgba(0, 0, 0, 0.5); | ||
| 571 | - z-index: 10001; | ||
| 572 | - display: flex; | ||
| 573 | - justify-content: center; | ||
| 574 | - align-items: center; | ||
| 575 | - `; | ||
| 576 | - | ||
| 577 | - const errorBox = document.createElement('div'); | ||
| 578 | - errorBox.style.cssText = ` background: white; | ||
| 579 | - padding: 20px; | ||
| 580 | - border-radius: 8px; | ||
| 581 | - text-align: center; | ||
| 582 | - width: 80%; | ||
| 583 | - max-width: 300px; | ||
| 584 | - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 585 | - `; | ||
| 586 | - | ||
| 587 | - const errorTitle = document.createElement('h3'); | ||
| 588 | - errorTitle.innerText = '提示'; | ||
| 589 | - errorTitle.style.cssText = ` margin-top: 0; | ||
| 590 | - color: #333; | ||
| 591 | - `; | ||
| 592 | - | ||
| 593 | - const errorText = document.createElement('p'); | ||
| 594 | - errorText.innerText = '地址解析失败,请重新选择'; | ||
| 595 | - errorText.style.cssText = ` color: #666; | ||
| 596 | - font-size: 14px; | ||
| 597 | - margin: 10px 0; | ||
| 598 | - `; | ||
| 599 | - | ||
| 600 | - const okBtn = document.createElement('button'); | ||
| 601 | - okBtn.innerText = '确定'; | ||
| 602 | - okBtn.style.cssText = ` display: inline-block; | ||
| 603 | - width: 100%; | ||
| 604 | - padding: 10px; | ||
| 605 | - margin: 5px 0; | ||
| 606 | - background: #409eff; | ||
| 607 | - color: white; | ||
| 608 | - border: none; | ||
| 609 | - border-radius: 4px; | ||
| 610 | - cursor: pointer; | ||
| 611 | - font-size: 14px; | ||
| 612 | - `; | ||
| 613 | - | ||
| 614 | - errorBox.appendChild(errorTitle); | ||
| 615 | - errorBox.appendChild(errorText); | ||
| 616 | - errorBox.appendChild(okBtn); | ||
| 617 | - errorContainer.appendChild(errorBox); | ||
| 618 | - document.body.appendChild(errorContainer); | ||
| 619 | - | ||
| 620 | - // 确定按钮事件 | ||
| 621 | - okBtn.onclick = function() { | ||
| 622 | - document.body.removeChild(errorContainer); | ||
| 623 | - }; | ||
| 624 | - }; | ||
| 625 | - | ||
| 626 | - jsonpScript.src = url + '&callback=' + callbackName; | ||
| 627 | - document.body.appendChild(jsonpScript); | ||
| 628 | - }); | ||
| 629 | - | ||
| 630 | - // 添加当前位置定位功能 | ||
| 631 | - if (navigator.geolocation) { | ||
| 632 | - navigator.geolocation.getCurrentPosition( | ||
| 633 | - (position) => { | ||
| 634 | - const lat = position.coords.latitude; | ||
| 635 | - const lng = position.coords.longitude; | ||
| 636 | - const pos = new qq.maps.LatLng(lat, lng); | ||
| 637 | - map.setCenter(pos); | ||
| 638 | - }, | ||
| 639 | - (error) => { | ||
| 640 | - console.log('获取当前位置失败', error); | ||
| 641 | - } | ||
| 642 | - ); | ||
| 643 | - } | ||
| 644 | - }; | ||
| 645 | - | ||
| 646 | - // 关闭按钮事件 | ||
| 647 | - closeBtn.onclick = function() { | ||
| 648 | - document.body.removeChild(mapContainer); | ||
| 649 | - // 清理全局函数 | ||
| 650 | - delete window.initMap; | ||
| 651 | - }; | ||
| 652 | - | ||
| 653 | - document.body.appendChild(script); | ||
| 654 | - }; | ||
| 655 | - | ||
| 656 | - // 手动输入按钮事件 | ||
| 657 | - manualBtn.onclick = function() { | ||
| 658 | - document.body.removeChild(choiceContainer); | ||
| 659 | - | ||
| 660 | - // 创建自定义输入框模态框 | ||
| 661 | - const inputContainer = document.createElement('div'); | ||
| 662 | - inputContainer.style.cssText = ` position: fixed; | ||
| 663 | - top: 0; | ||
| 664 | - left: 0; | ||
| 665 | - width: 100%; | ||
| 666 | - height: 100%; | ||
| 667 | - background: rgba(0, 0, 0, 0.5); | ||
| 668 | - z-index: 9999; | ||
| 669 | - display: flex; | ||
| 670 | - justify-content: center; | ||
| 671 | - align-items: center; | ||
| 672 | - `; | ||
| 673 | - | ||
| 674 | - const inputBox = document.createElement('div'); | ||
| 675 | - inputBox.style.cssText = ` background: white; | ||
| 676 | - padding: 20px; | ||
| 677 | - border-radius: 8px; | ||
| 678 | - text-align: center; | ||
| 679 | - width: 80%; | ||
| 680 | - max-width: 300px; | ||
| 681 | - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 682 | - `; | ||
| 683 | - | ||
| 684 | - const inputTitle = document.createElement('h3'); | ||
| 685 | - inputTitle.innerText = '请输入详细地址'; | ||
| 686 | - inputTitle.style.cssText = ` margin-top: 0; | ||
| 687 | - color: #333; | ||
| 688 | - `; | ||
| 689 | - | ||
| 690 | - const inputField = document.createElement('input'); | ||
| 691 | - inputField.type = 'text'; | ||
| 692 | - inputField.placeholder = '请输入详细地址'; | ||
| 693 | - inputField.style.cssText = ` width: 100%; | ||
| 694 | - padding: 10px; | ||
| 695 | - margin: 10px 0; | ||
| 696 | - border: 1px solid #ddd; | ||
| 697 | - border-radius: 4px; | ||
| 698 | - box-sizing: border-box; | ||
| 699 | - font-size: 14px; | ||
| 700 | - `; | ||
| 701 | - | ||
| 702 | - const submitBtn = document.createElement('button'); | ||
| 703 | - submitBtn.innerText = '确定'; | ||
| 704 | - submitBtn.style.cssText = ` display: inline-block; | ||
| 705 | - width: 45%; | ||
| 706 | - padding: 10px; | ||
| 707 | - margin: 5px; | ||
| 708 | - background: #19a97c; | ||
| 709 | - color: white; | ||
| 710 | - border: none; | ||
| 711 | - border-radius: 4px; | ||
| 712 | - cursor: pointer; | ||
| 713 | - font-size: 14px; | ||
| 714 | - `; | ||
| 715 | - | ||
| 716 | - const cancelInputBtn = document.createElement('button'); | ||
| 717 | - cancelInputBtn.innerText = '取消'; | ||
| 718 | - cancelInputBtn.style.cssText = ` display: inline-block; | ||
| 719 | - width: 45%; | ||
| 720 | - padding: 10px; | ||
| 721 | - margin: 5px; | ||
| 722 | - background: #ff4d4f; | ||
| 723 | - color: white; | ||
| 724 | - border: none; | ||
| 725 | - border-radius: 4px; | ||
| 726 | - cursor: pointer; | ||
| 727 | - font-size: 14px; | ||
| 728 | - `; | ||
| 729 | - | ||
| 730 | - inputBox.appendChild(inputTitle); | ||
| 731 | - inputBox.appendChild(inputField); | ||
| 732 | - inputBox.appendChild(submitBtn); | ||
| 733 | - inputBox.appendChild(cancelInputBtn); | ||
| 734 | - inputContainer.appendChild(inputBox); | ||
| 735 | - document.body.appendChild(inputContainer); | ||
| 736 | - | ||
| 737 | - // 确定按钮事件 | ||
| 738 | - submitBtn.onclick = function() { | ||
| 739 | - const manualAddress = inputField.value.trim(); | ||
| 740 | - if (manualAddress) { | ||
| 741 | - addressInfo.addressDetail = manualAddress; | ||
| 742 | - document.body.removeChild(inputContainer); | ||
| 743 | - } else { | ||
| 744 | - // 创建提示模态框 | ||
| 745 | - const tipContainer = document.createElement('div'); | ||
| 746 | - tipContainer.style.cssText = ` position: fixed; | ||
| 747 | - top: 0; | ||
| 748 | - left: 0; | ||
| 749 | - width: 100%; | ||
| 750 | - height: 100%; | ||
| 751 | - background: rgba(0, 0, 0, 0.5); | ||
| 752 | - z-index: 10000; | ||
| 753 | - display: flex; | ||
| 754 | - justify-content: center; | ||
| 755 | - align-items: center; | ||
| 756 | - `; | ||
| 757 | - | ||
| 758 | - const tipBox = document.createElement('div'); | ||
| 759 | - tipBox.style.cssText = ` background: white; | ||
| 760 | - padding: 20px; | ||
| 761 | - border-radius: 8px; | ||
| 762 | - text-align: center; | ||
| 763 | - width: 80%; | ||
| 764 | - max-width: 300px; | ||
| 765 | - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 766 | - `; | ||
| 767 | - | ||
| 768 | - const tipText = document.createElement('p'); | ||
| 769 | - tipText.innerText = '请输入详细地址'; | ||
| 770 | - tipText.style.cssText = ` color: #666; | ||
| 771 | - font-size: 14px; | ||
| 772 | - margin: 10px 0; | ||
| 773 | - `; | ||
| 774 | - | ||
| 775 | - const okBtn = document.createElement('button'); | ||
| 776 | - okBtn.innerText = '确定'; | ||
| 777 | - okBtn.style.cssText = ` display: inline-block; | ||
| 778 | - width: 100%; | ||
| 779 | - padding: 10px; | ||
| 780 | - margin: 5px 0; | ||
| 781 | - background: #409eff; | ||
| 782 | - color: white; | ||
| 783 | - border: none; | ||
| 784 | - border-radius: 4px; | ||
| 785 | - cursor: pointer; | ||
| 786 | - font-size: 14px; | ||
| 787 | - `; | ||
| 788 | - | ||
| 789 | - tipBox.appendChild(tipText); | ||
| 790 | - tipBox.appendChild(okBtn); | ||
| 791 | - tipContainer.appendChild(tipBox); | ||
| 792 | - document.body.appendChild(tipContainer); | ||
| 793 | - | ||
| 794 | - // 确定按钮事件 | ||
| 795 | - okBtn.onclick = function() { | ||
| 796 | - document.body.removeChild(tipContainer); | ||
| 797 | - }; | ||
| 798 | - } | ||
| 799 | - }; | ||
| 800 | - | ||
| 801 | - // 取消按钮事件 | ||
| 802 | - cancelInputBtn.onclick = function() { | ||
| 803 | - document.body.removeChild(inputContainer); | ||
| 804 | - }; | ||
| 805 | - | ||
| 806 | - // 回车键确认 | ||
| 807 | - inputField.addEventListener('keypress', function(e) { | ||
| 808 | - if (e.key === 'Enter') { | ||
| 809 | - submitBtn.click(); | ||
| 810 | - } | ||
| 811 | - }); | ||
| 812 | - | ||
| 813 | - // 聚焦到输入框 | ||
| 814 | - setTimeout(() => { | ||
| 815 | - inputField.focus(); | ||
| 816 | - }, 100); | ||
| 817 | - }; | ||
| 818 | - | ||
| 819 | - // 取消按钮事件 | ||
| 820 | - cancelBtn.onclick = function() { | ||
| 821 | - document.body.removeChild(choiceContainer); | ||
| 822 | - }; | ||
| 823 | -} | ||
| 824 | - | ||
| 825 | -// 定义定位回调函数 | ||
| 826 | -const takeLocationCallBack = (lngLat) => { | ||
| 827 | - const ll = lngLat.split(","); | ||
| 828 | - console.log("定位结果:", ll); | ||
| 829 | - | ||
| 830 | - if (ll.length >= 2) { | ||
| 831 | - const longitude = parseFloat(ll[0]); | ||
| 832 | - const latitude = parseFloat(ll[1]); | ||
| 833 | - | ||
| 834 | - // 在地图上定位到当前位置 | ||
| 835 | - const mapContainer = document.getElementById('mapContainer'); | ||
| 836 | - if (mapContainer && window.qq && qq.maps && window.currentMapInstance) { | ||
| 837 | - const pos = new qq.maps.LatLng(latitude, longitude); | ||
| 838 | - window.currentMapInstance.setCenter(pos); | ||
| 839 | - window.currentMapInstance.setZoom(17); // 放大一些以便更好地查看位置 | ||
| 840 | - | ||
| 841 | - // 清除之前的标记(如果有的话) | ||
| 842 | - if (window.currentLocationMarker) { | ||
| 843 | - window.currentLocationMarker.setMap(null); | ||
| 844 | - } | ||
| 845 | - | ||
| 846 | - // 添加新的当前位置标记 | ||
| 847 | - window.currentLocationMarker = new qq.maps.Marker({ | ||
| 848 | - position: pos, | ||
| 849 | - map: window.currentMapInstance | 168 | + console.log('打开地图选择地址(自动定位)'); |
| 169 | + | ||
| 170 | + // 1. 先获取当前位置的经纬度(关键:统一坐标系为 gcj02,关闭 altitude 避免额外权限) | ||
| 171 | + uni.getLocation({ | ||
| 172 | + type: 'gcj02', // 必须使用 gcj02(腾讯/高德地图标准,避免坐标系不匹配) | ||
| 173 | + altitude: false, // 关闭海拔获取,减少权限要求 | ||
| 174 | + isHighAccuracy: false, // 关闭高精度定位(降低硬件依赖) | ||
| 175 | + success: (locationRes) => { | ||
| 176 | + console.log('当前位置经纬度:', locationRes); | ||
| 177 | + const { latitude, longitude } = locationRes; | ||
| 178 | + | ||
| 179 | + // 2. 打开地图选择器(移除可能触发指南针的参数) | ||
| 180 | + uni.chooseLocation({ | ||
| 181 | + latitude: latitude, | ||
| 182 | + longitude: longitude, | ||
| 183 | + scale: 16, | ||
| 184 | + name: addressInfo.addressDetail || '', | ||
| 185 | + address: addressInfo.addressArea || '', | ||
| 186 | + success: (res) => { | ||
| 187 | + addressInfo.addressDetail = res.name; | ||
| 188 | + addressInfo.garLongitude = res.longitude; | ||
| 189 | + addressInfo.garLatitude = res.latitude; | ||
| 190 | + }, | ||
| 191 | + fail: (err) => { | ||
| 192 | + console.error('地图选择失败:', err); | ||
| 193 | + handleLocationError(err); | ||
| 194 | + } | ||
| 850 | }); | 195 | }); |
| 196 | + }, | ||
| 197 | + fail: (err) => { | ||
| 198 | + console.error('获取当前位置失败:', err); | ||
| 199 | + handleLocationError(err); | ||
| 200 | + } | ||
| 201 | + }); | ||
| 202 | +}; | ||
| 851 | 203 | ||
| 852 | - // 创建或更新信息窗口 | ||
| 853 | - if (!window.currentLocationInfoWindow) { | ||
| 854 | - window.currentLocationInfoWindow = new qq.maps.InfoWindow({ | ||
| 855 | - map: window.currentMapInstance | ||
| 856 | - }); | 204 | +/** |
| 205 | + * 统一处理定位/地图错误 | ||
| 206 | + */ | ||
| 207 | +const handleLocationError = (err) => { | ||
| 208 | + const errMsg = err.errMsg || ''; | ||
| 209 | + | ||
| 210 | + // 1. 处理权限拒绝 | ||
| 211 | + if (errMsg.includes('auth deny') || errMsg.includes('permission denied')) { | ||
| 212 | + uni.showModal({ | ||
| 213 | + title: '授权提示', | ||
| 214 | + content: '需要获取您的位置权限才能自动定位,请在设置中开启', | ||
| 215 | + confirmText: '去设置', | ||
| 216 | + cancelText: '手动输入', | ||
| 217 | + success: (modalRes) => { | ||
| 218 | + if (modalRes.confirm) { | ||
| 219 | + uni.openSetting(); // 打开系统设置 | ||
| 220 | + } else { | ||
| 221 | + // 手动输入地址(隐藏地图选择,直接让用户输入) | ||
| 222 | + uni.showToast({ title: '请手动输入详细地址', icon: 'none' }); | ||
| 223 | + } | ||
| 857 | } | 224 | } |
| 858 | - | ||
| 859 | - // 设置信息窗口内容并打开 | ||
| 860 | - window.currentLocationInfoWindow.setContent('<div style="padding:10px;">您的当前位置</div>'); | ||
| 861 | - window.currentLocationInfoWindow.setPosition(pos); | ||
| 862 | - window.currentLocationInfoWindow.open(); | ||
| 863 | - } | ||
| 864 | - } else { | ||
| 865 | - uni.showToast({ | ||
| 866 | - title: '定位结果异常', | ||
| 867 | - icon: 'none' | ||
| 868 | }); | 225 | }); |
| 869 | } | 226 | } |
| 870 | -} | ||
| 871 | 227 | ||
| 872 | -const takeLocation = () => { | ||
| 873 | - // 调用原生接口获取定位 | ||
| 874 | - if (window.JsInterface && typeof window.JsInterface.takeLocation === 'function') { | ||
| 875 | - window.JsInterface.takeLocation(); | ||
| 876 | - } else { | ||
| 877 | - // 如果没有原生接口,使用uni.getLocation作为备选方案 | ||
| 878 | - uni.getLocation({ | ||
| 879 | - type: 'gcj02', | ||
| 880 | - success: function (res) { | ||
| 881 | - // 直接处理结果 | ||
| 882 | - handleLocationResult(res.longitude, res.latitude); | ||
| 883 | - }, | ||
| 884 | - fail: function (err) { | ||
| 885 | - console.error('定位失败:', err); | ||
| 886 | - uni.showToast({ | ||
| 887 | - title: '定位失败', | ||
| 888 | - icon: 'none' | 228 | + // 2. 处理指南针失败(startCompass:fail) |
| 229 | + else if (errMsg.includes('startCompass:fail')) { | ||
| 230 | + uni.showModal({ | ||
| 231 | + title: '提示', | ||
| 232 | + content: '当前设备不支持指南针功能,将为您打开地图手动选择地址', | ||
| 233 | + showCancel: false, | ||
| 234 | + success: () => { | ||
| 235 | + // 降级方案:不传递初始经纬度,直接打开地图 | ||
| 236 | + uni.chooseLocation({ | ||
| 237 | + success: (res) => { | ||
| 238 | + addressInfo.addressDetail = res.name; | ||
| 239 | + addressInfo.garLongitude = res.longitude; | ||
| 240 | + addressInfo.garLatitude = res.latitude; | ||
| 241 | + }, | ||
| 242 | + fail: () => { | ||
| 243 | + uni.showToast({ title: '地图选择失败,请手动输入地址', icon: 'none' }); | ||
| 244 | + } | ||
| 889 | }); | 245 | }); |
| 890 | } | 246 | } |
| 891 | }); | 247 | }); |
| 892 | } | 248 | } |
| 893 | -} | 249 | + |
| 250 | + // 3. 其他错误(网络/设备问题) | ||
| 251 | + else { | ||
| 252 | + uni.showToast({ title: '定位失败,请手动输入地址', icon: 'none' }); | ||
| 253 | + } | ||
| 254 | +}; | ||
| 894 | 255 | ||
| 895 | onMounted(() => { | 256 | onMounted(() => { |
| 896 | proxy.$refs.addressFrom.setRules(rules) | 257 | proxy.$refs.addressFrom.setRules(rules) |
| 897 | - window.takeLocationCallBack = takeLocationCallBack | ||
| 898 | }) | 258 | }) |
| 899 | 259 | ||
| 900 | onLoad((options) => { | 260 | onLoad((options) => { |
garbage-removal/src/pages/home-info/clean/index.vue
| @@ -71,7 +71,7 @@ | @@ -71,7 +71,7 @@ | ||
| 71 | 71 | ||
| 72 | <view class="company-clean-container-car-main-content-type"> | 72 | <view class="company-clean-container-car-main-content-type"> |
| 73 | <view class="company-clean-container-car-main-content-type-price-area"> | 73 | <view class="company-clean-container-car-main-content-type-price-area"> |
| 74 | - <text style="color: red;">*</text>添加车辆数量: | 74 | + <text style="color: red;">*</text>预估车辆数(趟): |
| 75 | </view> | 75 | </view> |
| 76 | <view style=" width:100%;display:flex; color:#909399; align-items: center;"> | 76 | <view style=" width:100%;display:flex; color:#909399; align-items: center;"> |
| 77 | <u-number-box :min="0" :max="9999" integer buttonSize="46" :inputWidth="100" | 77 | <u-number-box :min="0" :max="9999" integer buttonSize="46" :inputWidth="100" |
garbage-removal/src/pages/home/index.vue
| @@ -45,10 +45,12 @@ | @@ -45,10 +45,12 @@ | ||
| 45 | <u-dropdown active-color="#19a97c"> | 45 | <u-dropdown active-color="#19a97c"> |
| 46 | <u-dropdown-item :height="'240rpx'" :placement="'left'" v-model="registrationAreaValue" | 46 | <u-dropdown-item :height="'240rpx'" :placement="'left'" v-model="registrationAreaValue" |
| 47 | @change="handleDropdownAreaChange" :title="'所属区域'" :options="dropdownOptions[0]"></u-dropdown-item> | 47 | @change="handleDropdownAreaChange" :title="'所属区域'" :options="dropdownOptions[0]"></u-dropdown-item> |
| 48 | + | ||
| 48 | <u-dropdown-item :placement="'center'" v-model="carTypeValue" @change="handleDropdownCarChange" | 49 | <u-dropdown-item :placement="'center'" v-model="carTypeValue" @change="handleDropdownCarChange" |
| 49 | :title="'车辆类型'" :options="dropdownOptions[1]"></u-dropdown-item> | 50 | :title="'车辆类型'" :options="dropdownOptions[1]"></u-dropdown-item> |
| 51 | + | ||
| 50 | <u-dropdown-item :placement="'right'" v-model="sortValue" @change="handleDropdownSortChange" | 52 | <u-dropdown-item :placement="'right'" v-model="sortValue" @change="handleDropdownSortChange" |
| 51 | - :title="dropdownOptions[2][sortValue].label" :options="dropdownOptions[2]"></u-dropdown-item> | 53 | + :title="'排序'" :options="dropdownOptions[2]"></u-dropdown-item> |
| 52 | </u-dropdown> | 54 | </u-dropdown> |
| 53 | </view> | 55 | </view> |
| 54 | </view> | 56 | </view> |
| @@ -158,18 +160,14 @@ const carTypeValue = ref('') | @@ -158,18 +160,14 @@ const carTypeValue = ref('') | ||
| 158 | const carTypeRealValue = ref('') | 160 | const carTypeRealValue = ref('') |
| 159 | const dropdownOptions = ref([ | 161 | const dropdownOptions = ref([ |
| 160 | [{ | 162 | [{ |
| 161 | - label: '芙蓉区', | ||
| 162 | - value: '芙蓉区', | 163 | + label: '湘江新区', |
| 164 | + value: '湘江新区' | ||
| 163 | }, | 165 | }, |
| 164 | { | 166 | { |
| 165 | label: '天心区', | 167 | label: '天心区', |
| 166 | value: '天心区' | 168 | value: '天心区' |
| 167 | }, | 169 | }, |
| 168 | { | 170 | { |
| 169 | - label: '岳麓区', | ||
| 170 | - value: '岳麓区' | ||
| 171 | - }, | ||
| 172 | - { | ||
| 173 | label: '开福区', | 171 | label: '开福区', |
| 174 | value: '开福区' | 172 | value: '开福区' |
| 175 | }, | 173 | }, |
| @@ -194,25 +192,25 @@ const dropdownOptions = ref([ | @@ -194,25 +192,25 @@ const dropdownOptions = ref([ | ||
| 194 | value: '宁乡市' | 192 | value: '宁乡市' |
| 195 | }, | 193 | }, |
| 196 | { | 194 | { |
| 197 | - label: '湘江新区', | ||
| 198 | - value: '湘江新区' | 195 | + label: '芙蓉区', |
| 196 | + value: '芙蓉区' | ||
| 199 | } | 197 | } |
| 200 | ], [{ | 198 | ], [{ |
| 201 | label: '暂未开放', | 199 | label: '暂未开放', |
| 202 | value: '暂未开放', | 200 | value: '暂未开放', |
| 203 | },] | 201 | },] |
| 204 | , [{ | 202 | , [{ |
| 205 | - label: '距离排序', | 203 | + label: '距离优先', |
| 206 | value: 0, | 204 | value: 0, |
| 207 | }, | 205 | }, |
| 208 | - { | ||
| 209 | - label: '清运排序', | ||
| 210 | - value: 1 | ||
| 211 | - }, | ||
| 212 | - { | ||
| 213 | - label: '评价排序', | ||
| 214 | - value: 2 | ||
| 215 | - }] | 206 | + { |
| 207 | + label: '运量优先', | ||
| 208 | + value: 1 | ||
| 209 | + }, | ||
| 210 | + { | ||
| 211 | + label: '评分优先', | ||
| 212 | + value: 2 | ||
| 213 | + }] | ||
| 216 | ]) | 214 | ]) |
| 217 | 215 | ||
| 218 | // 信息指南 | 216 | // 信息指南 |
| @@ -417,11 +415,27 @@ onShow(() => { | @@ -417,11 +415,27 @@ onShow(() => { | ||
| 417 | 415 | ||
| 418 | const updateOrderBadge = async () => { | 416 | const updateOrderBadge = async () => { |
| 419 | try { | 417 | try { |
| 420 | - const res = await getOrderCountByType(0); | ||
| 421 | - await uni.setTabBarBadge({ | ||
| 422 | - index: 1, // 订单tab在tabBar中的索引 | ||
| 423 | - text: String(res.data.data.total) | ||
| 424 | - }); | 418 | + // 获取待清运订单数量(type=0) |
| 419 | + const pendingRes = await getOrderCountByType(0); | ||
| 420 | + const pendingCount = pendingRes.data.data.total || 0; | ||
| 421 | + | ||
| 422 | + // 获取清运中订单数量(type=1) | ||
| 423 | + const processingRes = await getOrderCountByType(1); | ||
| 424 | + const processingCount = processingRes.data.data.total || 0; | ||
| 425 | + | ||
| 426 | + // 计算总数 | ||
| 427 | + const totalCount = pendingCount + processingCount; | ||
| 428 | + | ||
| 429 | + if (totalCount > 0) { | ||
| 430 | + await uni.setTabBarBadge({ | ||
| 431 | + index: 1, // 订单tab在tabBar中的索引 | ||
| 432 | + text: String(totalCount) | ||
| 433 | + }); | ||
| 434 | + } else { | ||
| 435 | + await uni.removeTabBarBadge({ | ||
| 436 | + index: 1 | ||
| 437 | + }); | ||
| 438 | + } | ||
| 425 | } catch (error) { | 439 | } catch (error) { |
| 426 | console.error('获取订单数量失败:', error); | 440 | console.error('获取订单数量失败:', error); |
| 427 | } | 441 | } |
garbage-removal/src/pages/login/code.vue
| @@ -97,7 +97,6 @@ | @@ -97,7 +97,6 @@ | ||
| 97 | 97 | ||
| 98 | <view class="alternative"> | 98 | <view class="alternative"> |
| 99 | <!-- <text class="link" @click="toRegister">立即注册</text>--> | 99 | <!-- <text class="link" @click="toRegister">立即注册</text>--> |
| 100 | - <text class="link" @click="toChangePassword">修改密码</text> | ||
| 101 | </view> | 100 | </view> |
| 102 | </view> | 101 | </view> |
| 103 | </view> | 102 | </view> |
garbage-removal/src/pages/order-info/order-disposal/scan-detail/index.vue
| @@ -228,31 +228,44 @@ | @@ -228,31 +228,44 @@ | ||
| 228 | const handlerInputChange = (val) => { | 228 | const handlerInputChange = (val) => { |
| 229 | console.log(val); | 229 | console.log(val); |
| 230 | } | 230 | } |
| 231 | - const handlerSubmit = async () => { | ||
| 232 | - // 校验参数 | ||
| 233 | - let params = { | ||
| 234 | - ...details.value, | ||
| 235 | - fillImageList: fileList.value.map((item) => item.url), | ||
| 236 | - garOrderHandlerCompanyName: details.value.garOrderCompanyName, | ||
| 237 | - garOrderHandlerCompanyId: details.value.garOrderCompanyId, | ||
| 238 | - // 添加定位信息 | ||
| 239 | - latitude: location.value.latitude, | ||
| 240 | - longitude: location.value.longitude, | ||
| 241 | - transportDistance : details.value.transportDistance | ||
| 242 | - } | ||
| 243 | - if (validateParams(params)) { | ||
| 244 | - await askTransport(params).then((res) => { | ||
| 245 | - console.log(res); | ||
| 246 | - if (res.data.code == 200) { | ||
| 247 | - // 修改提示框,添加跳转到订单页面的选项 | ||
| 248 | - uni.$u.toast("当前趟次记录完毕!") | ||
| 249 | - } | ||
| 250 | - }).catch((err) => { | ||
| 251 | - uni.$u.toast("当前趟次记录失败") | ||
| 252 | - }) | ||
| 253 | - } | ||
| 254 | 231 | ||
| 255 | - } | 232 | + const handlerSubmit = async () => { |
| 233 | + // 校验参数 | ||
| 234 | + let params = { | ||
| 235 | + ...details.value, | ||
| 236 | + fillImageList: fileList.value.map((item) => item.url), | ||
| 237 | + garOrderHandlerCompanyName: details.value.garOrderCompanyName, | ||
| 238 | + garOrderHandlerCompanyId: details.value.garOrderCompanyId, | ||
| 239 | + // 添加定位信息 | ||
| 240 | + latitude: location.value.latitude, | ||
| 241 | + longitude: location.value.longitude, | ||
| 242 | + transportDistance : details.value.transportDistance | ||
| 243 | + } | ||
| 244 | + if (validateParams(params)) { | ||
| 245 | + // 添加确认提醒对话框 | ||
| 246 | + uni.showModal({ | ||
| 247 | + title: '确认提交', | ||
| 248 | + content: `请确认以下信息:\n\n车辆载重:${params.garCarryingWeight} 吨\n\n确认无误后点击确定提交`, | ||
| 249 | + success: function (res) { | ||
| 250 | + if (res.confirm) { | ||
| 251 | + // 用户点击确定 | ||
| 252 | + askTransport(params).then((res) => { | ||
| 253 | + console.log(res); | ||
| 254 | + if (res.data.code == 200) { | ||
| 255 | + // 修改提示框,添加跳转到订单页面的选项 | ||
| 256 | + uni.$u.toast("当前趟次记录完毕!") | ||
| 257 | + } | ||
| 258 | + }).catch((err) => { | ||
| 259 | + uni.$u.toast("当前趟次记录失败") | ||
| 260 | + }) | ||
| 261 | + } else if (res.cancel) { | ||
| 262 | + // 用户点击取消 | ||
| 263 | + console.log('用户点击取消'); | ||
| 264 | + } | ||
| 265 | + } | ||
| 266 | + }); | ||
| 267 | + } | ||
| 268 | + } | ||
| 256 | 269 | ||
| 257 | const validateParams = (params) => { | 270 | const validateParams = (params) => { |
| 258 | if (!params.garOrderHandlerName) { | 271 | if (!params.garOrderHandlerName) { |