pur-search-index-pc.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578
  1. function getRandomString (len) {
  2. let randomString = ''
  3. if (len) {
  4. var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
  5. var maxPos = $chars.length
  6. for (let i = 0; i < len; i++) {
  7. randomString += $chars.charAt(Math.floor(Math.random() * maxPos))
  8. }
  9. } else {
  10. randomString = Math.random().toString(36).substring(2)
  11. }
  12. return randomString
  13. }
  14. // toast上限提示
  15. function toastFn (text, duration) {
  16. if (!duration) {
  17. duration = 1000
  18. }
  19. var _html = ""
  20. _html+='<div class="custom-toast"><div class="mask" style="background-color: transparent;"></div><div class="toast-container">'
  21. _html+='<span>' + text + '</span></div></div>'
  22. $('body').append(_html)
  23. setTimeout(function(){
  24. $(".custom-toast").fadeOut().remove();
  25. },duration)
  26. }
  27. function formatKeywordsList (res) {
  28. // if (!res || !res.a_items) return
  29. // const data = res.a_items
  30. var newArr = []
  31. res.forEach(function(v) {
  32. if (v.a_key) {
  33. v.a_key.forEach(function(s) {
  34. newArr.push(s)
  35. })
  36. }
  37. })
  38. return newArr
  39. }
  40. function ewmMoveHover() {
  41. var $div = $(".search-right-wx .search-right-wx-inner"),
  42. $parent = $(".search-right-wx");
  43. $parent.on("mouseover",function(){
  44. $div.css({
  45. "transform":"scale(1)",
  46. "transition":"transform 0.8s"
  47. })
  48. })
  49. $parent.on("mouseout",function(){
  50. $div.css({
  51. "transform":"scale(0)",
  52. "transition":"transform 0.2s"
  53. })
  54. })
  55. }
  56. var selectDataIds = []
  57. var vm = new Vue({
  58. el: '#pur-search-container',
  59. delimiters: ['${', '}'],
  60. mixins: [workspaceDescMixin],
  61. components: {
  62. areaCityComponent: areaCityComponent,
  63. selectListComponent: selectListComponent,
  64. priceComponent: priceComponent,
  65. // industrySelector: industrySelector,
  66. noData: noDataComponent,
  67. selectLevel2Component: selectLevel2Component,
  68. },
  69. data: function () {
  70. return {
  71. searchContent: '',
  72. tabActive: 'cgdw',
  73. filterShow: true,
  74. indusData: ['财政', '传媒', '城管', '采矿业', '出版广电', '档案', '党委办', '电信行业', '法院',
  75. '发改', '工信', '公安', '国资委', '公共资源交易',
  76. '海关', '教育', '军队', '交通', '纪委', '金融业', '建筑业', '检察院', '机关事务',
  77. '科技', '民政', '民宗', '农业', '能源化工', '农林牧渔', '批发零售', '气象', '人行', '人社', '人大',
  78. '税务', '水利', '市政', '审计', '商务', '司法', '社会团体', '市场监管', '生态环境',
  79. '统计', '统战', '体育', '文旅', '卫健委', '学校', '宣传', '信息技术',
  80. '医疗', '银保监', '运输物流', '应急管理',
  81. '组织', '政协', '住建', '证监', '政府办', '制造业', '政务中心', '住宿餐饮', '自然资源'
  82. ],
  83. indusList:[],
  84. caiIndex: [],
  85. qutive: true,
  86. indusList1:[],
  87. caiIndex1: [],
  88. qutive1: true,
  89. qyCheck: [],
  90. qyData: [],
  91. allChecked: false,
  92. singleChecked: false,
  93. follow: false,
  94. claim: false,
  95. jobData: [],
  96. entArea: {},
  97. arrs6: [],
  98. listState: {
  99. loaded: false, // 是否已经搜索过
  100. loading: false,
  101. pageNum: 1, // 当前页, 从0开始
  102. pageSize: 10, // 每页多少条数据
  103. total: 0, // 一共多少条数据
  104. listAll: [], // 所有数据
  105. list: [] // 查询请求返回的数据
  106. },
  107. preSearch: {
  108. hover: false,
  109. focus: false,
  110. list: []
  111. },
  112. showMore: true,
  113. industryExp: {
  114. name: '全部行业',
  115. selected: false,
  116. level: 0,
  117. children: [],
  118. id: ''
  119. },
  120. datas: {},
  121. attentionName: [],
  122. claimcheckName: [],
  123. showmoreBtn: true,
  124. industryListMap: [],
  125. getIndustryListMap: [],
  126. industryListMapExp: {
  127. '建筑工程': ['勘察设计', '工程施工', '监理咨询', '材料设备', '机电安装'],
  128. '水利水电': ['水利工程', '发电工程', '航运工程', '其他工程'],
  129. '能源化工': ['原材料', '仪器仪表', '新能源', '设备物资', '化工产品', '设备'],
  130. '弱电安防': ['综合布线', '智能系统', '智能家居'],
  131. '信息技术': ['系统集成及安全', '软件开发', '运维服务', '其他'],
  132. '行政办公': ['办公家具', '通用办公设备', '专业设备', '办公用品', '生活用品'],
  133. '机械设备': ['矿山机械', '工程机械', '机械零部件', '机床相关', '车辆', '其他机械设备'],
  134. '交通工程': ['道路','轨道','桥梁','隧道','其他'],
  135. '医疗卫生': ['设备','耗材','药品'],
  136. '市政设施': ['道路','绿化','线路管网','综合项目'],
  137. '服务采购': ['法律咨询','会计','物业','审计','安保','仓储物流','广告宣传印刷','其他'],
  138. '农林牧渔': ['生产物资','生产设备','相关服务']
  139. },
  140. getInfoTypeList: [],
  141. selectId: [],
  142. selectName: [],
  143. selectIndustry: [],
  144. tempData: [],
  145. buyClassMap: buyclassArr,
  146. buyerPhoneOptions: [
  147. {
  148. label: '不限',
  149. value: 0
  150. },
  151. {
  152. label: '有联系方式',
  153. value: 1
  154. },
  155. // {
  156. // label: '无联系方式',
  157. // value: 2
  158. // }
  159. ],
  160. buyerClassObj: {},
  161. buyerClassArr: [],
  162. buyerPhoneState: 0,
  163. inIframe: false,
  164. isLogin: false,
  165. isMember: false,
  166. isEntService: false,
  167. isNewEntNiche: false,
  168. area: {
  169. province: [],
  170. city: []
  171. },
  172. loadingOther: false
  173. }
  174. },
  175. watch: {
  176. tabActive: function (newVal, oldVal) {
  177. if (newVal === 'zb') {
  178. if (this.searchContent) {
  179. location.href = '/jylab/supsearch/index.html?keywords=' + this.searchContent + '&publishtime=thisyear'
  180. } else {
  181. location.href = '/jylab/supsearch/index.html'
  182. }
  183. } else if (newVal === 'qy') {
  184. if (this.searchContent) {
  185. location.href = '/jylab/entSearch/index.html?keywords=' + this.searchContent
  186. } else {
  187. location.href = '/jylab/entSearch/index.html'
  188. }
  189. } else if (newVal === 'gy') {
  190. if (this.searchContent) {
  191. location.href = '/swordfish/page_web_pc/search/issued?keywords=' + this.searchContent
  192. } else {
  193. location.href = '/swordfish/page_web_pc/search/issued'
  194. }
  195. }
  196. }
  197. },
  198. computed: {
  199. purListShow: function () {
  200. return this.searchContent.trim().length >= 2 && this.preSearch.list.length && (this.preSearch.focus || this.preSearch.hover)
  201. },
  202. getBIParams () {
  203. const urlParams = new URLSearchParams(window.location.search)
  204. return urlParams.get('resource')
  205. },
  206. loginIn () {
  207. return this.isLogin
  208. }
  209. },
  210. created: function () {
  211. var params = goTemplateData.params
  212. this.inIframe = goTemplateData.inIframe
  213. this.isLogin = params.login && Object.keys(params.login).length > 0
  214. this.isMember = params.isMember
  215. this.isEntService = params.isEntService
  216. this.isNewEntNiche = params.isEntnicheNew
  217. // this.initIndustryMap()
  218. // this.qyCustmer()
  219. // this.jobRange()
  220. this.initPageData()
  221. },
  222. mounted: function () {
  223. this.filterEcho()
  224. this.$nextTick(() => {
  225. this.getList()
  226. this.initCollectEvent()
  227. this.initDOMEvents()
  228. ewmMoveHover()
  229. this.$on('updatescope', function(data) {
  230. this.setData.keyList = data
  231. })
  232. })
  233. /**
  234. * 初始化页面搜索框与工作台顶部搜索联动事件函数,详情见对应函数 common.js
  235. * 需要在 dom 初始化后调用来监听事件,Vue中需要额外在 input 对应事件额外手动触发事件
  236. */
  237. // if (goTemplateData.inIframe) {
  238. // this._$SearchEvent = initSearchPageEvent({
  239. // type: 'buyer',
  240. // el: '.search-header-top .input-container',
  241. // submitSelector: '.search-button',
  242. // change: function(val) {
  243. // this.searchContent = val
  244. // }
  245. // })
  246. // }
  247. },
  248. methods: {
  249. goBack () {
  250. var back = function () {
  251. // 判断是否在iframe,如果在iframe,则用父级返回
  252. if (goTemplateData.inIframe) {
  253. window.parent.history.back()
  254. } else {
  255. history.back()
  256. }
  257. }
  258. var goHome = function () {
  259. // 判断是否在iframe,如果在iframe,则用父级返回
  260. if (goTemplateData.inIframe) {
  261. window.parent.location.href = '/'
  262. } else {
  263. window.location.href = '/'
  264. }
  265. }
  266. var referer = document.referer
  267. if(referer) {
  268. var inJianyuWebSite = referer.indexOf('jianyu360.cn') > 0
  269. if (inJianyuWebSite) {
  270. // 本站的,判断是否是新窗口打开的页面
  271. // 1.window.open可以通过判断window.opener
  272. // 2.a target='_black'可以通过判断history.length
  273. var opener = window.opener && window.opener !== window
  274. var target_blank = history.length <= 1
  275. // 是否新窗口打开
  276. var isNewWindow = opener || target_blank
  277. if (isNewWindow) {
  278. try {
  279. window.parent && window.parent.close()
  280. } catch (error) {
  281. window.close()
  282. }
  283. back()
  284. } else {
  285. back()
  286. }
  287. } else {
  288. goHome()
  289. }
  290. } else {
  291. goHome()
  292. }
  293. },
  294. goWorkSpace: function () {
  295. // 不在工作台,添加缓存
  296. if(!this.inIframe) {
  297. let obj = {
  298. buyerName: this.searchContent.trim(),
  299. province: this.area.province,
  300. city: this.area.city,
  301. buyerClass: this.buyerClassArr,
  302. isCheckFollow: this.isLogin ? true : false,
  303. isCheckReceive: this.isLogin ? true : false,
  304. isContact: this.buyerPhoneState,
  305. pageSize: this.listState.pageSize,
  306. pageNum: this.listState.pageNum,
  307. }
  308. obj.buyerClassObj = this.buyerClassObj
  309. sessionStorage.setItem('purParams', JSON.stringify(obj))
  310. }
  311. var goHref = location.origin + '/jylab/purSearch/index.html'
  312. window.location.replace('/page_workDesktop/work-bench/page?link=' + encodeURIComponent(goHref))
  313. },
  314. // 查询收录情况
  315. getEmployData (ids) {
  316. const url = '/jyapi/crmApplication/employ/info'
  317. const params = {
  318. employType: 3,
  319. idArr: ids ? ids.join(',') : ''
  320. }
  321. $.ajax({
  322. url: url,
  323. type: 'POST',
  324. data: JSON.stringify(params),
  325. contentType: 'application/json',
  326. success: function (res) {
  327. if (res.error_code === 0) {
  328. this.employInfo = res.data
  329. res.data.forEach((r) => {
  330. this.listState.list.forEach(m => {
  331. if(m.buyer === r.id) {
  332. m.active = r.isEmploy ? 1 : 0
  333. }
  334. })
  335. })
  336. this.$forceUpdate()
  337. }
  338. }.bind(this)
  339. })
  340. },
  341. // 收录操作
  342. setEmployEvent (item) {
  343. const url = '/jyapi/crmApplication/employ/operate'
  344. const params = {
  345. idArr: item.buyer,
  346. isEmploy: !item.active,
  347. employType: 3
  348. }
  349. $.ajax({
  350. url: url,
  351. type: 'POST',
  352. data: JSON.stringify(params),
  353. contentType: 'application/json',
  354. success: function (res) {
  355. if(res.error_code === 0) {
  356. if (res.data.status) {
  357. item.active = !item.active ? 1 : 0
  358. } else {
  359. toastFn(res.data.msg, 1000)
  360. }
  361. }
  362. this.$forceUpdate()
  363. }.bind(this),
  364. complete: function () {
  365. }.bind(this)
  366. })
  367. },
  368. randomBgc: function () {
  369. var arr = ['default', 'blue', 'orange', 'green']
  370. var randomIndex = utils.getRandomNumber(0, arr.length - 1)
  371. return 'bgc-' + arr[randomIndex]
  372. },
  373. getShortName: function (comName) {
  374. var areaMap = chinaMapJSON || []
  375. var shortname = comName
  376. // 1. 循环省份城市进行替换
  377. areaMap.forEach(function (item) {
  378. var p = item.name.replace(/[省市]/, '')
  379. if (shortname.indexOf(p) !== -1) {
  380. shortname = shortname.replace(item.name, '').replace(p, '')
  381. }
  382. item.city.forEach(function (iitem) {
  383. var c = iitem.name.replace(/[省市]/, '')
  384. if (shortname.indexOf(c) !== -1) {
  385. shortname = shortname.replace(iitem.name, '').replace(c, '')
  386. }
  387. iitem.area.forEach(function (iiitem) {
  388. if (shortname.indexOf(iiitem) !== -1) {
  389. shortname = shortname.replace(iiitem, '')
  390. }
  391. })
  392. })
  393. })
  394. var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm)
  395. var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4)
  396. if (shortname.length < 4) {
  397. shortname = shortname.slice(0, 4)
  398. }
  399. return shortname
  400. },
  401. buyerClassFilterChange: function (buyerclass) {
  402. var buyerclassArr = []
  403. this.buyerClassObj = buyerclass
  404. for (var key in buyerclass) {
  405. buyerclassArr = buyerclassArr.concat(buyerclass[key])
  406. }
  407. this.buyerClassArr = buyerclassArr
  408. this.doSearch()
  409. },
  410. otherFilterChange: function () {
  411. this.doSearch()
  412. },
  413. updatescope: function(data) {
  414. // console.log(data)
  415. },
  416. initPageData: function () {
  417. if (pageInfo.searchContent) {
  418. this.searchContent = pageInfo.searchContent
  419. console.info(this.searchContent)
  420. }
  421. },
  422. onFocusSearch: function () {
  423. this.preSearch.focus=true
  424. this.preSearch.list = []
  425. this.getPreSearchList()
  426. },
  427. // 采购单位模糊搜索
  428. getPreSearchList: utils.debounce(function () {
  429. /**
  430. * 初始化页面搜索框与工作台顶部搜索联动事件函数,详情见对应函数 common.js
  431. * 需要在 dom 初始化后调用来监听事件,Vue中需要额外在 input 对应事件额外手动触发事件
  432. */
  433. if (this._$SearchEvent) {
  434. this._$SearchEvent.syncInput()
  435. }
  436. var data = {
  437. name: this.searchContent.trim()
  438. }
  439. if (data.name.length < 2) return
  440. $.ajax({
  441. url: this.isNewEntNiche ? '/entnicheNew/customer/buyer/association' : '/bigmember/search/buyer/association',
  442. method: 'POST',
  443. data: data,
  444. success: function (res) {
  445. if (res.error_code === 0) {
  446. if (res.data) {
  447. if (this.isNewEntNiche) {
  448. this.preSearch.list = res.data.list || []
  449. } else {
  450. // 非商机管理用户(大会员接口)
  451. var names = []
  452. res.data.list.forEach(function(item){
  453. names.push({
  454. name: item
  455. })
  456. })
  457. this.preSearch.list = names
  458. }
  459. }
  460. } else {
  461. // this.checkLogin()
  462. }
  463. }.bind(this)
  464. })
  465. }, 200),
  466. goSearch: function(name) {
  467. this.searchContent = name
  468. this.preSearch.hover = false
  469. this.listState.pageNum = 1
  470. this.entArea = {}
  471. this.indusList = []
  472. this.indusList1 = []
  473. this.industryExp = []
  474. this.qyCheck = []
  475. this.doSearch()
  476. },
  477. checkLogin: function () {
  478. var moduleOpen = $('body').hasClass('modal-open')
  479. if (moduleOpen) return
  480. if (!loginflag) {
  481. $("#bidLogin").modal("show");
  482. }
  483. },
  484. yeFan: function() {
  485. if (goTemplateData.inIframe) {
  486. window.$BRACE.methods.open({
  487. route: {
  488. link: '/jylab/purScopebusniess/index.html'
  489. }
  490. })
  491. } else {
  492. window.location.href="/jylab/purScopebusniess/index.html"
  493. }
  494. },
  495. // 整理数据列表
  496. initIndustryMap: function () {
  497. var industryListMap = []
  498. // 全部
  499. var all = JSON.parse(JSON.stringify(this.industryExp))
  500. all.selected = true
  501. all.id = 'lv0-' + getRandomString(8).toLowerCase()
  502. industryListMap.push(all)
  503. for (var key in this.industryListMapExp) {
  504. var level1 = JSON.parse(JSON.stringify(this.industryExp))
  505. level1.name = key
  506. level1.level = 1
  507. level1.id = 'lv1-' + getRandomString(8).toLowerCase()
  508. var level2Arr = []
  509. this.industryListMapExp[key].forEach(function(item) {
  510. var level2 = JSON.parse(JSON.stringify(this.industryExp))
  511. level2.name = item
  512. level2.level = 2
  513. level2.id = 'lv2-' + getRandomString(8).toLowerCase()
  514. level2Arr.push(level2)
  515. })
  516. level1.children = level2Arr
  517. industryListMap.push(level1)
  518. }
  519. this.industryListMap = industryListMap
  520. var tempArr = []
  521. this.industryListMap.forEach(function(v) {
  522. var tempNode = v
  523. tempNode.zindex = 1
  524. tempArr.push(tempNode)
  525. if (tempNode.children) {
  526. tempNode.children.forEach(function(s) {
  527. var tempS = s
  528. tempS.zindex = 2
  529. tempArr.push(tempS)
  530. })
  531. }
  532. })
  533. this.getIndustryListMap = tempArr
  534. },
  535. // 按钮点击事件
  536. changeIndustryState: function (item) {
  537. // 循环所有数据,判断并改变状态
  538. switch (item.level) {
  539. case 0: {
  540. this.setIndustryState()
  541. break
  542. }
  543. case 1: {
  544. item.selected = !item.selected
  545. this.industryListMap[0].selected = false
  546. // 二级子按钮状态跟随一级按钮
  547. item.children.forEach(function(level2) {
  548. level2.selected = item.selected
  549. })
  550. break
  551. }
  552. case 2: {
  553. item.selected = !item.selected
  554. // 找到当前点击的父级元素
  555. this.industryListMap.forEach(function(level1) {
  556. var selectedStateArr = []
  557. if (item.level !== 0) {
  558. level1.children.forEach(function(level2) {
  559. selectedStateArr.push(level2.selected)
  560. })
  561. if (selectedStateArr.indexOf(false) === -1) {
  562. level1.selected = true
  563. } else {
  564. level1.selected = false
  565. }
  566. }
  567. })
  568. this.industryListMap[0].selected = false
  569. break
  570. }
  571. default: {
  572. console.log('未知level')
  573. }
  574. }
  575. if (item.level !== 0) {
  576. var allSelected = this.checkAllSelectedState()
  577. if (allSelected.allSelected || allSelected.allNotSelected) {
  578. this.setIndustryState()
  579. }
  580. }
  581. if (this.selectorType === 'line') {
  582. this.onChange()
  583. }
  584. // this.searchContent = ''
  585. this.doSearch()
  586. },
  587. // 检查是否全部选中了/全部不选中
  588. checkAllSelectedState: function () {
  589. // 一级标签选中状态(如果一级标签全部被选中,则说明,全部按钮被选中)
  590. var level1StateArr = []
  591. // 所有标签选中状态
  592. var allSelectedArr = []
  593. this.industryListMap.forEach(function(level1) {
  594. if (level1.level !== 0) {
  595. level1StateArr.push(level1.selected)
  596. allSelectedArr.push(level1.selected)
  597. level1.children.forEach(function(level2) {
  598. allSelectedArr.push(level2.selected)
  599. })
  600. }
  601. })
  602. return {
  603. // 找不到false,就说明全部被选中
  604. allSelected: level1StateArr.indexOf(false) === -1,
  605. // 找不到true,就说明没有一个被选中
  606. allNotSelected: allSelectedArr.indexOf(true) === -1
  607. }
  608. },
  609. /**
  610. * 初始化页面选中状态
  611. * @param { Array | undefined } data 要恢复的数据
  612. */
  613. setIndustryState: function (data) {
  614. // 设置全部按钮
  615. if (!data || Object.keys(data).length === 0) {
  616. // 其他全部设置不选中,全部按钮设置选中
  617. this.industryListMap.forEach(function(item) {
  618. item.selected = false
  619. item.children.forEach(function(iitem) {
  620. iitem.selected = false
  621. })
  622. })
  623. this.industryListMap[0].selected = true
  624. } else {
  625. this.setIndustryState()
  626. this.industryListMap[0].selected = false
  627. this.industryListMap.forEach(function(item) {
  628. if (data[item.name]) {
  629. // 如果恢复数组长度等于页面二级标签长度,则一级标签点亮
  630. if (data[item.name].length === item.children.length) {
  631. item.selected = true
  632. }
  633. item.children.forEach(function (iitem) {
  634. if (data[item.name].indexOf(iitem.name) !== -1) {
  635. iitem.selected = true
  636. }
  637. })
  638. }
  639. })
  640. }
  641. },
  642. // 获取选中的数据
  643. getSelected: function () {
  644. var map = {}
  645. this.industryListMap.forEach(function(item) {
  646. var mapArr = []
  647. if (item.level !== 0) {
  648. item.children.forEach(function(iitem) {
  649. if (iitem.selected) {
  650. mapArr.push(iitem.name)
  651. }
  652. })
  653. }
  654. if (mapArr.length !== 0) {
  655. map[item.name] = mapArr
  656. }
  657. })
  658. var tempArr = []
  659. Object.keys(map).forEach(function(v) {
  660. var tempItem = map[v]
  661. if (Array.isArray(tempItem)) {
  662. tempItem.forEach(function(vv) {
  663. tempArr.push(v + '_' + vv)
  664. })
  665. }
  666. })
  667. return tempArr
  668. },
  669. dataChange: function(val) {
  670. this.tempData = val
  671. this.doSearch()
  672. },
  673. doSearch: function () {
  674. $('.tags-box').hide()
  675. this.listState.pageNum = 1
  676. this.getList()
  677. try {
  678. var val = this.searchContent
  679. var baseDesc = '剑鱼标讯是国内专业的招标采购单位信息查询平台,为您提供包括采购单位信息、招标单位信息、采购人信息、招标人信息、业主单位信息的检索查询服务,查看更多招标采购单位详细信息就用剑鱼标讯!'
  680. var _title = val ? val + '相关搜索结果 - 剑鱼标讯' : '采购单位查询_采购单位信息_招标采购单位大全 - 剑鱼标讯'
  681. var _keywords = val ? val +',' + val + '招标,' + val + '采购,剑鱼标讯' : '采购单位,采购人信息,招标单位,招标人信息,业主单位,剑鱼标讯'
  682. var _desc = val ? '剑鱼标讯是国内专业的招标采购单位信息查询平台,为您提供' + val +'相关的采购单位信息详情,帮助您全面了解采购单位最新动态,获取更多' + val + '相关搜索结果就上剑鱼标讯!' : baseDesc
  683. seoTdkUpdate(_title, _keywords, _desc)
  684. } catch (error) {}
  685. },
  686. filterEcho: function (val) {
  687. let purParams = sessionStorage.getItem('purParams')
  688. if(purParams) {
  689. purParams = JSON.parse(purParams)
  690. this.searchContent = purParams.buyerName.trim()
  691. this.area.province = purParams.province
  692. this.area.city = purParams.city
  693. this.$refs.areaCityFilter.setStateData(this.area)
  694. this.buyerClassArr = purParams.buyerClass
  695. this.isLogin = purParams.isCheckFollow
  696. this.buyerPhoneState = purParams.isContact
  697. this.listState.pageSize = purParams.pageSize
  698. this.listState.pageNum = purParams.pageNum
  699. this.buyerClassObj = purParams.buyerClassObj
  700. sessionStorage.removeItem('purParams')
  701. }
  702. },
  703. getList: function () {
  704. let obj = {
  705. buyerName: this.searchContent.trim(),
  706. province: this.area.province,
  707. city: this.area.city,
  708. buyerClass: this.buyerClassArr,
  709. isCheckFollow: this.isLogin ? true : false,
  710. isCheckReceive: this.isLogin ? true : false,
  711. isContact: this.buyerPhoneState,
  712. pageSize: this.listState.pageSize,
  713. pageNum: this.listState.pageNum,
  714. }
  715. this.listState.loading = true
  716. this.listState.loaded = false
  717. var _this = this
  718. $.ajax({
  719. // /jybx/buyer/:userType/buyerList
  720. // fType:免费用户 pType:付费用户 vType:超级订阅用户 mType:大会员用户 eType:商机管理用户
  721. // userType传哪个都一样
  722. url: '/jyapi/jybx/buyer/eType/buyerList',
  723. method: 'POST',
  724. data: JSON.stringify(obj),
  725. contentType:'application/json;charset=utf-8',
  726. success: function (res) {
  727. if (res.error_code === 0 && $.isArray(res.data.list)) {
  728. this.listState.total = res.data.count
  729. var buyerNameArr = []
  730. res.data.list.forEach(function(v) {
  731. buyerNameArr.push(v.buyer)
  732. v.buyerShortName = _this.getShortName(v.buyer)
  733. v.randomBgc = _this.randomBgc()
  734. // 所在地区异常数据处理
  735. var same = v.province === v.city // 省份和城市相同
  736. var pBc = v.province && v.city && v.province.indexOf(v.city) > -1 // 省份包含城市
  737. var cBp = v.province && v.city && v.city.indexOf(v.province) > -1 // 城市包含了省份
  738. if (same || pBc || cBp) {
  739. v.city = ''
  740. }
  741. v.biddingCount = v.biddingCount ? v.biddingCount + '条' : ''
  742. v.contactCount = v.contactCount ? v.contactCount + '个' : ''
  743. v.projectCount = v.projectCount ? v.projectCount + '个' : ''
  744. })
  745. this.listState.list = res.data.list
  746. const resultIds = res.data.list.map(v => v.buyer)
  747. this.getEmployData(resultIds)
  748. this.listState.loading = false
  749. // this.getBuyerOtherInfo(buyerNameArr)
  750. } else {
  751. if (res.error_msg) {
  752. toastFn(res.error_msg, 2000)
  753. }
  754. this.listState.list = []
  755. }
  756. this.listState.loaded = true
  757. }.bind(this),
  758. complete: function () {
  759. this.listState.loading = false
  760. this.listState.loaded = true
  761. }.bind(this)
  762. })
  763. },
  764. getBuyerOtherInfo: function (arr) {
  765. if (!arr || arr.length === 0) return
  766. var params = {
  767. buyer: arr
  768. }
  769. this.loadingOther = true
  770. var _this = this
  771. $.ajax({
  772. url: '/jyapi/jybx/buyer/supply/info',
  773. method: 'POST',
  774. data: JSON.stringify(params),
  775. contentType:'application/json;charset=utf-8',
  776. success: function (res) {
  777. if (res.error_code === 0 && $.isArray(res.data)) {
  778. res.data.forEach(function(r) {
  779. _this.listState.list.forEach(function(v) {
  780. if (r.buyer === v.buyer) {
  781. v.biddingCount = r.biddingCount ? r.biddingCount + '条' : ''
  782. v.contactCount = r.contactCount ? r.contactCount + '个' : ''
  783. v.projectCount = r.projectCount ? r.projectCount + '个' : ''
  784. v.bidAmountCount = r.bidAmountCount
  785. }
  786. })
  787. })
  788. }
  789. _this.loadingOther = false
  790. },
  791. complete: function () {
  792. _this.loadingOther = false
  793. }
  794. })
  795. },
  796. onSizeChange: function (val) {
  797. this.listState.pageSize = val
  798. this.listState.pageNum = 1
  799. this.onPageChange(this.listState.pageNum)
  800. },
  801. onPageChange: function (p) {
  802. $('.tags-box').hide()
  803. this.listState.pageNum = p
  804. this.listState.loading = true
  805. var oTop = this.$refs.listContainer.offsetTop - 64 - 16 || 0
  806. // 翻页后页面滚动到列表第一条数据的位置
  807. document.documentElement.scrollTop = oTop; //ie下
  808. document.body.scrollTop = oTop
  809. this.getList()
  810. },
  811. goTitle: function(item) {
  812. var name = item.buyer
  813. var seoId = item.seo_id
  814. // 是渠道合作页面需要登录后重定向
  815. const BIPge = this.getBIParams ? '?resource=BI' : ''
  816. var seoUrl = '/dw/' + seoId + '.html' + BIPge
  817. var url = '/swordfish/page_big_pc/unit_portrayal/' + name
  818. if (this.isNewEntNiche) {
  819. url = '/entpc/unit_portrayal/' + name + BIPge
  820. } else {
  821. url = '/swordfish/page_big_pc/unit_portrayal/' + name + BIPge
  822. }
  823. if(cooperateCode) {
  824. openLoginDig(null, url)
  825. return
  826. }
  827. url = seoUrl
  828. window.open(url)
  829. },
  830. // 全选
  831. allChange: function() {
  832. var str1 = $('.check-all').prop('checked')
  833. var str2 = $('.custom-checkbox:not(".check-all")')
  834. var arr = $('.custom-checkbox:not(".check-all"):checked')
  835. let arrs1 = [], arrs2 = [], arrs3= []
  836. if (str1) {
  837. str2.prop('checked', true)
  838. this.listState.list.forEach(function(v) {
  839. arrs1.push(v.Buyer)
  840. arrs2.push(v.Buyerclass)
  841. arrs3.push(v.customerId)
  842. })
  843. selectDataIds = this.unique(selectDataIds.concat(arrs1))
  844. } else {
  845. $('.custom-checkbox:not(".check-all"):checked').each(function(){
  846. var dataName = $(this).attr('dataname')
  847. selectDataIds.forEach(function(item) {
  848. if(dataName == item) {
  849. selectDataIds.remove(item)
  850. }
  851. })
  852. })
  853. str2.prop('checked', false)
  854. arrs1 = []
  855. }
  856. this.selectName = selectDataIds
  857. this.selectIndustry = arrs2
  858. this.selectId = arrs3
  859. },
  860. // 单选
  861. singleChange: function () {
  862. let arr1 = [], arr2 = [], arr3 = []
  863. $('.custom-checkbox:not(".check-all"):checked').each(function(){
  864. if ($(this).attr('dataname')) {
  865. arr1.push($(this).attr('dataname'))
  866. arr2.push($(this).attr('dataindustry'))
  867. arr3.push($(this).attr('dataid'))
  868. }
  869. })
  870. selectDataIds = this.unique(selectDataIds.concat(arr1))
  871. $('.custom-checkbox:not(".check-all")').each(function(){
  872. if (!$(this).prop('checked')) {
  873. selectDataIds.remove($(this).attr('dataname'))
  874. }
  875. })
  876. if (arr1.length == this.listState.list.length) {
  877. $('.check-all').prop('checked', true)
  878. } else {
  879. $('.check-all').prop('checked', false)
  880. }
  881. this.selectName = selectDataIds
  882. this.selectIndustry = arr2
  883. this.selectId = arr3
  884. // console.info(this.attentionName, this.claimcheckName)
  885. var tempArray1 = this.arrDefault(this.selectName, this.attentionName)
  886. var tempArray2 = this.arrDefault(this.selectName, this.claimcheckName)
  887. if (tempArray1.length == 0) {
  888. this.follow = true
  889. if (this.selectName.length == 0) {
  890. this.follow = false
  891. }
  892. } else {
  893. this.follow = false
  894. }
  895. if (tempArray2.length == 0) {
  896. this.claim = true
  897. if (this.selectName.length == 0) {
  898. this.claim = false
  899. }
  900. } else {
  901. this.claim = false
  902. }
  903. },
  904. // 数组去重
  905. unique: function(arr) {
  906. var res = new Map()
  907. // return arr.filter((arr) => !res.has(arr) && res.set(arr, 1));
  908. return arr.filter(function (arr) {
  909. return !res.has(arr) && res.set(arr, 1)
  910. })
  911. },
  912. // 是否关注企业
  913. attentionCheck: function(arrs, item) {
  914. var _this = this
  915. $.ajax({
  916. url: '/entnicheNew/customer/check',
  917. method: 'POST',
  918. data: JSON.stringify({names: item}),
  919. contentType:'application/json;charset=utf-8',
  920. success: function (res) {
  921. if (res.data.names) {
  922. this.attentionName = res.data.names
  923. }
  924. arrs.forEach(function(v) {
  925. if (res.data.names.indexOf(v.Buyer) > -1) {
  926. v.isFollowed = true
  927. } else {
  928. v.isFollowed = false
  929. }
  930. })
  931. _this.claimcheck(arrs, item)
  932. }.bind(this)
  933. })
  934. },
  935. // 是否认领企业
  936. claimcheck: function(arrs, item) {
  937. $.ajax({
  938. url: '/entnicheNew/customer/claimcheck',
  939. method: 'POST',
  940. data: JSON.stringify({names: item}),
  941. contentType:'application/json;charset=utf-8',
  942. success: function (res) {
  943. if (res.data.names) {
  944. this.claimcheckName = []
  945. res.data.names.forEach(function(s) {
  946. this.claimcheckName.push(s.split(',')[0])
  947. })
  948. }
  949. arrs.forEach(function(v) {
  950. let renName = res.data.names.join(',')
  951. res.data.names.forEach(function(s) {
  952. if (renName.indexOf(v.Buyer) > -1) {
  953. v.claim1 = true
  954. if (s.split(',')[0] == v.Buyer) {
  955. v.customerId = s.split(',')[1]
  956. }
  957. } else {
  958. v.claim1 = false
  959. }
  960. })
  961. })
  962. this.listState.list = arrs
  963. this.listState.loading = false
  964. this.$nextTick(function() {
  965. var checkNum = 0
  966. var inputs = $('.custom-checkbox:not(".check-all")')
  967. $('.check-all').prop('checked', false)
  968. $('.custom-checkbox:not(".check-all")').each(function(){
  969. $(this).prop('checked', false)
  970. var that = this
  971. var dataName = $(this).attr('dataname')
  972. selectDataIds.forEach(function(item) {
  973. if(dataName == item) {
  974. checkNum++
  975. $(that).prop('checked', true)
  976. }
  977. })
  978. })
  979. if(checkNum == arrs.length) {
  980. $('.check-all').prop('checked', true)
  981. } else {
  982. $('.check-all').prop('checked', false)
  983. }
  984. })
  985. }.bind(this)
  986. })
  987. },
  988. // 关注、认领接口
  989. attention: function(item, type, str, per) {
  990. let obj = {}, _this = this
  991. if (type == 0) {
  992. // 商机管理的关注
  993. if (_this.isNewEntNiche) {
  994. obj = {
  995. name: per ? item : item.buyer,
  996. province: per ? '' : item.province,
  997. city: per ? '' : item.city,
  998. mold: type,
  999. B: per ? str : item.isFollowed,
  1000. }
  1001. } else {
  1002. // 大会员的关注
  1003. obj = {
  1004. name: per ? item : item.buyer,
  1005. province: per ? '' : item.province,
  1006. city: per ? '' : item.city,
  1007. b: Boolean(item.isFollowed),
  1008. }
  1009. }
  1010. } else {
  1011. obj = {
  1012. name: per ? item : item.recId,
  1013. province: per ? '' : item.province,
  1014. city: per ? '' : item.city,
  1015. mold: type,
  1016. D: per ? str : item.isReceived,
  1017. }
  1018. }
  1019. var url = '/entnicheNew/customer/attention'
  1020. if (type === 0 && _this.isMember) {
  1021. url = '/publicapply/customer/attention'
  1022. }
  1023. // console.info(obj)
  1024. $.ajax({
  1025. url: url,
  1026. method: 'POST',
  1027. data: JSON.stringify(obj),
  1028. contentType:'application/json;charset=utf-8',
  1029. success: function (res) {
  1030. if (res.error_code === 0) {
  1031. if (res.data == false) {
  1032. if (res.error_msg) {
  1033. toastFn(res.error_msg, 2000)
  1034. } else {
  1035. if (type == 0) {
  1036. if (str || item.isFollowed) {
  1037. toastFn('取消关注失败!', 2000)
  1038. } else {
  1039. toastFn('关注失败!', 2000)
  1040. }
  1041. } else {
  1042. toastFn('取消认领失败!', 2000)
  1043. }
  1044. }
  1045. } else {
  1046. if (type == 0) {
  1047. if (str || item.isFollowed) {
  1048. toastFn('取消关注成功!', 2000)
  1049. } else {
  1050. toastFn('关注成功!', 2000)
  1051. }
  1052. } else {
  1053. toastFn('取消认领成功!', 2000)
  1054. }
  1055. // this.follow = false
  1056. // this.claim = false
  1057. // $('.custom-checkbox').prop('checked', false)
  1058. // _this.selectName = selectDataIds
  1059. _this.getList(_this.listState.pageNum)
  1060. }
  1061. } else {
  1062. toastFn(res.error_msg, 2000)
  1063. }
  1064. }.bind(this)
  1065. })
  1066. },
  1067. arrDefault: function(array1, array2) {//比较的两个数组
  1068. var tempArray1 = []
  1069. var tempArray2 = []
  1070. for(var i=0;i<array2.length;i++){
  1071. if (!tempArray1.hasOwnProperty(array1[i])) {
  1072. tempArray1[array2[i]]=true;
  1073. }
  1074. }
  1075. for(var i=0;i<array1.length;i++){
  1076. if(!tempArray1[array1[i]]){
  1077. tempArray2.push(array1[i])
  1078. }
  1079. }
  1080. return tempArray2
  1081. },
  1082. allGuanren: function (type) {
  1083. if (this.selectName.length == 0) {
  1084. toastFn('至少选择一项', 1500)
  1085. } else {
  1086. var tempArray1 = this.arrDefault(this.selectName, this.attentionName)
  1087. var tempArray2 = this.arrDefault(this.selectName, this.claimcheckName)
  1088. if (type == 0) {
  1089. if (tempArray1.length == 0) {// 批量取关
  1090. this.follow = true
  1091. this.attention(String(this.selectName), type, true, 'pi')
  1092. } else if (tempArray1.length == this.selectName.length) {// 批量关注
  1093. this.follow = false
  1094. this.attention(String(this.selectName), type, false, 'pi')
  1095. } else {
  1096. toastFn('关注和取消关注不能同时进行!', 2000)
  1097. }
  1098. } else {
  1099. if (tempArray2.length == 0) {// 批量取认领
  1100. // this.claim = true
  1101. this.attention(String(this.selectId), type, true, 'pi')
  1102. } else if (tempArray2.length == this.selectName.length) {// 批量认领
  1103. this.claim = false
  1104. var top = index + 1 + 'px'
  1105. this.datas = {
  1106. name: String(this.selectName),
  1107. industry: ''
  1108. }
  1109. $('.tags-box').slideToggle(function () {
  1110. window.activeTags = []
  1111. $('.tag-labels').empty()
  1112. $('.clear-input').val('')
  1113. $('.tags-list').find('.tags-item').removeClass('tags-active')
  1114. $('.tag-placeholder').show()
  1115. }).css({
  1116. top: top,
  1117. right: 0
  1118. })
  1119. // this.attention(String(this.selectName), type, false, 'pi')
  1120. } else {
  1121. toastFn('认领和取消认领不能同时进行!', 2000)
  1122. }
  1123. }
  1124. }
  1125. },
  1126. guanAndren: function(item, type, index) {
  1127. if (type == 1) {
  1128. if (!item.isReceived) {
  1129. // 根据列表高度计算top值
  1130. var top = 95 * (index + 1) + 'px'
  1131. this.datas = {
  1132. name: item.buyer,
  1133. industry: item.buyerClass
  1134. }
  1135. $('.tags-box').slideToggle(function () {
  1136. window.activeTags = []
  1137. $('.tag-labels').empty()
  1138. $('.clear-input').val('')
  1139. $('.tags-list').find('.tags-item').removeClass('tags-active')
  1140. $('.tag-placeholder').show()
  1141. }).css({
  1142. top: top,
  1143. right: 0
  1144. })
  1145. } else {
  1146. this.attention(item, type, '')
  1147. }
  1148. } else {
  1149. this.attention(item, type, '')
  1150. }
  1151. },
  1152. caiIndus: function(val, index) {
  1153. let arrIndex = this.caiIndex.indexOf(index);
  1154. if(arrIndex>-1){
  1155. this.caiIndex.splice(arrIndex,1);
  1156. this.indusList.splice(arrIndex,1);
  1157. }else{
  1158. this.caiIndex.push(index);
  1159. this.indusList.push(val);
  1160. }
  1161. if (this.caiIndex.length < this.indusData.length) {
  1162. this.qutive = false;
  1163. }
  1164. if (this.indusList.length == 0) {
  1165. this.qutive = true;
  1166. }
  1167. if (this.caiIndex.length == this.indusData.length) {
  1168. this.qutive = true;
  1169. this.caiIndex = ["-2"];
  1170. }
  1171. // this.searchContent = ''
  1172. this.doSearch()
  1173. },
  1174. quanBu: function() {
  1175. this.caiIndex = [];
  1176. this.qutive = true;
  1177. this.indusList = [];
  1178. this.doSearch()
  1179. },
  1180. caiIndus1: function(val, index) {
  1181. let arrIndex = this.caiIndex1.indexOf(index);
  1182. if(arrIndex>-1){
  1183. this.caiIndex1.splice(arrIndex,1);
  1184. this.indusList1.splice(arrIndex,1);
  1185. }else{
  1186. this.caiIndex1.push(index);
  1187. this.indusList1 = this.indusList1.concat(val);
  1188. }
  1189. if (this.caiIndex1.length < this.jobData.length) {
  1190. this.qutive1 = false;
  1191. }
  1192. if (this.indusList1.length == 0) {
  1193. this.qutive1 = true;
  1194. }
  1195. if (this.caiIndex1.length == this.jobData.length) {
  1196. this.qutive1 = true;
  1197. this.caiIndex1 = ["-2"];
  1198. }
  1199. // this.searchContent = ''
  1200. this.doSearch()
  1201. },
  1202. quanBu1: function() {
  1203. this.caiIndex1 = [];
  1204. this.qutive1 = true;
  1205. this.indusList1 = [];
  1206. this.doSearch()
  1207. },
  1208. cusMore: function() {
  1209. console.log('1212')
  1210. },
  1211. qyCustmer: function() {
  1212. $.ajax({
  1213. url: '/entnicheNew/customer/history',
  1214. method: 'GET',
  1215. success: function (res) {
  1216. if (res.error_code == 0 && $.isArray(res.data.list)) {
  1217. this.qyData = res.data.list
  1218. }
  1219. }.bind(this)
  1220. })
  1221. },
  1222. qyChange: function() {
  1223. // this.searchContent = ''
  1224. this.doSearch()
  1225. },
  1226. jobRange: function() {
  1227. var decide = window.localStorage.getItem('bus-key-group-SCOPE')
  1228. if (decide) {
  1229. this.jobData = JSON.parse(decide)
  1230. } else {
  1231. $.ajax({
  1232. url: '/entnicheNew/subscribe/key/get',
  1233. method: 'POST',
  1234. success: function (res) {
  1235. if ($.isArray(res.data.data) && res.error_code == 0) {
  1236. res.data.data.forEach(function(v) {
  1237. v.a_key.forEach(function(t) {
  1238. this.jobData.push(t)
  1239. })
  1240. })
  1241. }
  1242. }.bind(this)
  1243. })
  1244. }
  1245. },
  1246. keyChange: function(appendkey, key, notkey) {
  1247. let str = String(appendkey.concat(key).concat(notkey)).replace(/,/g, ' ')
  1248. return str
  1249. },
  1250. initDOMEvents: function () {
  1251. setTimeout(function () {
  1252. // tabHover()
  1253. }, 300)
  1254. },
  1255. areaCityChange: function (area) {
  1256. var city = []
  1257. var province = []
  1258. for (var key in area) {
  1259. if (area[key].length === 0) {
  1260. province.push(key)
  1261. } else {
  1262. city = city.concat(area[key])
  1263. }
  1264. }
  1265. this.area.province = province
  1266. this.area.city = city
  1267. this.doSearch()
  1268. },
  1269. isFilterShow: function () {
  1270. if (this.filterShow) {
  1271. $('.search-filters').slideUp()
  1272. } else {
  1273. $('.search-filters').slideDown()
  1274. }
  1275. this.filterShow = !this.filterShow
  1276. },
  1277. moneyUnit: function (m, type, lv) {
  1278. if (!type) {
  1279. type = 'string'
  1280. }
  1281. if (!lv) {
  1282. lv = 0
  1283. }
  1284. var mUnit = {
  1285. levelArr: ['元', '万元', '亿元', '万亿元'],
  1286. test: function (num, type, lv) {
  1287. if (num === 0) {
  1288. if (type === 'string') {
  1289. return '0元'
  1290. }
  1291. if (type === 'lv') {
  1292. return this.levelArr[lv]
  1293. }
  1294. if (type === 'number') {
  1295. return 0
  1296. }
  1297. if (type === 'index') {
  1298. return lv
  1299. }
  1300. }
  1301. var result = num / Math.pow(10000, lv)
  1302. if (result > 10000 && lv < 2) {
  1303. return this.test(num, type, lv + 1)
  1304. } else {
  1305. if (type === 'string') {
  1306. return String(Math.floor(result * 100) / 100).replace('.00', '') + this.levelArr[lv]
  1307. }
  1308. if (type === 'lv') {
  1309. return this.levelArr[lv]
  1310. }
  1311. if (type === 'number') {
  1312. return String(Math.floor(result * 100) / 100).replace('.00', '')
  1313. }
  1314. if (type === 'index') {
  1315. return lv
  1316. }
  1317. }
  1318. }
  1319. }
  1320. if (m === undefined || m === null) {
  1321. return ''
  1322. } else {
  1323. return mUnit.test(m, type, lv)
  1324. }
  1325. },
  1326. initCollectEvent: function () {
  1327. var _this = this
  1328. // 自定义标签
  1329. // 标签输入框事件
  1330. $('.tags-box').click(function (e) {
  1331. e.stopPropagation()
  1332. })
  1333. $('.tag-input').click(function (e) {
  1334. e.stopPropagation()
  1335. $(this).children('.tag-placeholder').hide()
  1336. $(this).children('input').focus()
  1337. })
  1338. // 标签输入框回车事件
  1339. $('.tag-input .clear-input').keydown(function (event) {
  1340. event.stopPropagation()
  1341. if (event.keyCode == 13) {
  1342. if (!$('.tags-box').is(':hidden')) {
  1343. $('.tags-inputs .add-tag-button').trigger('click')
  1344. }
  1345. }
  1346. })
  1347. // 标签输入框失去焦点事件
  1348. $('.tag-input .clear-input').blur(function () {
  1349. if ($('.tag-labels').children().length == 0 && $(this).val() == '') {
  1350. $('.tag-placeholder').show()
  1351. }
  1352. })
  1353. // 添加标签按钮事件
  1354. $('.tags-inputs .add-tag-button').on('click', function () {
  1355. var input = $('.tag-input .clear-input')
  1356. if (input.val().length >= 2 && input.val().length < 6) {
  1357. // ajax提交自定义标签
  1358. addTagsAjax(input.val())
  1359. }
  1360. })
  1361. // 点击确定按钮,绑定标签
  1362. $('.tags-footer .button-confirm').on('click', function () {
  1363. if (!$('.tags-box').is(':hidden')) {
  1364. var lids = ''
  1365. var lname = ''
  1366. $('.tags-item.tags-active').each(function () {
  1367. if ($(this).attr('data-id')) {
  1368. if (lids != '') {
  1369. lids += ','
  1370. }
  1371. if (lname != '') {
  1372. lname += ','
  1373. }
  1374. lids += $(this).attr('data-id')
  1375. lname += $(this).text()
  1376. }
  1377. })
  1378. var params = {
  1379. name: _this.datas.name,
  1380. mold: 1,
  1381. D: false,
  1382. label: lids,
  1383. industry: _this.datas.industry
  1384. }
  1385. // 执行保存绑定标签操作
  1386. // if (params.label !== '') {
  1387. saveChooseTags(params, function () {
  1388. $('.tags-footer .button-cancel').trigger('click')
  1389. })
  1390. // }
  1391. }
  1392. })
  1393. $('.tags-footer .button-cancel').on('click', function () {
  1394. $('.tags-box').slideToggle(function () {
  1395. // 标签弹框消失时 清除上次选择的标签分类
  1396. activeTags = []
  1397. $('.tag-labels').empty()
  1398. $('.clear-input').val('')
  1399. $('.tags-list').find('.tags-item').removeClass('tags-active')
  1400. $('.tags-list').find('.disabled').removeClass('disabled')
  1401. $('.tag-placeholder').show()
  1402. })
  1403. })
  1404. window.activeTags = [] // 选中的自定义标签 作为全局变量使用
  1405. // 解绑自定义标签
  1406. function deleteInputTag (item) {
  1407. var index = $(item).parent().attr('data-index')
  1408. var id = $(item).parent().attr('data-id')
  1409. activeTags.splice(index, 1)
  1410. inputTagList()
  1411. $('.tags-item[data-id="' + id + '"]').removeClass('tags-active')
  1412. }
  1413. window.deleteInputTag = deleteInputTag
  1414. function inputTagList () {
  1415. var ht = ''
  1416. $('.tag-labels').html(ht)
  1417. activeTags.forEach(function (v, i) {
  1418. ht += '<span class="tag-label" data-index=' + i + ' data-id="' + v.lid + '">'
  1419. ht += '<em>' + v.lname + '</em>'
  1420. ht += '<i class="tag-close" onclick="deleteInputTag(this)"></i>'
  1421. ht += '</span>'
  1422. })
  1423. $('.tag-labels').html(ht)
  1424. if ($('.tag-labels').children('.tag-label').length > 0) {
  1425. $('.tag-placeholder').hide()
  1426. }
  1427. checkTagDisabled()
  1428. }
  1429. // 渲染标签列表数据
  1430. function renderTagsList (data) {
  1431. if (data && data.length > 0) {
  1432. var ht = ''
  1433. data.forEach(function (v, i) {
  1434. ht += '<span class="tags-item" data-count=' + v.count + ' data-id=' + v.lid + '>' + v.lanme + '</span>'
  1435. })
  1436. $('.tags-list').html(ht)
  1437. activeTags.forEach(function (s, j) {
  1438. $('.tags-list .tags-item[data-id="' + s.lid + '"]').addClass('tags-active')
  1439. })
  1440. $('.tags-item').click(function (e) {
  1441. e.stopPropagation()
  1442. if ($(this).hasClass('disabled')) return
  1443. var id = $(this).attr('data-id')
  1444. var name = $(this).text()
  1445. $(this).toggleClass('tags-active')
  1446. if ($(this).hasClass('tags-active')) {
  1447. activeTags.push({
  1448. lid: id,
  1449. lname: name
  1450. })
  1451. inputTagList()
  1452. } else {
  1453. var newArr = activeTags.filter(function (item) {
  1454. return item.lid != id
  1455. })
  1456. activeTags = newArr
  1457. inputTagList()
  1458. }
  1459. })
  1460. }
  1461. inputTagList()
  1462. }
  1463. // 获取用户自定义标签
  1464. function getUserTags () {
  1465. $.ajax({
  1466. type: 'post',
  1467. url: '/entnicheNew/customer/getLabel?t=' + Date.now(),
  1468. success: function (r) {
  1469. if (r.error_code == 0 && $.isArray(r.data)) {
  1470. renderTagsList(r.data.reverse())
  1471. }
  1472. }
  1473. })
  1474. }
  1475. window.getUserTags = getUserTags
  1476. // 添加标签后认领接口
  1477. function saveChooseTags (params, callback) {
  1478. $.ajax({
  1479. type: 'post',
  1480. url: '/entnicheNew/customer/attention',
  1481. contentType: 'application/json',
  1482. data: JSON.stringify(params),
  1483. dataType: 'json',
  1484. success: function (r) {
  1485. if (r.error_code == 0 && r.data) {
  1486. _this.follow = false
  1487. _this.claim = false
  1488. $('.custom-checkbox').prop('checked', false)
  1489. _this.selectName = selectDataIds
  1490. _this.claimcheckName = []
  1491. _this.getList(_this.listState.pageNum)
  1492. $('.tags-list').find('.disabled').removeClass('disabled')
  1493. toastFn('认领成功!', 1000)
  1494. _this.$emit('updatelist', true)
  1495. callback && callback()
  1496. } else {
  1497. if (r.error_msg) {
  1498. toastFn(r.error_msg, 2000)
  1499. }
  1500. }
  1501. }
  1502. })
  1503. }
  1504. // 新增标签
  1505. function addTagsAjax (name) {
  1506. $.ajax({
  1507. type: 'post',
  1508. url: '/entnicheNew/customer/addLabel',
  1509. data: {
  1510. name: name
  1511. },
  1512. dataType: 'json',
  1513. success: function (r) {
  1514. if (r.data) {
  1515. $('.tag-input .clear-input').val('')
  1516. // 添加标签成功后 绑定标签
  1517. if (activeTags.length < 3) {
  1518. activeTags.push({
  1519. lid: r.data,
  1520. lname: name
  1521. })
  1522. }
  1523. getUserTags()
  1524. } else {
  1525. toastFn('标签已经存在,无需添加', 1000)
  1526. }
  1527. }
  1528. })
  1529. }
  1530. function checkTagDisabled () {
  1531. if (activeTags.length >= 3) {
  1532. // 禁用标签
  1533. $('.tags-list').find('.tags-item:not(.tags-active)').addClass('disabled')
  1534. } else {
  1535. // 解除禁用
  1536. $('.tags-list').find('.disabled').removeClass('disabled')
  1537. }
  1538. }
  1539. function baiduEvent (str) {
  1540. try {
  1541. // eslint-disable-next-line no-undef
  1542. _hmt.push(['_trackEvent', '大会员-pc', 'click', str])
  1543. } catch (e) {
  1544. console.log('未初始化百度统计')
  1545. }
  1546. }
  1547. getUserTags()
  1548. }
  1549. }
  1550. })