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.

202 lines
4.8 KiB

3 years ago
<template>
3 years ago
<view class="page">
<ul class="tab">
<li v-for="(tab, i) in tabs" :class="{active: curTab === tab.id}" @click="tabChange(tab)">{{ tab.name }}</li>
</ul>
3 years ago
<uni-card :is-shadow="false" :border="false" padding="0" is-full>
<view class="filter">
3 years ago
<uni-search-bar class="search" radius="5" placeholder="请输入客户名称" v-model="keyword" clearButton="auto" cancelButton="none" />
<sl-filter class="sl-filter" :independence="true" :menuList="menuList" @result="result"></sl-filter>
</view>
3 years ago
</uni-card>
3 years ago
<template v-if="list.length">
<ul class="list">
<li v-for="item in list" @click="toDetail(item)">
<view class="name">{{ item.customerName }}</view>
<view class="info">
<view class="left">
<view class="text">联系人{{ item.orderContact }}</view>
<view class="text">账号{{ item.account }}</view>
<view class="text">产品到期时间{{ item.expireDate.replace(' 00:00:00', '') }}</view>
<view class="text">商务经理{{ item.account }}</view>
</view>
<view class="type">
{{ menuList[0].detailList.find(e => e.value === item.customerType).title }}客户
</view>
</view>
</li>
</ul>
<uni-load-more :status="status" />
</template>
<empty v-else></empty>
3 years ago
<uni-icons class="plus" type="plus-filled" size="60" color="#007eff" @click="$util.to('../clientDetail/clientDetail')"></uni-icons>
3 years ago
</view>
</template>
<script>
import { list, all } from '@/apis/modules/client.js'
3 years ago
import slFilter from '@/components/sl-filter/sl-filter.vue'
3 years ago
export default {
data() {
return {
3 years ago
menuList: [
{
'title': '客户类型',
'detailTitle': '请选择客户类型',
'key': 'customerType',
'isMutiple': false,
'detailList': [
{
'title': '正式',
'value': 1
},
{
'title': '试用',
'value': 2
},
{
'title': '到期',
'value': 3
}
]
}
],
curTab: 0,
tabs: [
{
name: '我的客户',
id: 0
},
{
name: '团队全部客户',
id: 1
}
],
3 years ago
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
status: 'more', // 上拉加载状态 more|loading|noMore
searchTimer: null,
customerType: '',
keyword: '',
list: [],
page: 1,
pageSize: 10
3 years ago
}
},
3 years ago
components: {
slFilter
},
watch: {
3 years ago
keyword () {
3 years ago
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initList()
}, 500)
}
},
// 下拉刷新
onPullDownRefresh() {
3 years ago
this.initList()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1500)
},
// 上拉加载
onReachBottom() {
3 years ago
if (this.reachBottom >= 0) {
this.reachBottom = 1
this.status = 'loading'
this.getList()
}
},
onShow() {
this.initList()
},
3 years ago
methods: {
getList() {
const method = this.curTab ? all : list
method({
businessManagerId: this.$util.getBmId(),
customerType: this.customerType,
keywords: this.keyword,
pageNum: this.page,
pageSize: this.pageSize
}).then(({ data }) => {
3 years ago
// 未加载完所有数据,并且不是筛选,则拼接list,否则直接赋值
this.list = this.reachBottom > 0 ? [...this.list, ...data.records] : data.records
3 years ago
this.page++ // 每次获取了数据后page+1
const noMore = this.list.length === data.total // 是否加载完所有数据
3 years ago
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1
}).catch(e => {})
},
3 years ago
initList() {
this.page = 1
this.reachBottom = 0
this.getList()
},
3 years ago
// 筛选确定回调
result(val) {
this.customerType = val.customerType
this.initList()
3 years ago
},
// tab切换
tabChange(tab) {
this.curTab = tab.id
this.initList()
},
// 跳转详情
3 years ago
toDetail(item) {
this.$util.to(`../clientDetail/clientDetail?customerId=${item.customerId}&show=1`)
3 years ago
}
}
}
</script>
3 years ago
<style scoped lang="scss">
3 years ago
.page {
padding-bottom: 90px;
}
.filter {
3 years ago
display: flex;
align-items: center;
.search {
flex: 1;
}
.sl-filter {
width: 30%;
margin-left: 10%;
}
3 years ago
}
.list {
margin-top: 20rpx;
background-color: #fff;
li {
padding: 20rpx 40rpx;
border-bottom: 1px solid #f1f1f1;
}
.num {
font-size: 32rpx;
3 years ago
color: #333;
}
.info {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10rpx;
3 years ago
}
.text {
padding: 8rpx 0;
font-size: 26rpx;
3 years ago
color: #ccc;
}
.type {
font-size: 28rpx;
color: #ff7b2d;
white-space: nowrap;
3 years ago
}
}
</style>