1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- function getRandomString (len) {
- let randomString = ''
- if (len) {
- const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
- const maxPos = $chars.length
- for (let i = 0; i < len; i++) {
- randomString += $chars.charAt(Math.floor(Math.random() * maxPos))
- }
- } else {
- randomString = Math.random().toString(36).substring(2)
- }
- return randomString
- }
- // toast上限提示
- function toastFn (text, duration = 1000) {
- // if (duration) {
- // duration = 1000
- // }
- var _html = ""
- _html+='<div class="custom-toast"><div class="mask" style="background-color: transparent;"></div><div class="toast-container">'
- _html+='<span>' + text + '</span></div></div>'
- $('body').append(_html)
- setTimeout(function(){
- $(".custom-toast").fadeOut().remove();
- },duration)
- }
- function formatKeywordsList (res) {
- // if (!res || !res.a_items) return
- // const data = res.a_items
- const newArr = []
- res.forEach((v) => {
- if (v.a_key) {
- v.a_key.forEach((s) => {
- newArr.push(s)
- })
- }
- })
- return newArr
- }
- 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"
- })
- })
- }
- var vm = new Vue({
- el: '#pur-search-container',
- delimiters: ['${', '}'],
- components: {
- areaCityComponent: areaCityComponent,
- selectListComponent: selectListComponent,
- priceComponent: priceComponent,
- noData: noDataComponent
- },
- data: function () {
- return {
- searchContent: '',
- tabActive: 'cgdw',
- filterShow: true,
- indusData: ['财政', '传媒', '城管', '采矿业', '出版广电', '档案', '党委办', '电信行业', '法院',
- '发改', '工信', '公安', '国资委', '公共资源交易',
- '海关', '教育', '军队', '交通', '纪委', '金融业', '建筑业', '检察院', '机关事务',
- '科技', '民政', '民宗', '农业', '能源化工', '农林牧渔', '批发零售', '气象', '人行', '人社', '人大',
- '税务', '水利', '市政', '审计', '商务', '司法', '社会团体', '市场监管', '生态环境',
- '统计', '统战', '体育', '文旅', '卫健委', '学校', '宣传', '信息技术',
- '医疗', '银保监', '运输物流', '应急管理',
- '组织', '政协', '住建', '证监', '政府办', '制造业', '政务中心', '住宿餐饮', '自然资源'
- ],
- indusList:[],
- caiIndex: [],
- qutive: true,
- indusList1:[],
- caiIndex1: [],
- qutive1: true,
- qyCheck: [],
- qyData: [],
- allChecked: false,
- singleChecked: false,
- follow: false,
- claim: false,
- jobData: [],
- entArea: {},
- arrs6: [],
- listState: {
- loaded: false, // 是否已经搜索过
- loading: false,
- pageNum: 1, // 当前页, 从0开始
- pageSize: 50, // 每页多少条数据
- total: 0, // 一共多少条数据
- list: [] // 查询请求返回的数据
- },
- preSearch: {
- hover: false,
- focus: false,
- list: []
- },
- showMore: true,
- industryExp: {
- name: '全部行业',
- selected: false,
- level: 0,
- children: [],
- id: ''
- },
- datas: '',
- attentionName: [],
- claimcheckName: [],
- showmoreBtn: true,
- industryListMap: [],
- getIndustryListMap: [],
- industryListMapExp: {
- '建筑工程': ['勘察设计', '工程施工', '监理咨询', '材料设备', '机电安装'],
- '水利水电': ['水利工程', '发电工程', '航运工程', '其他工程'],
- '能源化工': ['原材料', '仪器仪表', '新能源', '设备物资', '化工产品', '设备'],
- '弱电安防': ['综合布线', '智能系统', '智能家居'],
- '信息技术': ['系统集成及安全', '软件开发', '运维服务', '其他'],
- '行政办公': ['办公家具', '通用办公设备', '专业设备', '办公用品', '生活用品'],
- '机械设备': ['矿山机械', '工程机械', '机械零部件', '机床相关', '车辆', '其他机械设备'],
- '交通工程': ['道路','轨道','桥梁','隧道','其他'],
- '医疗卫生': ['设备','耗材','药品'],
- '市政设施': ['道路','绿化','线路管网','综合项目'],
- '服务采购': ['法律咨询','会计','物业','审计','安保','仓储物流','广告宣传印刷','其他'],
- '农林牧渔': ['生产物资','生产设备','相关服务']
- },
- getInfoTypeList: [],
- selectName: []
- }
- },
- 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 === 'qy') {
- if (this.searchContent) {
- location.href = '/jylab/entSearch/index.html?keywords=' + this.searchContent
- } else {
- location.href = '/jylab/entSearch/index.html'
- }
- }
- }
- },
- computed: {
- purListShow: function () {
- return this.searchContent.trim().length >= 2 && this.preSearch.list.length && (this.preSearch.focus || this.preSearch.hover)
- },
- },
- created: function () {
- this.initIndustryMap()
- this.qyCustmer()
- this.jobRange()
- this.getList(1)
- },
- mounted: function () {
- this.initCollectEvent()
- this.initDOMEvents()
- ewmMoveHover()
- this.$on('updatescope', (data) => {
- this.setData.keyList = data
- })
- },
- methods: {
- updatescope(data) {
- // console.log(data)
- },
- // 采购单位模糊搜索
- getPreSearchList: utils.debounce(function () {
- var data = {
- name: this.searchContent.trim()
- }
- if (data.name.length < 2) return
- $.ajax({
- url: '/entnicheNew/customer/buyer/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),
- goSearch(name) {
- this.searchContent = name
- this.preSearch.hover = false
- this.listState.pageNum = 1
- this.entArea = {}
- this.indusList = []
- this.indusList1 = []
- this.industryExp = []
- this.qyCheck = []
- this.doSearch()
- },
- checkLogin: function () {
- var moduleOpen = $('body').hasClass('modal-open')
- if (moduleOpen) return
- if (!loginflag) {
- $("#bidLogin").modal("show");
- }
- },
- yeFan() {
- location.href = '/jylab/purScopebusniess/index.html'
- },
- // 整理数据列表
- initIndustryMap () {
- const industryListMap = []
- // 全部
- const all = JSON.parse(JSON.stringify(this.industryExp))
- all.selected = true
- all.id = `lv0-${getRandomString(8).toLowerCase()}`
- industryListMap.push(all)
- for (const key in this.industryListMapExp) {
- const level1 = JSON.parse(JSON.stringify(this.industryExp))
- level1.name = key
- level1.level = 1
- level1.id = `lv1-${getRandomString(8).toLowerCase()}`
-
- const level2Arr = []
- this.industryListMapExp[key].forEach(item => {
- const level2 = JSON.parse(JSON.stringify(this.industryExp))
- level2.name = item
- level2.level = 2
- level2.id = `lv2-${getRandomString(8).toLowerCase()}`
- level2Arr.push(level2)
- })
-
- level1.children = level2Arr
- industryListMap.push(level1)
- }
-
- this.industryListMap = industryListMap
- const tempArr = []
- this.industryListMap.forEach(v => {
- const tempNode = v
- tempNode.zindex = 1
- tempArr.push(tempNode)
- tempNode?.children.forEach(s => {
- const tempS = s
- tempS.zindex = 2
- tempArr.push(tempS)
- })
- })
- this.getIndustryListMap = tempArr
- },
- // 按钮点击事件
- changeIndustryState (item) {
- // 循环所有数据,判断并改变状态
- switch (item.level) {
- case 0: {
- this.setIndustryState()
- break
- }
- case 1: {
- item.selected = !item.selected
-
- this.industryListMap[0].selected = false
- // 二级子按钮状态跟随一级按钮
- item.children.forEach(level2 => {
- level2.selected = item.selected
- })
- break
- }
- case 2: {
- item.selected = !item.selected
-
- // 找到当前点击的父级元素
- this.industryListMap.forEach(level1 => {
- const selectedStateArr = []
- if (item.level !== 0) {
- level1.children.forEach(level2 => {
- selectedStateArr.push(level2.selected)
- })
- if (selectedStateArr.indexOf(false) === -1) {
- level1.selected = true
- } else {
- level1.selected = false
- }
- }
- })
-
- this.industryListMap[0].selected = false
- break
- }
- default: {
- console.log('未知level')
- }
- }
-
- if (item.level !== 0) {
- const allSelected = this.checkAllSelectedState()
- if (allSelected.allSelected || allSelected.allNotSelected) {
- this.setIndustryState()
- }
- }
-
- if (this.selectorType === 'line') {
- this.onChange()
- }
- this.searchContent = ''
- this.doSearch()
- },
- // 检查是否全部选中了/全部不选中
- checkAllSelectedState () {
- // 一级标签选中状态(如果一级标签全部被选中,则说明,全部按钮被选中)
- const level1StateArr = []
- // 所有标签选中状态
- const allSelectedArr = []
-
- this.industryListMap.forEach(level1 => {
- if (level1.level !== 0) {
- level1StateArr.push(level1.selected)
- allSelectedArr.push(level1.selected)
- level1.children.forEach(level2 => {
- allSelectedArr.push(level2.selected)
- })
- }
- })
-
- return {
- // 找不到false,就说明全部被选中
- allSelected: level1StateArr.indexOf(false) === -1,
- // 找不到true,就说明没有一个被选中
- allNotSelected: allSelectedArr.indexOf(true) === -1
- }
- },
- /**
- * 初始化页面选中状态
- * @param { Array | undefined } data 要恢复的数据
- */
- setIndustryState (data) {
- // 设置全部按钮
- if (!data || Object.keys(data).length === 0) {
- // 其他全部设置不选中,全部按钮设置选中
- this.industryListMap.forEach(item => {
- item.selected = false
- item.children.forEach(iitem => {
- iitem.selected = false
- })
- })
-
- this.industryListMap[0].selected = true
- } else {
- this.setIndustryState()
- this.industryListMap[0].selected = false
-
- this.industryListMap.forEach(item => {
- if (data[item.name]) {
- // 如果恢复数组长度等于页面二级标签长度,则一级标签点亮
- if (data[item.name].length === item.children.length) {
- item.selected = true
- }
- item.children.forEach(function (iitem) {
- if (data[item.name].indexOf(iitem.name) !== -1) {
- iitem.selected = true
- }
- })
- }
- })
- }
- },
- // 获取选中的数据
- getSelected () {
- const map = {}
- this.industryListMap.forEach(item => {
- const mapArr = []
- if (item.level !== 0) {
- item.children.forEach(iitem => {
- if (iitem.selected) {
- mapArr.push(iitem.name)
- }
- })
- }
- if (mapArr.length !== 0) {
- map[item.name] = mapArr
- }
- })
- const tempArr = []
- Object.keys(map).forEach(v => {
- const tempItem = map[v]
- if (Array.isArray(tempItem)) {
- tempItem.forEach(vv => {
- tempArr.push(`${v}_${vv}`)
- })
- }
- })
- return tempArr
- },
- doSearch: function () {
- $('.tags-box').hide()
- this.listState.pageNum = 1
- this.getList(1, 'search')
- },
- getList: function (p, str) {
- let obj = {
- entName: this.searchContent.trim(),
- area: this.entArea,
- buyerclass: this.indusList,
- business_scope: this.indusList1,
- industry: this.getSelected(),
- entcustomer: this.qyCheck,
- pageSize: this.listState.pageSize,
- pageNum: this.listState.pageNum - 1,
- }
- this.listState.loading = true
- this.listState.loaded = false
- const _this = this
- let arrs = [], arr1 = []
- $.ajax({
- url: '/entnicheNew/customer/corList',
- method: 'POST',
- data: JSON.stringify(obj),
- contentType:'application/json;charset=utf-8',
- success: function (res) {
- if (res.error_code === 0 && $.isArray(res.data.list)) {
- if (res.data.list.length > this.listState.pageSize) {
- arrs = res.data.list.slice((p - 1) * this.listState.pageSize, (p - 1) * this.listState.pageSize + this.listState.pageSize) || []
- } else {
- arrs = res.data.list
- }
- arrs.forEach(v => {
- arr1.push(v.Buyer)
- })
- if (arrs.length == 0) {
- this.listState.list = []
- } else {
- _this.attentionCheck(arrs, String(arr1))
- }
- this.listState.total = res.data.list.length
- this.listState.loading = false
- } else {
- if (res.error_msg) {
- toastFn(res.error_msg, 2000)
- }
- this.listState.list = []
- }
- }.bind(this),
- complete: function () {
- this.listState.loading = false
- this.listState.loaded = true
- }.bind(this)
- })
- },
- onPageChange: function (p) {
- $('.tags-box').hide()
- this.listState.pageNum = p
- this.getList(p)
- },
- goTitle(name) {
- // location.href = '/entpc/unit_portrayal/' + name
- window.open('/entpc/unit_portrayal/' + name)
- },
- // 全选
- allChange() {
- const str1 = $('.check-all').prop('checked')
- const str2 = $('.custom-checkbox:not(".check-all")')
- const arr = $('.custom-checkbox:not(".check-all"):checked')
- let arrs1 = []
- if (str1) {
- str2.prop('checked', true)
- this.listState.list.forEach(v => {
- arrs1.push(v.Buyer)
- })
- } else {
- str2.prop('checked', false)
- arrs1 = []
- }
- this.selectName = arrs1
- },
- // 单选
- singleChange () {
- let arr1 = []
- $('.custom-checkbox:not(".check-all"):checked').each(function(){
- if ($(this).attr('dataname')) {
- arr1.push($(this).attr('dataname'))
- }
- })
- if (arr1.length == this.listState.list.length) {
- $('.check-all').prop('checked', true)
- } else {
- $('.check-all').prop('checked', false)
- }
- this.selectName = arr1
- var tempArray1 = this.arrDefault(this.selectName, this.attentionName)
- var tempArray2 = this.arrDefault(this.selectName, this.claimcheckName)
- if (tempArray1.length == 0) {
- this.follow = true
- if (this.selectName.length == 0) {
- this.follow = false
- }
- } else {
- this.follow = false
- }
- if (tempArray2.length == 0) {
- this.claim = true
- if (this.selectName.length == 0) {
- this.claim = false
- }
- } else {
- this.claim = false
- }
- },
- // 是否关注企业
- attentionCheck(arrs, item) {
- const _this = this
- $.ajax({
- url: '/entnicheNew/customer/check',
- method: 'POST',
- data: JSON.stringify({names: item}),
- contentType:'application/json;charset=utf-8',
- success: function (res) {
- if (res.data.names) {
- this.attentionName = res.data.names
- }
- arrs.forEach(v => {
- if (res.data.names.indexOf(v.Buyer) > -1) {
- v.follow1 = true
- } else {
- v.follow1 = false
- }
- })
- _this.claimcheck(arrs, item)
- }.bind(this)
- })
- },
- // 是否认领企业
- claimcheck(arrs, item) {
- $.ajax({
- url: '/entnicheNew/customer/claimcheck',
- method: 'POST',
- data: JSON.stringify({names: item}),
- contentType:'application/json;charset=utf-8',
- success: function (res) {
- if (res.data.names) {
- this.claimcheckName = res.data.names
- }
- arrs.forEach(v => {
- if (res.data.names.indexOf(v.Buyer) > -1) {
- v.claim1 = true
- } else {
- v.claim1 = false
- }
- })
- this.listState.list = arrs
- }.bind(this)
- })
- },
- // 关注、认领接口
- attention(item, type, str, per) {
- let obj = {}, _this = this
- if (type == 0) {
- obj = {
- name: per ? item : item.Buyer,
- province: per ? '' : item.WProvince,
- city: per ? '' : item.WCity,
- mold: type,
- B: per ? str : item.follow1,
- }
- } else {
- obj = {
- name: per ? item : item.Buyer,
- province: per ? '' : item.WProvince,
- city: per ? '' : item.WCity,
- mold: type,
- D: per ? str : item.claim1
- }
- }
- $.ajax({
- url: '/entnicheNew/customer/attention',
- method: 'POST',
- data: JSON.stringify(obj),
- contentType:'application/json;charset=utf-8',
- success: function (res) {
- if (res.data == false) {
- if (res.error_msg) {
- toastFn(res.error_msg, 2000)
- }
- } else {
- _this.getList(_this.listState.pageNum)
- // if (per && this.follow) {
- // this.follow = false
- // } else {
- // this.follow = true
- // }
- // if (per && this.claim) {
- // this.claim = false
- // } else {
- // this.claim = true
- // }
- }
- }.bind(this)
- })
- },
- arrDefault(array1, array2) {//比较的两个数组
- var tempArray1 = []
- var tempArray2 = []
- for(var i=0;i<array2.length;i++){
- if (!tempArray1.hasOwnProperty(array1[i])) {
- tempArray1[array2[i]]=true;
- }
- }
- for(var i=0;i<array1.length;i++){
- if(!tempArray1[array1[i]]){
- tempArray2.push(array1[i])
- }
- }
- return tempArray2
- },
- allGuanren (type) {
- if (this.selectName.length == 0) {
- toastFn('至少选择一项', 1500)
- } else {
- var tempArray1 = this.arrDefault(this.selectName, this.attentionName)
- var tempArray2 = this.arrDefault(this.selectName, this.claimcheckName)
- if (type == 0) {
- if (tempArray1.length == 0) {// 批量取关
- this.follow = true
- this.attention(String(this.selectName), type, true, 'pi')
- } else if (tempArray1.length == this.selectName.length) {// 批量关注
- this.follow = false
- this.attention(String(this.selectName), type, false, 'pi')
- } else {
- toastFn('关注和取消不能同时进行!', 2000)
- }
- } else {
- if (tempArray2.length == 0) {// 批量取认领
- this.claim = true
- this.attention(String(this.selectName), type, true, 'pi')
- } else if (tempArray2.length == this.selectName.length) {// 批量认领
- this.claim = false
- this.attention(String(this.selectName), type, false, 'pi')
- } else {
- toastFn('认领和取消不能同时进行!', 2000)
- }
- }
- }
- },
- guanAndren(item, type, index) {
- if (type == 1) {
- if (!item.claim1) {
- var top = 91 * (index + 1) + 'px'
- this.datas = item.Buyer
- $('.tags-box').slideToggle(function () {
- window.activeTags = []
- $('.tag-labels').empty()
- $('.clear-input').val('')
- $('.tags-list').find('.tags-item').removeClass('tags-active')
- $('.tag-placeholder').show()
- }).css({
- top: top,
- right: 0
- })
- } else {
- this.attention(item, type, '')
- }
- } else {
- this.attention(item, type, '')
- }
- },
- caiIndus(val, index) {
- let arrIndex = this.caiIndex.indexOf(index);
- if(arrIndex>-1){
- this.caiIndex.splice(arrIndex,1);
- this.indusList.splice(arrIndex,1);
- }else{
- this.caiIndex.push(index);
- this.indusList.push(val);
- }
- if (this.caiIndex.length < this.indusData.length) {
- this.qutive = false;
- }
- if (this.indusList.length == 0) {
- this.qutive = true;
- }
- if (this.caiIndex.length == this.indusData.length) {
- this.qutive = true;
- this.caiIndex = ["-2"];
- }
- this.searchContent = ''
- this.doSearch()
- },
- quanBu() {
- this.caiIndex = [];
- this.qutive = true;
- this.indusList = [];
- this.doSearch()
- },
- caiIndus1(val, index) {
- let arrIndex = this.caiIndex1.indexOf(index);
- if(arrIndex>-1){
- this.caiIndex1.splice(arrIndex,1);
- this.indusList1.splice(arrIndex,1);
- }else{
- this.caiIndex1.push(index);
- this.indusList1 = this.indusList1.concat(val);
- }
- if (this.caiIndex1.length < this.jobData.length) {
- this.qutive1 = false;
- }
- if (this.indusList1.length == 0) {
- this.qutive1 = true;
- }
- if (this.caiIndex1.length == this.jobData.length) {
- this.qutive1 = true;
- this.caiIndex1 = ["-2"];
- }
- this.searchContent = ''
- this.doSearch()
- },
- quanBu1() {
- this.caiIndex1 = [];
- this.qutive1 = true;
- this.indusList1 = [];
- this.doSearch()
- },
- cusMore() {
- console.log('1212')
- },
- qyCustmer() {
- $.ajax({
- url: '/entnicheNew/customer/history',
- method: 'GET',
- success: function (res) {
- if (res.error_code == 0 && $.isArray(res.data.list)) {
- this.qyData = res.data.list
- }
- }.bind(this)
- })
- },
- qyChange() {
- this.searchContent = ''
- this.doSearch()
- },
- jobRange() {
- const decide = window.localStorage.getItem('bus-key-group-SCOPE')
- if (decide) {
- this.jobData = JSON.parse(decide)
- } else {
- $.ajax({
- url: '/entnicheNew/subscribe/key/get',
- method: 'POST',
- success: function (res) {
- if ($.isArray(res.data.data) && res.error_code == 0) {
- res.data.data.forEach(v => {
- v.a_key.forEach(t => {
- this.jobData.push(t)
- })
- })
- }
- }.bind(this)
- })
- }
- },
- keyChange(appendkey, key, notkey) {
- let str = String(appendkey.concat(key).concat(notkey)).replace(/,/g, ' ')
- return str
- },
- initDOMEvents: function () {
- setTimeout(function () {
- // tabHover()
- }, 300)
- },
- areaCityChange: function (area) {
- var city = []
- for (var key in area) {
- city = city.concat(area[key])
- }
- this.entArea = area
- this.searchContent = ''
- this.doSearch()
- },
- isFilterShow: function () {
- if (this.filterShow) {
- $('.search-filters').slideUp()
- } else {
- $('.search-filters').slideDown()
- }
- this.filterShow = !this.filterShow
- },
- moneyUnit (m, type = 'string', lv = 0) {
- const mUnit = {
- levelArr: ['元', '万元', '亿元', '万亿元'],
- test (num, type, lv) {
- if (num === 0) {
- if (type === 'string') {
- return '0元'
- }
- if (type === 'lv') {
- return this.levelArr[lv]
- }
- if (type === 'number') {
- return 0
- }
- if (type === 'index') {
- return lv
- }
- }
-
- var result = num / Math.pow(10000, lv)
-
- if (result > 10000 && lv < 2) {
- return this.test(num, type, lv + 1)
- } else {
- if (type === 'string') {
- return String(Math.floor(result * 100) / 100).replace('.00', '') + this.levelArr[lv]
- }
- if (type === 'lv') {
- return this.levelArr[lv]
- }
- if (type === 'number') {
- return String(Math.floor(result * 100) / 100).replace('.00', '')
- }
- if (type === 'index') {
- return lv
- }
- }
- }
- }
- if (m === undefined || m === null) {
- return ''
- } else {
- return mUnit.test(m, type, lv)
- }
- },
- initCollectEvent () {
- const _this = this
- // 自定义标签
- // 标签输入框事件
- $('.tags-box').click(function (e) {
- e.stopPropagation()
- })
-
- $('.tag-input').click(function (e) {
- e.stopPropagation()
- $(this).children('.tag-placeholder').hide()
- $(this).children('input').focus()
- })
- // 标签输入框回车事件
- $('.tag-input .clear-input').keydown(function (event) {
- event.stopPropagation()
- if (event.keyCode == 13) {
- if (!$('.tags-box').is(':hidden')) {
- $('.tags-inputs .add-tag-button').trigger('click')
- }
- }
- })
- // 标签输入框失去焦点事件
- $('.tag-input .clear-input').blur(function () {
- if ($('.tag-labels').children().length == 0 && $(this).val() == '') {
- $('.tag-placeholder').show()
- }
- })
- // 添加标签按钮事件
- $('.tags-inputs .add-tag-button').on('click', function () {
- var input = $('.tag-input .clear-input')
- if (input.val().length >= 2 && input.val().length < 6) {
- // ajax提交自定义标签
- addTagsAjax(input.val())
- }
- })
- // 点击确定按钮,绑定标签
- $('.tags-footer .button-confirm').on('click', function () {
- if (!$('.tags-box').is(':hidden')) {
- var lids = ''
- var lname = ''
- $('.tags-item.tags-active').each(function () {
- if ($(this).attr('data-id')) {
- if (lids != '') {
- lids += ','
- }
- if (lname != '') {
- lname += ','
- }
- lids += $(this).attr('data-id')
- lname += $(this).text()
- }
- })
- var params = {
- name: _this.datas,
- mold: 1,
- D: false,
- label: lids
- }
- // 执行保存绑定标签操作
- // if (params.label !== '') {
- saveChooseTags(params, function () {
- $('.tags-footer .button-cancel').trigger('click')
- })
- // }
- }
- })
-
- $('.tags-footer .button-cancel').on('click', function () {
- $('.tags-box').slideToggle(function () {
- // 标签弹框消失时 清除上次选择的标签分类
- activeTags = []
- $('.tag-labels').empty()
- $('.clear-input').val('')
- $('.tags-list').find('.tags-item').removeClass('tags-active')
- $('.tag-placeholder').show()
- })
- })
-
- window.activeTags = [] // 选中的自定义标签 作为全局变量使用
- // 解绑自定义标签
- function deleteInputTag (item) {
- var index = $(item).parent().attr('data-index')
- var id = $(item).parent().attr('data-id')
- activeTags.splice(index, 1)
- inputTagList()
- $('.tags-item[data-id="' + id + '"]').removeClass('tags-active')
- }
-
- window.deleteInputTag = deleteInputTag
-
- function inputTagList () {
- var ht = ''
- $('.tag-labels').html(ht)
- activeTags.forEach(function (v, i) {
- ht += '<span class="tag-label" data-index=' + i + ' data-id="' + v.lid + '">'
- ht += '<em>' + v.lname + '</em>'
- ht += '<i class="tag-close" onclick="deleteInputTag(this)"></i>'
- ht += '</span>'
- })
- $('.tag-labels').html(ht)
- if ($('.tag-labels').children('.tag-label').length > 0) {
- $('.tag-placeholder').hide()
- }
- checkTagDisabled()
- }
-
- // 渲染标签列表数据
- function renderTagsList (data) {
- if (data && data.length > 0) {
- var ht = ''
- data.forEach(function (v, i) {
- ht += '<span class="tags-item" data-count=' + v.count + ' data-id=' + v.lid + '>' + v.lanme + '</span>'
- })
- $('.tags-list').html(ht)
- activeTags.forEach(function (s, j) {
- $('.tags-list .tags-item[data-id="' + s.lid + '"]').addClass('tags-active')
- })
- $('.tags-item').click(function (e) {
- e.stopPropagation()
- if ($(this).hasClass('disabled')) return
- var id = $(this).attr('data-id')
- var name = $(this).text()
- $(this).toggleClass('tags-active')
- if ($(this).hasClass('tags-active')) {
- activeTags.push({
- lid: id,
- lname: name
- })
- inputTagList()
- } else {
- var newArr = activeTags.filter(function (item) {
- return item.lid != id
- })
- activeTags = newArr
- inputTagList()
- }
- })
- }
- inputTagList()
- }
-
- // 获取用户自定义标签
- function getUserTags () {
- $.ajax({
- type: 'post',
- url: '/entnicheNew/customer/getLabel?t=' + Date.now(),
- success: function (r) {
- if (r.error_code == 0 && $.isArray(r.data)) {
- renderTagsList(r.data.reverse())
- }
- }
- })
- }
-
- window.getUserTags = getUserTags
- // 添加标签后认领接口
- function saveChooseTags (params, callback) {
- $.ajax({
- type: 'post',
- url: '/entnicheNew/customer/attention',
- contentType: 'application/json',
- data: JSON.stringify(params),
- dataType: 'json',
- success: function (r) {
- if (r.error_code == 0 && r.data) {
- $('.tags-box').slideToggle()
- _this.getList(_this.listState.pageNum)
- _this.$toast('认领成功!')
- _this.$emit('updatelist', true)
- callback && callback()
- } else {
- if (r.error_msg) {
- toastFn(r.error_msg, 2000)
- }
- }
- }
- })
- }
-
- // 新增标签
- function addTagsAjax (name) {
- $.ajax({
- type: 'post',
- url: '/entnicheNew/customer/addLabel',
- data: {
- name: name
- },
- dataType: 'json',
- success: function (r) {
- if (r.data) {
- $('.tag-input .clear-input').val('')
- // 添加标签成功后 绑定标签
- if (activeTags.length < 3) {
- activeTags.push({
- lid: r.data,
- lname: name
- })
- }
- getUserTags()
- } else {
- toastFn('标签已经存在,无需添加', 1000)
- }
- }
- })
- }
-
- function checkTagDisabled () {
- if (activeTags.length >= 3) {
- // 禁用标签
- $('.tags-list').find('.tags-item:not(.tags-active)').addClass('disabled')
- } else {
- // 解除禁用
- $('.tags-list').find('.disabled').removeClass('disabled')
- }
- }
-
- function baiduEvent (str) {
- try {
- // eslint-disable-next-line no-undef
- _hmt.push(['_trackEvent', '大会员-pc', 'click', str])
- } catch (e) {
- console.log('未初始化百度统计')
- }
- }
- getUserTags()
- }
- }
- })
|