demand.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. var imgUrl=thisdata.pictureUrl!==null?thisdata.pictureUrl:"/img/timg.gif";
  145. var star='';
  146. for(var n=0;n<thisdata.maturity;n++){
  147. star+='<li></li>'
  148. }
  149. theArr.push([
  150. '<li val="'+thisdata.id+'" typ="'+thisdata.dataCategory+'">', //图片地址
  151. '<img src="' + globalConfig.avatarHost + '/upload' + imgUrl + '"/>',
  152. '<div class="list_text">',
  153. '<p>行业<span>' + (thisdata.industryCategoryA?getIndustryCategory(thisdata.industryCategoryA, thisdata.industryCategoryB):"未知行业") + '</span></p>',
  154. '<p>名称<span title=' + thisdata.name + '>' + (thisdata.name?thisdata.name:"未知名称") + '</span></p>',
  155. '<p>类型<span>' + (thisdata.demandType ? categoryObj[thisdata.demandType] : '类型未知') + '</span></p>',
  156. '<p class="money">预算<span>'+ (thisdata.budgetCost ? (thisdata.budgetCost + '万元') : '价格面议') + '</span></p>',
  157. '<a href="#">了解详情</a>',
  158. '</div>',
  159. '<div class="star">',
  160. '<p>成熟度:<ol><li></li><li></li><li></li><li></li><li></li></ol></p>',
  161. '</div>',
  162. '<input type="hidden" class="demandId" value="' + thisdata.id + '">',
  163. '<input type="hidden" class="demandType" value="' + thisdata.dataCategory + '">',
  164. '</li>',
  165. ].join(''));
  166. };
  167. };
  168. $('.main_introduce ul').empty();
  169. $('.main_introduce ul').append(theArr.join(''));
  170. if(data.data.list.length===0){
  171. $('.main_introduce ul').html("<div class='list_none'></div>") ;
  172. };
  173. // $('.totalCount').html("共" + data.data.totalCount + "条数据");
  174. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  175. var pageArr = [],
  176. firstNo = 1,
  177. endNo = 5;
  178. if (thePageNo > 3) {
  179. firstNo = thePageNo - 2;
  180. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  181. } else {
  182. endNo = Math.min(thePageLength, 5);
  183. };
  184. for (let i = firstNo; i <= endNo; i++) {
  185. if (i == thePageNo) {
  186. pageArr.push(
  187. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  188. );
  189. } else {
  190. pageArr.push(
  191. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  192. );
  193. }
  194. };
  195. $('.pageNumber').remove();
  196. $('.pagePre').after(pageArr.join(''));
  197. }
  198. });
  199. }
  200. if (window.location.search) {
  201. let theUrl = window.location.search
  202. theKeyword = theUrl.substring(1, theUrl.length);
  203. theKeyword = decodeURIComponent(theKeyword);
  204. $('#search_on input').val(theKeyword);
  205. };
  206. loadDate();
  207. var industryListArr = [],
  208. industryChildrenArr = [];
  209. industryListArr.push(['<li value="999" class="active">',
  210. '<span>',
  211. '不限',
  212. '</span>',
  213. '</li>',
  214. ].join(''));
  215. industryObject.map(function (item) {
  216. industryListArr.push(['<li value="' + item.value + '">',
  217. '<span>',
  218. item.label,
  219. '</span>',
  220. '</li>',
  221. ].join(''));
  222. });
  223. if (industryListArr && industryListArr.length) {
  224. $('#industryList').append(industryListArr.join(''));
  225. };
  226. $('#industryList li').click(function () {
  227. var theValue = this.value;
  228. $(this).siblings("li").removeClass("active");
  229. $(this).addClass("active");
  230. industryChildrenArr = [];
  231. industryChildrenArr.push(['<li value="999" class="active">',
  232. '<span>',
  233. '不限',
  234. '</span>',
  235. '</li>',
  236. ].join(''));
  237. if (theValue !== 999) {
  238. $('#industryChildrenBox').css("display", "block");
  239. industryObject.map(function (item) {
  240. if (item.value == theValue) {
  241. item.children.map(function (child) {
  242. industryChildrenArr.push(['<li value="' + child.value + '">',
  243. '<span>',
  244. child.label,
  245. '</span>',
  246. '</li>',
  247. ].join(''));
  248. });
  249. };
  250. });
  251. } else {
  252. $('#industryChildrenBox').css("display", "none");
  253. };
  254. if (industryChildrenArr && industryChildrenArr.length) {
  255. $('#industryChildrenList').empty();
  256. $('#industryChildrenList').append(industryChildrenArr.join(''));
  257. };
  258. theFieldA = this.value;
  259. theFieldB = '999';
  260. loadDate();
  261. });
  262. $('#industryChildrenList').on('click', 'li', function () {
  263. $(this).siblings("li").removeClass("active");
  264. $(this).addClass("active");
  265. theFieldB = this.value;
  266. loadDate();
  267. });
  268. $('#technologyModeList').on('click', 'li', function () {
  269. $(this).siblings("li").removeClass("active");
  270. $(this).addClass("active");
  271. theMode = this.value;
  272. loadDate();
  273. });
  274. $('#btt_search').click(function () {
  275. theKeyword = $('#search_on input').val();
  276. loadDate();
  277. });
  278. $('.pagination').on('click', 'li', function (e) {
  279. e.preventDefault();
  280. if (this.className === 'pagePre') {
  281. if (thePageNo > 1) {
  282. thePageNo = 1;
  283. loadDate(thePageNo);
  284. }
  285. } else if (this.className === 'pageNext') {
  286. if (thePageNo < thePageLength) {
  287. thePageNo = thePageLength;
  288. loadDate(thePageNo);
  289. }
  290. } else {
  291. var nextPageNo = $(this).children()[0].text;
  292. if (thePageNo != nextPageNo) {
  293. $(this).siblings("li").removeClass("active");
  294. $(this).addClass("active");
  295. thePageNo = nextPageNo;
  296. loadDate(thePageNo);
  297. };
  298. };
  299. });
  300. $('main_introduce').on('click', 'li', function () {
  301. var theId = $(this).children(".demandId")[0].value;
  302. var theType = $(this).children(".demandType")[0].value;
  303. window.open(globalConfig.context + '/portal/detail/demandDetail.html?id=' + theId + '&type=' + theType);
  304. })
  305. $('#industryList li').click(function(){
  306. var text_ind=$(this).find('span').text();
  307. $('.achievement_header ul li').eq(0).show()
  308. $('.achievement_header ul li').eq(0).find('p').text(text_ind);
  309. })
  310. //搜索城市下拉
  311. var addlength=provinceList.length;
  312. var soption='';
  313. for(var i=0;i<addlength;i++){
  314. soption+="<option value='"+provinceList[i].id+"'>"+provinceList[i].name+"</option>";
  315. };
  316. $('#selt').html(soption);
  317. //全部结果查询
  318. $('.achievement_header ul li img').click(function(){
  319. $(this).parent().hide();
  320. var lilen=$('.achievement_header ul li').css('display');
  321. if(lilen=='none'){
  322. $('#search_on input').val('');
  323. $('.searchs button').click();
  324. }
  325. });
  326. $('.text_replace').hide()
  327. // 搜索功能关联关键字
  328. $('.searchs button').click(function(e){
  329. e.preventDefault();
  330. var search_txt=$('#search_on input').val();
  331. $('.text_replace span').text(search_txt);
  332. if(search_txt==''){
  333. $('.text_replace').hide()
  334. }else{
  335. $('.text_replace').show()
  336. }
  337. })
  338. //点击技术类型
  339. $('#technologyModeList li').click(function(){
  340. $('.achievement_header ul li').eq(1).show()
  341. $(this).addClass('active').siblings().removeClass('active')
  342. var txt_tech=$(this).find('span').text();
  343. $('.achievement_header ul li').eq(1).find('p').text(txt_tech);
  344. })
  345. //点击搜索下面的字段快捷搜索
  346. $('.head_right ol li').click(function () {
  347. theKeyword = $(this).text();
  348. $('#technologyModeList li').eq(0).addClass('active').siblings().removeClass('active');
  349. $('#transferModeList li').eq(0).addClass('active').siblings().removeClass('active');
  350. $('.achievement_header ul li').eq(0).show().siblings().hide();
  351. $('.achievement_header ul li').eq(0).find('p').text(theKeyword);
  352. $('#search_on input').val(theKeyword);
  353. loadDate();
  354. });
  355. //点击行业分类
  356. $('#industryList li').click(function(){
  357. $('.achievement_header ul li').eq(0).show();
  358. var text_ind=$(this).find('span').text();
  359. $('.achievement_header ul li').eq(0).find('p').text(text_ind);
  360. })
  361. //排序下拉选择
  362. $('.head-left ul li p').click(function(){
  363. $(this).siblings().slideToggle(300);
  364. })
  365. $('.head-left ul li').mouseleave(function(){
  366. $(this).find('.time_select').slideUp(300);
  367. })
  368. $('.time_select ul li').click(function(){
  369. var txt=$(this).text();
  370. $(this).parents('.time_select').siblings('p').find('span').text(txt);
  371. $('.time_select').hide();
  372. });
  373. $('.timeSelect li').click(function(){
  374. var timeTxt=$(this).attr('value');
  375. $('head-left ul li:first-child').removeClass('active')
  376. dateSort=timeTxt;
  377. loadDate();
  378. })
  379. //价格
  380. $('.inp_select input').keyup(function(){
  381. var val_min=$(this).val();
  382. if(val_min<0){
  383. $(this).val('0')
  384. }
  385. })
  386. $('.inp_select button').click(function(){
  387. var minpri=$('.inp_select #minprice').val();
  388. var maxpri=$('.inp_select #maxprice').val();
  389. budgetCostLower=minpri;
  390. budgetCostUpper=maxpri;
  391. loadDate();
  392. })
  393. $('#industryList li:first-child').click(function(){
  394. theFieldA = $(this).attr('value');
  395. theFieldB = '999';
  396. loadDate();
  397. })
  398. })