| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
- <title>登录</title>
- <!-- 引入基础依赖 -->
- <script src="/js/mp_base/base.js"></script>
- </head>
- <body>
- <!-- 页面加载状态 -->
- <div id="page-loading" class="page-loading">
- <div class="loading-content">
- <div class="loading-spinner"></div>
- <div class="loading-text">加载中...</div>
- </div>
- </div>
- <div id="app" v-cloak>
- <div class="login-popup show">
- <div class="mask" ></div>
- <div class="popup-content">
- <!-- <div class="popup-header">
- <span class="title">登录</span>
- </div> -->
- <!-- 用户协议 -->
- <div class="agreement">
- <input
- type="checkbox"
- v-model="agreed"
- id="agreement-checkbox"
- class="agreement-checkbox"
- />
- <label for="agreement-checkbox" class="agreement-text">
- 我已阅读并同意
- <span class="link" @click="openAgreement('user')">《用户协议》</span>与<span class="link" @click="openAgreement('privacy')">《隐私协议》</span>
- </label>
- </div>
- <!-- 账号密码登录 -->
- <div class="account-login">
- <div class="input-item">
- <Icon name="icon-renyuan" size="32" color="#575d6d" class="input-icon"></Icon>
- <input
- type="text"
- v-model="form.username"
- placeholder="请输入您的账号"
- class="login-input"
- />
- </div>
- <div class="input-item">
- <Icon name="icon-kaisuo" size="32" color="#575d6d" class="input-icon"></Icon>
- <input
- :type="showPassword ? 'text' : 'password'"
- v-model="form.password"
- placeholder="请输入您的密码"
- class="login-input"
- />
- <div class="eye-icon" @click="showPassword = !showPassword">
- <Icon :name="showPassword ? 'icon-yanjing-kai' : 'icon-yanjing-bi'" size="32" color="#575d6d"></Icon>
- </div>
- </div>
- <button
- class="account-btn"
- :class="{ 'disabled': isLogging }"
- :disabled="isLogging"
- @click="handleAccountLogin"
- >
- <Icon name="icon-tuichu" size="32" color="#fff" class="btn-icon"></Icon>
- <span>{{ isLogging ? '登录中...' : '登录' }}</span>
- </button>
- </div>
-
- </div>
- </div>
- <!-- Loading 遮罩 -->
- <div v-if="showLoading" class="loading-mask">
- <div class="loading-content">
- <div class="loading-spinner"></div>
- <div class="loading-text">{{ loadingText }}</div>
- </div>
- </div>
- <!-- Toast 提示 -->
- <div v-if="toast.show" class="toast" :class="toast.type">
- {{ toast.message }}
- </div>
- <!-- 自定义确认弹窗 -->
- <div v-if="confirmDialog.show" class="confirm-dialog-mask">
- <div class="confirm-dialog">
- <div class="confirm-content">
- <div class="confirm-message">{{ confirmDialog.message }}</div>
- <div class="confirm-buttons">
- <button class="confirm-btn cancel-btn" @click="handleConfirmCancel">取消</button>
- <button class="confirm-btn confirm-btn-primary" @click="handleConfirmOk">确认</button>
- </div>
- </div>
- </div>
- </div>
- <!-- 底部抽屉:显示协议内容 -->
- <div v-if="agreementDrawer.show" class="drawer-mask" @click="closeAgreementDrawer">
- <div class="drawer-content" @click.stop>
- <div class="drawer-header">
- <div class="drawer-title">{{ agreementDrawer.title }}</div>
- <div class="drawer-close" @click="closeAgreementDrawer">
- <Icon name="icon-X-xi" size="32" color="#666"></Icon>
- </div>
- </div>
- <div class="drawer-body">
- <div v-html="agreementDrawer.content"></div>
- </div>
- </div>
- </div>
- </div>
- <script>
- // 等待SS框架加载完成
- window.SS.ready(function () {
- // 使用SS框架的方式创建Vue实例
- window.SS.dom.initializeFormApp({
- el: '#app',
- data() {
- return {
- form: {
- username: '',
- password: ''
- },
- showPassword: false,
- agreed: false,
- isLogging: false,
- showLoading: false,
- loadingText: '',
- toast: {
- show: false,
- message: '',
- type: 'info'
- },
- confirmDialog: {
- show: false,
- message: '',
- resolve: null
- },
- agreementDrawer: {
- show: false,
- title: '',
- content: ''
- }
- }
- },
- mounted() {
- // 隐藏页面加载状态
- const pageLoading = document.getElementById('page-loading')
- if (pageLoading) {
- pageLoading.style.display = 'none'
- }
- // 初始化页面,使用自定义结果处理
- if (typeof initPage === 'function') {
- initPage('login', this.handleResult)
- }
- // 获取URL参数,用于调试
- const urlParams = this.getUrlParams()
- console.log('🔗 H5登录页面参数:', urlParams)
- },
- methods: {
- // 获取URL参数
- getUrlParams() {
- const params = {}
- const urlSearchParams = new URLSearchParams(window.location.search)
- for (const [key, value] of urlSearchParams) {
- params[key] = decodeURIComponent(value)
- }
- return params
- },
- // 处理操作结果(来自小程序的回调)
- handleResult(data) {
- console.log('🎯 收到小程序回调:', data)
- // 这里可以处理来自小程序的各种回调
- },
- // 显示Loading
- showLoadingMask(text = '加载中...') {
- this.showLoading = true
- this.loadingText = text
- },
- // 隐藏Loading
- hideLoadingMask() {
- this.showLoading = false
- this.loadingText = ''
- },
- // 显示Toast
- showToast(message, type = 'info', duration = 3000) {
- this.toast = {
- show: true,
- message,
- type
- }
- setTimeout(() => {
- this.toast.show = false
- }, duration)
- },
- // 自定义确认对话框
- showConfirm(message) {
- return new Promise((resolve) => {
- this.confirmDialog = {
- show: true,
- message: message,
- resolve: resolve
- }
- })
- },
- // 处理确认对话框 - 取消
- handleConfirmCancel() {
- this.confirmDialog.show = false
- if (this.confirmDialog.resolve) {
- this.confirmDialog.resolve(false)
- }
- this.confirmDialog.resolve = null
- },
- // 处理确认对话框 - 确认
- handleConfirmOk() {
- this.confirmDialog.show = false
- if (this.confirmDialog.resolve) {
- this.confirmDialog.resolve(true)
- }
- this.confirmDialog.resolve = null
- },
-
- // 账号密码登录
- async handleAccountLogin() {
- if (this.isLogging) {
- console.log('正在登录中,请勿重复点击')
- return
- }
- if (!this.agreed) {
- // 使用自定义确认对话框替换原生confirm
- const userConfirmed = await this.showConfirm('是否同意用户协议和隐私协议?');
- if (userConfirmed) {
- this.agreed = true; // 用户点击了“确定”,视为同意
- // 继续执行后续逻辑
- } else {
- return; // 用户点击了“取消”,中断操作
- }
-
- }
- if (!this.form.username || !this.form.password) {
- this.showToast('请输入用户名和密码', 'warning')
- return
- }
- try {
- this.isLogging = true
- this.showLoadingMask('登录中...')
- // 获取URL参数中的wechatCode
- const urlParams = this.getUrlParams()
- const wechatCode = urlParams.wechatCode || ''
- console.log('🔗 使用wechatCode:', wechatCode)
- // 使用真实的API进行登录
- const response = await h5UserApi.accountLogin({
- yhm: this.form.username,
- mm: this.form.password,
- wdConfirmationCaptchaService: "0",
- wechatCode: wechatCode // 传递wechatCode
- })
- // 检查是否有错误信息
- if (response && response.data && response.data.msg) {
- // 登录失败,显示错误信息
- console.error('❌ 登录失败:', response.data.msg)
- this.showToast(response.data.msg, 'error')
- return
- }
- console.log("response:",response)
- // 检查登录是否成功
- if (response && response.data ) {
- if (typeof response.data === 'string' && response.data.includes('页面执行时错误')) {
- throw new Error('服务器处理错误')
- return
- }
- const userData = {
- devId:response.data.devId,
- sbmc:response.data.sbmc,
- sessId:response.data.sessId,
- xm:response.data.xm,
- yhsbToken:response.data.yhsbToken,
- onlineToken:response.data.onlineToken,
- syList:response.data.sylist,
- yhid:response.data.yhid,
- yhm:response.data.yhm
- }
- // 保存用户信息到H5本地存储
- h5UserApi.saveUserInfo(userData)
- // 准备返回数据给小程序
- const loginResult = {
- success: true,
- userInfo: userData,
- }
- console.log('✅ 登录成功,准备返回数据:', loginResult)
- // this.showToast('登录成功!', 'success')
- // 延迟一下让用户看到成功提示
- setTimeout(() => {
- // 通过h5-bridge返回登录结果给小程序
- this.returnLoginResult(loginResult)
- }, 1000)
- } else {
- throw new Error('登录响应数据无效')
- }
- } catch (error) {
- console.error('❌ 登录失败:', error)
- this.showToast('登录失败: ' + error.message, 'error')
- } finally {
- this.isLogging = false
- this.hideLoadingMask()
- }
- },
- // 返回登录结果给小程序
- returnLoginResult(result) {
- // console.log('🔄 返回登录结果给小程序:', result)
-
- // 使用h5-bridge的数据传递功能
- // 这里需要跳转到h5-controller中转页来传递数据
- callNative('loginSuccess', '登录成功', result)
- },
- // 打开协议页面
- openAgreement(type) {
- const agreementData = {
- user: {
- title: '用户协议',
- content: `
- <h3>用户协议</h3>
- <p>欢迎使用本平台服务。在使用本平台服务前,请您仔细阅读并充分理解本协议内容。</p>
- <h4>1. 服务条款的接受</h4>
- <p>您使用本平台服务即视为您已阅读并同意接受本协议的全部条款。</p>
- <h4>2. 账号注册和使用</h4>
- <p>用户在注册账号时,应提供真实、准确、完整的个人信息。</p>
- <h4>3. 用户权利和义务</h4>
- <p>用户有权使用本平台提供的各项服务,但应遵守相关法律法规。</p>
- <h4>4. 隐私保护</h4>
- <p>我们承诺保护用户的个人信息安全,不会泄露用户隐私。</p>
- <p style="margin-top: 20px; color: #999;">本协议最终解释权归本平台所有。</p>
- `
- },
- privacy: {
- title: '隐私协议',
- content: `
- <h3>隐私协议</h3>
- <p>本指引是海丰县德成中英文学校小程序开发者 海丰县德成中英文学校(以下简称"开发者")为处理你的个人信息而制定。</p>
- <h4>开发者处理的信息</h4>
- <p>根据法律规定,开发者仅处理实现小程序功能所必要的信息。</p>
- <p>开发者收集你的设备信息,用于识别你的账号登录设备。</p>
- <p>开发者将在获取你的明示同意后,收集你的微信昵称、头像,用途是【更新OA系统中你的头像信息】</p>
- <h4>你的权益</h4>
- <p>关于你的个人信息,你可以通过以下方式与开发者联系,行使查阅、复制、更正、删除等法定权利。</p>
- <p>若你在小程序中注,不会对外公开披露你的信息,如必须公开披露时,开发者应当向你告知公开披露的目的、披露信息的类型及可能涉及的信息,并征得你的单独同意。</p>
- <p>你认为开发者未遵守上述约定,或有其他的投诉建议、或未成年人个人信息保护相关问题,可通过以下方式与开发者联系;或者向微信进行投诉。</p>
- <p><strong>邮箱:</strong> DC1612356478@163.com</p>
- <p style="margin-top: 20px; color: #999;">更新日期:2025-10-11</p>
- `
- }
- };
- const agreement = agreementData[type];
- if (agreement) {
- this.agreementDrawer = {
- show: true,
- title: agreement.title,
- content: agreement.content
- };
- }
- },
- // 关闭协议抽屉
- closeAgreementDrawer() {
- this.agreementDrawer.show = false;
- }
- }
- })
- console.log('✅ 登录页面初始化完成')
- })
- </script>
- <style>
- /* 防止Vue模板闪烁 */
- [v-cloak] {
- display: none !important;
- }
- /* 页面加载状态 */
- .page-loading {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: #f5f5f5;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 9999;
- }
- .page-loading .loading-content {
- text-align: center;
- }
- .page-loading .loading-spinner {
- width: 40px;
- height: 40px;
- border: 4px solid #f3f3f3;
- border-top: 4px solid #40ac6d;
- border-radius: 50%;
- animation: page-spin 1s linear infinite;
- margin: 0 auto 15px;
- }
- @keyframes page-spin {
- 0% { transform: rotate(0deg); }
- 100% { transform: rotate(360deg); }
- }
- .page-loading .loading-text {
- color: #666;
- font-size: 14px;
- }
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
- background: #f5f5f5;
- overflow: hidden;
- }
- .login-popup {
- position: fixed;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- z-index: 9999;
- visibility: hidden;
- }
- .login-popup.show {
- visibility: visible;
- }
- .mask {
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.6);
- }
- .popup-content {
- width: calc(100% - 20px);
- position: absolute;
- left: 50%;
-
- top: 50%;
- background: #fff;
- border-radius: 4px;
- padding: 30px 20px;
- transform: translate(-50%, -50%);
- transition: transform 0.3s ease-out;
- border: 1px solid #d3d4d5;
- max-height: 80vh;
- overflow-y: auto;
- }
- .popup-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20px;
- }
- .title {
- font-size: 18px;
- font-weight: bold;
- color: #333;
- }
- .close-btn {
- font-size: 24px;
- color: #999;
- padding: 10px;
- margin: -10px;
- cursor: pointer;
- user-select: none;
- }
- .close-btn:hover {
- color: #666;
- }
-
- .input-item {
- position: relative;
- margin-bottom: 15px;
- display: flex;
- }
- .input-icon {
- position: absolute;
- left: 18px;
- top: 50%;
- transform: translateY(-50%);
- z-index: 1;
- }
- .login-input {
- width: 100%;
- height: 44px;
- /* background: #f5f5f5; */
- border-radius: 4px;
- padding: 0 40px 0 50px;
- font-size: 16px;
- border: none;
- outline: none;
- border: 1px solid #d5d8dc;
- }
- .login-input:focus {
- /* background: #f0f0f0; */
- border: 1px solid #d0d2d6;
- }
- .eye-icon {
- position: absolute;
- right: 10px;
- top: 50%;
- transform: translateY(-50%);
- padding: 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- z-index: 1000;
- }
- .account-btn {
- width: 100%;
- height: 44px;
- line-height: 44px;
- background: #575d6d;
- color: #fff;
- border-radius: 4px;
- font-size: 16px;
- border: none;
- margin-top: 35px;
- transition: all 0.3s ease;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- }
- .btn-icon {
- display: inline-block;
- }
- .account-btn span {
- line-height: 1;
- }
- .account-btn:hover {
- background: #555;
- }
- .account-btn.disabled {
- background: #cccccc !important;
- color: #999999 !important;
- opacity: 0.6;
- cursor: not-allowed;
- }
- /* 用户协议 */
- .agreement {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 25px;
- }
- /* 自定义checkbox样式 */
- .agreement-checkbox {
- position: relative;
- margin-right: 8px;
- width: 20px;
- height: 20px;
- appearance: none;
- -webkit-appearance: none;
- border: 2px solid #d5d8dc;
- border-radius: 4px;
- outline: none;
- cursor: pointer;
- transition: all 0.2s;
- }
- .agreement-checkbox:hover {
- border-color: #575d6d;
- }
- .agreement-checkbox:checked {
- background-color: #575d6d;
- border-color: #575d6d;
- }
- .agreement-checkbox:checked::after {
- content: '';
- position: absolute;
- left: 5px;
- top: 0;
- width: 5px;
- height: 10px;
- border: solid white;
- border-width: 0 2px 2px 0;
- transform: rotate(45deg);
- }
- .agreement-text {
- font-size: 0.372rem;
- font-weight: 500;
- color: #999;
- cursor: pointer;
- }
- .link {
- /* color: #40ac6d; */
- cursor: pointer;
- }
- .link:hover {
- text-decoration: underline;
- }
- /* Loading 遮罩 */
- .loading-mask {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 10000;
- }
- .loading-content {
- background: white;
- padding: 20px;
- border-radius: 4px;
- text-align: center;
- min-width: 120px;
- }
- .loading-spinner {
- width: 30px;
- height: 30px;
- border: 3px solid #f3f3f3;
- border-top: 3px solid #40ac6d;
- border-radius: 50%;
- animation: spin 1s linear infinite;
- margin: 0 auto 10px;
- }
- @keyframes spin {
- 0% { transform: rotate(0deg); }
- 100% { transform: rotate(360deg); }
- }
- .loading-text {
- color: #333;
- font-size: 14px;
- }
- /* Toast 提示 */
- .toast {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background: rgba(0, 0, 0, 0.8);
- color: white;
- padding: 12px 20px;
- border-radius: 4px;
- font-size: 14px;
- z-index: 10001;
- max-width: 80%;
- text-align: center;
- }
- .toast.success {
- background: rgba(40, 167, 69, 0.9);
- }
- .toast.warning {
- background: rgba(255, 193, 7, 0.9);
- color: #212529;
- }
- .toast.error {
- background: rgba(220, 53, 69, 0.9);
- }
- /* 自定义确认对话框 - 优化样式 */
- .confirm-dialog-mask {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.6);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 10002;
- }
- .confirm-dialog {
- background: white;
- border-radius: 4px;
- min-width: 280px;
- max-width: 90%;
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
- overflow: hidden;
- animation: confirmFadeIn 0.3s ease-out;
- }
- @keyframes confirmFadeIn {
- from {
- opacity: 0;
- transform: scale(0.95) translateY(-20px);
- }
- to {
- opacity: 1;
- transform: scale(1) translateY(0);
- }
- }
- .confirm-content {
- padding: 24px 20px 20px;
- }
- .confirm-message {
- font-size: 16px;
- color: #333;
- text-align: center;
- margin-bottom: 24px;
- line-height: 1.6;
- }
- .confirm-buttons {
- display: flex;
- gap: 10px;
- }
- .confirm-btn {
- flex: 1;
- height: 40px;
- border: none;
- border-radius: 4px;
- font-size: 15px;
- cursor: pointer;
- transition: all 0.2s ease;
- font-weight: 500;
- }
- .cancel-btn {
- background: #f5f5f5;
- color: #666;
- border: 1px solid #e5e5e5;
- }
- .cancel-btn:hover {
- background: #eeeeee;
- border-color: #d5d5d5;
- }
- .confirm-btn-primary {
- background: #575d6d;
- color: white;
- }
- .confirm-btn-primary:hover {
- background: #494e5b;
- }
- .confirm-btn:active {
- transform: scale(0.98);
- }
- /* 底部抽屉样式 */
- .drawer-mask {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.6);
- z-index: 10003;
- animation: drawerMaskFadeIn 0.3s ease-out;
- }
- @keyframes drawerMaskFadeIn {
- from { opacity: 0; }
- to { opacity: 1; }
- }
- .drawer-content {
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- max-height: 80vh;
- background: white;
- border-radius: 4px 4px 0 0;
- animation: drawerSlideUp 0.3s ease-out;
- display: flex;
- flex-direction: column;
- }
- @keyframes drawerSlideUp {
- from {
- transform: translateY(100%);
- }
- to {
- transform: translateY(0);
- }
- }
- .drawer-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 20px;
- border-bottom: 1px solid #f0f0f0;
- flex-shrink: 0;
- }
- .drawer-title {
- font-size: 18px;
- font-weight: 600;
- color: #333;
- }
- .drawer-close {
- width: 32px;
- height: 32px;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- border-radius: 4px;
- transition: background 0.2s;
- }
- .drawer-close:hover {
- background: #f5f5f5;
- }
- .drawer-body {
- flex: 1;
- overflow-y: auto;
- padding: 20px;
- -webkit-overflow-scrolling: touch;
- }
- .drawer-body h3 {
- font-size: 18px;
- color: #333;
- margin-bottom: 16px;
- }
- .drawer-body h4 {
- font-size: 16px;
- color: #555;
- margin-top: 20px;
- margin-bottom: 12px;
- }
- .drawer-body p {
- font-size: 14px;
- color: #666;
- line-height: 1.8;
- margin-bottom: 12px;
- }
- /* 响应式设计 */
- /* @media (max-width: 480px) {
- .popup-content {
- padding: 15px 10px;
- }
- .login-input {
- height: 40px;
- font-size: 13px;
- }
- .account-btn {
- height: 40px;
- line-height: 40px;
- font-size: 14px;
- }
- } */
- </style>
- </body>
- </html>
|