| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>邮箱登录</title>
- <style>
- * { margin: 0; padding: 0; box-sizing: border-box; }
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- background: #f5f5f5;
- font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
- }
- .container {
- text-align: center;
- padding: 40px;
- }
- .tip-icon {
- width: 48px;
- height: 48px;
- margin: 0 auto 16px;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 24px;
- }
- .tip-icon.warn { background: #fff3e0; }
- .spinner {
- width: 36px;
- height: 36px;
- margin: 0 auto 16px;
- border: 3px solid #e0e0e0;
- border-top-color: #1890ff;
- border-radius: 50%;
- animation: spin 0.8s linear infinite;
- }
- @keyframes spin {
- to { transform: rotate(360deg); }
- }
- .tip-text {
- font-size: 15px;
- color: #666;
- line-height: 1.6;
- }
- </style>
- </head>
- <body>
- <!-- 页面内loading(兜底) -->
- <div class="container" id="loading" style="display:none;">
- <div class="spinner"></div>
- <p class="tip-text" id="loadingText">正在登录邮箱...</p>
- </div>
- <!-- 非钉钉环境提示 -->
- <div class="container" id="tipContainer" style="display:none;">
- <div class="tip-icon warn">⚠</div>
- <p class="tip-text">请在钉钉内打开此页面<br>浏览器不支持自动登录</p>
- </div>
- <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/3.0.12/dingtalk.open.js"></script>
- <script>
- var CORP_ID = 'dingc54682076c69f0f2bc961a6cb783455b';
- function isDingTalk() {
- return /DingTalk/i.test(navigator.userAgent);
- }
- // 钉钉原生loading
- function showLoading(text) {
- dd.device.notification.showPreloader({ text: text || '正在跳转邮箱...' });
- }
- function hideLoading() {
- dd.device.notification.hidePreloader();
- }
- // 钉钉原生toast提示
- function showToast(text, icon) {
- dd.device.notification.toast({ icon: icon || '', text: text, duration: 3 });
- }
- // 钉钉原生alert弹窗(用于错误提示)
- function showAlert(title, message) {
- hideLoading();
- dd.device.notification.alert({
- title: title || '提示',
- message: message,
- buttonName: '我知道了'
- });
- }
- function updateLoading(text) {
- document.getElementById('loadingText').textContent = text;
- }
- if (!isDingTalk()) {
- document.getElementById('tipContainer').style.display = 'block';
- } else {
- // 页面内loading + 钉钉原生loading
- document.getElementById('loading').style.display = 'block';
- showLoading('正在登录邮箱...');
- try {
- var result = dd.runtime.permission.requestAuthCode({
- corpId: CORP_ID,
- onSuccess: function(res) {
- updateLoading('正在跳转邮箱系统...');
- showLoading('正在跳转邮箱系统...');
- window.location.href = '/api/gm/sso/mail?authCode=' + res.code;
- },
- onFail: function(err) {
- showAlert('授权失败', err.errorMessage || JSON.stringify(err));
- }
- });
- // 新版JSAPI返回Promise
- if (result && typeof result.then === 'function') {
- result.then(function(res) {
- updateLoading('正在跳转邮箱系统...');
- showLoading('正在跳转邮箱系统...');
- var code = res.code || (res.result && res.result.code);
- if (code) {
- window.location.href = '/api/gm/sso/mail?authCode=' + code;
- }
- }).catch(function(err) {
- showAlert('授权失败', err.errorMessage || JSON.stringify(err));
- });
- }
- } catch(e) {
- showAlert('系统异常', e.message);
- }
- }
- </script>
- </body>
- </html>
|