12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157 |
- 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,
- industrySelector: industrySelector,
- 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, // 一共多少条数据
- 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: []
- }
- },
- 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.initPageData()
- this.getList(1)
- },
- mounted: function () {
- this.initCollectEvent()
- this.initDOMEvents()
- ewmMoveHover()
- this.$on('updatescope', (data) => {
- this.setData.keyList = data
- })
- },
- methods: {
- updatescope(data) {
- // console.log(data)
- },
- initPageData () {
- if (pageInfo.searchContent) {
- this.searchContent = pageInfo.searchContent
- console.info(this.searchContent)
- }
- },
- // 采购单位模糊搜索
- 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
- },
- dataChange(val) {
- this.tempData = val
- this.doSearch()
- },
- 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.tempData,
- 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)) {
- this.listState.listAll = 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
- let arrs = this.listState.listAll, arr1 = [], arr2 = []
- this.listState.loading = true
- setTimeout(() => {
- arr1 = arrs.slice((p - 1) * this.listState.pageSize, (p - 1) * this.listState.pageSize + this.listState.pageSize) || []
- arr1.forEach(v => {
- arr2.push(v.Buyer)
- })
- if (arr1.length == 0) {
- this.listState.list = []
- } else {
- this.attentionCheck(arr1, String(arr2))
- }
- }, 600)
- },
- 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 = [], arrs2 = [], arrs3= []
- if (str1) {
- str2.prop('checked', true)
- this.listState.list.forEach(v => {
- arrs1.push(v.Buyer)
- arrs2.push(v.Buyerclass)
- arrs3.push(v.customerId)
- })
- } else {
- str2.prop('checked', false)
- arrs1 = []
- }
- this.selectName = arrs1
- this.selectIndustry = arrs2
- this.selectId = arrs3
- },
- // 单选
- singleChange () {
- 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'))
- }
- })
- if (arr1.length == this.listState.list.length) {
- $('.check-all').prop('checked', true)
- } else {
- $('.check-all').prop('checked', false)
- }
- this.selectName = arr1
- 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
- }
- },
- // 是否关注企业
- 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.forEach(s => {
- this.claimcheckName.push(s.split(',')[0])
- })
- }
- arrs.forEach(v => {
- let renName = res.data.names.join(',')
- res.data.names.forEach(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
- }.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.customerId,
- province: per ? '' : item.WProvince,
- city: per ? '' : item.WCity,
- mold: type,
- D: per ? str : item.claim1,
- }
- }
- // console.info(obj)
- $.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 {
- if (type == 0) {
- if (str || item.follow1) {
- toastFn('取消关注失败!', 2000)
- } else {
- toastFn('关注失败!', 2000)
- }
- } else {
- toastFn('取消认领失败!', 2000)
- }
- }
- } else {
- if (type == 0) {
- if (str || item.follow1) {
- toastFn('取消关注成功!', 2000)
- } else {
- toastFn('关注成功!', 2000)
- }
- } else {
- toastFn('取消认领成功!', 2000)
- }
- this.follow = false
- this.claim = false
- $('.custom-checkbox').prop('checked', false)
- _this.selectName = []
- _this.getList(_this.listState.pageNum)
- }
- }.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.selectId), type, true, 'pi')
- } else if (tempArray2.length == this.selectName.length) {// 批量认领
- this.claim = false
- var top = index + 1 + 'px'
- this.datas = {
- name: String(this.selectName),
- industry: ''
- }
- $('.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
- })
- // 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 = {
- name: item.Buyer,
- industry: item.Buyerclass
- }
- $('.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.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 += '<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) {
- _this.follow = false
- _this.claim = false
- $('.custom-checkbox').prop('checked', false)
- _this.selectName = []
- _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()
- }
- }
- })
|