You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bsdgy-front/src/pages/CustomerView.vue

488 lines
22 KiB
Vue

6 years ago
<template>
<div>
<Row :gutter="32">
<i-col span="32">
<row>
<!--筛选-->
<row style="margin-top: -2px">
<i-col span="5">
<row style="width: 330px;border: 1px solid #E8ECF2;border-radius: 8px;padding: 3px">
<span class="date-btn" :style="dateBtnValue === '今日' ? 'background: #2D8CF0;color: #fff' : ''" @click="dateBtnClick('今日')"></span>
<span class="date-btn" :style="dateBtnValue === '本周' ? 'background: #2D8CF0;color: #fff' : ''" @click="dateBtnClick('本周')"></span>
<span class="date-btn" :style="dateBtnValue === '本月' ? 'background: #2D8CF0;color: #fff' : ''" @click="dateBtnClick('本月')"></span>
<span class="date-btn" :style="dateBtnValue === '自定义' ? 'background: #2D8CF0;color: #fff' : ''" @click="dateBtnClick('自定义')"></span>
</row>
</i-col>
<i-col span="6" style="height: 38px;line-height: 38px;">
<span class="view-text">{{dateBtnValue}}概览</span>
<span v-if="dateBtnValue !== '自定义'" class="view-date">{{viewDate}}</span>
<span class="left-10" v-if="dateBtnValue === '自定义'" style="vertical-align: top">
<DatePicker v-model="selectStartTime" :options="options1" type="date" placeholder="请选择时间" style="width: 120px" size="small" @on-change="diyDateChange"></DatePicker>
<span style="margin: 0 5px"></span>
<DatePicker v-model="selectEndTime" :options="options2" type="date" placeholder="请选择时间" style="width: 120px" size="small" @on-change="diyDateChange"></DatePicker>
<Tooltip content="限制最大31天" placement="bottom">
<Icon type="ios-alert-outline" style="margin-left: 5px" />
</Tooltip>
</span>
</i-col>
6 years ago
</row>
<!--5块客户数-->
<row class="top-20">
<Row type="flex" justify="space-between" class="code-row-bg">
<i-col span="4" class="big-blank" style="border: 1px solid #FFCC00;border-left: 6px solid #FFCC00;">
<row class="top-20"><span class="left-10">新增好友</span></row><row><span class="left-25 big-blank-font">{{customerViewVO.newCustomer}}</span></row>
</i-col>
<i-col span="4" class="big-blank" style="border: 1px solid #EC6A2F;border-left: 6px solid #EC6A2F;">
<row class="top-20"><span class="left-10">新增好友去重</span></row><row><span class="left-25 big-blank-font">{{customerViewVO.newValidCustomer}}</span></row>
</i-col>
<i-col span="4" class="big-blank" style="border: 1px solid #2EA4E4;border-left: 6px solid #2EA4E4;">
<row class="top-20"><span class="left-10">好友总数</span></row><row><span class="left-25 big-blank-font">{{customerViewVO.allCustomer}}</span></row>
</i-col>
<i-col span="4" class="big-blank" style="border: 1px solid #63C16D;border-left: 6px solid #63C16D;">
<row class="top-20"><span class="left-10">好友总数去重</span></row><row><span class="left-25 big-blank-font">{{customerViewVO.allValidCustomer}}</span></row>
</i-col>
<i-col span="4" class="big-blank" style="border: 1px solid #2DC6EA;border-left: 6px solid #2DC6EA;">
<row class="top-20"><span class="left-10">删除拉黑数累计去重</span></row><row><span class="left-25 big-blank-font">{{customerViewVO.validDeleteCustomer}}</span></row>
</i-col>
</Row>
</row>
<!--柱状图-->
<row class="top-10">
<i-col span="16" class="outline">
<span class="blue-logo"></span>
<span style="display: inline-block;margin-left: 5px">{{this.$moment(startTime).format("YYYY-MM-DD")}}{{this.$moment(endTime).format("YYYY-MM-DD")}}{{recentName}}趋势图</span>
<ve-histogram :data="chartData" :extend="chartExtend" :colors="chartColor"></ve-histogram>
</i-col>
<i-col span="8" class="padding-left-10">
<row class="outline">
<span class="blue-logo"></span>
<span style="display: inline-block;margin-left: 5px">好友&会员情况</span>
<row style="height: 399px;padding: 99px 15px;">
<i-col span="6" style="border-right: 1px solid #D3D3D3;">
<row style="height: 50px"></row>
<row class="percent-text"><span>好友总数(去重)</span></row>
<row style="height: 25px"></row>
<row class="percent-text"><span>会员总数</span></row>
<row style="height: 50px"></row>
</i-col>
<i-col span="18">
<row style="height: 50px"></row>
<row><span class="percent-span" style="background: #EC6A2F;" :style="percent1"></span><span>{{customerViewVO.allValidCustomer}}</span></row>
<row style="height: 25px"></row>
<row><span class="percent-span" style="background: #FFCC00;" :style="percent2"></span><span>{{customerViewVO.allVipCount}}</span></row>
<row style="height: 50px"></row>
</i-col>
</row>
</row>
</i-col>
</row>
<!--前十名-->
<row class="top-10">
<i-col span="8">
<row class="outline" style="min-height: 305px">
<span class="blue-logo"></span>
<span style="display: inline-block;margin-left: 5px;">零售公司店均新增好友top10</span>
<row v-if="customerViewVO.orgNewCustomerList.length === 0" style="text-align: center"></row>
<row v-if="customerViewVO.orgNewCustomerList.length > 0" class="pading-12">
<row v-for="item in customerViewVO.orgNewCustomerList" :key="item.orgId">
<i-col span="6" class="text-ellipsis" style="text-align: right">{{item.orgName}}</i-col>
<i-col span="1"><span style="visibility: hidden">visible</span></i-col>
<i-col span="17"><span class="top10-percent-span" style="background: #FFCC00;" :style="'width:' + item.newCustomerCount/customerViewVO.orgNewCustomerList[0].newCustomerCount*80 + '%'"></span><span>{{item.newCustomerCount}}</span></i-col>
</row>
6 years ago
</row>
</row>
</i-col>
6 years ago
<i-col span="8" class="padding-left-10">
<row class="outline" style="min-height: 305px">
<span class="blue-logo"></span>
<span style="display: inline-block;margin-left: 5px">店铺新增好友top10</span>
<row v-if="customerViewVO.shopNewCustomerList.length === 0" style="text-align: center"></row>
<row v-if="customerViewVO.shopNewCustomerList.length > 0" class="pading-12">
<row v-for="item in customerViewVO.shopNewCustomerList" :key="item.shopId">
<i-col span="8" class="text-ellipsis" style="text-align: right">{{item.shopName}}</i-col>
<i-col span="1"><span style="visibility: hidden">visible</span></i-col>
<i-col span="15"><span class="top10-percent-span" style="background: #EC6A2F;" :style="'width:' + item.newCustomerCount/customerViewVO.shopNewCustomerList[0].newCustomerCount*80 + '%'"></span><span>{{item.newCustomerCount}}</span></i-col>
</row>
6 years ago
</row>
</row>
</i-col>
<i-col span="8" class="padding-left-10">
<row class="outline" style="min-height: 305px">
<span class="blue-logo"></span>
<span style="display: inline-block;margin-left: 5px">推广为0的店铺数</span>
<span style="position: absolute;right: 5px;cursor: pointer" @click="zeroExtendMore"><span style="vertical-align: top">更多</span><img src="../../static/img/right-angle.png"/></span>
<row v-if="customerViewVO.zeroExtendList.length === 0" style="text-align: center"></row>
<row v-if="customerViewVO.zeroExtendList.length > 0" class="pading-12">
<row>
<i-col span="1"><span style="visibility: hidden">visible</span></i-col>
<i-col span="9">零售公司</i-col>
<i-col span="7">店铺总数</i-col>
<i-col span="7">推广为0店铺数</i-col>
</row>
<row v-for="item in customerViewVO.zeroExtendList" :key="item.orgId">
<i-col span="1"><span style="visibility: hidden">visible</span></i-col>
<i-col span="9" class="text-ellipsis">{{item.orgName}}</i-col>
<i-col span="7">{{item.allShopCount}}</i-col>
<i-col span="7">{{item.zeroShopCount}}</i-col>
</row>
6 years ago
</row>
</row>
</i-col>
</row><!--条形图结束-->
<Spin style="top: 50px" size="large" fix v-if="spinShow"></Spin>
6 years ago
</row>
</i-col>
</Row>
</div>
</template>
<script>
import customerView from "../services/datacenter/customerView";
export default {
6 years ago
inject:['setMenuName'],
6 years ago
data() {
return {
userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId,
6 years ago
//加载遮罩
spinShow: false,
dateBtnValue: "今日",
viewDate: this.$moment(new Date()).format("YYYY-MM-DD"),
//近七天日期
recentName : "近七天",
//选中时间
selectStartTime: "",
selectEndTime: "",
//柱状图时间
startTime: "",
endTime: "",
6 years ago
//人数占比
percent1: "width:0%",
percent2: "width:0%",
6 years ago
customerViewVO: {
newCustomer: 0,
newValidCustomer: 0,
allCustomer: 0,
allValidCustomer: 0,
validDeleteCustomer: 0,
allVipCount: 0,
//柱状图
customerList: [],
validCustomerList: [],
//下面3大块
orgNewCustomerList: [],
shopNewCustomerList: [],
zeroExtendList: [],
6 years ago
},
chartExtend: {
barWidth: 28,
label: { show: true, position: "top" }
6 years ago
},
chartColor:["#ffcc00","#ec6a2f"],
chartData: {
columns: ['date', '新增好友', '新增好友(去重)' ],
6 years ago
rows: [
{ 'date': '1/1', '新增好友': 14, '新增好友(去重)': 14 },
{ 'date': '1/1', '新增好友': 20, '新增好友(去重)': 10 },
{ 'date': '1/1', '新增好友': 30, '新增好友(去重)': 25 },
{ 'date': '1/1', '新增好友': 11, '新增好友(去重)': 11 },
{ 'date': '1/1', '新增好友': 14, '新增好友(去重)': 14 },
{ 'date': '1/1', '新增好友': 20, '新增好友(去重)': 10 },
{ 'date': '1/1', '新增好友': 30, '新增好友(去重)': 25 },
6 years ago
]
},
}
},
computed:{
options1() {
let that = this;
return{
disabledDate (date) {
if(that.selectEndTime == null || that.selectEndTime == ""){
return false;
}else{
return date && date.valueOf() > that.selectEndTime || date && date.valueOf() < that.$moment(that.selectEndTime).add(-31,"days");
}
}
}
},
options2() {
let that = this;
return{
disabledDate (date) {
if(that.selectStartTime == null || that.selectStartTime == ""){
return false;
}else{
return date && date.valueOf() < that.selectStartTime || date && date.valueOf() > that.$moment(that.selectStartTime).add(31,"days");
}
}
}
},
},
6 years ago
mounted: function () {
this.dateBtnClick('今日');
6 years ago
},
methods: {
//页面重绘
resizeWindow: function(){
let event = document.createEvent("HTMLEvents");
event.initEvent("resize", true, true);
window.dispatchEvent(event);
},
//占比重绘
percentResize: function(){
let allValidCustomer = this.customerViewVO.allValidCustomer;
let allVipCount = this.customerViewVO.allVipCount;
let sum = allValidCustomer + allVipCount;
6 years ago
if(sum === 0){
this.percent1 = "width:0%";
this.percent2 = "width:0%";
6 years ago
return;
}
if(allValidCustomer > allVipCount){
let p2 = Math.floor(allVipCount/allValidCustomer * 100 *100)/100 * 0.8;
this.percent1 = "width:80%";
this.percent2 = "width:" + p2 + "%";
}
if(allValidCustomer < allVipCount){
let p1 = Math.floor(allValidCustomer/allVipCount * 100 *100)/100 * 0.8;
this.percent1 = "width:" + p1 + "%";
this.percent2 = "width:80%";
}
if(allValidCustomer === allVipCount){
this.percent1 = "width:80%";
this.percent2 = "width:80%";
}
6 years ago
},
//0转null
checkZero: function (value) {
if(value === 0){return null;}
return value;
},
//日期按钮
dateBtnClick: function(value){
switch (value) {
case '今日': this.dateBtnValue = "今日";this.recentName = "近七天";this.dateSelectChange('今日');this.chartExtend.barWidth = 28;this.chartExtend.label.show = true;break;
case '本周': this.dateBtnValue = "本周";this.recentName = "本周";this.dateSelectChange('本周');this.chartExtend.barWidth = 28;this.chartExtend.label.show = true;break;
case '本月': this.dateBtnValue = "本月";this.recentName = "本月";this.dateSelectChange('本月');this.chartExtend.barWidth = 8;this.chartExtend.label.show = false;break;
case '自定义': this.dateBtnValue = "自定义";this.recentName = "自定义";this.diyDateChange();break;
}
},
//自定义日期
diyDateChange: function(){
if(this.selectStartTime && this.selectEndTime){
//超过15天柱状图不显示数字
if(this.$moment(this.selectEndTime).valueOf() - this.$moment(this.selectStartTime).valueOf() > 15*24*60*60*1000){
this.chartExtend.barWidth = 8;
this.chartExtend.label.show = false;
}else{
this.chartExtend.barWidth = 28;
this.chartExtend.label.show = true;
}
this.dateSelectChange('自定义');
}
6 years ago
},
//日期改变
dateSelectChange: function(value){
//概览日期text
let nowDate = this.$moment(new Date());
switch (value) {
case '今日':
this.viewDate = nowDate.format("YYYY-MM-DD");
this.selectStartTime = this.$moment(new Date()).format("YYYY-MM-DD 00:00:00");
this.selectEndTime = this.$moment(new Date()).format("YYYY-MM-DD HH:mm:ss");
this.startTime = this.$moment(new Date()).add(-6, "days").format("YYYY-MM-DD 00:00:00");
this.endTime = this.$moment(new Date()).format("YYYY-MM-DD HH:mm:ss");
break;
case '本周':
this.viewDate = nowDate.startOf('week').format("YYYY-MM-DD") + ' 至 ' + this.$moment(new Date()).format("YYYY-MM-DD");
this.selectStartTime = this.$moment(new Date()).startOf("week").format("YYYY-MM-DD 00:00:00");
this.selectEndTime = this.$moment(new Date()).format("YYYY-MM-DD HH:mm:ss");
this.startTime = this.selectStartTime;
this.endTime = this.$moment(new Date()).endOf("week").format("YYYY-MM-DD HH:mm:ss");
break;
case '本月':
this.viewDate = nowDate.startOf('month').format("YYYY-MM-DD") + ' 至 ' + this.$moment(new Date()).format("YYYY-MM-DD");
this.selectStartTime = this.$moment(new Date()).startOf("month").format("YYYY-MM-DD 00:00:00");
this.selectEndTime = this.$moment(new Date()).format("YYYY-MM-DD HH:mm:ss");
this.startTime = this.selectStartTime;
this.endTime = this.$moment(new Date()).endOf("month").format("YYYY-MM-DD HH:mm:ss");
break;
case '自定义':
this.selectStartTime = this.$moment(this.selectStartTime).format("YYYY-MM-DD 00:00:00");
this.selectEndTime = this.$moment(this.selectEndTime).format("YYYY-MM-DD 23:59:59");
this.startTime = this.selectStartTime;
this.endTime = this.selectEndTime;
break;
}
this.getMainList();
},
6 years ago
/**mainList*/
getMainList: function(){
let request = {
userId: this.userId,
selectStartTime: this.selectStartTime == null ? null : this.$moment(this.selectStartTime).format("YYYY-MM-DD 00:00:00"),
selectEndTime: this.selectEndTime == null ? null : this.$moment(this.selectEndTime).format("YYYY-MM-DD HH:mm:ss"),
startTime: this.startTime,
endTime: this.endTime
6 years ago
};
let that = this;
//加载遮罩
this.spinShow = true;
customerView.getMainRequest(request,function (data) {
that.spinShow = false;
if(data.data.code !== "0000"){
that.$Message.error("系统异常");
}
data = data.data.results;
that.customerViewVO = data;
that.chartData.rows = [];
if(that.startTime && that.endTime){
let tmpStartTime = that.startTime;
while(that.$moment(tmpStartTime).format("YYYY-MM-DD") <= that.$moment(that.endTime).format("YYYY-MM-DD")){
let date = that.$moment(tmpStartTime).format("M-DD");
let obj = {
date:date,
"新增好友": that.customerViewVO.customerList.filter(customer => date === that.$moment(customer.registerTime).format("M-DD")).length,
"新增好友(去重)": that.customerViewVO.validCustomerList.filter(vip => date === that.$moment(vip.registerTime).format("M-DD")).length,
};
that.chartData.rows.push(obj);
tmpStartTime = that.$moment(tmpStartTime).add(1,"days").format("YYYY-MM-DD HH:mm:ss");
}
6 years ago
}
//占比重绘
that.percentResize();
//页面重绘(柱状图)
that.resizeWindow();
});
},
//零推广更多跳转
zeroExtendMore: function () {
6 years ago
this.setMenuName("首页","推广为0店铺数");
let that = this;
this.$router.push({
path: '/zero/extend/detail',
query: {
userId: that.userId,
startDate: that.selectStartTime,
endDate : that.selectEndTime,
}
});
}
6 years ago
}
}
</script>
<style scoped>
/*日期按钮*/
.date-btn{
display: inline-block;
width: 80px;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 8px;
cursor: pointer;
}
/*概览字体*/
.view-text{
font-size: 18px;
font-weight: 600;
font-family: "Microsoft YaHei";
}
/*概览日期*/
.view-date{
font-size: 16px;
color: #97A4B3;
margin-left: 10px;
}
/*5大块客户数*/
.big-blank{
height: 100px;
border-radius: 4px;
}
.big-blank-font{
font-size: 28px;
font-weight: 700;
font-family: 'Microsoft YaHei';
}
6 years ago
/*蓝色logo*/
.blue-logo{
background: #1A80D2;
height: 26px;
width: 6px;
border-radius:3px;
display: inline-block;
vertical-align: middle;
}
/*外面的边框*/
.outline{
border: #e8ecf2 2px solid;
padding: 10px;
border-radius: 4px;
6 years ago
}
.left-10{
margin-left: 10px;
}
.left-15{
margin-left: 15px;
}
.left-25{
margin-left: 25px;
}
6 years ago
.top-10{
margin-top: 10px;
}
.top-15{
margin-top: 15px;
}
.top-20{
margin-top: 20px;
}
.top-30{
margin-top: 30px;
}
.pading-12{
padding: 12px;
}
.padding-left-10{
padding-left: 10px;
}
/*占比样式*/
.percent-text{
height: 38px;
line-height: 38px;
text-align: right;
padding-right: 8px;
}
.percent-span{
display: inline-block;
vertical-align: middle;
height: 38px;
line-height: 38px;
margin-right: 5px;
}
6 years ago
/*文字过长...*/
.text-ellipsis{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/*top10,占比样式*/
.top10-percent-span{
6 years ago
display: inline-block;
vertical-align: middle;
height: 18px;
line-height: 18px;
margin-right: 5px;
6 years ago
}
</style>