adviser.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * @author:liting
  3. * @update:2018/09/07
  4. *
  5. */
  6. import 'css/bootstrap.less';
  7. import 'bootstrap/dist/js/bootstrap.js';
  8. import 'css/newMenu/public.css';
  9. import 'css/newMenu/header.css'
  10. import 'css/newMenu/adviser.css';
  11. import 'js/public.js';
  12. "use strict";
  13. $(function () {
  14. var thePageNo = 1,
  15. thePageLength = 1,
  16. dataList = {},
  17. pageSize = 15;
  18. init();
  19. function init() {
  20. pages();
  21. inpFun();
  22. search();
  23. };
  24. //一级界面跳转此页面
  25. function jump() {
  26. let hash = window.location.search;
  27. if (hash) {
  28. if (hash.indexOf('name') > -1 || hash.indexOf('topId') > -1 || hash.indexOf('secondId') > -1) {
  29. let newHash = hash.substr(1, hash.length)
  30. if (newHash.indexOf('name') > -1) {
  31. let names = newHash.split('=')
  32. dataList.name = decodeURIComponent(names[1])
  33. $('.demandSearch').val(dataList.name);
  34. }
  35. loadDate()
  36. }
  37. } else {
  38. dataList.name = "",
  39. loadDate();
  40. }
  41. }
  42. function loadDate(pageNo) {
  43. $('.loading').show();
  44. $.ajax({
  45. method: "get",
  46. dataType: "json",
  47. url: globalConfig.context + "/api/portal/identity/consultantList",
  48. data: {
  49. pageNo: pageNo || 1,
  50. pageSize: 15,
  51. name: dataList.name,
  52. },
  53. success: function (data) {
  54. var theArrs = [];
  55. if (data && data.error.length) {
  56. msg(data.error[0].message)
  57. };
  58. let times = new Date().getTime();
  59. if (data.data && data.data.list.length) {
  60. let nub = data.data.list.length;
  61. for (let i = 0; i < nub; i++) {
  62. let thisdata = data.data.list[i],txtCont='';
  63. switch(thisdata.consultantType){
  64. case 0:
  65. txtCont='专利代理人';
  66. break;
  67. case 1:
  68. txtCont='专利顾问';
  69. break;
  70. case 2:
  71. txtCont='版权顾问';
  72. break;
  73. case 3:
  74. txtCont='商标顾问';
  75. break;
  76. default:
  77. txtCont="暂无";
  78. }
  79. theArrs.push(`
  80. <li>
  81. <a href="${globalConfig.context}/portal/adviser/adviserDetail?id=${thisdata.id}">
  82. <div class="headPortrait">
  83. ${thisdata.personPortraitUrl&&thisdata.personPortraitUrl!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.personPortraitUrl+'"/>':''}
  84. </div>
  85. <div class="txt">
  86. <h4><span class="name">${thisdata.username}</span><span class="position">${txtCont}</span></h4>
  87. <p>${thisdata.introduction?thisdata.introduction:'暂无描述'}</p>
  88. </div>
  89. </a>
  90. </li>
  91. `);
  92. };
  93. };
  94. $('.loading').hide().stop(true, true);
  95. $('.adviserList ul').empty();
  96. $('.adviserList ul').append(theArrs.join(''));
  97. $('.pagination_box').css('display', 'block');
  98. $('.inp').css('display', 'block');
  99. if (data.data.list.length === 0) {
  100. $('.adviserList ul').html("<div class='list_none'></div>");
  101. $('.pagination_box').css('display', 'none');
  102. $('.inp').css('display', 'none');
  103. };
  104. thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
  105. $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
  106. var pageArr = [],
  107. firstNo = 1,
  108. endNo = 5;
  109. if (thePageNo > 3) {
  110. firstNo = thePageNo - 2;
  111. endNo = Math.min((Number(thePageNo) + 2), thePageLength);
  112. } else {
  113. endNo = Math.min(thePageLength, 5);
  114. };
  115. for (let i = firstNo; i <= endNo; i++) {
  116. if (i == thePageNo) {
  117. pageArr.push(
  118. '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
  119. );
  120. } else {
  121. pageArr.push(
  122. '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
  123. );
  124. }
  125. };
  126. $('.pageNumber').remove();
  127. $('.pagePre').after(pageArr.join(''));
  128. }
  129. });
  130. }
  131. //f分页
  132. function pages() {
  133. $('.pagination').on('click', 'li', function (e) {
  134. e.preventDefault();
  135. if (this.className === 'pagePre') {
  136. if (thePageNo > 1) {
  137. thePageNo = 1;
  138. loadDate(thePageNo);
  139. }
  140. } else if (this.className === 'pageNext') {
  141. if (thePageNo < thePageLength) {
  142. thePageNo = thePageLength;
  143. loadDate(thePageNo);
  144. }
  145. } else {
  146. var nextPageNo = $(this).children()[0].text;
  147. if (thePageNo != nextPageNo) {
  148. $(this).siblings("li").removeClass("active");
  149. $(this).addClass("active");
  150. thePageNo = nextPageNo;
  151. loadDate(thePageNo);
  152. };
  153. };
  154. });
  155. }
  156. //输入跳转
  157. function inpFun() {
  158. $('.inp .btn').on('click', function () {
  159. let val = $(this).siblings().val();
  160. if (!isNaN(val) && val <= thePageLength && val > 0) {
  161. thePageNo = val;
  162. loadDate(thePageNo);
  163. } else {
  164. msg('请输入正确页码')
  165. }
  166. })
  167. }
  168. //搜索
  169. function search() {
  170. $('.searchBtn').click(function () {
  171. let val = $('.demandSearch').val();
  172. dataList.name = val;
  173. loadDate();
  174. })
  175. }
  176. /* 提示 */
  177. //提示框渐隐函数
  178. function msg(txt) {
  179. if ($('.smg').hasClass('active')) {
  180. return;
  181. }
  182. $('.smg').addClass('active');
  183. var lit = $('#msg').val(txt);
  184. setTimeout(function () {
  185. $('.smg').removeClass('active')
  186. $('#msg').val('');
  187. }, 2000)
  188. }
  189. })