123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422 |
- 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+='<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
- 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: ['${', '}'],
- 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)
- },
- },
- 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()
- this.getList()
- },
- mounted: function () {
- 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: {
- 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) {}
- },
- 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
- 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(name) {
- // 是渠道合作页面需要登录后重定向
- var url = '/swordfish/page_big_pc/unit_portrayal/' + name
- if (this.isNewEntNiche) {
- url = '/entpc/unit_portrayal/' + name
- } else {
- url = '/swordfish/page_big_pc/unit_portrayal/' + name
- }
- if(cooperateCode) {
- openLoginDig(null, url)
- return
- }
- 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<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: function (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: function(item, type, index) {
- if (type == 1) {
- if (!item.isReceived) {
- // 根据列表高度计算top值
- var top = 95 * (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: function(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: 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 += '<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 = 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()
- }
- }
- })
|