facilitator.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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/facilitator/facilitator.css';
  6. import 'js/public.js';
  7. $(function(){
  8. function GetQueryString(name){
  9. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  10. var r = window.location.search.substr(1).match(reg);
  11. if(r!=null)return unescape(r[2]); return null;
  12. }
  13. var UID=GetQueryString("uid");
  14. var pageSize = 15,
  15. thePageNo = 1,
  16. thePageLength = 1;
  17. init();
  18. function init() {
  19. pages();
  20. inpFun();
  21. loadDate();
  22. $('.onSelect .preFirst').css('display', 'none')
  23. $('.onSelect .next').css('display', 'none')
  24. };
  25. if(window.location.hash&&window.location.hash.indexOf('2')>-1){
  26. let hash = window.location.hash,
  27. ind = [...hash][1];
  28. $('.facJuan>div').eq(ind).show().siblings().hide();
  29. $('.facTab span').eq(ind).addClass("facActive").siblings().removeClass('facActive');
  30. loadJuan();
  31. }else{
  32. $('.facJuan>div').eq(0).show().siblings().hide();
  33. $('.facTab span').eq(0).addClass("facActive").siblings().removeClass('facActive');
  34. }
  35. $(".facTab>span").click(function(){
  36. $(this).addClass("facActive").siblings().removeClass('facActive');
  37. var facIndex=$(this).index();
  38. $('.facJuan>div').eq(facIndex).show().siblings().hide();
  39. if(facIndex==2){
  40. loadJuan()
  41. }
  42. })
  43. //领劵
  44. function liJ(){
  45. $('.listJ ul li a').click(function(){
  46. let loginTxt=$('.head_login')[0];
  47. if(loginTxt&&($(loginTxt).text())=='登录'){
  48. $('.head_login').click();
  49. window.location.hash='jump';
  50. return false;
  51. }
  52. let ids = $(this).siblings('input').val();
  53. $.ajax({
  54. method: "post",
  55. dataType: "json",
  56. url: globalConfig.context + "/open/userGetVoucher",
  57. data: {
  58. vid:ids
  59. },
  60. success: function (data) {
  61. if (data.error && data.error.length) {
  62. msg(data.error[0].message);
  63. return;
  64. }
  65. msg('领取成功,请至个人中心查看。')
  66. loadJuan()
  67. }
  68. })
  69. })
  70. }
  71. //获取卷
  72. function loadJuan(){
  73. $.ajax({
  74. method: "get",
  75. dataType: "json",
  76. url: globalConfig.context + "/open/getUserVoucher",
  77. data: {
  78. pageNo: 1,
  79. pageSize: 999999,
  80. uid:UID
  81. },
  82. success: function (data) {
  83. if (data.error && data.error.length) {
  84. msg(data.error[0].message);
  85. return ;
  86. }
  87. let htmls = '';
  88. if(!data.data.list.length){
  89. htmls="<div class='Nodata'>暂无优惠劵<div>";
  90. $('.listJ ul').html(htmls);
  91. return;
  92. }
  93. data.data.list.map(item=>{
  94. htmls+=`
  95. <li>
  96. <div>
  97. <p>${item.money} <span>枚</span></p>
  98. <div class="listTxt">
  99. ${!item.isGet?'<a href="javascript:;">立即领取</a>':'<span class="get">已领取</span>'}
  100. <input type='hidden' value="${item.id}">
  101. </div>
  102. </div>
  103. <div class="ypTxt">
  104. <p>限定:${item.name}</p>
  105. <p>有效天数:${item.durationDay} 天</p>
  106. </div>
  107. </li>
  108. `
  109. })
  110. $('.listJ ul').html(htmls);
  111. liJ();
  112. }
  113. })
  114. };
  115. function loadDate(pageNo) {
  116. $.ajax({
  117. method: "get",
  118. dataType: "json",
  119. url: globalConfig.context + "/open/user/projectList",
  120. data: {
  121. pageNo: pageNo || 1,
  122. pageSize: 15,
  123. uid:UID
  124. },
  125. success: function (data) {
  126. if (data.error && data.error.length) {
  127. msg(data.error[0].message);
  128. }else if(data.error==""){
  129. var contHtml="";
  130. var dataList=data.data.list;
  131. if(dataList.length){
  132. for(var a=0;a<dataList.length;a++){
  133. var name=dataList[a].name?dataList[a].name:"";
  134. var imgUrl=dataList[a].maxImgUrl?globalConfig.avatarUploadHost+dataList[a].maxImgUrl:globalConfig.portalHost+"/img/initPic/serviceInit.jpg"
  135. contHtml+=`<div>
  136. <img src="${imgUrl}" alt="" />
  137. <p>${name}</p>
  138. <input type="hidden" dates="${dataList[a].id}" datee="${dataList[a].module}"/>
  139. </div>`;
  140. }
  141. }
  142. $(".facAll").html(contHtml);
  143. }else{
  144. return;
  145. }
  146. //分页部分的处理
  147. $('.pagination_box').css('display', 'block');
  148. $('.inp').css('display', 'block');
  149. if (data.data.list&&data.data.list.length === 0) {
  150. $('.achievementHot .hotList').html("<div class='list_none'></div>");
  151. $('.pagination_box').css('display', 'none')
  152. $('.inp').css('display', 'none');
  153. };
  154. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  155. $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
  156. var pageArr = [],
  157. firstNo = 1,
  158. endNo = 5;
  159. if (thePageNo > 3) {
  160. firstNo = thePageNo - 2;
  161. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  162. } else {
  163. endNo = Math.min(thePageLength, 5);
  164. };
  165. for (let i = firstNo; i <= endNo; i++) {
  166. if (i == thePageNo) {
  167. pageArr.push(
  168. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  169. );
  170. } else {
  171. pageArr.push(
  172. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  173. );
  174. }
  175. };
  176. $('.pageNumber').remove();
  177. $('.pagePre').after(pageArr.join(''));
  178. }
  179. });
  180. }
  181. //f分页
  182. function pages() {
  183. $('.pagination').on('click', 'li', function (e) {
  184. e.preventDefault();
  185. if (this.className === 'pagePre') {
  186. if (thePageNo > 1) {
  187. thePageNo = 1;
  188. loadDate(thePageNo);
  189. }
  190. } else if (this.className === 'pageNext') {
  191. if (thePageNo < thePageLength) {
  192. thePageNo = thePageLength;
  193. loadDate(thePageNo);
  194. }
  195. } else {
  196. var nextPageNo = $(this).children()[0].text;
  197. if (thePageNo != nextPageNo) {
  198. $(this).siblings("li").removeClass("active");
  199. $(this).addClass("active");
  200. thePageNo = nextPageNo;
  201. loadDate(thePageNo);
  202. };
  203. };
  204. });
  205. }
  206. //输入跳转
  207. function inpFun() {
  208. $('.inp .btn').on('click', function () {
  209. let val = $(this).siblings().val();
  210. if (!isNaN(val) && val <= thePageLength && val > 0) {
  211. thePageNo = val;
  212. loadDate(thePageNo);
  213. }else{
  214. msg('请输入正确页码')
  215. }
  216. })
  217. }
  218. /* 提示 */
  219. //提示框渐隐函数
  220. function msg(txt) {
  221. if($('.smg').hasClass('active')){
  222. return ;
  223. }
  224. $('.smg').addClass('active');
  225. var lit = $('#msg').val(txt);
  226. setTimeout(function () {
  227. $('.smg').removeClass('active');
  228. $('#msg').val('');
  229. }, 2000)
  230. }
  231. $(".facAll").on("click","div",function(){
  232. var id=$(this).children("input").attr("dates");
  233. var module=$(this).children("input").attr("datee");
  234. if(module==1){
  235. window.open(globalConfig.context+"/portal/service/patentDetail?id="+id);
  236. }else{
  237. window.open(globalConfig.context+"/portal/service/serviceDetail?id="+id);
  238. }
  239. })
  240. })