function getRandomString (len) { let randomString = '' if (len) { var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678' var 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) { if (!duration) { duration = 1000 } var _html = "" _html+='
' _html+='' + text + '
' $('body').append(_html) setTimeout(function(){ $(".custom-toast").fadeOut().remove(); },duration) } function formatKeywordsList (res) { // if (!res || !res.a_items) return // const data = res.a_items var newArr = [] res.forEach(function(v) { if (v.a_key) { v.a_key.forEach(function(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 selectDataIds = [] var vm = new Vue({ el: '#pur-search-container', delimiters: ['${', '}'], mixins: [workspaceDescMixin], components: { areaCityComponent: areaCityComponent, selectListComponent: selectListComponent, priceComponent: priceComponent, // industrySelector: industrySelector, noData: noDataComponent, selectLevel2Component: selectLevel2Component, }, 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: 10, // 每页多少条数据 total: 0, // 一共多少条数据 listAll: [], // 所有数据 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: [], selectId: [], selectName: [], selectIndustry: [], tempData: [], buyClassMap: buyclassArr, buyerPhoneOptions: [ { label: '不限', value: 0 }, { label: '有联系方式', value: 1 }, // { // label: '无联系方式', // value: 2 // } ], buyerClassObj: {}, buyerClassArr: [], buyerPhoneState: 0, inIframe: false, isLogin: false, isMember: false, isEntService: false, isNewEntNiche: false, area: { province: [], city: [] }, loadingOther: 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 === 'qy') { if (this.searchContent) { location.href = '/jylab/entSearch/index.html?keywords=' + this.searchContent } else { location.href = '/jylab/entSearch/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: { purListShow: function () { return this.searchContent.trim().length >= 2 && this.preSearch.list.length && (this.preSearch.focus || this.preSearch.hover) }, getBIParams () { const urlParams = new URLSearchParams(window.location.search) return urlParams.get('resource') }, loginIn () { return this.isLogin } }, created: function () { var params = goTemplateData.params this.inIframe = goTemplateData.inIframe this.isLogin = params.login && Object.keys(params.login).length > 0 this.isMember = params.isMember this.isEntService = params.isEntService this.isNewEntNiche = params.isEntnicheNew // this.initIndustryMap() // this.qyCustmer() // this.jobRange() this.initPageData() }, mounted: function () { this.filterEcho() this.$nextTick(() => { this.getList() this.initCollectEvent() this.initDOMEvents() ewmMoveHover() this.$on('updatescope', function(data) { this.setData.keyList = data }) }) /** * 初始化页面搜索框与工作台顶部搜索联动事件函数,详情见对应函数 common.js * 需要在 dom 初始化后调用来监听事件,Vue中需要额外在 input 对应事件额外手动触发事件 */ // if (goTemplateData.inIframe) { // this._$SearchEvent = initSearchPageEvent({ // type: 'buyer', // el: '.search-header-top .input-container', // submitSelector: '.search-button', // change: function(val) { // this.searchContent = val // } // }) // } }, methods: { goBack () { var back = function () { // 判断是否在iframe,如果在iframe,则用父级返回 if (goTemplateData.inIframe) { window.parent.history.back() } else { history.back() } } var goHome = function () { // 判断是否在iframe,如果在iframe,则用父级返回 if (goTemplateData.inIframe) { window.parent.location.href = '/' } else { window.location.href = '/' } } var referer = document.referer if(referer) { var inJianyuWebSite = referer.indexOf('jianyu360.cn') > 0 if (inJianyuWebSite) { // 本站的,判断是否是新窗口打开的页面 // 1.window.open可以通过判断window.opener // 2.a target='_black'可以通过判断history.length var opener = window.opener && window.opener !== window var target_blank = history.length <= 1 // 是否新窗口打开 var isNewWindow = opener || target_blank if (isNewWindow) { try { window.parent && window.parent.close() } catch (error) { window.close() } back() } else { back() } } else { goHome() } } else { goHome() } }, goWorkSpace: function () { // 不在工作台,添加缓存 if(!this.inIframe) { let obj = { buyerName: this.searchContent.trim(), province: this.area.province, city: this.area.city, buyerClass: this.buyerClassArr, isCheckFollow: this.isLogin ? true : false, isCheckReceive: this.isLogin ? true : false, isContact: this.buyerPhoneState, pageSize: this.listState.pageSize, pageNum: this.listState.pageNum, } obj.buyerClassObj = this.buyerClassObj sessionStorage.setItem('purParams', JSON.stringify(obj)) } var goHref = location.origin + '/jylab/purSearch/index.html' window.location.replace('/page_workDesktop/work-bench/page?link=' + encodeURIComponent(goHref)) }, // 查询收录情况 getEmployData (ids) { const url = '/jyapi/crmApplication/employ/info' const params = { employType: 3, idArr: ids ? ids.join(',') : '' } $.ajax({ url: url, type: 'POST', data: JSON.stringify(params), contentType: 'application/json', success: function (res) { if (res.error_code === 0) { this.employInfo = res.data res.data.forEach((r) => { this.listState.list.forEach(m => { if(m.buyer === r.id) { m.active = r.isEmploy ? 1 : 0 } }) }) this.$forceUpdate() } }.bind(this) }) }, // 收录操作 setEmployEvent (item) { const url = '/jyapi/crmApplication/employ/operate' const params = { idArr: item.buyer, isEmploy: !item.active, employType: 3 } $.ajax({ url: url, type: 'POST', data: JSON.stringify(params), contentType: 'application/json', success: function (res) { if(res.error_code === 0) { if (res.data.status) { item.active = !item.active ? 1 : 0 } else { toastFn(res.data.msg, 1000) } } this.$forceUpdate() }.bind(this), complete: function () { }.bind(this) }) }, 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, '') } item.city.forEach(function (iitem) { var c = iitem.name.replace(/[省市]/, '') if (shortname.indexOf(c) !== -1) { shortname = shortname.replace(iitem.name, '').replace(c, '') } iitem.area.forEach(function (iiitem) { if (shortname.indexOf(iiitem) !== -1) { shortname = shortname.replace(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 }, buyerClassFilterChange: function (buyerclass) { var buyerclassArr = [] this.buyerClassObj = buyerclass for (var key in buyerclass) { buyerclassArr = buyerclassArr.concat(buyerclass[key]) } this.buyerClassArr = buyerclassArr this.doSearch() }, otherFilterChange: function () { this.doSearch() }, updatescope: function(data) { // console.log(data) }, initPageData: function () { if (pageInfo.searchContent) { this.searchContent = pageInfo.searchContent console.info(this.searchContent) } }, onFocusSearch: function () { this.preSearch.focus=true this.preSearch.list = [] this.getPreSearchList() }, // 采购单位模糊搜索 getPreSearchList: utils.debounce(function () { /** * 初始化页面搜索框与工作台顶部搜索联动事件函数,详情见对应函数 common.js * 需要在 dom 初始化后调用来监听事件,Vue中需要额外在 input 对应事件额外手动触发事件 */ if (this._$SearchEvent) { this._$SearchEvent.syncInput() } var data = { name: this.searchContent.trim() } if (data.name.length < 2) return $.ajax({ url: this.isNewEntNiche ? '/entnicheNew/customer/buyer/association' : '/bigmember/search/buyer/association', method: 'POST', data: data, success: function (res) { if (res.error_code === 0) { if (res.data) { if (this.isNewEntNiche) { this.preSearch.list = res.data.list || [] } else { // 非商机管理用户(大会员接口) var names = [] res.data.list.forEach(function(item){ names.push({ name: item }) }) this.preSearch.list = names } } } else { // this.checkLogin() } }.bind(this) }) }, 200), goSearch: function(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: function() { if (goTemplateData.inIframe) { window.$BRACE.methods.open({ route: { link: '/jylab/purScopebusniess/index.html' } }) } else { window.location.href="/jylab/purScopebusniess/index.html" } }, // 整理数据列表 initIndustryMap: function () { var industryListMap = [] // 全部 var all = JSON.parse(JSON.stringify(this.industryExp)) all.selected = true all.id = 'lv0-' + getRandomString(8).toLowerCase() industryListMap.push(all) for (var key in this.industryListMapExp) { var level1 = JSON.parse(JSON.stringify(this.industryExp)) level1.name = key level1.level = 1 level1.id = 'lv1-' + getRandomString(8).toLowerCase() var level2Arr = [] this.industryListMapExp[key].forEach(function(item) { var 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 var tempArr = [] this.industryListMap.forEach(function(v) { var tempNode = v tempNode.zindex = 1 tempArr.push(tempNode) if (tempNode.children) { tempNode.children.forEach(function(s) { var tempS = s tempS.zindex = 2 tempArr.push(tempS) }) } }) this.getIndustryListMap = tempArr }, // 按钮点击事件 changeIndustryState: function (item) { // 循环所有数据,判断并改变状态 switch (item.level) { case 0: { this.setIndustryState() break } case 1: { item.selected = !item.selected this.industryListMap[0].selected = false // 二级子按钮状态跟随一级按钮 item.children.forEach(function(level2) { level2.selected = item.selected }) break } case 2: { item.selected = !item.selected // 找到当前点击的父级元素 this.industryListMap.forEach(function(level1) { var selectedStateArr = [] if (item.level !== 0) { level1.children.forEach(function(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) { var allSelected = this.checkAllSelectedState() if (allSelected.allSelected || allSelected.allNotSelected) { this.setIndustryState() } } if (this.selectorType === 'line') { this.onChange() } // this.searchContent = '' this.doSearch() }, // 检查是否全部选中了/全部不选中 checkAllSelectedState: function () { // 一级标签选中状态(如果一级标签全部被选中,则说明,全部按钮被选中) var level1StateArr = [] // 所有标签选中状态 var allSelectedArr = [] this.industryListMap.forEach(function(level1) { if (level1.level !== 0) { level1StateArr.push(level1.selected) allSelectedArr.push(level1.selected) level1.children.forEach(function(level2) { allSelectedArr.push(level2.selected) }) } }) return { // 找不到false,就说明全部被选中 allSelected: level1StateArr.indexOf(false) === -1, // 找不到true,就说明没有一个被选中 allNotSelected: allSelectedArr.indexOf(true) === -1 } }, /** * 初始化页面选中状态 * @param { Array | undefined } data 要恢复的数据 */ setIndustryState: function (data) { // 设置全部按钮 if (!data || Object.keys(data).length === 0) { // 其他全部设置不选中,全部按钮设置选中 this.industryListMap.forEach(function(item) { item.selected = false item.children.forEach(function(iitem) { iitem.selected = false }) }) this.industryListMap[0].selected = true } else { this.setIndustryState() this.industryListMap[0].selected = false this.industryListMap.forEach(function(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: function () { var map = {} this.industryListMap.forEach(function(item) { var mapArr = [] if (item.level !== 0) { item.children.forEach(function(iitem) { if (iitem.selected) { mapArr.push(iitem.name) } }) } if (mapArr.length !== 0) { map[item.name] = mapArr } }) var tempArr = [] Object.keys(map).forEach(function(v) { var tempItem = map[v] if (Array.isArray(tempItem)) { tempItem.forEach(function(vv) { tempArr.push(v + '_' + vv) }) } }) return tempArr }, dataChange: function(val) { this.tempData = val this.doSearch() }, doSearch: function () { $('.tags-box').hide() this.listState.pageNum = 1 this.getList() try { var val = this.searchContent var baseDesc = '剑鱼标讯是国内专业的招标采购单位信息查询平台,为您提供包括采购单位信息、招标单位信息、采购人信息、招标人信息、业主单位信息的检索查询服务,查看更多招标采购单位详细信息就用剑鱼标讯!' var _title = val ? val + '相关搜索结果 - 剑鱼标讯' : '采购单位查询_采购单位信息_招标采购单位大全 - 剑鱼标讯' var _keywords = val ? val +',' + val + '招标,' + val + '采购,剑鱼标讯' : '采购单位,采购人信息,招标单位,招标人信息,业主单位,剑鱼标讯' var _desc = val ? '剑鱼标讯是国内专业的招标采购单位信息查询平台,为您提供' + val +'相关的采购单位信息详情,帮助您全面了解采购单位最新动态,获取更多' + val + '相关搜索结果就上剑鱼标讯!' : baseDesc seoTdkUpdate(_title, _keywords, _desc) } catch (error) {} }, filterEcho: function (val) { let purParams = sessionStorage.getItem('purParams') if(purParams) { purParams = JSON.parse(purParams) this.searchContent = purParams.buyerName.trim() this.area.province = purParams.province this.area.city = purParams.city this.$refs.areaCityFilter.setStateData(this.area) this.buyerClassArr = purParams.buyerClass this.isLogin = purParams.isCheckFollow this.buyerPhoneState = purParams.isContact this.listState.pageSize = purParams.pageSize this.listState.pageNum = purParams.pageNum this.buyerClassObj = purParams.buyerClassObj sessionStorage.removeItem('purParams') } }, getList: function () { let obj = { buyerName: this.searchContent.trim(), province: this.area.province, city: this.area.city, buyerClass: this.buyerClassArr, isCheckFollow: this.isLogin ? true : false, isCheckReceive: this.isLogin ? true : false, isContact: this.buyerPhoneState, pageSize: this.listState.pageSize, pageNum: this.listState.pageNum, } this.listState.loading = true this.listState.loaded = false var _this = this $.ajax({ // /jybx/buyer/:userType/buyerList // fType:免费用户 pType:付费用户 vType:超级订阅用户 mType:大会员用户 eType:商机管理用户 // userType传哪个都一样 url: '/jyapi/jybx/buyer/eType/buyerList', method: 'POST', data: JSON.stringify(obj), contentType:'application/json;charset=utf-8', success: function (res) { if (res.error_code === 0 && $.isArray(res.data.list)) { this.listState.total = res.data.count var buyerNameArr = [] res.data.list.forEach(function(v) { buyerNameArr.push(v.buyer) v.buyerShortName = _this.getShortName(v.buyer) v.randomBgc = _this.randomBgc() // 所在地区异常数据处理 var same = v.province === v.city // 省份和城市相同 var pBc = v.province && v.city && v.province.indexOf(v.city) > -1 // 省份包含城市 var cBp = v.province && v.city && v.city.indexOf(v.province) > -1 // 城市包含了省份 if (same || pBc || cBp) { v.city = '' } v.biddingCount = v.biddingCount ? v.biddingCount + '条' : '' v.contactCount = v.contactCount ? v.contactCount + '个' : '' v.projectCount = v.projectCount ? v.projectCount + '个' : '' }) this.listState.list = res.data.list const resultIds = res.data.list.map(v => v.buyer) this.getEmployData(resultIds) this.listState.loading = false // this.getBuyerOtherInfo(buyerNameArr) } else { if (res.error_msg) { toastFn(res.error_msg, 2000) } this.listState.list = [] } this.listState.loaded = true }.bind(this), complete: function () { this.listState.loading = false this.listState.loaded = true }.bind(this) }) }, getBuyerOtherInfo: function (arr) { if (!arr || arr.length === 0) return var params = { buyer: arr } this.loadingOther = true var _this = this $.ajax({ url: '/jyapi/jybx/buyer/supply/info', method: 'POST', data: JSON.stringify(params), contentType:'application/json;charset=utf-8', success: function (res) { if (res.error_code === 0 && $.isArray(res.data)) { res.data.forEach(function(r) { _this.listState.list.forEach(function(v) { if (r.buyer === v.buyer) { v.biddingCount = r.biddingCount ? r.biddingCount + '条' : '' v.contactCount = r.contactCount ? r.contactCount + '个' : '' v.projectCount = r.projectCount ? r.projectCount + '个' : '' v.bidAmountCount = r.bidAmountCount } }) }) } _this.loadingOther = false }, complete: function () { _this.loadingOther = false } }) }, onSizeChange: function (val) { this.listState.pageSize = val this.listState.pageNum = 1 this.onPageChange(this.listState.pageNum) }, onPageChange: function (p) { $('.tags-box').hide() this.listState.pageNum = p this.listState.loading = true var oTop = this.$refs.listContainer.offsetTop - 64 - 16 || 0 // 翻页后页面滚动到列表第一条数据的位置 document.documentElement.scrollTop = oTop; //ie下 document.body.scrollTop = oTop this.getList() }, goTitle: function(item) { var name = item.buyer var seoId = item.seo_id // 是渠道合作页面需要登录后重定向 const BIPge = this.getBIParams ? '?resource=BI' : '' var seoUrl = '/dw/' + seoId + '.html' + BIPge var url = '/swordfish/page_big_pc/unit_portrayal/' + name if (this.isNewEntNiche) { url = '/entpc/unit_portrayal/' + name + BIPge } else { url = '/swordfish/page_big_pc/unit_portrayal/' + name + BIPge } if(cooperateCode) { openLoginDig(null, url) return } url = seoUrl window.open(url) }, // 全选 allChange: function() { var str1 = $('.check-all').prop('checked') var str2 = $('.custom-checkbox:not(".check-all")') var arr = $('.custom-checkbox:not(".check-all"):checked') let arrs1 = [], arrs2 = [], arrs3= [] if (str1) { str2.prop('checked', true) this.listState.list.forEach(function(v) { arrs1.push(v.Buyer) arrs2.push(v.Buyerclass) arrs3.push(v.customerId) }) selectDataIds = this.unique(selectDataIds.concat(arrs1)) } else { $('.custom-checkbox:not(".check-all"):checked').each(function(){ var dataName = $(this).attr('dataname') selectDataIds.forEach(function(item) { if(dataName == item) { selectDataIds.remove(item) } }) }) str2.prop('checked', false) arrs1 = [] } this.selectName = selectDataIds this.selectIndustry = arrs2 this.selectId = arrs3 }, // 单选 singleChange: function () { let arr1 = [], arr2 = [], arr3 = [] $('.custom-checkbox:not(".check-all"):checked').each(function(){ if ($(this).attr('dataname')) { arr1.push($(this).attr('dataname')) arr2.push($(this).attr('dataindustry')) arr3.push($(this).attr('dataid')) } }) selectDataIds = this.unique(selectDataIds.concat(arr1)) $('.custom-checkbox:not(".check-all")').each(function(){ if (!$(this).prop('checked')) { selectDataIds.remove($(this).attr('dataname')) } }) if (arr1.length == this.listState.list.length) { $('.check-all').prop('checked', true) } else { $('.check-all').prop('checked', false) } this.selectName = selectDataIds this.selectIndustry = arr2 this.selectId = arr3 // console.info(this.attentionName, this.claimcheckName) 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 } }, // 数组去重 unique: function(arr) { var res = new Map() // return arr.filter((arr) => !res.has(arr) && res.set(arr, 1)); return arr.filter(function (arr) { return !res.has(arr) && res.set(arr, 1) }) }, // 是否关注企业 attentionCheck: function(arrs, item) { var _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(function(v) { if (res.data.names.indexOf(v.Buyer) > -1) { v.isFollowed = true } else { v.isFollowed = false } }) _this.claimcheck(arrs, item) }.bind(this) }) }, // 是否认领企业 claimcheck: function(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.forEach(function(s) { this.claimcheckName.push(s.split(',')[0]) }) } arrs.forEach(function(v) { let renName = res.data.names.join(',') res.data.names.forEach(function(s) { if (renName.indexOf(v.Buyer) > -1) { v.claim1 = true if (s.split(',')[0] == v.Buyer) { v.customerId = s.split(',')[1] } } else { v.claim1 = false } }) }) this.listState.list = arrs this.listState.loading = false this.$nextTick(function() { var checkNum = 0 var inputs = $('.custom-checkbox:not(".check-all")') $('.check-all').prop('checked', false) $('.custom-checkbox:not(".check-all")').each(function(){ $(this).prop('checked', false) var that = this var dataName = $(this).attr('dataname') selectDataIds.forEach(function(item) { if(dataName == item) { checkNum++ $(that).prop('checked', true) } }) }) if(checkNum == arrs.length) { $('.check-all').prop('checked', true) } else { $('.check-all').prop('checked', false) } }) }.bind(this) }) }, // 关注、认领接口 attention: function(item, type, str, per) { let obj = {}, _this = this if (type == 0) { // 商机管理的关注 if (_this.isNewEntNiche) { obj = { name: per ? item : item.buyer, province: per ? '' : item.province, city: per ? '' : item.city, mold: type, B: per ? str : item.isFollowed, } } else { // 大会员的关注 obj = { name: per ? item : item.buyer, province: per ? '' : item.province, city: per ? '' : item.city, b: Boolean(item.isFollowed), } } } else { obj = { name: per ? item : item.recId, province: per ? '' : item.province, city: per ? '' : item.city, mold: type, D: per ? str : item.isReceived, } } var url = '/entnicheNew/customer/attention' if (type === 0 && _this.isMember) { url = '/publicapply/customer/attention' } // console.info(obj) $.ajax({ url: url, method: 'POST', data: JSON.stringify(obj), contentType:'application/json;charset=utf-8', success: function (res) { if (res.error_code === 0) { if (res.data == false) { if (res.error_msg) { toastFn(res.error_msg, 2000) } else { if (type == 0) { if (str || item.isFollowed) { toastFn('取消关注失败!', 2000) } else { toastFn('关注失败!', 2000) } } else { toastFn('取消认领失败!', 2000) } } } else { if (type == 0) { if (str || item.isFollowed) { toastFn('取消关注成功!', 2000) } else { toastFn('关注成功!', 2000) } } else { toastFn('取消认领成功!', 2000) } // this.follow = false // this.claim = false // $('.custom-checkbox').prop('checked', false) // _this.selectName = selectDataIds _this.getList(_this.listState.pageNum) } } else { toastFn(res.error_msg, 2000) } }.bind(this) }) }, arrDefault: function(array1, array2) {//比较的两个数组 var tempArray1 = [] var tempArray2 = [] for(var i=0;i-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: function() { this.caiIndex = []; this.qutive = true; this.indusList = []; this.doSearch() }, caiIndus1: function(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: function() { this.caiIndex1 = []; this.qutive1 = true; this.indusList1 = []; this.doSearch() }, cusMore: function() { console.log('1212') }, qyCustmer: function() { $.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: function() { // this.searchContent = '' this.doSearch() }, jobRange: function() { var 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(function(v) { v.a_key.forEach(function(t) { this.jobData.push(t) }) }) } }.bind(this) }) } }, keyChange: function(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 = [] var province = [] for (var key in area) { if (area[key].length === 0) { province.push(key) } else { city = city.concat(area[key]) } } this.area.province = province this.area.city = city this.doSearch() }, isFilterShow: function () { if (this.filterShow) { $('.search-filters').slideUp() } else { $('.search-filters').slideDown() } this.filterShow = !this.filterShow }, moneyUnit: function (m, type, lv) { if (!type) { type = 'string' } if (!lv) { lv = 0 } var mUnit = { levelArr: ['元', '万元', '亿元', '万亿元'], test: function (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: function () { var _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.name, mold: 1, D: false, label: lids, industry: _this.datas.industry } // 执行保存绑定标签操作 // 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') $('.tags-list').find('.disabled').removeClass('disabled') $('.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 += '' ht += '' + v.lname + '' ht += '' ht += '' }) $('.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 += '' + v.lanme + '' }) $('.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) { _this.follow = false _this.claim = false $('.custom-checkbox').prop('checked', false) _this.selectName = selectDataIds _this.claimcheckName = [] _this.getList(_this.listState.pageNum) $('.tags-list').find('.disabled').removeClass('disabled') toastFn('认领成功!', 1000) _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() } } })