ent-search-index-pc.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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. }
  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
  179. } else {
  180. location.href = '/jylab/supsearch/index.html'
  181. }
  182. }
  183. }
  184. },
  185. computed: {
  186. preSearchListShow: function () {
  187. return this.searchContent.trim().length >= 2 && this.preSearch.list.length && (this.preSearch.focus || this.preSearch.hover)
  188. },
  189. buttonText: function () {
  190. if (this.power) {
  191. return '升级'
  192. } else {
  193. if (this.powerInfo.vip === 0) {
  194. return '开通'
  195. } else if (this.powerInfo.vip === 1) {
  196. return '升级'
  197. } else {
  198. return '升级'
  199. }
  200. }
  201. }
  202. },
  203. created: function () {
  204. this.getPower()
  205. this.initPageData()
  206. this.initProvinceMapList()
  207. },
  208. mounted: function () {
  209. this.initDOMEvents()
  210. // 默认选中搜索范围
  211. this.$refs.searchType.setState(this.filterState.searchType)
  212. },
  213. methods: {
  214. checkLogin: function () {
  215. var moduleOpen = $('body').hasClass('modal-open')
  216. if (moduleOpen) return
  217. if (!loginflag) {
  218. $("#bidLogin").modal("show");
  219. }
  220. },
  221. getPower: function (callback) {
  222. $.ajax({
  223. url: '/publicapply/bidcoll/power',
  224. type: 'POST',
  225. success: function (res) {
  226. if (res.error_code === 0 && res.data) {
  227. Object.assign(this.powerInfo, res.data)
  228. this.checkPower()
  229. this.doSearch()
  230. } else {
  231. this.checkLogin()
  232. }
  233. }.bind(this),
  234. complete: function () {
  235. this.powerLoaded = true
  236. callback && callback()
  237. }.bind(this)
  238. })
  239. },
  240. checkPower: function () {
  241. this.power = this.powerInfo.member || this.powerInfo.vip !== 0
  242. },
  243. initPageData: function () {
  244. if (pageInfo.searchContent) {
  245. this.searchContent = pageInfo.searchContent
  246. }
  247. },
  248. initProvinceMapList: function () {
  249. var provinceMapList = []
  250. for (var key in this.provinceMap) {
  251. this.provinceMap[key].forEach(function (item) {
  252. provinceMapList.push({
  253. label: item,
  254. value: item
  255. })
  256. })
  257. }
  258. this.zblyFilterOption.zbAreaOptions = provinceMapList
  259. },
  260. initDOMEvents: function () {
  261. ewmMoveHover()
  262. refreshEwmText(this.searchContent)
  263. setTimeout(function () {
  264. tabHover()
  265. }, 300)
  266. },
  267. isFilterShow: function () {
  268. if (this.filterShow) {
  269. $('.search-filters').slideUp()
  270. } else {
  271. $('.search-filters').slideDown()
  272. }
  273. this.filterShow = !this.filterShow
  274. },
  275. searchTypeChange: function (t) {
  276. var eIndex = t.indexOf('E')
  277. if (!this.power && eIndex !== -1) {
  278. this.powerDialogShow = true
  279. t.splice(eIndex, 1)
  280. this.$refs.searchType.setState(t)
  281. return
  282. }
  283. this.filterState.searchType = t
  284. this.doSearch()
  285. },
  286. areaCityChange: function (area) {
  287. var city = []
  288. for (var key in area) {
  289. city = city.concat(area[key])
  290. }
  291. this.filterState.entArea = Object.keys(area)
  292. this.filterState.entCity = city
  293. this.doSearch()
  294. },
  295. entTypeChange: function (e) {
  296. this.filterState.entType = e
  297. this.doSearch()
  298. },
  299. entStateChange: function (e) {
  300. this.filterState.entStatus = e
  301. this.doSearch()
  302. },
  303. // 标准金额区间
  304. inexactPriceChange: function (p) {
  305. this.filterState.entCapital = p
  306. this.doSearch()
  307. },
  308. // 输入金额区间
  309. exactPriceChange: function (p) {
  310. this.$refs.entCapital.setState()
  311. this.filterState.entCapital = [p.min + '-' + p.max]
  312. this.doSearch()
  313. },
  314. zbFilterChange: function () {
  315. if (this.power) {
  316. this.doSearch()
  317. } else {
  318. this.filterState.biddingArea = ''
  319. this.filterState.entClass = ''
  320. this.filterState.entContact = ''
  321. this.powerDialogShow = true
  322. }
  323. },
  324. doSearch: function () {
  325. this.resetListState()
  326. this.getList()
  327. },
  328. resetListState: function () {
  329. var state = {
  330. loaded: false,
  331. loading: false,
  332. pageNum: 1,
  333. total: 0,
  334. list: []
  335. }
  336. Object.assign(this.listState, state)
  337. },
  338. getPreSearchList: utils.debounce(function () {
  339. var data = {
  340. name: this.searchContent.trim()
  341. }
  342. if (data.name.length < 2) return
  343. $.ajax({
  344. url: '/bigmember/search/ent/association',
  345. method: 'POST',
  346. data: data,
  347. success: function (res) {
  348. if (res.error_code === 0) {
  349. if (res.data) {
  350. this.preSearch.list = res.data.list || []
  351. }
  352. } else {
  353. this.checkLogin()
  354. }
  355. }.bind(this)
  356. })
  357. }, 200),
  358. getList: function () {
  359. var data = {
  360. match: this.searchContent,
  361. matchType: this.filterState.searchType.join(','),
  362. entArea: this.filterState.entArea.join(','),
  363. entCity: this.filterState.entCity.join(','),
  364. entCapital: this.filterState.entCapital.join(','),
  365. entType: this.filterState.entType.join(','),
  366. entStatus: this.filterState.entStatus.join(','),
  367. biddingArea: this.filterState.biddingArea,
  368. entClass: this.filterState.entClass,
  369. entContact: this.filterState.entContact,
  370. pageSize: this.listState.pageSize,
  371. pageNum: this.listState.pageNum - 1, // 当前页, 从0开始
  372. }
  373. this.listState.loading = true
  374. this.listState.loaded = false
  375. $.ajax({
  376. url: '/publicapply/enterpriseSearch/doQuery',
  377. method: 'POST',
  378. data: data,
  379. success: function (res) {
  380. if (res.error_code === 0) {
  381. this.setListStateAndCheckPower(res)
  382. } else {
  383. this.checkLogin()
  384. }
  385. }.bind(this),
  386. complete: function () {
  387. this.listState.loading = false
  388. this.listState.loaded = true
  389. }.bind(this)
  390. })
  391. },
  392. setListStateAndCheckPower: function (res) {
  393. var _this = this
  394. if (res.data) {
  395. if (res.data.total) {
  396. if (this.power) {
  397. this.listState.total = res.data.total
  398. } else {
  399. this.listState.total = 4
  400. }
  401. }
  402. if (res.data.list) {
  403. res.data.list.forEach(function (d) {
  404. d.company_shortname = _this.getShortName(d.company_name)
  405. d.randomBgc = _this.randomBgc()
  406. })
  407. if (this.power) {
  408. this.listState.list = res.data.list || []
  409. } else {
  410. if (res.data.list.length >= 4) {
  411. res.data.list.length = 4
  412. res.data.list.push({
  413. company_shortname: 'xxx',
  414. company_address: 'xxx',
  415. company_name: 'xxx',
  416. company_status: 'xxx',
  417. legal_person: 'xxx',
  418. id: 'xxx',
  419. showMask: true
  420. })
  421. }
  422. this.listState.list = res.data.list || []
  423. }
  424. }
  425. } else {
  426. this.listState.total = 0
  427. this.listState.list = []
  428. }
  429. },
  430. onPageChange: function (p) {
  431. this.listState.pageNum = p
  432. this.getList()
  433. },
  434. openVipPage: function () {
  435. window.open('/front/subscribe.html')
  436. },
  437. toDetail: function (id) {
  438. window.open('/swordfish/page_big_pc/svip/ent_ser_portrait/' + id)
  439. },
  440. calcListItemForCap: function (p) {
  441. if (p) {
  442. return p + '万元'
  443. } else {
  444. return '-'
  445. }
  446. },
  447. getEntStatus: function (status) {
  448. if (status === '吊销') {
  449. return 'tag-danger'
  450. } else if (status === '注销') {
  451. return 'tag-danger'
  452. } else if (status === '撤销') {
  453. return 'tag-disabled'
  454. } else {
  455. return ''
  456. }
  457. },
  458. randomBgc: function () {
  459. var arr = ['default', 'blue', 'orange', 'green']
  460. var randomIndex = utils.getRandomNumber(0, arr.length - 1)
  461. return 'bgc-' + arr[randomIndex]
  462. },
  463. getShortName: function (comName) {
  464. var areaMap = chinaMapJSON || []
  465. var shortname = comName
  466. // 1. 循环省份城市进行替换
  467. areaMap.forEach(function (item) {
  468. var p = item.name.replace(/[省市]/, '')
  469. if (shortname.indexOf(p) !== -1) {
  470. shortname = shortname.replace(item.name, '').replace(p, '')
  471. console.log(p + ' -> \'\'')
  472. }
  473. item.city.forEach(function (iitem) {
  474. var c = iitem.name.replace(/[省市]/, '')
  475. if (shortname.indexOf(c) !== -1) {
  476. shortname = shortname.replace(iitem.name, '').replace(c, '')
  477. console.log(c + ' -> \'\'')
  478. }
  479. iitem.area.forEach(function (iiitem) {
  480. if (shortname.indexOf(iiitem) !== -1) {
  481. shortname = shortname.replace(iiitem, '')
  482. console.log(iiitem + ' -> \'\'')
  483. }
  484. })
  485. })
  486. })
  487. var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm)
  488. var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4)
  489. if (shortname.length < 4) {
  490. shortname = shortname.slice(0, 4)
  491. }
  492. return shortname
  493. }
  494. }
  495. })
  496. ;(function () {
  497. var backUpLoginCallback = logic
  498. logic = function (data, num) {
  499. // do something
  500. // 如果是当前页面已经使用过了,则只需要刷新power即可
  501. if (data.result === 'ok') {
  502. vm.getPower()
  503. }
  504. backUpLoginCallback(data, num)
  505. }
  506. })()
  507. function tabHover () {
  508. $('#tab-zb').on('mouseover', function () {
  509. $(this).siblings('.el-tabs__active-bar').css({transform: 'translateX(0)'})
  510. }).on('mouseout', function () {
  511. $(this).siblings('.el-tabs__active-bar').css({transform: 'translateX(96px)'})
  512. })
  513. }
  514. function refreshEwmText (text) {
  515. if (text && text.trim().length > 0) {
  516. $(".wx-inner-title").html("扫码关注企业");
  517. $(".wx-inner-bottom").html('扫码即可实时接收<span style="color:#2cb7ca">'+'"'+text+'"'+'</span>的中标信息!');
  518. }
  519. }
  520. function ewmMoveHover() {
  521. var $div = $(".search-right-wx .search-right-wx-inner"),
  522. $parent = $(".search-right-wx");
  523. $parent.on("mouseover",function(){
  524. $div.css({
  525. "transform":"scale(1)",
  526. "transition":"transform 0.8s"
  527. })
  528. })
  529. $parent.on("mouseout",function(){
  530. $div.css({
  531. "transform":"scale(0)",
  532. "transition":"transform 0.2s"
  533. })
  534. })
  535. }