pur-search-index-pc.js 54 KB

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