ent-search-index-pc.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. var vm = new Vue({
  2. el: '.vue-search-container',
  3. delimiters: ['${', '}'],
  4. components: {
  5. areaCityComponent: areaCityComponent,
  6. selectListComponent: selectListComponent,
  7. priceComponent: priceComponent,
  8. noData: noDataComponent
  9. },
  10. data: function () {
  11. return {
  12. provinceMap: provinceMap,
  13. searchContent: '',
  14. tabActive: 'qy',
  15. filterShow: true,
  16. searchTypeList: [
  17. {
  18. label: '企业名称',
  19. value: 'A'
  20. },
  21. {
  22. label: '法定代表人',
  23. value: 'B'
  24. },
  25. // {
  26. // label: '股东',
  27. // value: 'C'
  28. // },
  29. // {
  30. // label: '高管',
  31. // value: 'D'
  32. // },
  33. {
  34. label: '中标项目/标的物',
  35. value: 'E'
  36. }
  37. ],
  38. entTypeList: [
  39. {
  40. label: '有限责任公司',
  41. value: 'A'
  42. },
  43. {
  44. label: '股份有限公司',
  45. value: 'B'
  46. },
  47. {
  48. label: '有限合伙',
  49. value: 'C'
  50. },
  51. {
  52. label: '普通合伙',
  53. value: 'D'
  54. }
  55. ],
  56. entStateList: [
  57. {
  58. label: '存续(在营、开业、在业)',
  59. value: 'A'
  60. },
  61. {
  62. label: '吊销',
  63. value: 'B'
  64. },
  65. {
  66. label: '注销',
  67. value: 'C'
  68. },
  69. {
  70. label: '撤销',
  71. value: 'D'
  72. }
  73. ],
  74. priceList: [
  75. {
  76. label: '100万以内',
  77. value: '0-100'
  78. },
  79. {
  80. label: '100-500万',
  81. value: '100-500'
  82. },
  83. {
  84. label: '500-1000万',
  85. value: '500-1000'
  86. },
  87. {
  88. label: '1000-5000万',
  89. value: '1000-5000'
  90. },
  91. {
  92. label: '5000万以上',
  93. value: '5000-'
  94. },
  95. ],
  96. zblyFilterOption: {
  97. zbAreaOptions: [
  98. // {
  99. // label: '北京',
  100. // value: '北京'
  101. // }
  102. ],
  103. dwlxOptions: [
  104. {
  105. label: '采购单位',
  106. value: '1'
  107. },
  108. {
  109. label: '投标企业',
  110. value: '2'
  111. },
  112. {
  113. label: '招标代理机构',
  114. value: '3'
  115. },
  116. {
  117. label: '厂商',
  118. value: '4'
  119. }
  120. ],
  121. lxfsOptions: [
  122. {
  123. label: '固定电话',
  124. value: '1'
  125. },
  126. {
  127. label: '手机号',
  128. value: '2'
  129. },
  130. {
  131. label: '电子邮箱',
  132. value: '3'
  133. },
  134. {
  135. label: '不存在',
  136. value: '4'
  137. }
  138. ],
  139. },
  140. filterState: {
  141. searchType: ['A'],
  142. entArea: [],
  143. entCity: [],
  144. entType: [],
  145. entStatus: [],
  146. entCapital: [],
  147. biddingArea: '', // 中标区域
  148. entClass: '', // 单位类型
  149. entContact: '' // 联系方式
  150. },
  151. listState: {
  152. loaded: false, // 是否已经搜索过
  153. loading: false,
  154. pageNum: 1, // 当前页, 从0开始
  155. pageSize: 10, // 每页多少条数据
  156. total: 0, // 一共多少条数据
  157. list: [] // 查询请求返回的数据
  158. },
  159. preSearch: {
  160. hover: false,
  161. focus: false,
  162. list: []
  163. },
  164. powerInfo: {
  165. entniche: '',
  166. member: '',
  167. vip: ''
  168. },
  169. power: false,
  170. powerLoaded: false,
  171. powerDialogShow: false,
  172. baiduName: ''
  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
  180. } else {
  181. location.href = '/jylab/supsearch/index.html'
  182. }
  183. }
  184. }
  185. },
  186. computed: {
  187. preSearchListShow: function () {
  188. return this.searchContent.trim().length >= 2 && this.preSearch.list.length && (this.preSearch.focus || this.preSearch.hover)
  189. },
  190. buttonText: function () {
  191. if (this.power) {
  192. return '升级'
  193. } else {
  194. if (this.powerInfo.vip === 0) {
  195. return '开通'
  196. } else if (this.powerInfo.vip === 1) {
  197. return '升级'
  198. } else {
  199. return '升级'
  200. }
  201. }
  202. }
  203. },
  204. created: function () {
  205. this.getPower()
  206. this.initPageData()
  207. this.initProvinceMapList()
  208. },
  209. mounted: function () {
  210. this.initDOMEvents()
  211. // 默认选中搜索范围
  212. this.$refs.searchType.setState(this.filterState.searchType)
  213. },
  214. methods: {
  215. checkLogin: function () {
  216. var moduleOpen = $('body').hasClass('modal-open')
  217. if (moduleOpen) return
  218. if (!loginflag) {
  219. $("#bidLogin").modal("show");
  220. }
  221. },
  222. getPower: function (callback) {
  223. $.ajax({
  224. url: '/publicapply/bidcoll/power',
  225. type: 'POST',
  226. success: function (res) {
  227. if (res.error_code === 0 && res.data) {
  228. Object.assign(this.powerInfo, res.data)
  229. this.checkPower()
  230. this.doSearch()
  231. } else {
  232. this.checkLogin()
  233. }
  234. }.bind(this),
  235. complete: function () {
  236. this.powerLoaded = true
  237. callback && callback()
  238. }.bind(this)
  239. })
  240. },
  241. checkPower: function () {
  242. this.power = this.powerInfo.member || this.powerInfo.vip !== 0
  243. },
  244. initPageData: function () {
  245. if (pageInfo.searchContent) {
  246. this.searchContent = pageInfo.searchContent
  247. }
  248. },
  249. initProvinceMapList: function () {
  250. var provinceMapList = []
  251. for (var key in this.provinceMap) {
  252. this.provinceMap[key].forEach(function (item) {
  253. provinceMapList.push({
  254. label: item,
  255. value: item
  256. })
  257. })
  258. }
  259. this.zblyFilterOption.zbAreaOptions = provinceMapList
  260. },
  261. initDOMEvents: function () {
  262. ewmMoveHover()
  263. refreshEwmText(this.searchContent)
  264. setTimeout(function () {
  265. tabHover()
  266. }, 300)
  267. },
  268. isFilterShow: function () {
  269. if (this.filterShow) {
  270. $('.search-filters').slideUp()
  271. } else {
  272. $('.search-filters').slideDown()
  273. }
  274. this.filterShow = !this.filterShow
  275. },
  276. searchTypeChange: function (t) {
  277. var eIndex = t.indexOf('E')
  278. if (!this.power && eIndex !== -1) {
  279. this.powerDialogShow = true
  280. t.splice(eIndex, 1)
  281. this.$refs.searchType.setState(t)
  282. return
  283. }
  284. this.filterState.searchType = t
  285. this.doSearch()
  286. },
  287. areaCityChange: function (area) {
  288. var city = []
  289. for (var key in area) {
  290. city = city.concat(area[key])
  291. }
  292. this.filterState.entArea = Object.keys(area)
  293. this.filterState.entCity = city
  294. this.doSearch()
  295. },
  296. entTypeChange: function (e) {
  297. this.filterState.entType = e
  298. this.doSearch()
  299. },
  300. entStateChange: function (e) {
  301. this.filterState.entStatus = e
  302. this.doSearch()
  303. },
  304. // 标准金额区间
  305. inexactPriceChange: function (p) {
  306. this.filterState.entCapital = p
  307. this.doSearch()
  308. },
  309. // 输入金额区间
  310. exactPriceChange: function (p) {
  311. this.$refs.entCapital.setState()
  312. this.filterState.entCapital = [p.min + '-' + p.max]
  313. this.doSearch()
  314. },
  315. zbFilterChange: function (name) {
  316. this.baiduName = name
  317. if (this.power) {
  318. this.doSearch()
  319. } else {
  320. this.filterState.biddingArea = ''
  321. this.filterState.entClass = ''
  322. this.filterState.entContact = ''
  323. this.powerDialogShow = true
  324. }
  325. },
  326. doSearch: function () {
  327. this.resetListState()
  328. this.getList()
  329. },
  330. resetListState: function () {
  331. var state = {
  332. loaded: false,
  333. loading: false,
  334. pageNum: 1,
  335. total: 0,
  336. list: []
  337. }
  338. Object.assign(this.listState, state)
  339. },
  340. getPreSearchList: utils.debounce(function () {
  341. var data = {
  342. name: this.searchContent.trim()
  343. }
  344. if (data.name.length < 2) return
  345. $.ajax({
  346. url: '/bigmember/search/ent/association',
  347. method: 'POST',
  348. data: data,
  349. success: function (res) {
  350. if (res.error_code === 0) {
  351. if (res.data) {
  352. this.preSearch.list = res.data.list || []
  353. }
  354. } else {
  355. this.checkLogin()
  356. }
  357. }.bind(this)
  358. })
  359. }, 200),
  360. getList: function () {
  361. var data = {
  362. match: this.searchContent,
  363. matchType: this.filterState.searchType.join(','),
  364. entArea: this.filterState.entArea.join(','),
  365. entCity: this.filterState.entCity.join(','),
  366. entCapital: this.filterState.entCapital.join(','),
  367. entType: this.filterState.entType.join(','),
  368. entStatus: this.filterState.entStatus.join(','),
  369. biddingArea: this.filterState.biddingArea,
  370. entClass: this.filterState.entClass,
  371. entContact: this.filterState.entContact,
  372. pageSize: this.listState.pageSize,
  373. pageNum: this.listState.pageNum - 1, // 当前页, 从0开始
  374. }
  375. this.listState.loading = true
  376. this.listState.loaded = false
  377. $.ajax({
  378. url: '/publicapply/enterpriseSearch/doQuery',
  379. method: 'POST',
  380. data: data,
  381. success: function (res) {
  382. if (res.error_code === 0) {
  383. this.setListStateAndCheckPower(res)
  384. } else {
  385. this.checkLogin()
  386. }
  387. }.bind(this),
  388. complete: function () {
  389. this.listState.loading = false
  390. this.listState.loaded = true
  391. }.bind(this)
  392. })
  393. },
  394. setListStateAndCheckPower: function (res) {
  395. var _this = this
  396. if (res.data) {
  397. if (res.data.total) {
  398. if (this.power) {
  399. this.listState.total = res.data.total
  400. } else {
  401. this.listState.total = 4
  402. }
  403. }
  404. if (res.data.list) {
  405. res.data.list.forEach(function (d) {
  406. d.company_shortname = _this.getShortName(d.company_name)
  407. d.randomBgc = _this.randomBgc()
  408. })
  409. if (this.power) {
  410. this.listState.list = res.data.list || []
  411. } else {
  412. if (res.data.list.length >= 4) {
  413. res.data.list.length = 4
  414. res.data.list.push({
  415. company_shortname: 'xxx',
  416. company_address: 'xxx',
  417. company_name: 'xxx',
  418. company_status: 'xxx',
  419. legal_person: 'xxx',
  420. id: 'xxx',
  421. showMask: true
  422. })
  423. }
  424. this.listState.list = res.data.list || []
  425. }
  426. }
  427. } else {
  428. this.listState.total = 0
  429. this.listState.list = []
  430. }
  431. },
  432. onPageChange: function (p) {
  433. this.listState.pageNum = p
  434. this.getList()
  435. },
  436. openVipPage: function (param) {
  437. // 企业搜索中标区域-去开通
  438. // 企业搜索单位类型-去开通
  439. // 企业搜索联系方式-去开通
  440. // 企业搜索底部第五条-去开通
  441. if(param === 'more') {
  442. this.baiduName = '底部第五条'
  443. }
  444. var str = '企业搜索' + this.baiduName + '-去开通'
  445. baiduEvent(str) // 去开通按钮百度统计
  446. window.open('/front/subscribe.html')
  447. },
  448. toDetail: function (id) {
  449. window.open('/swordfish/page_big_pc/svip/ent_ser_portrait/' + id)
  450. },
  451. calcListItemForCap: function (p) {
  452. if (p) {
  453. return p + '万元'
  454. } else {
  455. return '-'
  456. }
  457. },
  458. getEntStatus: function (status) {
  459. if (status === '吊销') {
  460. return 'tag-danger'
  461. } else if (status === '注销') {
  462. return 'tag-danger'
  463. } else if (status === '撤销') {
  464. return 'tag-disabled'
  465. } else {
  466. return ''
  467. }
  468. },
  469. randomBgc: function () {
  470. var arr = ['default', 'blue', 'orange', 'green']
  471. var randomIndex = utils.getRandomNumber(0, arr.length - 1)
  472. return 'bgc-' + arr[randomIndex]
  473. },
  474. getShortName: function (comName) {
  475. var areaMap = chinaMapJSON || []
  476. var shortname = comName
  477. // 1. 循环省份城市进行替换
  478. areaMap.forEach(function (item) {
  479. var p = item.name.replace(/[省市]/, '')
  480. if (shortname.indexOf(p) !== -1) {
  481. shortname = shortname.replace(item.name, '').replace(p, '')
  482. console.log(p + ' -> \'\'')
  483. }
  484. item.city.forEach(function (iitem) {
  485. var c = iitem.name.replace(/[省市]/, '')
  486. if (shortname.indexOf(c) !== -1) {
  487. shortname = shortname.replace(iitem.name, '').replace(c, '')
  488. console.log(c + ' -> \'\'')
  489. }
  490. iitem.area.forEach(function (iiitem) {
  491. if (shortname.indexOf(iiitem) !== -1) {
  492. shortname = shortname.replace(iiitem, '')
  493. console.log(iiitem + ' -> \'\'')
  494. }
  495. })
  496. })
  497. })
  498. var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm)
  499. var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4)
  500. if (shortname.length < 4) {
  501. shortname = shortname.slice(0, 4)
  502. }
  503. return shortname
  504. }
  505. }
  506. })
  507. ;(function () {
  508. var backUpLoginCallback = logic
  509. logic = function (data, num) {
  510. // do something
  511. // 如果是当前页面已经使用过了,则只需要刷新power即可
  512. if (data.result === 'ok') {
  513. vm.getPower()
  514. }
  515. backUpLoginCallback(data, num)
  516. }
  517. })()
  518. function tabHover () {
  519. $('#tab-zb').on('mouseover', function () {
  520. $(this).siblings('.el-tabs__active-bar').css({transform: 'translateX(0)'})
  521. }).on('mouseout', function () {
  522. $(this).siblings('.el-tabs__active-bar').css({transform: 'translateX(96px)'})
  523. })
  524. }
  525. function refreshEwmText (text) {
  526. if (text && text.trim().length > 0) {
  527. $(".wx-inner-title").html("扫码关注企业");
  528. $(".wx-inner-bottom").html('扫码即可实时接收<span style="color:#2cb7ca">'+'"'+text+'"'+'</span>的中标信息!');
  529. }
  530. }
  531. function ewmMoveHover() {
  532. var $div = $(".search-right-wx .search-right-wx-inner"),
  533. $parent = $(".search-right-wx");
  534. $parent.on("mouseover",function(){
  535. $div.css({
  536. "transform":"scale(1)",
  537. "transition":"transform 0.8s"
  538. })
  539. })
  540. $parent.on("mouseout",function(){
  541. $div.css({
  542. "transform":"scale(0)",
  543. "transition":"transform 0.2s"
  544. })
  545. })
  546. }
  547. function baiduEvent(name) {
  548. console.log(name)
  549. try {
  550. _hmt.push(['_trackEvent', '超级订阅-pc', 'click', name]);
  551. } catch (e) {
  552. console.log('未初始化百度统计')
  553. }
  554. }