demand.js 13 KB

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