demand.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. theKeyword=localStorage.getItem("keyWord");
  38. var typ=localStorage.getItem("pageType");
  39. localStorage.removeItem("keyWord");
  40. localStorage.removeItem("pageType");
  41. loadDate();
  42. function loadDate(pageNo) {
  43. $.ajax({
  44. method: "get",
  45. dataType: "json",
  46. url: globalConfig.context + "/portal/search/demandList",
  47. data: {
  48. pageNo: pageNo || 1,
  49. pageSize: pageSize,
  50. keyword: theKeyword,
  51. sign: 0,
  52. demandType: theMode != 999 ? theMode : undefined,
  53. industryCategoryA: theFieldA != 999 ? theFieldA : undefined,
  54. industryCategoryB: theFieldB != 999 ? theFieldB : undefined,
  55. dateSort:dateSort,
  56. budgetCostLower:budgetCostLower,
  57. budgetCostUpper:budgetCostUpper
  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. if(thisdata.pictureUrl==null){
  65. thisdata.pictureUrl=''
  66. }
  67. var imgUrl=thisdata.pictureUrl!=''?globalConfig.avatarHost + '/upload' +thisdata.pictureUrl:globalConfig.avatarHost+ "/upload/default/xuqiuimg_null.png";
  68. var star='';
  69. for(var n=0;n<thisdata.maturity;n++){
  70. star+='<li></li>'
  71. }
  72. theArr.push([
  73. '<li val="'+thisdata.id+'" typ="'+thisdata.dataCategory+'">', //图片地址
  74. '<img src="' +imgUrl + '"/>',
  75. '<div class="list_text">',
  76. '<p>行业<span>' + (thisdata.industryCategoryA?getIndustryCategory(thisdata.industryCategoryA, thisdata.industryCategoryB):"未知行业") + '</span></p>',
  77. '<p>名称<span title=' + thisdata.name + '>' + (thisdata.name?thisdata.name:"未知名称") + '</span></p>',
  78. '<p>类型<span>' + (thisdata.demandType ? categoryObj[thisdata.demandType] : '类型未知') + '</span></p>',
  79. '<p class="money">预算<span>'+ (thisdata.budgetCost ? (thisdata.budgetCost + '万元') : '价格面议') + '</span></p>',
  80. '<a href="#">了解详情</a>',
  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. }
  120. if (window.location.search) {
  121. let theUrl = window.location.search
  122. theKeyword = theUrl.substring(1, theUrl.length);
  123. theKeyword = decodeURIComponent(theKeyword);
  124. $('#search_on input').val(theKeyword);
  125. };
  126. loadDate();
  127. var industryListArr = [],
  128. industryChildrenArr = [];
  129. industryListArr.push(['<li value="999" class="active">',
  130. '<span>',
  131. '不限',
  132. '</span>',
  133. '</li>',
  134. ].join(''));
  135. industryObject.map(function (item) {
  136. industryListArr.push(['<li value="' + item.value + '">',
  137. '<span>',
  138. item.label,
  139. '</span>',
  140. '</li>',
  141. ].join(''));
  142. });
  143. if (industryListArr && industryListArr.length) {
  144. $('#industryList').append(industryListArr.join(''));
  145. };
  146. $('#industryList li').click(function () {
  147. var theValue = this.value;
  148. $(this).siblings("li").removeClass("active");
  149. $(this).addClass("active");
  150. industryChildrenArr = [];
  151. industryChildrenArr.push(['<li value="999" class="active">',
  152. '<span>',
  153. '不限',
  154. '</span>',
  155. '</li>',
  156. ].join(''));
  157. if (theValue !== 999) {
  158. $('#industryChildrenBox').css("display", "block");
  159. industryObject.map(function (item) {
  160. if (item.value == theValue) {
  161. item.children.map(function (child) {
  162. industryChildrenArr.push(['<li value="' + child.value + '">',
  163. '<span>',
  164. child.label,
  165. '</span>',
  166. '</li>',
  167. ].join(''));
  168. });
  169. };
  170. });
  171. } else {
  172. $('#industryChildrenBox').css("display", "none");
  173. };
  174. if (industryChildrenArr && industryChildrenArr.length) {
  175. $('#industryChildrenList').empty();
  176. $('#industryChildrenList').append(industryChildrenArr.join(''));
  177. };
  178. theFieldA = this.value;
  179. theFieldB = '999';
  180. loadDate();
  181. });
  182. $('#industryChildrenList').on('click', 'li', function () {
  183. $(this).siblings("li").removeClass("active");
  184. $(this).addClass("active");
  185. theFieldB = this.value;
  186. loadDate();
  187. });
  188. $('#technologyModeList').on('click', 'li', function () {
  189. $(this).siblings("li").removeClass("active");
  190. $(this).addClass("active");
  191. theMode = this.value;
  192. loadDate();
  193. });
  194. $('#btt_search').click(function () {
  195. theKeyword = $('#search_on input').val();
  196. loadDate();
  197. });
  198. $('.pagination').on('click', 'li', function (e) {
  199. e.preventDefault();
  200. var texton=$("#search_on input").val();
  201. if (this.className === 'pagePre'){
  202. if (thePageNo > 1) {
  203. thePageNo = 1;
  204. loadDate(thePageNo);
  205. }
  206. } else if (this.className === 'pageNext') {
  207. if (thePageNo < thePageLength) {
  208. thePageNo = thePageLength;
  209. loadDate(thePageNo);
  210. }
  211. } else {
  212. var nextPageNo = $(this).children()[0].text;
  213. if (thePageNo != nextPageNo) {
  214. $(this).siblings("li").removeClass("active");
  215. $(this).addClass("active");
  216. thePageNo = nextPageNo;
  217. loadDate(thePageNo);
  218. };
  219. };
  220. });
  221. $('main_introduce').on('click', 'li', function () {
  222. var theId = $(this).children(".demandId")[0].value;
  223. var theType = $(this).children(".demandType")[0].value;
  224. window.open(globalConfig.context + '/portal/detail/demandDetail.html?id=' + theId + '&type=' + theType);
  225. })
  226. $('#industryList li').click(function(){
  227. var text_ind=$(this).find('span').text();
  228. $('.achievement_header ul li').eq(0).show()
  229. $('.achievement_header ul li').eq(0).find('p').text(text_ind);
  230. })
  231. //搜索城市下拉
  232. var addlength=provinceList.length;
  233. var soption='';
  234. for(var i=0;i<addlength;i++){
  235. soption+="<option value='"+provinceList[i].id+"'>"+provinceList[i].name+"</option>";
  236. };
  237. $('#selt').html(soption);
  238. //全部结果查询
  239. $('.achievement_header ul li img').click(function(){
  240. $(this).parent().hide();
  241. var lilen=$('.achievement_header ul li').css('display');
  242. if(lilen=='none'){
  243. $('#search_on input').val('');
  244. $('.searchs button').click();
  245. }
  246. });
  247. $('.text_replace').hide()
  248. // 搜索功能关联关键字
  249. $('.searchs button').click(function(e){
  250. e.preventDefault();
  251. var search_txt=$('#search_on input').val();
  252. $('.text_replace span').text(search_txt);
  253. if(search_txt==''){
  254. $('.text_replace').hide()
  255. }else{
  256. $('.text_replace').show()
  257. }
  258. })
  259. //点击技术类型
  260. $('#technologyModeList li').click(function(){
  261. $('.achievement_header ul li').eq(1).show()
  262. $(this).addClass('active').siblings().removeClass('active')
  263. var txt_tech=$(this).find('span').text();
  264. $('.achievement_header ul li').eq(1).find('p').text(txt_tech);
  265. })
  266. //点击搜索下面的字段快捷搜索
  267. $('.head_right ol li').click(function () {
  268. //theKeyword = $(this).text();
  269. theFieldA=$(this).attr("val");
  270. $('#technologyModeList li').eq(0).addClass('active').siblings().removeClass('active');
  271. $('#transferModeList li').eq(0).addClass('active').siblings().removeClass('active');
  272. $('.text_replace').show();
  273. $('.text_replace span').text(theKeyword);
  274. $('#search_on input').val(theKeyword);
  275. loadDate();
  276. });
  277. //点击行业分类
  278. $('#industryList li').click(function(){
  279. $('.achievement_header ul li').eq(0).show();
  280. var text_ind=$(this).find('span').text();
  281. $('.achievement_header ul li').eq(0).find('p').text(text_ind);
  282. })
  283. //排序下拉选择
  284. $('.head-left ul li p').click(function(){
  285. $(this).siblings().slideToggle(300);
  286. })
  287. $('.head-left ul li').mouseleave(function(){
  288. $(this).find('.time_select').slideUp(300);
  289. })
  290. $('.time_select ul li').click(function(){
  291. var txt=$(this).text();
  292. $(this).parents('.time_select').siblings('p').find('span').text(txt);
  293. $('.time_select').hide();
  294. });
  295. $('.timeSelect li').click(function(){
  296. var timeTxt=$(this).attr('value');
  297. $('.head-left ul li:first-child').removeClass('active')
  298. dateSort=timeTxt;
  299. loadDate();
  300. })
  301. //价格
  302. $('.inp_select input').keyup(function(){
  303. var val_min=$(this).val();
  304. if(val_min<0){
  305. $(this).val('0')
  306. }
  307. })
  308. $('.inp_select button').click(function(){
  309. var minpri=$('.inp_select #minprice').val();
  310. var maxpri=$('.inp_select #maxprice').val();
  311. budgetCostLower=minpri;
  312. budgetCostUpper=maxpri;
  313. loadDate();
  314. })
  315. $('#industryList li:first-child').click(function(){
  316. theFieldA = $(this).attr('value');
  317. theFieldB = '999';
  318. loadDate();
  319. })
  320. })