demand.js 11 KB

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