| | |
| | | |
| | | <script> |
| | | import { mapState } from 'vuex' |
| | | import { checkLocationPermission } from '@/utils/utils' |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | if (this.hallLoading || !this.hallHasMore) { |
| | | return |
| | | } |
| | | this.hallLoading = true |
| | | |
| | | let distance = null |
| | | if (this.selectedFilters.distance !== '不限') { |
| | | const distanceText = this.selectedFilters.distance |
| | | if (distanceText.includes('km')) { |
| | | distance = parseInt(distanceText) * 1000 |
| | | |
| | | checkLocationPermission().then((granted) => { |
| | | if (granted) { |
| | | console.log('已有位置权限') |
| | | this.hallLoading = true |
| | | |
| | | let distance = null |
| | | if (this.selectedFilters.distance !== '不限') { |
| | | const distanceText = this.selectedFilters.distance |
| | | if (distanceText.includes('km')) { |
| | | distance = parseInt(distanceText) * 1000 |
| | | } else { |
| | | distance = parseInt(distanceText) |
| | | } |
| | | } |
| | | |
| | | const sortTypeMap = { |
| | | '综合排序': 1, |
| | | '距离最近': 2 |
| | | } |
| | | const sortType = this.selectedFilters.sort !== '不限' ? (sortTypeMap[this.selectedFilters.sort] || null) : null |
| | | |
| | | let gradeId = null |
| | | if (this.selectedFilters.level !== '不限') { |
| | | const selectedCategory = this.categoryList.find(item => item.name === this.selectedFilters.level) |
| | | if (selectedCategory) { |
| | | gradeId = selectedCategory.id |
| | | } |
| | | } |
| | | |
| | | console.log('接单大厅:', { distance, gradeId, sortType }) |
| | | this.$u.api.grabOrderHall({ |
| | | capacity: this.hallPageSize, |
| | | page: this.hallPage, |
| | | model: { |
| | | distance: distance, |
| | | gradeId: gradeId, |
| | | sortType: sortType |
| | | } |
| | | }).then(res => { |
| | | console.log('接单大厅', res) |
| | | this.hallLoading = false |
| | | if (res.code === 200) { |
| | | const list = res.data.records || [] |
| | | this.orderList = this.hallPage === 1 ? list : this.orderList.concat(list) |
| | | this.hallHasMore = list.length >= this.hallPageSize |
| | | } |
| | | }).finally(() => { |
| | | this.hallLoading = false |
| | | }) |
| | | } else { |
| | | distance = parseInt(distanceText) |
| | | console.log('还没有位置权限') |
| | | } |
| | | } |
| | | |
| | | const sortTypeMap = { |
| | | '综合排序': 1, |
| | | '距离最近': 2 |
| | | } |
| | | const sortType = this.selectedFilters.sort !== '不限' ? (sortTypeMap[this.selectedFilters.sort] || null) : null |
| | | |
| | | let gradeId = null |
| | | if (this.selectedFilters.level !== '不限') { |
| | | const selectedCategory = this.categoryList.find(item => item.name === this.selectedFilters.level) |
| | | if (selectedCategory) { |
| | | gradeId = selectedCategory.id |
| | | } |
| | | } |
| | | |
| | | console.log('接单大厅:', { distance, gradeId, sortType }) |
| | | this.$u.api.grabOrderHall({ |
| | | capacity: this.hallPageSize, |
| | | page: this.hallPage, |
| | | model: { |
| | | distance: distance, |
| | | gradeId: gradeId, |
| | | sortType: sortType |
| | | } |
| | | }).then(res => { |
| | | console.log('接单大厅', res) |
| | | this.hallLoading = false |
| | | if (res.code === 200) { |
| | | const list = res.data.records || [] |
| | | this.orderList = this.hallPage === 1 ? list : this.orderList.concat(list) |
| | | this.hallHasMore = list.length >= this.hallPageSize |
| | | } |
| | | }).finally(() => { |
| | | this.hallLoading = false |
| | | }) |
| | | }, |
| | | |