首页更新
This commit is contained in:
@@ -63,7 +63,8 @@
|
||||
<view class="fivecontent" :style="{'height':seighT + 'px'}">
|
||||
<!-- <scroll-view :style="{'height':seighT + 'px'}" scroll-y @scrolltolower="loadMore"
|
||||
scroll-with-animation> -->
|
||||
<view class="fivecontent_item" v-for="(item,index) in homelist" :key="index">
|
||||
<view class="fivecontent_item" v-for="(item,index) in homelist" :key="index"
|
||||
@click="fivecontentclick(item)">
|
||||
<view class="fivecontent_item_nav flex-start">
|
||||
<image :src="item.shopImage" mode="aspectFill"></image>
|
||||
<view class="fivecontent_item_nav_left">
|
||||
@@ -72,7 +73,7 @@
|
||||
{{item.shopName}}
|
||||
</view>
|
||||
<view>
|
||||
龙首.{{item.distances}}m
|
||||
龙首.{{item.distances}}km
|
||||
</view>
|
||||
</view>
|
||||
<view class="fivecontent_item_nav_lefttopstart flex-start">
|
||||
@@ -288,6 +289,26 @@
|
||||
},
|
||||
},
|
||||
async onLoad() {
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
console.log(res, '获取距离')
|
||||
// this.lng = res.longitude
|
||||
// this.lat = res.latitude
|
||||
// this.positionindex()
|
||||
},
|
||||
fail: (err) => {
|
||||
// this.positionindex()
|
||||
console.log(err, '获取错误')
|
||||
}
|
||||
});
|
||||
// 测试
|
||||
let datastorage = {
|
||||
address: '西安市', //地址
|
||||
lng: '108.949158',
|
||||
lat: '34.301731',
|
||||
}
|
||||
uni.cache.set('getLocationstorage', datastorage);
|
||||
setTimeout(() => {
|
||||
this.GetTop()
|
||||
}, 1000)
|
||||
@@ -311,8 +332,11 @@
|
||||
uindexlist() {
|
||||
uni.pro.navigateTo('index/uindexlist')
|
||||
},
|
||||
fivecontentclick(item) {
|
||||
uni.pro.navigateTo('product/index', item)
|
||||
},
|
||||
updateCity(data) {
|
||||
this.list[data].end_times = 0;
|
||||
thiss.list[data].end_times = 0;
|
||||
this.$forceUpdate();
|
||||
},
|
||||
//获取元素距离顶部的距离
|
||||
@@ -370,9 +394,9 @@
|
||||
init_fn() {
|
||||
this.homelist = []
|
||||
this.form = {
|
||||
address: '西安市', //地址
|
||||
lng: '108.949158',
|
||||
lat: '34.301731',
|
||||
address:uni.cache.get('getLocationstorage').address, //地址
|
||||
lng: uni.cache.get('getLocationstorage').lng,
|
||||
lat: uni.cache.get('getLocationstorage').lat,
|
||||
type: '', //品类
|
||||
orderBy: 0, //1.理我最近 2.销量优先 3.价格优先
|
||||
other: '', //附近1KM 1选中 0不选中
|
||||
@@ -386,7 +410,7 @@
|
||||
try {
|
||||
let res = await this.api.home(this.form)
|
||||
var dates = new Date().getTime();
|
||||
res.data.forEach((item, index) => {
|
||||
res.data.list.forEach((item, index) => {
|
||||
var leftTime = item.endTime - dates; //计算两日期之间相差的毫秒数
|
||||
if (leftTime >= 0) {
|
||||
let d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
|
||||
@@ -403,19 +427,22 @@
|
||||
item.end_times = 0
|
||||
}
|
||||
})
|
||||
|
||||
if (res.data.length == 0) {
|
||||
if (res.data.pages < this.form.page) {
|
||||
this.form.status = 'nomore'
|
||||
// if (res.data.pageNum == 1) {
|
||||
// this.is_end = true
|
||||
// }
|
||||
return false;
|
||||
} else {
|
||||
this.form.status = 'loading';
|
||||
this.form.page = ++this.form.page;
|
||||
setTimeout(() => {
|
||||
this.homelist = [...this.homelist, ...res.data];
|
||||
if (res.data.length == 10) {
|
||||
this.form.status = 'loading';
|
||||
} else {
|
||||
this.homelist = [...this.homelist, ...res.data.list];
|
||||
this.form.status = 'loading';
|
||||
if (res.data.pageNum == res.data.pages) {
|
||||
this.form.status = 'nomore';
|
||||
} else {
|
||||
this.form.status = 'loading';
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user