index.html 16.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>绿纤协同平台</title>
  <script src="config.js"></script>
  <script src="auth-utils.js"></script>
  <style>
    body {
      margin: 0;
      min-height: 100vh;
      background: #e8f5e9;
      font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    .header {
      width: 100%;
      background: linear-gradient(120deg, #43e97b 0%, #38f9d7 100%);
      border-bottom-left-radius: 24px;
      border-bottom-right-radius: 24px;
      padding: 32px 0 24px 0;
      position: relative;
      box-shadow: 0 2px 12px 0 rgba(67, 233, 123, 0.08);
      text-align: center;
    }
    .header-title {
      color: #fff;
      font-size: 1.18em;
      font-weight: bold;
      letter-spacing: 2px;
      margin-bottom: 8px;
    }
    .header-desc {
      color: #e0f2f1;
      font-size: 0.98em;
      margin-bottom: 10px;
    }
    .header-illustration {
      width: 60px;
      height: 60px;
      margin: 0 auto;
      margin-bottom: -18px;
      background: rgba(255,255,255,0.12);
      border-radius: 16px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .summary-card {
      width: 90%;
      max-width: 420px;
      background: #fff;
      border-radius: 14px;
      box-shadow: 0 2px 12px 0 rgba(67, 233, 123, 0.08);
      margin: -28px auto 18px auto;
      display: flex;
      justify-content: space-between;
      padding: 14px 10px;
      position: relative;
      z-index: 2;
    }
    .summary-item {
      flex: 1;
      text-align: center;
      color: #388e3c;
    }
    .summary-item .num {
      font-size: 1.18em;
      font-weight: bold;
      color: #43a047;
      margin-bottom: 2px;
      display: block;
    }
    .summary-item .label {
      font-size: 0.92em;
      color: #6a9c6a;
    }
    .section-title {
      width: 90%;
      max-width: 420px;
      margin: 0 auto 8px auto;
      font-size: 1.05em;
      color: #388e3c;
      font-weight: bold;
      letter-spacing: 1px;
      padding-left: 2px;
    }
    .func-card {
      width: 90%;
      /* max-width: 420px; */
      background: #fff;
      border-radius: 14px;
      box-shadow: 0 2px 12px 0 rgba(67, 233, 123, 0.08);
      padding: 18px 0 8px 0;
      margin: 0 auto 18px auto;
    }
    .icon-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 18px 0;
      width: 100%;
      justify-items: center;
    }
    .icon-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #e8f5e9 60%, #c8e6c9 100%);
      border-radius: 16px;
      box-shadow: 0 2px 8px #c8e6c9;
      padding: 14px 0 8px 0;
      text-decoration: none;
      color: #388e3c;
      transition: box-shadow 0.18s, background 0.18s;
      border: none;
      width: 70px;
      height: 80px;
    }
    .icon-btn:active, .icon-btn:hover {
      box-shadow: 0 4px 16px #a5d6a7;
      background: linear-gradient(135deg, #b2dfdb 60%, #e8f5e9 100%);
    }
    .icon {
      width: 32px;
      height: 32px;
      margin-bottom: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .icon svg {
      width: 100%;
      height: 100%;
      fill: #43a047;
    }
    .icon-label {
      font-size: 0.98em;
      color: #388e3c;
      margin-top: 2px;
      letter-spacing: 1px;
    }
    .bottom-nav {
      position: fixed;
      left: 0; right: 0; bottom: 0;
      width: 100vw;
      background: #fff;
      border-top: 1.5px solid #e0f2f1;
      display: flex;
      justify-content: space-around;
      align-items: center;
      height: 54px;
      z-index: 10;
      box-shadow: 0 -2px 12px 0 rgba(67, 233, 123, 0.06);
    }
    .nav-item {
      flex: 1;
      text-align: center;
      color: #6a9c6a;
      font-size: 0.98em;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100%;
      text-decoration: none;
      transition: color 0.18s;
    }
    .nav-item.active {
      color: #43a047;
      font-weight: bold;
    }
    .nav-item .nav-icon {
      width: 22px;
      height: 22px;
      margin-bottom: 2px;
      display: inline-block;
    }
    @media (max-width: 520px) {
      .header { padding: 24px 0 18px 0; }
      .header-illustration { width: 44px; height: 44px; }
      .summary-card, .func-card, .section-title { width: 90%; }
      .icon-btn { width: 60px; height: 70px; }
      .icon { width: 26px; height: 26px; }
      .bottom-nav { height: 48px; }
      .nav-item { font-size: 0.93em; }
    }

    /* 等待效果样式 */
    .loading-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(255, 255, 255, 0.95);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 9999;
      backdrop-filter: blur(4px);
    }

    .loading-overlay.show {
      display: flex;
    }

    .loading-spinner {
      width: 60px;
      height: 60px;
      border: 4px solid #e8f5e9;
      border-top: 4px solid #43a047;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin: 0 auto;
    }

    .loading-text {
      margin-top: 20px;
      color: #388e3c;
      font-size: 16px;
      font-weight: 500;
      text-align: center;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    /* 按钮点击时的等待效果 */
    .icon-btn.loading {
      position: relative;
      pointer-events: none;
    }

    .icon-btn.loading::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 20px;
      height: 20px;
      margin: -10px 0 0 -10px;
      border: 2px solid transparent;
      border-top: 2px solid #43a047;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }
  </style>
</head>
<body>
  <!-- 等待效果遮罩层 -->
  <div class="loading-overlay" id="loadingOverlay">
    <div style="text-align: center;">
      <div class="loading-spinner"></div>
      <div class="loading-text" id="loadingText">加载中...</div>
    </div>
  </div>

  <div class="header">
    <div class="header-title">绿纤协同办公平台</div>
    <div class="header-desc">高效协同,移动办公</div>
    <div class="header-illustration">
      <!-- 简单时钟插画SVG -->
      <svg viewBox="0 0 48 48"><circle cx="24" cy="24" r="22" fill="#fff" opacity="0.18"/><circle cx="24" cy="24" r="18" fill="#fff" opacity="0.32"/><circle cx="24" cy="24" r="14" fill="#fff"/><path d="M24 14v10l7 4" stroke="#43a047" stroke-width="2.5" stroke-linecap="round" fill="none"/></svg>
    </div>
  </div>
  <div class="summary-card">
    <div class="summary-item" onclick="gopath('appointment-list.html')"><span class="num">0</span><span class="label">预约数</span></div>
    <div class="summary-item" onclick="gopath('invite-list.html')"><span class="num">0</span><span class="label">邀约数</span></div>
    <div class="summary-item" onclick="gopath('expansion-list.html')" style="cursor: pointer;"><span class="num">0</span><span class="label">拓客数</span></div>
    <div class="summary-item" onclick="gopath('refund-list.html')" style="cursor: pointer;"><span class="num">0</span><span class="label">退卡数</span></div>
  </div>
  <div class="section-title">常用功能</div>
  <div class="func-card">
    <div class="icon-grid">
      <div class="icon-btn" onclick="gopath('lx.html')">
        <span class="icon">
          <svg viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="4"/><path d="M8 8h8M8 12h8M8 16h4" stroke="#fff" stroke-width="1.5" fill="none"/></svg>
        </span>
        <span class="icon-label">开单</span>
      </div>
      <div class="icon-btn" onclick="gopath('member-consume.html')">
        <span class="icon">
          <svg viewBox="0 0 24 24"><rect x="3" y="6" width="18" height="12" rx="3"/><rect x="7" y="10" width="10" height="2" rx="1" fill="#fff"/></svg>
        </span>
        <span class="icon-label">耗卡</span>
      </div>
      <div class="icon-btn" onclick="gopath('refund.html')">
        <span class="icon">
          <svg viewBox="0 0 24 24"><rect x="4" y="6" width="16" height="10" rx="3"/><path d="M12 9v4m0 0l-2-2m2 2l2-2" stroke="#fff" stroke-width="1.5" fill="none"/></svg>
        </span>
        <span class="icon-label">退卡</span>
      </div>
      <div class="icon-btn" onclick="gopath('appointment.html')">
        <span class="icon">
          <svg viewBox="0 0 24 24"><rect x="4" y="6" width="16" height="14" rx="3"/><rect x="8" y="10" width="8" height="6" rx="2" fill="#fff"/></svg>
        </span>
        <span class="icon-label">预约</span>
      </div>
      <div class="icon-btn" onclick="gopath('clue-list.html')">
        <span class="icon">
          <svg viewBox="0 0 24 24"><rect x="3" y="7" width="18" height="10" rx="3"/><path d="M3 7l9 6 9-6" stroke="#fff" stroke-width="1.5" fill="none"/></svg>
        </span>
        <span class="icon-label">邀约</span>
      </div>
      <div class="icon-btn" onclick="gopath('expansion.html')">
        <span class="icon">
          <svg viewBox="0 0 24 24"><circle cx="12" cy="10" r="4"/><path d="M4 20c0-3.3 2.7-6 6-6h4c3.3 0 6 2.7 6 6" stroke="#fff" stroke-width="1.5" fill="none"/></svg>
        </span>
        <span class="icon-label">拓客</span>
      </div>
      <div class="icon-btn" id="dailyReportBtn" onclick="gopath('dailyReport.html')" style="display: none;">
        <span class="icon">
          <svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" fill="none" stroke="#388e3c" stroke-width="1.5"/><path d="M8 14l3 3 5-5" stroke="#fff" stroke-width="1.5" fill="none"/><path d="M9 9h.01" stroke="#fff" stroke-width="1.5" fill="none"/><path d="M15 9h.01" stroke="#fff" stroke-width="1.5" fill="none"/><path d="M12 9h.01" stroke="#fff" stroke-width="1.5" fill="none"/></svg>
        </span>
        <span class="icon-label">报表</span>
      </div>
    </div>
  </div>

  <script>
    // 等待效果控制函数
    function showLoading(text = '加载中...') {
      document.getElementById('loadingText').textContent = text;
      document.getElementById('loadingOverlay').classList.add('show');
    }

    function hideLoading() {
      document.getElementById('loadingOverlay').classList.remove('show');
    }

    // 按钮等待效果
    function showButtonLoading(button, text = '处理中...') {
      button.classList.add('loading');
      button.setAttribute('data-original-text', button.querySelector('.icon-label').textContent);
      button.querySelector('.icon-label').textContent = text;
    }

    function hideButtonLoading(button) {
      button.classList.remove('loading');
      const originalText = button.getAttribute('data-original-text');
      if (originalText) {
        button.querySelector('.icon-label').textContent = originalText;
        button.removeAttribute('data-original-text');
      }
    }

    let userInfo = {};

    // 获取统计数据
    async function getSummaryData() {
      try {
        const apiBaseUrl = APP_CONFIG.getApiBaseUrl();
        
        // 获取预约数
        const appointmentResponse = await fetch(`${apiBaseUrl}/api/Extend/LqYyjl?yyr=${userInfo.userId}&pageSize=1`, {
          method: 'GET',
          headers: {
            'Authorization': `${getAuthToken()}`,
            'Content-Type': 'application/json'
          }
        });
        
        // 获取邀请数
        const inviteResponse = await fetch(`${apiBaseUrl}/api/Extend/LqYaoyjl?yyr=${userInfo.userId}&pageSize=1`, {
          method: 'GET',
          headers: {
            'Authorization': `${getAuthToken()}`,
            'Content-Type': 'application/json'
          }
        });
        
        // 获取拓客数
        const expansionResponse = await fetch(`${apiBaseUrl}/api/Extend/LqTkjlb?tkry=${userInfo.userId}&pageSize=1`, {
          method: 'GET',
          headers: {
            'Authorization': `${getAuthToken()}`,
            'Content-Type': 'application/json'
          }
        });
        
        // 获取退卡数
        const refundResponse = await fetch(`${apiBaseUrl}/api/Extend/LqHytkHytk?tkr=${userInfo.userId}&pageSize=1`, {
          method: 'GET',
          headers: {
            'Authorization': `${getAuthToken()}`,
            'Content-Type': 'application/json'
          }
        });
        
        // 更新页面显示
        if (appointmentResponse.ok) {
          const appointmentData = await appointmentResponse.json();
          if (appointmentData.code === 200) {
           
            document.querySelector('.summary-item:nth-child(1) .num').textContent = appointmentData.data.pagination.total || 0;
          }
        }
        
        if (inviteResponse.ok) {
          const inviteData = await inviteResponse.json();
          if (inviteData.code === 200) {
            document.querySelector('.summary-item:nth-child(2) .num').textContent = inviteData.data.pagination.total || 0;
          }
        }
        
        if (expansionResponse.ok) {
          const expansionData = await expansionResponse.json();
          if (expansionData.code === 200) {
            console.log(expansionData.data.pagination.total)
            document.querySelector('.summary-item:nth-child(3) .num').textContent = expansionData.data.pagination.total || 0;
          }
        }
        
        if (refundResponse.ok) {
          const refundData = await refundResponse.json();
          if (refundData.code === 200) {
            document.querySelector('.summary-item:nth-child(4) .num').textContent = refundData.data.pagination.total || 0;
          }
        }
        
      } catch (error) {
        console.error('获取统计数据失败:', error);
        // 如果API调用失败,保持默认的0值
      } finally {
        hideLoading();
      }
    }

    // 获取用户信息
    async function getUserInfo() {
      try {
        const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/oauth/CurrentUser`;
        const response = await fetch(apiUrl, {
          method: 'GET',
          headers: {
            'Authorization': `${getAuthToken()}`,
            'Content-Type': 'application/json'
          },
        });
        
        if (response.ok) {
          const result = await response.json();
          if (result.code == 200 && result.data) {
            return result.data.userInfo
          }
        }
        return {};
        
      } catch (error) {
        console.error('获取用户信息出错:', error);
        return {};
      }
    }

    // 检查登录状态
    async function checkLoginStatus() {
      
      try {
        userInfo = await getUserInfo()
        if (!userInfo || Object.keys(userInfo).length === 0) {
          // 没有登录,跳转到登录页面
          window.location.href = 'login.html';
          return;
        }
        console.log('用户已登录:', userInfo);
        
        // 根据手机号判断是否显示报表按钮
        const dailyReportBtn = document.getElementById('dailyReportBtn');
        if (dailyReportBtn && userInfo.userAccount == 'admin' || userInfo.userAccount == '13198568627' || userInfo.userAccount == '18884847552' || userInfo.userAccount == '13608016021' || userInfo.userAccount == '18628973287') {
          dailyReportBtn.style.display = 'flex';
        }
        
        // 登录成功后获取统计数据
        await getSummaryData();
      } catch (error) {
        console.error('登录检查失败:', error);
        hideLoading();
        // 如果出错,也跳转到登录页面
        window.location.href = 'login.html';
      }
    }

    // 页面加载时检查登录状态
    document.addEventListener('DOMContentLoaded', function() {
      showLoading('加载中...');
      checkLoginStatus();
     
    });
    
    // 跳转到拓客列表页
    function gopath(e) {
      // showLoading('页面跳转中...');
      window.location.href = e;
      // if(e == 'expansion.html' || e == 'expansion-list.html' || e == 'dailyReport.html' || ){
    
      // }else{
      //   alert('暂未开通');
      // }
  
    }
  </script>
</body>
</html>