|
|
|
@ -9,27 +9,18 @@ import PageSkeleton from './components/PageSkeleton.vue'
|
|
|
|
|
import PhoneContact from './components/PhoneContact.vue'
|
|
|
|
|
import NeighborhoodSite from './components/NeighborhoodSite.vue'
|
|
|
|
|
import { getHomeCategoryAPI, getNearbySiteAPI } from '@/services/home'
|
|
|
|
|
import { serviceDomain } from '@/services/constants'
|
|
|
|
|
import { serviceDomain, bannerList, categoryListDefault } from '@/services/constants'
|
|
|
|
|
import { useCategoryStore } from '@/stores/modules/category'
|
|
|
|
|
|
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
|
const categoryStore = useCategoryStore()
|
|
|
|
|
|
|
|
|
|
// 获取轮播图数据
|
|
|
|
|
const bannerList = reactive<BannerItem[]>([
|
|
|
|
|
{
|
|
|
|
|
id: '1',
|
|
|
|
|
imgUrl: '/static/images/banner1.jpg',
|
|
|
|
|
hrefUrl: '1013001',
|
|
|
|
|
type: '1',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: '2',
|
|
|
|
|
imgUrl: '/static/images/banner1.jpg',
|
|
|
|
|
hrefUrl: '1019000',
|
|
|
|
|
type: '1',
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
const isLogin = computed(() => {
|
|
|
|
|
const token = memberStore.profile?.token
|
|
|
|
|
const storage_token = uni.getStorageSync('storage_userInfo')?.token
|
|
|
|
|
return !!token || !!storage_token
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 获取前台分类数据
|
|
|
|
|
const categoryList = ref<CategoryItem[]>([])
|
|
|
|
|
let siteList = reactive([])
|
|
|
|
@ -38,27 +29,24 @@ let location = reactive({
|
|
|
|
|
longitude: 0,
|
|
|
|
|
latitude: 0,
|
|
|
|
|
})
|
|
|
|
|
const isLogin = computed(() => {
|
|
|
|
|
const token = memberStore.profile?.token
|
|
|
|
|
const storage_token = uni.getStorageSync('storage_userInfo')?.token
|
|
|
|
|
return !!token || !!storage_token
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 是否加载中标记
|
|
|
|
|
const isLoading = ref(false)
|
|
|
|
|
const isUpdate = ref(true)
|
|
|
|
|
// 页面加载
|
|
|
|
|
onShow(async () => {
|
|
|
|
|
// getHomeCategory()
|
|
|
|
|
if (isLogin.value) {
|
|
|
|
|
getSettingInfo()
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateTo({ url: '/pages/login/login' })
|
|
|
|
|
categoryList.value = categoryListDefault
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const init = async () => {
|
|
|
|
|
isLoading.value = true
|
|
|
|
|
await getHomeCategory()
|
|
|
|
|
await getHomeSite()
|
|
|
|
|
isUpdate.value = false
|
|
|
|
|
// await Promise.all([getHomeCategory(), getHomeSite()])
|
|
|
|
|
isLoading.value = false
|
|
|
|
|
}
|
|
|
|
@ -66,7 +54,6 @@ const init = async () => {
|
|
|
|
|
const getHomeCategory = async () => {
|
|
|
|
|
const params = {}
|
|
|
|
|
const res = await getHomeCategoryAPI(params)
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
res.data.forEach((e) => {
|
|
|
|
|
const arr = e.photo && JSON.parse(e.photo) || []
|
|
|
|
|
const obj2 = arr[0]
|
|
|
|
@ -75,7 +62,6 @@ const getHomeCategory = async () => {
|
|
|
|
|
})
|
|
|
|
|
categoryList.value = res.data
|
|
|
|
|
categoryStore.changeSelectedCategory(res.data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const getHomeSite = async () => {
|
|
|
|
|
// 请求参数
|
|
|
|
@ -110,7 +96,7 @@ const getLocationInfo = () => {
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
})
|
|
|
|
|
uni.setStorageSync('location', location)
|
|
|
|
|
if (!categoryList.value.length) {
|
|
|
|
|
if (isUpdate.value) {
|
|
|
|
|
init()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|