You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.7 KiB

<template>
<view>
<view class="card-box" v-if="list.length > 0" style="margin-top: 20rpx;">
<task-home-list class="task-home" splitLine @click="clickItem" :list="list"></task-home-list>
</view>
<!-- 加载更多提示 -->
<view v-if="list.length > 0 ">
<load-more :loadingType="loadingType" :contentText="contentText"></load-more>
</view>
<!-- 暂无数据展示 -->
<empty v-if="list.length === 0" des="暂无渠道商品数据" show="false"></empty>
</view>
</template>
<script>
import taskHomeList from "@/components/mask/task-home-list1.vue"
export default {
components: {
taskHomeList
},
data() {
return {
page: 1,
limit: 10,
list: [],
loadingType: 0,
scrollTop: false,
contentText: {
contentdown: '上拉显示更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了'
},
}
},
onLoad() {
this.getGoodsList();
},
methods: {
goLogin() {
this.$queue.setData('href', '/pages/index/index');
uni.navigateTo({
url: '/pages/public/login'
});
},
clickItem: function(options) {
let token = this.$queue.getData('token');
let userId = this.$queue.getData('userId');
let latitude = this.$queue.getData('latitude');
let longitude = this.$queue.getData('longitude');
if (token) {
uni.navigateTo({
url: '/pages/index/taskDetail?goodsId=' + options.item.goodsId + '&latitude=' + latitude + '&longitude=' + 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
},
getGoodsList() {
this.$queue.showLoading('加载中...');
let userId = this.$queue.getData('userId');
this.$Request.getT('/wm/selectGoodsList?page=' + this.page + '&limit=' + this.limit + '&channelUserId=' +
userId).then(res => {
if (res.code === 0) {
if (this.page === 1) {
this.list = [];
}
res.data.list.forEach(d => {
// d.distance = this.setMorKm(d.distance);
this.list.push(d)
});
console.log(this.list.length)
if (res.data.list.length === this.limit) {
this.loadingType = 0;
} else {
this.loadingType = 3;
}
} else {
this.loadingType = 2;
}
uni.hideLoading();
});
},
topScrollTap: function() {
uni.pageScrollTo({
scrollTop: 0,
duration: 300
});
}
},
onPageScroll: function(e) {
this.scrollTop = e.scrollTop > 200;
},
onReachBottom: function() {
this.page = this.page + 1;
this.getGoodsList();
}
}
</script>
<style>
</style>