index.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. $(function () {
  2. $("#copy_url").val(window.location.href)
  3. // 点击复制链接
  4. $(".copy").click(function (e) {
  5. var copyobject = document.getElementById("copy_url");
  6. copyobject.select();
  7. document.execCommand('copy');
  8. alert("提示:复制成功!");
  9. })
  10. var qrcode = new QRCode("qrcode");
  11. qrcode.makeCode(window.location.href);
  12. $.getUrlParam = function (name) {
  13. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  14. var r = window.location.search.substr(1).match(reg);
  15. if (r != null) return unescape(r[2]);
  16. return null;
  17. }
  18. if ($.getUrlParam('type') == 1) {
  19. // $(".first_2").html("相关公告")
  20. $(".first_1").html("公告内容")
  21. } else {
  22. // $(".first_2").html("相关公示")
  23. $(".first_1").html("公示内容")
  24. }
  25. var keyid = $.getUrlParam('kid');
  26. var dataUrl = '/nx/n/w/' + keyid;
  27. //获取url后的参数
  28. $.ajax({
  29. url: getServerHttp() + dataUrl,
  30. type: 'post',
  31. cache: false,
  32. dataType: 'json',
  33. success: function (data) {
  34. var data = ajaxDataParames(data);
  35. var applyTime = data.apply_date_end;
  36. var noticeTime = data.notice_end_time;
  37. var releaseTime = new Date(data.notice_release_time);
  38. if (applyTime > noticeTime || applyTime === noticeTime) {
  39. var endTime = new Date(applyTime);
  40. } else if (applyTime < noticeTime) {
  41. var endTime = new Date(noticeTime);
  42. }
  43. var times = releaseTime.getFullYear() + '-' + (releaseTime.getMonth() + 1) + '-' + releaseTime.getDate();
  44. $('.detailed-content-box').html(data.notice_content);
  45. $('.detailed-title h1').html(data.notice_title);
  46. $('.times').html(times);
  47. $.ajax({
  48. url: getServerHttp() + '/current_time',
  49. type: 'post',
  50. cache: false,
  51. dataType: 'json',
  52. success: function (res) {
  53. var res = ajaxDataParames(res);
  54. if (res.current_time > data.apply_date_end) {
  55. $('.position-box').css({
  56. 'display': 'none'
  57. });
  58. }
  59. }
  60. });
  61. if (data.notice_nature === "变更公告" || data.notice_nature === "延期公告" || data.notice_nature === "补充公告" || data.notice_nature ===
  62. "控制价" || data.notice_type === "候选人公示" || data.notice_type === "中标公示") {
  63. $('.position-box').css({
  64. 'display': 'none'
  65. });
  66. $('.origin-url a').attr('href', '../page_detailed/list.html?kid=' + data.reference_notice_id + '&type=' + $.getUrlParam('type'))
  67. } else if (data.notice_nature === "撤销公告") {
  68. $('.position-box').css({
  69. 'display': 'none'
  70. });
  71. $('.origin-url a').css({
  72. 'display': 'none'
  73. })
  74. } else {
  75. $('.origin-url a').css({
  76. 'display': 'none'
  77. });
  78. if (data.is_login) {
  79. if (data.res) {
  80. $('.position-box').css({
  81. 'display': 'none'
  82. });
  83. } else {
  84. if (data.tender_fee_type === '线下') {
  85. if (data.is_signup) {
  86. $('.bid-process a').attr('href', '/web-back/view/task/tender/sign_up/sign_up_form.html?tender_id=' + data.tender_id);
  87. } else {
  88. $.ajax({
  89. url: getServerHttp() + '/back/tender/sign_up/sign_up_form',
  90. type: 'post',
  91. dataType: 'json',
  92. data: {
  93. tender_id: data.tender_id
  94. },
  95. success: function (res) {
  96. var res = ajaxDataParames(res);
  97. $('.bid-process a').attr('href',
  98. '/web-back/view/task/tender/sign_up/offline_pay_form.html?signup_id=' + res.signup_id);
  99. }
  100. });
  101. }
  102. } else if (data.tender_fee_type === '线上') {
  103. $('.bid-process a').attr('href', '/web-back/view/task/tender/sign_up/sign_up_form.html?tender_id=' + data.tender_id);
  104. }
  105. }
  106. } else {
  107. $('.bid-process a').attr('href', '/web-back?kid=' + keyid);
  108. }
  109. };
  110. // 判断来源是否登录页
  111. if ($.getUrlParam('source')) {
  112. $('.bid-process a').click();
  113. }
  114. },
  115. error: function (xml, info, errorobj) {
  116. // console.log(xml);
  117. // console.log(info);
  118. // console.log(errorobj);
  119. // console.log('请求错误');
  120. }
  121. });
  122. //更多公告
  123. $.ajax({
  124. url: getServerHttp() + '/nx/n/list/notice',
  125. type: 'post',
  126. cache: false,
  127. dataType: 'json',
  128. success: function (data) {
  129. var data = ajaxDataParames(data);
  130. var doms = '';
  131. for (var i = 0; i < 5; i++) {
  132. doms += '<li><a title="' + data.pagePackage.data[i].notice_title + '" href="../page_detailed/list.html?kid=' + data.pagePackage.data[i].kid + '" target="_blank">' + data.pagePackage.data[i].notice_title + '</a></li>'
  133. }
  134. $('.more-notice-content ul').html(doms);
  135. }
  136. })
  137. announcement($.getUrlParam('kid'), $.getUrlParam('type'));
  138. })
  139. // 获取相关公告
  140. function announcement(id, type) {
  141. if (type == 1) {
  142. var url = getServerHttp() + "/nx/n/list/refer_notice?notice_id=" + id;
  143. } else {
  144. var url = getServerHttp() + "/nx/n/list/refer_notice?publicity_id=" + id;
  145. }
  146. $.ajax({
  147. url: url,
  148. type: 'post',
  149. cache: false,
  150. dataType: 'json',
  151. success: function (data) {
  152. var data = ajaxDataParames(data);
  153. if (data.length == 0) {
  154. $(".more_content").html("无");
  155. } else {
  156. var doms = "";
  157. var iDom = "";
  158. for (var i in data) {
  159. var iconStyle = data[i].notice_nature;
  160. if (iconStyle === "正常公告" || iconStyle === "再次公告") {
  161. iDom = '<i class="icons greens">新</i>';
  162. } else if (iconStyle === "变更公告") {
  163. iDom = '<i class="icons blues">变更</i>';
  164. } else if (iconStyle === "延期公告") {
  165. iDom = '<i class="icons blues">延期</i>';
  166. } else if (iconStyle === "补充公告") {
  167. iDom = '<i class="icons blues">补充</i>';
  168. } else if (iconStyle === "控制价") {
  169. iDom = '<i class="icons blues">控价</i>';
  170. } else if (iconStyle === "撤销公告") {
  171. iDom = '<i class="icons reds">撤销</i>';
  172. }
  173. function type(name) {
  174. if (name == "中标公示" || name == "候选人公示") {
  175. return 2
  176. } else if (name = "招标公告") {
  177. return 1
  178. }
  179. }
  180. var porjectUrl = './list.html?kid=' + data[i].kid + '&type=' + type(data[i].notice_type);
  181. doms += '<li>' + iDom + '<a href="' + porjectUrl + '" class="names" target="_blank" title="' + data[i].notice_title +
  182. '">' + data[i].notice_title + '</a><span class="times_list">' + checkDateTime(data[i].notice_release_time) +
  183. '</span></li>';
  184. }
  185. $('.more_content').html(doms);
  186. }
  187. }
  188. })
  189. }
  190. function copy() {
  191. var createInput = document.createElement('input');
  192. createInput.value = window.location.href;
  193. document.body.appendChild(createInput);
  194. createInput.select(); // 选择对象
  195. document.execCommand("Copy"); // 执行浏览器复制命令
  196. createInput.className = 'createInput';
  197. createInput.style.display = 'none';
  198. layui.use(['layer', 'carousel'], function () {
  199. var layer = layui.layer;
  200. layer.msg('复制成功,可以粘贴了!'); //没有layui的可以改为alert
  201. })
  202. };