123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- /*
- * @author:liting
- * @update:2018/09/07
- *
- */
- import 'css/bootstrap.less';
- import 'bootstrap/dist/js/bootstrap.js';
- import 'css/newMenu/public.css';
- import 'css/newMenu/header.css'
- import 'css/newMenu/adviser.css';
- import 'js/public.js';
- "use strict";
- $(function () {
- var thePageNo = 1,
- thePageLength = 1,
- dataList = {},
- pageSize = 15;
- init();
- function init() {
- pages();
- inpFun();
- search();
- };
- //一级界面跳转此页面
- function jump() {
- let hash = window.location.search;
- if (hash) {
- if (hash.indexOf('name') > -1 || hash.indexOf('topId') > -1 || hash.indexOf('secondId') > -1) {
- let newHash = hash.substr(1, hash.length)
- if (newHash.indexOf('name') > -1) {
- let names = newHash.split('=')
- dataList.name = decodeURIComponent(names[1])
- $('.demandSearch').val(dataList.name);
- }
- loadDate()
- }
- } else {
- dataList.name = "",
- loadDate();
- }
- }
- function loadDate(pageNo) {
- $('.loading').show();
- $.ajax({
- method: "get",
- dataType: "json",
- url: globalConfig.context + "/api/portal/identity/consultantList",
- data: {
- pageNo: pageNo || 1,
- pageSize: 15,
- name: dataList.name,
- },
- success: function (data) {
- var theArrs = [];
- if (data && data.error.length) {
- msg(data.error[0].message)
- };
- let times = new Date().getTime();
- if (data.data && data.data.list.length) {
- let nub = data.data.list.length;
- for (let i = 0; i < nub; i++) {
- let thisdata = data.data.list[i],txtCont='';
- switch(thisdata.consultantType){
- case 0:
- txtCont='专利代理人';
- break;
- case 1:
- txtCont='专利顾问';
- break;
- case 2:
- txtCont='版权顾问';
- break;
- case 3:
- txtCont='商标顾问';
- break;
- default:
- txtCont="暂无";
- }
- theArrs.push(`
- <li>
- <a href="${globalConfig.context}/portal/adviser/adviserDetail?id=${thisdata.id}">
- <div class="headPortrait">
- ${thisdata.personPortraitUrl&&thisdata.personPortraitUrl!=null?'<img src="'+globalConfig.avatarHost+'/upload'+thisdata.personPortraitUrl+'"/>':''}
- </div>
- <div class="txt">
- <h4><span class="name">${thisdata.username}</span><span class="position">${txtCont}</span></h4>
- <p>${thisdata.introduction?thisdata.introduction:'暂无描述'}</p>
- </div>
- </a>
- </li>
- `);
- };
- };
- $('.loading').hide().stop(true, true);
- $('.adviserList ul').empty();
- $('.adviserList ul').append(theArrs.join(''));
- $('.pagination_box').css('display', 'block');
- $('.inp').css('display', 'block');
- if (data.data.list.length === 0) {
- $('.adviserList ul').html("<div class='list_none'></div>");
- $('.pagination_box').css('display', 'none');
- $('.inp').css('display', 'none');
- };
- thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
- $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
- var pageArr = [],
- firstNo = 1,
- endNo = 5;
- if (thePageNo > 3) {
- firstNo = thePageNo - 2;
- endNo = Math.min((Number(thePageNo) + 2), thePageLength);
- } else {
- endNo = Math.min(thePageLength, 5);
- };
- for (let i = firstNo; i <= endNo; i++) {
- if (i == thePageNo) {
- pageArr.push(
- '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
- );
- } else {
- pageArr.push(
- '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
- );
- }
- };
- $('.pageNumber').remove();
- $('.pagePre').after(pageArr.join(''));
- }
- });
- }
- //f分页
- function pages() {
- $('.pagination').on('click', 'li', function (e) {
- e.preventDefault();
- if (this.className === 'pagePre') {
- if (thePageNo > 1) {
- thePageNo = 1;
- loadDate(thePageNo);
- }
- } else if (this.className === 'pageNext') {
- if (thePageNo < thePageLength) {
- thePageNo = thePageLength;
- loadDate(thePageNo);
- }
- } else {
- var nextPageNo = $(this).children()[0].text;
- if (thePageNo != nextPageNo) {
- $(this).siblings("li").removeClass("active");
- $(this).addClass("active");
- thePageNo = nextPageNo;
- loadDate(thePageNo);
- };
- };
- });
- }
- //输入跳转
- function inpFun() {
- $('.inp .btn').on('click', function () {
- let val = $(this).siblings().val();
- if (!isNaN(val) && val <= thePageLength && val > 0) {
- thePageNo = val;
- loadDate(thePageNo);
- } else {
- msg('请输入正确页码')
- }
- })
- }
- //搜索
- function search() {
- $('.searchBtn').click(function () {
- let val = $('.demandSearch').val();
- dataList.name = val;
- loadDate();
- })
- }
- /* 提示 */
- //提示框渐隐函数
- function msg(txt) {
- if ($('.smg').hasClass('active')) {
- return;
- }
- $('.smg').addClass('active');
- var lit = $('#msg').val(txt);
- setTimeout(function () {
- $('.smg').removeClass('active')
- $('#msg').val('');
- }, 2000)
- }
- })
|