|
|
@ -1,8 +1,8 @@
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed, ref, toRaw, reactive } from 'vue'
|
|
|
|
import { computed, ref, toRaw, reactive } from 'vue'
|
|
|
|
import { onShow, onLoad } from '@dcloudio/uni-app'
|
|
|
|
import { onShow, onLoad } from '@dcloudio/uni-app'
|
|
|
|
import AddressPopup from './components/addressPopup.vue'
|
|
|
|
// import AddressPopup from './components/addressPopup.vue'
|
|
|
|
import SitePopup from './components/sitePopup.vue'
|
|
|
|
// import SitePopup from './components/sitePopup.vue'
|
|
|
|
import { postBookingAPI } from '@/services/booking'
|
|
|
|
import { postBookingAPI } from '@/services/booking'
|
|
|
|
import { getNearbySiteAPI } from '@/services/home'
|
|
|
|
import { getNearbySiteAPI } from '@/services/home'
|
|
|
|
import { getMemberAddressAPI } from '@/services/address'
|
|
|
|
import { getMemberAddressAPI } from '@/services/address'
|
|
|
@ -12,17 +12,15 @@ import TimePanel from './components/TimePanel.vue'
|
|
|
|
import SitePanel from './components/SitePanel.vue'
|
|
|
|
import SitePanel from './components/SitePanel.vue'
|
|
|
|
import { useMemberStore } from '@/stores'
|
|
|
|
import { useMemberStore } from '@/stores'
|
|
|
|
import { useCategoryStore } from '@/stores/modules/category'
|
|
|
|
import { useCategoryStore } from '@/stores/modules/category'
|
|
|
|
|
|
|
|
|
|
|
|
const categoryStore = useCategoryStore()
|
|
|
|
const categoryStore = useCategoryStore()
|
|
|
|
const locationStorge = uni.getStorageSync('location')
|
|
|
|
|
|
|
|
const storage_staffId = uni.getStorageSync('storage_userInfo').id
|
|
|
|
|
|
|
|
// 散户id
|
|
|
|
// 散户id
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
const staffId = memberStore.profile?.id || storage_staffId
|
|
|
|
let staffId = memberStore.profile?.id
|
|
|
|
|
|
|
|
|
|
|
|
// 经纬度
|
|
|
|
// 经纬度
|
|
|
|
let location = reactive({
|
|
|
|
let location = reactive({
|
|
|
|
longitude: locationStorge.longitude,
|
|
|
|
longitude: '',
|
|
|
|
latitude: locationStorge.latitude,
|
|
|
|
latitude: '',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 弹出层组件是否展示
|
|
|
|
// 弹出层组件是否展示
|
|
|
@ -47,17 +45,21 @@ const isBooking = computed(() => {
|
|
|
|
const categorySelecteds = categoryList.filter((e) => e.selected)
|
|
|
|
const categorySelecteds = categoryList.filter((e) => e.selected)
|
|
|
|
return appointmentTime.value && recycleAddress.value && categorySelecteds.length
|
|
|
|
return appointmentTime.value && recycleAddress.value && categorySelecteds.length
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onShow(() => {
|
|
|
|
onLoad(() => {
|
|
|
|
|
|
|
|
const categoryListStore = categoryStore.categoryVal
|
|
|
|
|
|
|
|
categoryList = Object.assign([], categoryListStore)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
onShow(async () => {
|
|
|
|
// 分类
|
|
|
|
// 分类
|
|
|
|
const categoryListStore = categoryStore.selectedCategoryVal || []
|
|
|
|
|
|
|
|
const productCode = uni.getStorageSync('productCode')
|
|
|
|
const productCode = uni.getStorageSync('productCode')
|
|
|
|
categoryListStore.forEach((e) => {
|
|
|
|
categoryList.forEach((e) => {
|
|
|
|
e.selected = e.code == productCode
|
|
|
|
e.selected = e.code == productCode
|
|
|
|
e.disabled = false
|
|
|
|
// e.disabled = false
|
|
|
|
})
|
|
|
|
|
|
|
|
categoryList = Object.assign(categoryList, categoryListStore)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onLoad(async () => {
|
|
|
|
categoryList = Object.assign([], categoryList)
|
|
|
|
|
|
|
|
if (!staffId) {
|
|
|
|
|
|
|
|
staffId = uni.getStorageSync('storage_userInfo').id
|
|
|
|
|
|
|
|
}
|
|
|
|
// 地址
|
|
|
|
// 地址
|
|
|
|
await getMemberAddressData()
|
|
|
|
await getMemberAddressData()
|
|
|
|
// 获取默认地址的站点类目
|
|
|
|
// 获取默认地址的站点类目
|
|
|
@ -69,14 +71,13 @@ onLoad(async () => {
|
|
|
|
* @return {[type]} [return description]
|
|
|
|
* @return {[type]} [return description]
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
const getNearbySite = async () => {
|
|
|
|
const getNearbySite = async () => {
|
|
|
|
// const productCode = uni.getStorageSync('productCode')
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
const params = {
|
|
|
|
...location,
|
|
|
|
...location,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('getNearbySiteAPI-params', params)
|
|
|
|
console.log('getNearbySiteAPI-params', params)
|
|
|
|
const res = await getNearbySiteAPI(params)
|
|
|
|
const res = await getNearbySiteAPI(params)
|
|
|
|
const obj = res.data
|
|
|
|
const obj = res.data
|
|
|
|
console.log('getNearbySiteAPI', res.data.stationProducts)
|
|
|
|
console.log('getNearbySiteAPI', res.data)
|
|
|
|
if (obj) {
|
|
|
|
if (obj) {
|
|
|
|
if (obj.stationProducts && obj.stationProducts.length) {
|
|
|
|
if (obj.stationProducts && obj.stationProducts.length) {
|
|
|
|
categoryList.forEach((e) => {
|
|
|
|
categoryList.forEach((e) => {
|
|
|
@ -91,33 +92,41 @@ const getNearbySite = async () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
recycleStationId.value = obj.id
|
|
|
|
recycleStationId.value = obj.id
|
|
|
|
console.log('categoryList', categoryList)
|
|
|
|
categoryList = Object.assign([], categoryList)
|
|
|
|
|
|
|
|
// categoryStore.changeCategory(categoryList)
|
|
|
|
|
|
|
|
// console.log('categoryList', categoryList)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
uni.showToast({ icon: 'none', title: '当前位置的回收站点没有配置回收品类...' })
|
|
|
|
categoryList.forEach((e) => {
|
|
|
|
|
|
|
|
e.disabled = true
|
|
|
|
|
|
|
|
e.selected = false
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
categoryList = Object.assign([], categoryList)
|
|
|
|
|
|
|
|
uni.showToast({ icon: 'none', duration: 3000, title: '下单地址附近的回收站没有配置回收品类...' })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
categoryList.forEach((e) => {
|
|
|
|
categoryList.forEach((e) => {
|
|
|
|
e.disabled = true
|
|
|
|
e.disabled = true
|
|
|
|
e.selected = false
|
|
|
|
e.selected = false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
uni.showToast({ icon: 'none', title: '当前位置附近没有回收站点...' })
|
|
|
|
categoryList = Object.assign([], categoryList)
|
|
|
|
|
|
|
|
uni.showToast({ icon: 'none', duration: 3000, title: '下单地址附近没有回收站...' })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取地址,取默认地址
|
|
|
|
// 获取地址,取默认地址
|
|
|
|
const getMemberAddressData = async () => {
|
|
|
|
const getMemberAddressData = async () => {
|
|
|
|
|
|
|
|
console.log(staffId)
|
|
|
|
const params = {
|
|
|
|
const params = {
|
|
|
|
clientId: staffId,
|
|
|
|
clientId: staffId,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const res = await getMemberAddressAPI(params)
|
|
|
|
const res = await getMemberAddressAPI(params)
|
|
|
|
const index = res.data.findIndex((e) => e.isDefault)
|
|
|
|
const index = res.data.findIndex((e) => e.isDefault)
|
|
|
|
const defaultAddress = res.data[index]
|
|
|
|
const defaultAddress = res.data[index]
|
|
|
|
recycleAddress.value = defaultAddress.receiveStreet
|
|
|
|
recycleAddress.value = defaultAddress?.receiveStreet
|
|
|
|
clientAddressId.value = defaultAddress.id
|
|
|
|
clientAddressId.value = defaultAddress.id
|
|
|
|
location = Object.assign(location, {
|
|
|
|
location = Object.assign(location, {
|
|
|
|
longitude: defaultAddress.location.longitude,
|
|
|
|
longitude: defaultAddress.location.longitude,
|
|
|
|
latitude: defaultAddress.location.latitude,
|
|
|
|
latitude: defaultAddress.location.latitude,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
uni.setStorageSync('location', location)
|
|
|
|
|
|
|
|
addressList = Object.assign(addressList, res.data)
|
|
|
|
addressList = Object.assign(addressList, res.data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 预估重量
|
|
|
|
// 预估重量
|
|
|
@ -209,7 +218,6 @@ const handlePopClose = (item) => {
|
|
|
|
longitude: item.location.longitude,
|
|
|
|
longitude: item.location.longitude,
|
|
|
|
latitude: item.location.latitude,
|
|
|
|
latitude: item.location.latitude,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
uni.setStorageSync('location', location)
|
|
|
|
|
|
|
|
// 更新类目
|
|
|
|
// 更新类目
|
|
|
|
getNearbySite()
|
|
|
|
getNearbySite()
|
|
|
|
}
|
|
|
|
}
|
|
|
|