demand.js 13 KB

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