Refactor(首页):改版重构-接口对接

This commit is contained in:
lifizer
2024-07-31 21:38:49 +08:00
parent b9c3ff756c
commit 46b4f05a6b
5 changed files with 110 additions and 21 deletions
+40 -10
View File
@@ -7,16 +7,15 @@
}"
:class="scrollTop > 40 ? 'blur' : ''"
class="fix-header"
@click="goGoodSearch"
>
<view class="location">
昆明
<view class="location" @click="reLocateHandle()">
{{ isLocating ? '定位中' : (cityName || '定位失败') }}
<image
:src="webUrl + '/home/icon-location.png'"
class="icon"
/>
</view>
<view class="search-wrap">
<view class="search-wrap" @click="goGoodSearch">
<image
:src="webUrl + '/home/icon-search.png'"
class="icon"
@@ -191,7 +190,7 @@
:src="swiperItem.image"
mode="scaleToFill"
class="swiper-img"
@click="goHomeStay(swiperItem)"
@click="productSwiperItemClickHandle(swiperItem)"
/>
</swiper-item>
</swiper>
@@ -208,7 +207,7 @@
</view>
<!-- v9 老用户弹窗 -->
<u-popup
:show="isOldUser"
:show="isOldUser && oldUserPopup.image"
mode="center"
bgColor="transparent"
>
@@ -251,6 +250,12 @@ import { getCouponReceive } from '@/api/user'
import { getHomeData, getShareImage } from '@/api/public'
import { sharpBannar } from '@/api/goods'
import { pageListenMixins } from '@/mixins/pageListenMixins'
import {
getCurAddress,
getLocationPromise,
getLocationSetting,
openLocationSettting
} from "@/utils/common"
export default {
name: 'IndexPage',
components: {
@@ -267,6 +272,8 @@ export default {
rightDistance: 10,
banner: [],
menus: [],
// 定位中
isLocating: true,
cityName: '',
// 地标好物
landmarkGoodsImage: {},
@@ -334,11 +341,31 @@ export default {
this.bannerList = data.banner
this.getPageData()
})
this.getLocationData()
},
reLocateHandle() {
if (this.cityName) return
getLocationSetting(() => openLocationSettting().then(() => {
this.getLocationData()
}))
},
async getLocationData() {
this.isLocating = true
const mapData = await getLocationPromise()
if (mapData.errMsg) {
const { latitude, longitude } = mapData
const address = await getCurAddress(latitude, longitude)
this.cityName = address[1].data.result.ad_info.city
this.isLocating = false
this.getPageData()
} else {
this.isLocating = false
}
},
getPageData() {
const _this = this
uni.showLoading({ title: '加载中' })
getHomeData().then(res => {
getHomeData({ cityName: this.cityName }).then(res => {
const { data } = res
_this.$set(_this, 'banner', data.banner)
_this.$set(_this, 'menus', data.menus)
@@ -366,15 +393,15 @@ export default {
list: [
{
image: 'http://resource.xdd618.com/19/20240722/1721615384602_入口图8.jpg',
url: '/pkg_product/views/festival'
id: 5781
},
{
image: 'http://resource.xdd618.com/19/20240715/1721006994007_微信图片_20240715092549.jpg',
url: '/pkg_product/views/festival'
id: 5781
},
{
image: 'http://resource.xdd618.com/19/20240722/1721615384602_入口图8.jpg',
url: '/pkg_product/views/festival'
id: 5781
}
]
})
@@ -478,6 +505,9 @@ export default {
hotelItemClickHandle(item) {
uni.navigateTo({ url: item.url })
},
productSwiperItemClickHandle(item) {
uni.navigateTo({url: '/pkg_product/views/homestay?id=' + item.id})
},
setTopHandle() {
uni.pageScrollTo({
scrollTop: 0,