demand.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. import '../../css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import '../../css/public.css';
  4. import '../../css/main_banner.css';
  5. import '../../js/public.js';
  6. import '../../js/main_banner.js';
  7. import '../../css/technologyTrading/demand.css';
  8. import '../../css/technologyTrading/achievement.css';
  9. import {
  10. provinceList
  11. } from '../../js/NewDicProvinceList';
  12. import {
  13. industryObject,
  14. getIndustryCategory
  15. } from '../DicIndustryList';
  16. $(function(){
  17. //页面里面的详情链接
  18. $(".main_introduce ul").on('click', 'li', function () {
  19. var ol_index= $(".title_details ol>li.act").index();
  20. var theId = $(this).attr('val');
  21. var thetype=$(this).attr('typ');
  22. window.open(globalConfig.context + '/portal/technologyTrading/demandDetail?id=' + theId+'&type='+thetype );
  23. });
  24. //数据处理
  25. var theKeyword, theMode, theFieldA, theFieldB,dataCategory,category,dateSort,budgetCostLower,budgetCostUpper;
  26. var thePageNo = 1,
  27. thePageLength = 1,
  28. pageSize = 12;
  29. var categoryObj = {
  30. "0": "技术购买型需求",
  31. "1": "技术设备类需求",
  32. "2": "技术方案型需求",
  33. "3": "技术攻关型需求",
  34. "4": "技术咨询型需求",
  35. "5": "技术人才型需求"
  36. };
  37. var valu=localStorage.getItem("keyWord");
  38. var typ=localStorage.getItem("pageType");
  39. sessionStorage.removeItem("keyWord");
  40. sessionStorage.removeItem("pageType");
  41. if(typ){
  42. $.ajax({
  43. method: "get",
  44. dataType: "json",
  45. url: globalConfig.context + "/portal/search/achievementList",
  46. data: {
  47. pageNo: 1,
  48. pageSize: pageSize,
  49. keyword: valu,
  50. transferMode: theMode != 999 ? theMode : undefined,
  51. fieldA: theFieldA != 999 ? theFieldA : undefined,
  52. fieldB: theFieldB != 999 ? theFieldB : undefined,
  53. dataCategory:dataCategory != 999 ? dataCategory : undefined,
  54. category:category != 999 ? category : undefined
  55. //dateSort:dateSort,
  56. //lowerPrice:lowerPrice,
  57. //upperPrice:upperPrice
  58. },
  59. success: function (data) {
  60. var theArr = [];
  61. if (data.data && data.data.list) {
  62. for (let i = 0; i < data.data.list.length; i++) {
  63. let thisdata = data.data.list[i];
  64. var imgUrl=thisdata.pictureUrl!==null?thisdata.pictureUrl:"/img/timg.gif";
  65. var star='';
  66. for(var n=0;n<thisdata.maturity;n++){
  67. star+='<li></li>'
  68. }
  69. theArr.push([
  70. '<li val="'+thisdata.id+'" typ="'+thisdata.dataCategory+'">', //图片地址
  71. '<img src="' + globalConfig.avatarHost + '/upload' + imgUrl + '"/>',
  72. '<div class="list_text">',
  73. '<p>行业<span>' + (thisdata.industryCategoryA?getIndustryCategory(thisdata.industryCategoryA, thisdata.industryCategoryB):"未知行业") + '</span></p>',
  74. '<p>名称<span title=' + thisdata.name + '>' + (thisdata.name?thisdata.name:"未知名称") + '</span></p>',
  75. '<p>类型<span>' + (thisdata.demandType ? categoryObj[thisdata.demandType] : '类型未知') + '</span></p>',
  76. '<p class="money">预算<span>'+ (thisdata.budgetCost ? (thisdata.budgetCost + '万元') : '价格面议') + '</span></p>',
  77. '<a href="#">了解详情</a>',
  78. '</div>',
  79. //'<div class="star">',
  80. //'<p>成熟度:<ol><li></li><li></li><li></li><li></li><li></li></ol></p>',
  81. //'</div>',
  82. '<input type="hidden" class="demandId" value="' + thisdata.id + '">',
  83. '<input type="hidden" class="demandType" value="' + thisdata.dataCategory + '">',
  84. '</li>',
  85. ].join(''));
  86. };
  87. };
  88. $('.main_introduce ul').empty();
  89. $('.main_introduce ul').append(theArr.join(''));
  90. if(data.data.list.length===0){
  91. $('.main_introduce ul').html("<div class='list_none'></div>") ;
  92. };
  93. // $('.totalCount').html("共" + data.data.totalCount + "条数据");
  94. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  95. var pageArr = [],
  96. firstNo = 1,
  97. endNo = 5;
  98. if (thePageNo > 3) {
  99. firstNo = thePageNo - 2;
  100. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  101. } else {
  102. endNo = Math.min(thePageLength, 5);
  103. };
  104. for (let i = firstNo; i <= endNo; i++) {
  105. if (i == thePageNo) {
  106. pageArr.push(
  107. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  108. );
  109. } else {
  110. pageArr.push(
  111. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  112. );
  113. }
  114. };
  115. $('.pageNumber').remove();
  116. $('.pagePre').after(pageArr.join(''));
  117. }
  118. });
  119. }else{
  120. loadDate();
  121. }
  122. function loadDate(pageNo) {
  123. $.ajax({
  124. method: "get",
  125. dataType: "json",
  126. url: globalConfig.context + "/portal/search/demandList",
  127. data: {
  128. pageNo: pageNo || 1,
  129. pageSize: pageSize,
  130. keyword: theKeyword,
  131. sign: 0,
  132. demandType: theMode != 999 ? theMode : undefined,
  133. industryCategoryA: theFieldA != 999 ? theFieldA : undefined,
  134. industryCategoryB: theFieldB != 999 ? theFieldB : undefined,
  135. dateSort:dateSort,
  136. budgetCostLower:budgetCostLower,
  137. budgetCostUpper:budgetCostUpper
  138. },
  139. success: function (data) {
  140. var theArr = [];
  141. if (data.data && data.data.list) {
  142. for (let i = 0; i < data.data.list.length; i++) {
  143. let thisdata = data.data.list[i];
  144. if(thisdata.pictureUrl==null){
  145. thisdata.pictureUrl=''
  146. }
  147. var imgUrl=thisdata.pictureUrl!=''?globalConfig.avatarHost + '/upload' +thisdata.pictureUrl:globalConfig.avatarHost+ "/upload/default/xuqiuimg_null.png";
  148. var star='';
  149. for(var n=0;n<thisdata.maturity;n++){
  150. star+='<li></li>'
  151. }
  152. theArr.push([
  153. '<li val="'+thisdata.id+'" typ="'+thisdata.dataCategory+'">', //图片地址
  154. '<img src="' +imgUrl + '"/>',
  155. '<div class="list_text">',
  156. '<p>行业<span>' + (thisdata.industryCategoryA?getIndustryCategory(thisdata.industryCategoryA, thisdata.industryCategoryB):"未知行业") + '</span></p>',
  157. '<p>名称<span title=' + thisdata.name + '>' + (thisdata.name?thisdata.name:"未知名称") + '</span></p>',
  158. '<p>类型<span>' + (thisdata.demandType ? categoryObj[thisdata.demandType] : '类型未知') + '</span></p>',
  159. '<p class="money">预算<span>'+ (thisdata.budgetCost ? (thisdata.budgetCost + '万元') : '价格面议') + '</span></p>',
  160. '<a href="#">了解详情</a>',
  161. '</div>',
  162. //'<div class="star">',
  163. //'<p>成熟度:<ol><li></li><li></li><li></li><li></li><li></li></ol></p>',
  164. //'</div>',
  165. '<input type="hidden" class="demandId" value="' + thisdata.id + '">',
  166. '<input type="hidden" class="demandType" value="' + thisdata.dataCategory + '">',
  167. '</li>',
  168. ].join(''));
  169. };
  170. };
  171. $('.main_introduce ul').empty();
  172. $('.main_introduce ul').append(theArr.join(''));
  173. if(data.data.list.length===0){
  174. $('.main_introduce ul').html("<div class='list_none'></div>") ;
  175. };
  176. // $('.totalCount').html("共" + data.data.totalCount + "条数据");
  177. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  178. var pageArr = [],
  179. firstNo = 1,
  180. endNo = 5;
  181. if (thePageNo > 3) {
  182. firstNo = thePageNo - 2;
  183. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  184. } else {
  185. endNo = Math.min(thePageLength, 5);
  186. };
  187. for (let i = firstNo; i <= endNo; i++) {
  188. if (i == thePageNo) {
  189. pageArr.push(
  190. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  191. );
  192. } else {
  193. pageArr.push(
  194. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  195. );
  196. }
  197. };
  198. $('.pageNumber').remove();
  199. $('.pagePre').after(pageArr.join(''));
  200. }
  201. });
  202. }
  203. if (window.location.search) {
  204. let theUrl = window.location.search
  205. theKeyword = theUrl.substring(1, theUrl.length);
  206. theKeyword = decodeURIComponent(theKeyword);
  207. $('#search_on input').val(theKeyword);
  208. };
  209. loadDate();
  210. var industryListArr = [],
  211. industryChildrenArr = [];
  212. industryListArr.push(['<li value="999" class="active">',
  213. '<span>',
  214. '不限',
  215. '</span>',
  216. '</li>',
  217. ].join(''));
  218. industryObject.map(function (item) {
  219. industryListArr.push(['<li value="' + item.value + '">',
  220. '<span>',
  221. item.label,
  222. '</span>',
  223. '</li>',
  224. ].join(''));
  225. });
  226. if (industryListArr && industryListArr.length) {
  227. $('#industryList').append(industryListArr.join(''));
  228. };
  229. $('#industryList li').click(function () {
  230. var theValue = this.value;
  231. $(this).siblings("li").removeClass("active");
  232. $(this).addClass("active");
  233. industryChildrenArr = [];
  234. industryChildrenArr.push(['<li value="999" class="active">',
  235. '<span>',
  236. '不限',
  237. '</span>',
  238. '</li>',
  239. ].join(''));
  240. if (theValue !== 999) {
  241. $('#industryChildrenBox').css("display", "block");
  242. industryObject.map(function (item) {
  243. if (item.value == theValue) {
  244. item.children.map(function (child) {
  245. industryChildrenArr.push(['<li value="' + child.value + '">',
  246. '<span>',
  247. child.label,
  248. '</span>',
  249. '</li>',
  250. ].join(''));
  251. });
  252. };
  253. });
  254. } else {
  255. $('#industryChildrenBox').css("display", "none");
  256. };
  257. if (industryChildrenArr && industryChildrenArr.length) {
  258. $('#industryChildrenList').empty();
  259. $('#industryChildrenList').append(industryChildrenArr.join(''));
  260. };
  261. theFieldA = this.value;
  262. theFieldB = '999';
  263. loadDate();
  264. });
  265. $('#industryChildrenList').on('click', 'li', function () {
  266. $(this).siblings("li").removeClass("active");
  267. $(this).addClass("active");
  268. theFieldB = this.value;
  269. loadDate();
  270. });
  271. $('#technologyModeList').on('click', 'li', function () {
  272. $(this).siblings("li").removeClass("active");
  273. $(this).addClass("active");
  274. theMode = this.value;
  275. loadDate();
  276. });
  277. $('#btt_search').click(function () {
  278. theKeyword = $('#search_on input').val();
  279. loadDate();
  280. });
  281. $('.pagination').on('click', 'li', function (e) {
  282. e.preventDefault();
  283. var texton=$("#search_on input").val();
  284. if (this.className === 'pagePre'){
  285. if (thePageNo > 1) {
  286. thePageNo = 1;
  287. loadDate(thePageNo);
  288. }
  289. } else if (this.className === 'pageNext') {
  290. if (thePageNo < thePageLength) {
  291. thePageNo = thePageLength;
  292. loadDate(thePageNo);
  293. }
  294. } else {
  295. var nextPageNo = $(this).children()[0].text;
  296. if (thePageNo != nextPageNo) {
  297. $(this).siblings("li").removeClass("active");
  298. $(this).addClass("active");
  299. thePageNo = nextPageNo;
  300. loadDate(thePageNo);
  301. };
  302. };
  303. });
  304. $('main_introduce').on('click', 'li', function () {
  305. var theId = $(this).children(".demandId")[0].value;
  306. var theType = $(this).children(".demandType")[0].value;
  307. window.open(globalConfig.context + '/portal/detail/demandDetail.html?id=' + theId + '&type=' + theType);
  308. })
  309. $('#industryList li').click(function(){
  310. var text_ind=$(this).find('span').text();
  311. $('.achievement_header ul li').eq(0).show()
  312. $('.achievement_header ul li').eq(0).find('p').text(text_ind);
  313. })
  314. //搜索城市下拉
  315. var addlength=provinceList.length;
  316. var soption='';
  317. for(var i=0;i<addlength;i++){
  318. soption+="<option value='"+provinceList[i].id+"'>"+provinceList[i].name+"</option>";
  319. };
  320. $('#selt').html(soption);
  321. //全部结果查询
  322. $('.achievement_header ul li img').click(function(){
  323. $(this).parent().hide();
  324. var lilen=$('.achievement_header ul li').css('display');
  325. if(lilen=='none'){
  326. $('#search_on input').val('');
  327. $('.searchs button').click();
  328. }
  329. });
  330. $('.text_replace').hide()
  331. // 搜索功能关联关键字
  332. $('.searchs button').click(function(e){
  333. e.preventDefault();
  334. var search_txt=$('#search_on input').val();
  335. $('.text_replace span').text(search_txt);
  336. if(search_txt==''){
  337. $('.text_replace').hide()
  338. }else{
  339. $('.text_replace').show()
  340. }
  341. })
  342. //点击技术类型
  343. $('#technologyModeList li').click(function(){
  344. $('.achievement_header ul li').eq(1).show()
  345. $(this).addClass('active').siblings().removeClass('active')
  346. var txt_tech=$(this).find('span').text();
  347. $('.achievement_header ul li').eq(1).find('p').text(txt_tech);
  348. })
  349. //点击搜索下面的字段快捷搜索
  350. $('.head_right ol li').click(function () {
  351. theKeyword = $(this).text();
  352. $('#technologyModeList li').eq(0).addClass('active').siblings().removeClass('active');
  353. $('#transferModeList li').eq(0).addClass('active').siblings().removeClass('active');
  354. $('.text_replace').show();
  355. $('.text_replace span').text(theKeyword);
  356. $('#search_on input').val(theKeyword);
  357. loadDate();
  358. });
  359. //点击行业分类
  360. $('#industryList li').click(function(){
  361. $('.achievement_header ul li').eq(0).show();
  362. var text_ind=$(this).find('span').text();
  363. $('.achievement_header ul li').eq(0).find('p').text(text_ind);
  364. })
  365. //排序下拉选择
  366. $('.head-left ul li p').click(function(){
  367. $(this).siblings().slideToggle(300);
  368. })
  369. $('.head-left ul li').mouseleave(function(){
  370. $(this).find('.time_select').slideUp(300);
  371. })
  372. $('.time_select ul li').click(function(){
  373. var txt=$(this).text();
  374. $(this).parents('.time_select').siblings('p').find('span').text(txt);
  375. $('.time_select').hide();
  376. });
  377. $('.timeSelect li').click(function(){
  378. var timeTxt=$(this).attr('value');
  379. $('head-left ul li:first-child').removeClass('active')
  380. dateSort=timeTxt;
  381. loadDate();
  382. })
  383. //价格
  384. $('.inp_select input').keyup(function(){
  385. var val_min=$(this).val();
  386. if(val_min<0){
  387. $(this).val('0')
  388. }
  389. })
  390. $('.inp_select button').click(function(){
  391. var minpri=$('.inp_select #minprice').val();
  392. var maxpri=$('.inp_select #maxprice').val();
  393. budgetCostLower=minpri;
  394. budgetCostUpper=maxpri;
  395. loadDate();
  396. })
  397. $('#industryList li:first-child').click(function(){
  398. theFieldA = $(this).attr('value');
  399. theFieldB = '999';
  400. loadDate();
  401. })
  402. })