|
|
|
<template>
|
|
|
|
<view>
|
|
|
|
<!-- 筛选 -->
|
|
|
|
<view class="root" v-if="filterData.length > 1">
|
|
|
|
<ren-dropdown-filter v-if="filterData.length > 1" :filterData='filterData' @click="navClick"
|
|
|
|
:defaultIndex='defaultIndex' @ed='ed' @dateChange='dateChange'></ren-dropdown-filter>
|
|
|
|
</view>
|
|
|
|
<view class="card-box" v-if="goodsHomeList.length > 0">
|
|
|
|
<task-home-list class="task-home" splitLine @click="clickItem" :list="goodsHomeList"></task-home-list>
|
|
|
|
</view>
|
|
|
|
<!-- 加载更多提示 -->
|
|
|
|
<view v-if="goodsHomeList.length > 0">
|
|
|
|
<load-more :loadingType="loadingType" :contentText="contentText"></load-more>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import RenDropdownFilter from '@/components/ren-dropdown-filter/ren-dropdown-filter.vue'
|
|
|
|
import taskHomeList from "@/components/mask/task-home-list1.vue"
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
taskHomeList,
|
|
|
|
RenDropdownFilter
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
city: '',
|
|
|
|
latitude: '',
|
|
|
|
longitude: '',
|
|
|
|
sortType: 0,
|
|
|
|
typeId: 0,
|
|
|
|
tuijianList: [],
|
|
|
|
goodsHomeList: [],
|
|
|
|
page: 1,
|
|
|
|
limit: 10,
|
|
|
|
loadingType: 0,
|
|
|
|
contentText: {
|
|
|
|
contentdown: '上拉显示更多',
|
|
|
|
contentrefresh: '正在加载...',
|
|
|
|
contentnomore: '没有更多数据了'
|
|
|
|
},
|
|
|
|
filterData: [
|
|
|
|
[{
|
|
|
|
text: '综合分类',
|
|
|
|
value: ''
|
|
|
|
}, {
|
|
|
|
text: '返现最高',
|
|
|
|
value: 1
|
|
|
|
}, {
|
|
|
|
text: '最新发布',
|
|
|
|
value: 2
|
|
|
|
}, {
|
|
|
|
text: '距离最近',
|
|
|
|
value: 3
|
|
|
|
}]
|
|
|
|
],
|
|
|
|
defaultIndex: [0, 0]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad() {
|
|
|
|
this.city = this.$queue.getData('city');
|
|
|
|
this.latitude = this.$queue.getData('latitude');
|
|
|
|
this.longitude = this.$queue.getData('longitude');
|
|
|
|
this.getnavlistClassify();
|
|
|
|
this.getHaoDianTuiJian();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getnavlistClassify() {
|
|
|
|
this.$Request.getT('/banner/selectBannerList?state=-1&classify=2').then(res => {
|
|
|
|
if (res.code === 0) {
|
|
|
|
let dataList = [];
|
|
|
|
let data = {
|
|
|
|
text: '全部品类',
|
|
|
|
value: 0
|
|
|
|
}
|
|
|
|
dataList.push(data);
|
|
|
|
|
|
|
|
res.data.forEach(d => {
|
|
|
|
let data = {
|
|
|
|
text: '',
|
|
|
|
value: ''
|
|
|
|
}
|
|
|
|
data.text = d.name;
|
|
|
|
data.value = d.id;
|
|
|
|
dataList.push(data);
|
|
|
|
});
|
|
|
|
this.filterData.push(dataList);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getHaoDianTuiJian() {
|
|
|
|
this.loadingType = 1;
|
|
|
|
uni.showLoading({
|
|
|
|
title: '加载中...',
|
|
|
|
});
|
|
|
|
let data = {
|
|
|
|
page: this.page,
|
|
|
|
limit: this.limit,
|
|
|
|
longitude: this.longitude,
|
|
|
|
latitude: this.latitude,
|
|
|
|
city: this.city,
|
|
|
|
search: '',
|
|
|
|
sort: this.sortType,
|
|
|
|
typeId: this.typeId,
|
|
|
|
isGoods: '1'
|
|
|
|
|
|
|
|
}
|
|
|
|
this.$Request.getT('/wm/selectHomeGoodsList', data).then(res => {
|
|
|
|
if (res.code === 0) {
|
|
|
|
if (this.page === 1) {
|
|
|
|
this.goodsHomeList = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
res.data.list.forEach(d => {
|
|
|
|
d.distance = this.setMorKm(d.distance);
|
|
|
|
this.goodsHomeList.push(d)
|
|
|
|
});
|
|
|
|
if (res.data.list.length === this.limit) {
|
|
|
|
this.loadingType = 0;
|
|
|
|
} else {
|
|
|
|
this.loadingType = 3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.loadingType = 2;
|
|
|
|
}
|
|
|
|
uni.hideLoading();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
goLogin() {
|
|
|
|
//#ifndef H5
|
|
|
|
uni.navigateTo({
|
|
|
|
url: '/pages/public/login'
|
|
|
|
});
|
|
|
|
//#endif
|
|
|
|
//#ifdef H5
|
|
|
|
window.location.href = 'http://waimai.admin.service.yiqihuiju.com/sqx_fast/appLogin/wechatLogin';
|
|
|
|
//#endif
|
|
|
|
},
|
|
|
|
goDetail(nav) {
|
|
|
|
uni.navigateTo({
|
|
|
|
url: '/pages/index/taskDetail?goodsId=' + nav.goodsId + '&latitude=' + this
|
|
|
|
.latitude + '&longitude=' + this.longitude
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navClick: function(res) {
|
|
|
|
console.log('点击', res)
|
|
|
|
this.page = 1;
|
|
|
|
if (res.index1 == 0) {
|
|
|
|
this.sortType = res.index ? res.index : 0;
|
|
|
|
this.getHaoDianTuiJian();
|
|
|
|
} else if (res.index1 == 1) {
|
|
|
|
this.typeId = res.index ? res.index : 0;
|
|
|
|
this.getHaoDianTuiJian();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clickItem: function(options) {
|
|
|
|
let token = this.$queue.getData('token');
|
|
|
|
let userId = this.$queue.getData('userId');
|
|
|
|
if (token) {
|
|
|
|
uni.navigateTo({
|
|
|
|
url: '/pages/index/taskDetail?goodsId=' + options.item.goodsId + '&latitude=' + this
|
|
|
|
.latitude + '&longitude=' + this.longitude
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.goLogin();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setMorKm(m) {
|
|
|
|
var n = ''
|
|
|
|
if (m) {
|
|
|
|
if (m >= 1000) {
|
|
|
|
n = (m / 1000).toFixed(0) + 'km'
|
|
|
|
} else {
|
|
|
|
n = parseInt(m) + 'm'
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
n = '0m'
|
|
|
|
}
|
|
|
|
return n
|
|
|
|
},
|
|
|
|
topScrollTap: function() {
|
|
|
|
uni.pageScrollTo({
|
|
|
|
scrollTop: 0,
|
|
|
|
duration: 300
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onPageScroll: function(e) {
|
|
|
|
this.scrollTop = e.scrollTop > 200;
|
|
|
|
},
|
|
|
|
onReachBottom: function() {
|
|
|
|
this.page = this.page + 1;
|
|
|
|
this.getHaoDianTuiJian();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
page {
|
|
|
|
width: 100%;
|
|
|
|
background: #F7F7F7;
|
|
|
|
}
|
|
|
|
|
|
|
|
.root {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
z-index: 1;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.card-box {
|
|
|
|
// padding: 0 30upx;
|
|
|
|
background-color: #FFF;
|
|
|
|
margin-top: 100rpx;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
.title {
|
|
|
|
height: 86upx;
|
|
|
|
font-size: 34upx;
|
|
|
|
font-weight: 800;
|
|
|
|
color: #333333;
|
|
|
|
line-height: 86upx;
|
|
|
|
padding: 0 30upx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.task-home {
|
|
|
|
display: inline-block;
|
|
|
|
width: 100%;
|
|
|
|
// margin-top: 30upx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|