demandDetail.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // import '../../css/bootstrap.less';
  2. // import 'bootstrap/dist/js/bootstrap.js';
  3. import 'css/newMenu/public.css';
  4. import 'css/newMenu/header.css'
  5. import '../../css/main_banner.css';
  6. import '../../js/public.js';
  7. import '../../js/main_banner.js';
  8. import '../../css/technologyTrading/demandDetail.css';
  9. import 'js/newMenu/publicComment';
  10. (function(){
  11. var isIntereste=$("#isInterester").attr("isInterester");
  12. if(isIntereste==0){
  13. $(".loves>span:first-child").removeClass("box_love").addClass("bj_love");
  14. }else if(isIntereste==1){
  15. $(".loves>span:first-child").removeClass("bj_love").addClass("box_love");
  16. }
  17. $(".fine").on('click', 'div.pointer', function () {
  18. var theId = $(this).children("p.demandId").html();
  19. var thetype=$(this).children("p.demandTyp").html();
  20. window.open(globalConfig.context + '/portal/technologyTrading/demandDetail?id=' + theId+'&type='+thetype );
  21. });
  22. $(".main_introduce ul").on("click","li",function(){
  23. var theId = $(this).children("div").children("p.demandId").html();
  24. var thetype=$(this).children("div").children("p.demandTyp").html();
  25. window.open(globalConfig.context + '/portal/technologyTrading/demandDetail?id=' + theId+'&type='+thetype );
  26. })
  27. //收藏
  28. $('.collection p').eq(0).click(function () {
  29. window.location.hash='jump';
  30. let heart = $('.heart');
  31. if (heart.hasClass('active')) {
  32. collectionApi(0) //取消收藏
  33. } else {
  34. collectionApi(1) //收藏
  35. }
  36. })
  37. let hash = window.location.search,
  38. hashArr =hash.split('&'),
  39. idArr = hashArr[0].split('='),
  40. ids =idArr[1];
  41. function collectionApi(index) {
  42. let url = index?'/api/user/portal/demandInterest':'/api/user/portal/demandCancelInterest'
  43. $.ajax({
  44. method: "post",
  45. dataType: "json",
  46. url: globalConfig.context + url,
  47. data: {
  48. id:ids
  49. },
  50. success: function (data) {
  51. if (data.error && data.error.length) {
  52. $('#msg').val(data.error[0].message);
  53. msg();
  54. }else{
  55. if(!index){
  56. $('.heart').removeClass('active');
  57. }else{
  58. $('.heart').addClass('active');
  59. }
  60. $('#msg').val(index?'收藏成功,请至个人中心查看.':'撤销收藏');
  61. msg();
  62. }
  63. }
  64. })
  65. }
  66. //点击感兴趣
  67. var t=0;
  68. $('.basic .loves').click(function(){
  69. var theId=$("#demand_id").attr("val");
  70. var islogin=$("#isLogin").attr("islogin");
  71. if(islogin=="true"){
  72. $(".head_login").click();
  73. }
  74. if($(this).find('span:first-child').hasClass('box_love')&&islogin=="false"){
  75. t=$('.dem_number').text();
  76. $('.dem_number').text(parseInt(t)+1);
  77. $(this).find('span:first-child').addClass('bj_love').removeClass('box_love');
  78. $.ajax({
  79. method: "post",
  80. dataType: "json",
  81. url: globalConfig.context + "/api/user/portal/demandInterest",
  82. data: {
  83. id:theId
  84. },
  85. success: function (data) {
  86. }
  87. });
  88. return false;
  89. }
  90. if($(this).find('span:first-child').hasClass('bj_love')&&islogin=="false"){
  91. t=$('.dem_number').text();
  92. $('.dem_number').text(parseInt(t)-1)
  93. $(this).find('span:first-child').addClass('box_love').removeClass('bj_love')
  94. $.ajax({
  95. method: "post",
  96. dataType: "json",
  97. url: globalConfig.context + "/api/user/portal/demandCancelInterest",
  98. data: {
  99. id:theId
  100. },
  101. success: function (data) {
  102. }
  103. });
  104. }
  105. })
  106. $("#purchase").click(function(){
  107. var isLogin=$("#isLogin").attr("islogin");
  108. var theId = $("#Id_").attr('val');
  109. var thetype=$("#ownerType_").attr('typ');
  110. if(isLogin=="false"){
  111. window.open(globalConfig.context + '/portal/technologyTrading/demandOrder?id=' + theId+'&type='+thetype );
  112. }else{
  113. $(".head_login").click();
  114. }
  115. });
  116. //提示框渐隐函数
  117. function msg() {
  118. if($('.smg').hasClass('active')){
  119. return ;
  120. }
  121. $('.smg').addClass('active')
  122. setTimeout(function () {
  123. $('.smg').removeClass('active')
  124. $('#msg').val('');
  125. }, 2000)
  126. }
  127. })();