var vm = new Vue({
el: '.vue-search-container',
delimiters: ['${', '}'],
components: {
areaCityComponent: areaCityComponent,
selectListComponent: selectListComponent,
priceComponent: priceComponent,
noData: noDataComponent
},
data: function () {
return {
foundingTime:'',//成立时间
provinceMap: provinceMap,
searchContent: '',
tabActive: 'qy',
filterShow: true,
searchTypeList: [
{
label: '企业名称',
value: 'A'
},
{
label: '法定代表人',
value: 'B'
},
// {
// label: '股东',
// value: 'C'
// },
// {
// label: '高管',
// value: 'D'
// },
{
label: '经营范围',
value: 'F'
},
{
label: '中标项目/标的物',
value: 'E'
}
],
entTypeList: [
{
label: '有限责任公司',
value: 'A'
},
{
label: '股份有限公司',
value: 'B'
},
{
label: '有限合伙',
value: 'C'
},
{
label: '普通合伙',
value: 'D'
}
],
entStateList: [
{
label: '存续(在营、开业、在业)',
value: 'A'
},
{
label: '吊销',
value: 'B'
},
{
label: '注销',
value: 'C'
},
{
label: '撤销',
value: 'D'
}
],
entTimeList:[
{
label: '近1年内',
value: 'A'
},
{
label: '1-3年',
value: 'B'
},
{
label: '3-5年',
value: 'C'
},
{
label: '5-10年',
value: 'D'
},
{
label: '10年以上',
value: 'E'
},
],
priceList: [
{
label: '100万以内',
value: '0-100'
},
{
label: '100-500万',
value: '100-500'
},
{
label: '500-1000万',
value: '500-1000'
},
{
label: '1000-5000万',
value: '1000-5000'
},
{
label: '5000万以上',
value: '5000-'
},
],
zblyFilterOption: {
zbAreaOptions: [
// {
// label: '北京',
// value: '北京'
// }
],
dwlxOptions: [
{
label: '采购单位',
value: '1'
},
{
label: '投标企业',
value: '2'
},
{
label: '招标代理机构',
value: '3'
},
{
label: '厂商',
value: '4'
}
],
lxfsOptions: [
{
label: '固定电话',
value: '1'
},
{
label: '手机号',
value: '2'
},
// {
// label: '电子邮箱',
// value: '3'
// },
// {
// label: '不存在',
// value: '4'
// }
],
},
filterState: {
searchType: ['A'],
entArea: [],
entCity: [],
entType: [],
entStatus: [],
entCapital: [],
biddingArea: '', // 中标区域
entClass: '', // 单位类型
entContact: '', // 联系方式
establish:[],//成立时间
},
listState: {
loaded: false, // 是否已经搜索过
loading: false,
pageNum: 1, // 当前页, 从0开始
pageSize: 10, // 每页多少条数据
total: 0, // 一共多少条数据
list: [] // 查询请求返回的数据
},
preSearch: {
hover: false,
focus: false,
list: []
},
entUseInfo: {
used: 0,
total: 0,
province: 0
},
powerInfo: {
entniche: '',
member: '',
vip: ''
},
power: false,
powerLoaded: false,
powerDialogShow: false,
baiduName: '',
inputStatus: false,
buttonType:false,//成立时间自定义区间确定按钮的显示状态
focusColor:false,//改变获取焦点输入框的背景颜色
startDate:'',
endDate:'',
thisStartTime:'',
thisEndTime:'',
indusShow: false
}
},
watch: {
tabActive: function (newVal, oldVal) {
if (newVal === 'zb') {
if (this.searchContent) {
location.href = '/jylab/supsearch/index.html?keywords=' + this.searchContent + '&publishtime=thisyear'
} else {
location.href = '/jylab/supsearch/index.html'
}
} else if (newVal === 'cgdw') {
if (this.searchContent) {
location.href = '/jylab/purSearch/index.html?keywords=' + this.searchContent
} else {
location.href = '/jylab/purSearch/index.html'
}
} else if (newVal === 'gy') {
if (this.searchContent) {
location.href = '/swordfish/page_web_pc/search/issued?keywords=' + this.searchContent
} else {
location.href = '/swordfish/page_web_pc/search/issued'
}
}
}
},
computed: {
getInputStatus: function () {
return this.inputStatus
},
preSearchListShow: function () {
return this.searchContent.trim().length >= 2 && this.preSearch.list.length && (this.preSearch.focus || this.preSearch.hover)
},
buttonText: function () {
if (this.power) {
return '升级'
} else {
if (this.powerInfo.vip === 0) {
return '开通'
} else if (this.powerInfo.vip === 1) {
return '升级'
} else {
return '升级'
}
}
},
showEntUsage: function () {
return !this.powerInfo.member && this.powerInfo.vip > 1
},
getVipSubText: function () {
var count = this.entUseInfo.province
if (count == -1) {
return '全国'
} else {
if (count) {
return count + '个省'
} else {
return ''
}
}
},
},
created: function () {
this.getPower()
this.initPageData()
this.initProvinceMapList()
},
mounted: function () {
this.initDOMEvents()
// 默认选中搜索范围
this.$refs.searchType.setState(this.filterState.searchType)
// 全选按钮逻辑
// this.searchTypeChange([], true)
this.industryTab()
},
methods: {
industryTab: function() {
$.ajax({
type:'POST',
url:'/entnicheNew/buy/whetherbuy',
success:function (res) {
if (res.data.isNew) {
$('#tab-cgdw').css('display', 'inline-block')
} else {
$('#tab-cgdw').css('display', 'none')
}
}
})
},
getSearchForValues: function () {
return this.searchTypeList.map(function (v) {
return v.value
})
},
checkLogin: function () {
var moduleOpen = $('body').hasClass('modal-open')
if (moduleOpen) return
if (!loginflag) {
$("#bidLogin").modal("show");
}
},
getPower: function (callback) {
$.ajax({
url: '/publicapply/bidcoll/power',
type: 'POST',
success: function (res) {
if (res.error_code === 0 && res.data) {
Object.assign(this.powerInfo, res.data)
this.checkPower()
this.doSearch()
if (this.showEntUsage) {
this.getEntProtUsage()
}
} else {
this.checkLogin()
}
}.bind(this),
complete: function () {
this.powerLoaded = true
callback && callback()
}.bind(this)
})
},
checkPower: function () {
this.power = this.powerInfo.member || this.powerInfo.vip !== 0
return this.power
},
initPageData: function () {
console.info(pageInfo)
if (pageInfo.searchContent) {
this.searchContent = pageInfo.searchContent
}
},
initProvinceMapList: function () {
var provinceMapList = []
for (var key in this.provinceMap) {
this.provinceMap[key].forEach(function (item) {
provinceMapList.push({
label: item,
value: item
})
})
}
this.zblyFilterOption.zbAreaOptions = provinceMapList
},
initDOMEvents: function () {
ewmMoveHover()
refreshEwmText(this.searchContent)
insertVipIcon($('.search-type .el-checkbox:last-of-type'))
insertVipIcon($('.search-type .el-checkbox:nth-of-type(4)'))
setTimeout(function () {
tabHover()
}, 300)
},
isFilterShow: function () {
if (this.filterShow) {
$('.search-filters').slideUp()
} else {
$('.search-filters').slideDown()
}
this.filterShow = !this.filterShow
},
searchTypeChange: function (t, hideTip) {
// 全选逻辑隐藏
// var tempRef = this.$refs.searchType
// var tempList = this.getSearchForValues()
// if (t.length === 0) {
// if (tempRef && tempRef.$data.selectList[0].selected) {
// t = tempList
// }
// } else if (tempList.join('') === t.join('')) {
// tempRef && tempRef.setState()
// }
console.info(t);
console.info(hideTip);
var eIndex = t.indexOf('E')
if (!this.power && eIndex !== -1) {
t.splice(eIndex, 1)
this.$refs.searchType.setState(t)
if (!hideTip) {
this.powerDialogShow = true
return
}
}
var eIndex1 = t.indexOf('F')
if (!this.power && eIndex1 !== -1) {
t.splice(eIndex1, 1)
this.$refs.searchType.setState(t)
if (!hideTip) {
this.powerDialogShow = true
return
}
}
this.filterState.searchType = t
this.doSearch()
},
areaCityChange: function (area) {
var city = []
var area_arr = []
for (var key in area) {
if(area[key].length>0){
city = city.concat(area[key])
}else{
area_arr = area_arr.concat(key)
}
}
this.filterState.entArea = area_arr//Object.keys(area)
this.filterState.entCity = city
this.doSearch()
},
entTypeChange: function (e) {
if (!e.length) {
this.$refs.entType.$data.selectList[0].selected = true
}
this.filterState.entType = e
this.doSearch()
},
entStateChange: function (e) {
if (!e.length) {
this.$refs.entState.$data.selectList[0].selected = true
}
this.filterState.entStatus = e
this.doSearch()
},
//计算几年前的时间戳
getTimeDate: function(year){
let time = Number(year);
let date = new Date();
let lastYear = Number(date.getFullYear()-time)+'-'+Number(date.getMonth()+1)+'-'+date.getDate();
let lastYearDate = new Date(lastYear);
lastYearDate = lastYearDate.getTime();//一年前时间戳;
return lastYearDate;
},
//成立时间多选
entTimeChange: function (e) {
let _this = this;
// console.info('成立时间多选',e);
_this.focusColor = false;
if (!e.length) {
_this.$refs.entTime.$data.selectList[0].selected = true;
_this.filterState.establish = [];
}else{
let thisList = [];
e.forEach(function (item) {
// console.info(item);
switch (item) {
case 'A':
// thisList.push(_this.getTimeDate(0)+'-'+_this.getTimeDate(1))
thisList.push('-1y')
break;
case 'B':
// thisList.push(_this.getTimeDate(1)+'-'+_this.getTimeDate(3))
thisList.push('1y-3y')
break;
case 'C':
// thisList.push(_this.getTimeDate(3)+'-'+_this.getTimeDate(5))
thisList.push('3y-5y')
break;
case 'D':
// thisList.push(_this.getTimeDate(5)+'-'+_this.getTimeDate(10))
thisList.push('5y-10y')
break;
case 'E':
// thisList.push(_this.getTimeDate(10)+'-'+_this.getTimeDate(1))
thisList.push('10y-')
break;
default:
break;
}
_this.filterState.establish = thisList;
})
// if (_this.foundingTime) {
// // console.info(_this.foundingTime)
// _this.filterState.establish.push(_this.foundingTime[0]+'-'+_this.foundingTime[1])
// }
}
console.info(_this.filterState.establish);
_this.doSearch()
},
//时间戳转换yyyy-mm-dd
getThisDate:function(time){
var date = new Date(time);
var YY = date.getFullYear() + '年';
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '月';
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + '日';
return YY + MM + DD
},
//成立时间区间
foundingTimeChange:function(e){
if (e) {
let time = e[0]+'-'+e[1];
console.info('成立时间',time);
console.info('成立时间',e);
this.startDate = this.getThisDate(e[0]);
this.endDate = this.getThisDate(e[1]);
}
},
startTimeChange:function(e){
if (e) {
console.info('startTimeChange',e);
this.startDate = this.getThisDate(e);
}
},
endTimeChange:function(e){
if (e) {
console.info('endTimeChange',e);
if (e < this.thisStartTime && this.thisStartTime) {
// alert('结束日期不能小于开始日期,请重新选择')
this.endDate = '';
this.thisEndTime = '';
this.$notify.error({
title: '错误',
message: '结束日期不能小于开始日期,请重新选择'
});
}else{
this.endDate = this.getThisDate(e);
}
}
},
//成立时间自定义区间搜索按钮
establishSearch:function () {
let _this = this;
let thisList = [];
// console.info(_this.foundingTime);
// if (_this.foundingTime) {
// thisList.push(_this.foundingTime[0]/1000+'-'+_this.foundingTime[1]/1000)
// _this.$refs.entTime.$data.selectList.forEach(function (item) {
// // console.info(item);
// item.selected = false;
// })
// _this.filterState.establish = thisList;
// }else{
// _this.$refs.entTime.$data.selectList.forEach(function (item) {
// // console.info(item);
// item.selected = false;
// })
// _this.$refs.entTime.$data.selectList[0].selected = true;
// _this.filterState.establish = [];
// }
if (_this.thisStartTime && _this.thisEndTime) {
thisList.push(_this.thisStartTime/1000+'-'+_this.thisEndTime/1000)
_this.$refs.entTime.$data.selectList.forEach(function (item) {
// console.info(item);
item.selected = false;
})
_this.filterState.establish = thisList;
}else{
_this.$refs.entTime.$data.selectList.forEach(function (item) {
// console.info(item);
item.selected = false;
})
_this.$refs.entTime.$data.selectList[0].selected = true;
_this.filterState.establish = [];
}
_this.doSearch();
_this.buttonType = false;
},
showButton:function () {
let _this = this;
_this.buttonType = true;
},
hiddenButton:function () {
// let _this = this;
// _this.buttonType = false;
},
changeColor:function() {
let _this = this;
_this.focusColor = true;
},
// 标准金额区间
inexactPriceChange: function (p) {
if (!p.length) {
this.$refs.entCapital.$data.selectList[0].selected = true
}
this.filterState.entCapital = p
this.inputStatus = false
this.doSearch()
},
// 输入金额区间
exactPriceChange: function (p) {
this.$refs.entCapital.setState()
if (p.min === '' && p.max === '') {
this.filterState.entCapital = ['']
this.$refs.entCapital.$data.selectList[0].selected = true
this.inputStatus = false
} else {
this.$refs.entCapital.$data.selectList[0].selected = false
this.filterState.entCapital = [p.min + '-' + p.max]
this.inputStatus = true
}
this.doSearch()
},
zbFilterChange: function (name) {
this.baiduName = name
if (this.power) {
this.doSearch()
} else {
this.filterState.biddingArea = ''
this.filterState.entClass = ''
this.filterState.entContact = ''
this.powerDialogShow = true
}
},
getEntProtUsage: function () {
$.ajax({
url: '/bigmember/portrait/subVipPortrait/usage',
method: 'POST',
data: data,
success: function (res) {
if (res.error_code === 0) {
if (res.data.total) {
this.entUseInfo.total = res.data.total
}
if (res.data.provin) {
this.entUseInfo.province = res.data.provin
}
if (res.data.usage) {
this.entUseInfo.used = res.data.usage
}
}
}.bind(this)
})
},
doSearch: function () {
this.resetListState()
this.getList()
},
resetListState: function () {
var state = {
loaded: false,
loading: false,
pageNum: 1,
total: 0,
list: []
}
Object.assign(this.listState, state)
},
getPreSearchList: utils.debounce(function () {
var data = {
name: this.searchContent.trim()
}
if (data.name.length < 2) return
$.ajax({
url: '/bigmember/search/ent/association',
method: 'POST',
data: data,
success: function (res) {
if (res.error_code === 0) {
if (res.data) {
this.preSearch.list = res.data.list || []
}
} else {
this.checkLogin()
}
}.bind(this)
})
}, 200),
getList: function () {
var data = {
match: this.searchContent,
matchType: this.filterState.searchType.join(','),
entArea: this.filterState.entArea.join(','),
entCity: this.filterState.entCity.join(','),
entCapital: this.filterState.entCapital.join(','),
entType: this.filterState.entType.join(','),
entStatus: this.filterState.entStatus.join(','),
establish: this.filterState.establish.join(','),//成立时间筛选条件
biddingArea: this.filterState.biddingArea,
entClass: this.filterState.entClass,
entContact: this.filterState.entContact,
pageSize: this.listState.pageSize,
pageNum: this.listState.pageNum - 1, // 当前页, 从0开始
}
this.listState.loading = true
this.listState.loaded = false
$.ajax({
url: '/publicapply/enterpriseSearch/doQuery',
method: 'POST',
data: data,
success: function (res) {
if (res.error_code === 0) {
this.setListStateAndCheckPower(res)
} else {
this.checkLogin()
}
}.bind(this),
complete: function () {
this.listState.loading = false
this.listState.loaded = true
}.bind(this)
})
},
setListStateAndCheckPower: function (res) {
var _this = this
if (res.data) {
if (res.data.total) {
if (this.power) {
this.listState.total = res.data.total
} else {
this.listState.total = 4
}
}
if (res.data.list) {
res.data.list.forEach(function (d) {
d.company_shortname = _this.getShortName(d.company_name)
d.randomBgc = _this.randomBgc()
try {
d.visited = visitedPath.pathVisited(
new VisitedPathItem(
'/ent_portrait/*',
'id=' + d.id
)
)
} catch (error) {}
})
if (this.power) {
this.listState.list = res.data.list || []
} else {
if (res.data.list.length >= 4) {
res.data.list.length = 4
res.data.list.push({
company_shortname: 'xxx',
company_address: 'xxx',
company_name: 'xxx',
company_status: 'xxx',
legal_person: 'xxx',
id: 'xxx',
showMask: true
})
}
this.listState.list = res.data.list || []
}
}
} else {
this.listState.total = 0
this.listState.list = []
}
},
onPageChange: function (p) {
this.listState.pageNum = p
this.getList()
},
openVipPage: function (param) {
// 企业搜索中标区域-去开通
// 企业搜索单位类型-去开通
// 企业搜索联系方式-去开通
// 企业搜索底部第五条-去开通
// 企业搜索popover-去开通
if (param === 'more') {
this.baiduName = '底部第五条'
} else if (param === 'popover-link') {
this.baiduName = '-超级订阅用户-当月已使用hover'
}
var str = '企业搜索' + this.baiduName + '-去开通'
baiduEvent(str) // 去开通按钮百度统计
window.open('/swordfish/page_big_pc/free/svip/buy')
},
openEntHistory: function () {
baiduEvent('企业画像查看历史记录')
window.open('/swordfish/frontPage/seeHistory/sess/index')
},
openCustomerService: function () {
$('#go-customer-4').trigger('click')
},
toDetail: function (item) {
var id = item.id || item.entId
// 去超级订阅画像
var svipLink = '/swordfish/page_big_pc/svip/ent_ser_portrait/' + id
// 大会员画像
var memberLink = '/swordfish/page_big_pc/ent_portrait/' + id
try {
item.visited = true
visitedPath.pathVisiting(
new VisitedPathItem(
'/ent_portrait/*',
'id=' + id
)
)
} catch (error) {}
if (this.powerInfo.member) {
// 如果是专家版、智慧版 跳大会员页面
if (window.memberPower && window.memberPower.indexOf(4) !== -1) {
window.open(memberLink)
} else {
// 如果是商机版、自定义版
// 如果同时是超级订阅 判断有没有画像查看次数
if (this.powerInfo.vip > 0) {
$.ajax({
type: "POST",
url: "/bigmember/portrait/subVipPortrait/usage",
data: {
entId: id
},
success: function(r){
// 如果次数已用完 跳大会员企业画像页面
if (r.data.usage >= r.data.total) {
window.open(memberLink)
} else {
// 没用完 超级订阅跳企业画像页面
window.open(svipLink)
}
}
});
} else {
window.open(memberLink)
}
}
} else {
window.open(svipLink)
}
},
calcListItemForCap: function (p) {
if (p) {
return p + '万元'
} else {
return '-'
}
},
getEntStatus: function (status) {
if (status === '吊销') {
return 'tag-danger'
} else if (status === '注销') {
return 'tag-danger'
} else if (status === '撤销') {
return 'tag-disabled'
} else {
return ''
}
},
randomBgc: function () {
var arr = ['default', 'blue', 'orange', 'green']
var randomIndex = utils.getRandomNumber(0, arr.length - 1)
return 'bgc-' + arr[randomIndex]
},
getShortName: function (comName) {
var areaMap = chinaMapJSON || []
var shortname = comName
// 1. 循环省份城市进行替换
areaMap.forEach(function (item) {
var p = item.name.replace(/[省市]/, '')
if (shortname.indexOf(p) !== -1) {
shortname = shortname.replace(item.name, '').replace(p, '')
console.log(p + ' -> \'\'')
}
item.city.forEach(function (iitem) {
var c = iitem.name.replace(/[省市]/, '')
if (shortname.indexOf(c) !== -1) {
shortname = shortname.replace(iitem.name, '').replace(c, '')
console.log(c + ' -> \'\'')
}
iitem.area.forEach(function (iiitem) {
if (shortname.indexOf(iiitem) !== -1) {
shortname = shortname.replace(iiitem, '')
console.log(iiitem + ' -> \'\'')
}
})
})
})
var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm)
var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4)
if (shortname.length < 4) {
shortname = shortname.slice(0, 4)
}
return shortname
}
}
})
;(function () {
var backUpLoginCallback = logic
logic = function (data, num) {
// do something
// 如果是当前页面已经使用过了,则只需要刷新power即可
if (data.result === 'ok') {
vm.getPower()
}
backUpLoginCallback(data, num)
}
})()
function insertVipIcon (target) {
$(target).append('')
}
function tabHover () {
$('#tab-zb, #tab-cgdw, #tab-gy').on('mouseover', function () {
var left = $(this).position().left
var offset = 0
if (left < 40) {
offset = ($(this).width() - 56) / 2
} else {
offset = ($(this).width() + 40 - 56) / 2
}
$(this).siblings('.el-tabs__active-bar').css({transform: 'translateX('+ (left + offset) +'px)'})
}).on('mouseout', function () {
$(this).siblings('.el-tabs__active-bar').css({transform: 'translateX(124px)'})
})
}
function refreshEwmText (text) {
if (text && text.trim().length > 0) {
$(".wx-inner-title").html("扫码关注企业");
$(".wx-inner-bottom").html('扫码即可实时接收'+'"'+text+'"'+'的中标信息!');
}
}
function ewmMoveHover() {
var $div = $(".search-right-wx .search-right-wx-inner"),
$parent = $(".search-right-wx");
$parent.on("mouseover",function(){
$div.css({
"transform":"scale(1)",
"transition":"transform 0.8s"
})
})
$parent.on("mouseout",function(){
$div.css({
"transform":"scale(0)",
"transition":"transform 0.2s"
})
})
}
function baiduEvent(name) {
console.log(name)
try {
_hmt.push(['_trackEvent', '超级订阅-pc', 'click', name]);
} catch (e) {
console.log('未初始化百度统计')
}
}