login.html 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, user-scalable=no"
  8. />
  9. <title>登录</title>
  10. <!-- 引入基础依赖 -->
  11. <script src="/js/mp_base/base.js"></script>
  12. </head>
  13. <body>
  14. <!-- 页面加载状态 -->
  15. <div id="page-loading" class="page-loading">
  16. <div class="loading-content">
  17. <div class="loading-spinner"></div>
  18. <div class="loading-text">加载中...</div>
  19. </div>
  20. </div>
  21. <div id="app" v-cloak>
  22. <div class="login-popup show">
  23. <div class="mask"></div>
  24. <div class="popup-content">
  25. <!-- <div class="popup-header">
  26. <span class="title">登录</span>
  27. </div> -->
  28. <!-- 用户协议 -->
  29. <div class="agreement">
  30. <input
  31. type="checkbox"
  32. v-model="agreed"
  33. id="agreement-checkbox"
  34. class="agreement-checkbox"
  35. />
  36. <label for="agreement-checkbox" class="agreement-text">
  37. 我已阅读并同意
  38. <span class="link" @click="openAgreement('user')"
  39. >《用户协议》</span
  40. >与<span class="link" @click="openAgreement('privacy')"
  41. >《隐私协议》</span
  42. >
  43. </label>
  44. </div>
  45. <!-- 账号密码登录 -->
  46. <div class="account-login">
  47. <div class="input-item">
  48. <Icon
  49. name="icon-renyuan"
  50. size="32"
  51. color="#575d6d"
  52. class="input-icon"
  53. ></Icon>
  54. <input
  55. type="text"
  56. v-model="form.username"
  57. placeholder="请输入您的账号"
  58. class="login-input"
  59. />
  60. </div>
  61. <div class="input-item">
  62. <Icon
  63. name="icon-kaisuo"
  64. size="32"
  65. color="#575d6d"
  66. class="input-icon"
  67. ></Icon>
  68. <input
  69. :type="showPassword ? 'text' : 'password'"
  70. v-model="form.password"
  71. placeholder="请输入您的密码"
  72. class="login-input"
  73. />
  74. <div class="eye-icon" @click="showPassword = !showPassword">
  75. <Icon
  76. :name="showPassword ? 'icon-yanjing-kai' : 'icon-yanjing-bi'"
  77. size="32"
  78. color="#575d6d"
  79. ></Icon>
  80. </div>
  81. </div>
  82. <button
  83. class="account-btn"
  84. :class="{ 'disabled': isLogging }"
  85. :disabled="isLogging"
  86. @click="handleAccountLogin"
  87. >
  88. <Icon
  89. name="icon-tuichu"
  90. size="32"
  91. color="#fff"
  92. class="btn-icon"
  93. ></Icon>
  94. <span>{{ isLogging ? '登录中...' : '登录' }}</span>
  95. </button>
  96. </div>
  97. </div>
  98. </div>
  99. <!-- Loading 遮罩 -->
  100. <div v-if="showLoading" class="loading-mask">
  101. <div class="loading-content">
  102. <div class="loading-spinner"></div>
  103. <div class="loading-text">{{ loadingText }}</div>
  104. </div>
  105. </div>
  106. <!-- Toast 提示 -->
  107. <div v-if="toast.show" class="toast" :class="toast.type">
  108. {{ toast.message }}
  109. </div>
  110. <!-- warnMsg 使用 ss-confirm -->
  111. <ss-confirm
  112. v-model="warnConfirm.show"
  113. title="提示"
  114. :mask-closable="false"
  115. @confirm="handleWarnConfirmOk"
  116. @cancel="handleWarnConfirmCancel"
  117. >
  118. <div class="warn-confirm-text">{{ warnConfirm.message }}</div>
  119. </ss-confirm>
  120. <!-- 自定义确认弹窗 -->
  121. <div v-if="confirmDialog.show" class="confirm-dialog-mask">
  122. <div class="confirm-dialog">
  123. <div class="confirm-content">
  124. <div class="confirm-title">{{ confirmDialog.title }}</div>
  125. <div class="confirm-message">{{ confirmDialog.message }}</div>
  126. <div class="confirm-buttons">
  127. <button
  128. v-if="confirmDialog.showCancel"
  129. class="confirm-btn cancel-btn"
  130. @click="handleConfirmCancel"
  131. >
  132. 取消
  133. </button>
  134. <button
  135. class="confirm-btn confirm-btn-primary"
  136. :class="{ 'full-width': !confirmDialog.showCancel }"
  137. @click="handleConfirmOk"
  138. >
  139. 确认
  140. </button>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <!-- 底部抽屉:显示协议内容 -->
  146. <div
  147. v-if="agreementDrawer.show"
  148. class="drawer-mask"
  149. @click="closeAgreementDrawer"
  150. >
  151. <div class="drawer-content" @click.stop>
  152. <div class="drawer-header">
  153. <div class="drawer-title">{{ agreementDrawer.title }}</div>
  154. <div class="drawer-close" @click="closeAgreementDrawer">
  155. <Icon name="icon-X-xi" size="32" color="#666"></Icon>
  156. </div>
  157. </div>
  158. <div class="drawer-body">
  159. <div v-html="agreementDrawer.content"></div>
  160. </div>
  161. </div>
  162. </div>
  163. <!-- 修改初始密码弹窗 -->
  164. <div v-if="resetPwdModal.show" class="reset-pwd-mask">
  165. <div class="reset-pwd-modal">
  166. <div class="reset-pwd-header">
  167. <div class="reset-pwd-title">请修改初始密码</div>
  168. </div>
  169. <div class="reset-pwd-body">
  170. <div class="pwd-strength-msg">
  171. {{ resetPwdModal.pwdStrengthMsg }}
  172. </div>
  173. <div class="reset-pwd-form">
  174. <div class="reset-pwd-input-item">
  175. <input
  176. :type="showNewPwd ? 'text' : 'password'"
  177. v-model="resetPwdForm.newPwd"
  178. placeholder="请输入新密码"
  179. class="reset-pwd-input"
  180. />
  181. <div class="eye-icon" @click="showNewPwd = !showNewPwd">
  182. <Icon
  183. :name="showNewPwd ? 'icon-yanjing-kai' : 'icon-yanjing-bi'"
  184. size="28"
  185. color="#999"
  186. ></Icon>
  187. </div>
  188. </div>
  189. <div class="reset-pwd-input-item">
  190. <input
  191. :type="showConfirmPwd ? 'text' : 'password'"
  192. v-model="resetPwdForm.confirmPwd"
  193. placeholder="请确认新密码"
  194. class="reset-pwd-input"
  195. />
  196. <div class="eye-icon" @click="showConfirmPwd = !showConfirmPwd">
  197. <Icon
  198. :name="showConfirmPwd ? 'icon-yanjing-kai' : 'icon-yanjing-bi'"
  199. size="28"
  200. color="#999"
  201. ></Icon>
  202. </div>
  203. </div>
  204. </div>
  205. <button
  206. class="reset-pwd-btn"
  207. :class="{ 'disabled': resetPwdLoading }"
  208. :disabled="resetPwdLoading"
  209. @click="handleResetPwd"
  210. >
  211. {{ resetPwdLoading ? '保存中...' : '保存' }}
  212. </button>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. <script>
  218. // 等待SS框架加载完成
  219. window.SS.ready(function () {
  220. // 使用SS框架的方式创建Vue实例
  221. window.SS.dom.initializeFormApp({
  222. el: "#app",
  223. data() {
  224. return {
  225. form: {
  226. username: "",
  227. password: "",
  228. },
  229. showPassword: false,
  230. agreed: false,
  231. isLogging: false,
  232. showLoading: false,
  233. loadingText: "",
  234. toast: {
  235. show: false,
  236. message: "",
  237. type: "info",
  238. },
  239. warnConfirm: {
  240. show: false,
  241. message: "",
  242. resolve: null,
  243. },
  244. confirmDialog: {
  245. show: false,
  246. title: "提示",
  247. message: "",
  248. showCancel: true,
  249. resolve: null,
  250. },
  251. agreementDrawer: {
  252. show: false,
  253. title: "",
  254. content: "",
  255. },
  256. // 修改初始密码弹窗状态
  257. resetPwdModal: {
  258. show: false,
  259. yhid: "",
  260. yhm: "",
  261. pwdStrengthMsg: "",
  262. },
  263. // 修改密码表单
  264. resetPwdForm: {
  265. newPwd: "",
  266. confirmPwd: "",
  267. },
  268. showNewPwd: false,
  269. showConfirmPwd: false,
  270. resetPwdLoading: false,
  271. };
  272. },
  273. mounted() {
  274. // 隐藏页面加载状态
  275. const pageLoading = document.getElementById("page-loading");
  276. if (pageLoading) {
  277. pageLoading.style.display = "none";
  278. }
  279. // 初始化页面,使用自定义结果处理
  280. if (typeof initPage === "function") {
  281. initPage("login", this.handleResult);
  282. }
  283. // 获取URL参数,用于调试
  284. const urlParams = this.getUrlParams();
  285. console.log("🔗 H5登录页面参数:", urlParams);
  286. },
  287. methods: {
  288. // 获取URL参数
  289. getUrlParams() {
  290. const params = {};
  291. const urlSearchParams = new URLSearchParams(
  292. window.location.search
  293. );
  294. for (const [key, value] of urlSearchParams) {
  295. params[key] = decodeURIComponent(value);
  296. }
  297. return params;
  298. },
  299. // 处理操作结果(来自小程序的回调)
  300. handleResult(data) {
  301. console.log("🎯 收到小程序回调:", data);
  302. // 这里可以处理来自小程序的各种回调
  303. },
  304. // 显示Loading
  305. showLoadingMask(text = "加载中...") {
  306. this.showLoading = true;
  307. this.loadingText = text;
  308. },
  309. // 隐藏Loading
  310. hideLoadingMask() {
  311. this.showLoading = false;
  312. this.loadingText = "";
  313. },
  314. // 显示Toast
  315. showToast(message, type = "info", duration = 3000) {
  316. this.toast = {
  317. show: true,
  318. message,
  319. type,
  320. };
  321. setTimeout(() => {
  322. this.toast.show = false;
  323. }, duration);
  324. },
  325. // 自定义确认对话框
  326. showConfirm(message, options = {}) {
  327. const { title = "提示", showCancel = true } = options;
  328. return new Promise((resolve) => {
  329. this.confirmDialog = {
  330. show: true,
  331. title,
  332. message,
  333. showCancel,
  334. resolve,
  335. };
  336. });
  337. },
  338. // 处理确认对话框 - 取消
  339. handleConfirmCancel() {
  340. this.confirmDialog.show = false;
  341. if (this.confirmDialog.resolve) {
  342. this.confirmDialog.resolve(false);
  343. }
  344. this.confirmDialog.resolve = null;
  345. },
  346. // 处理确认对话框 - 确认
  347. handleConfirmOk() {
  348. this.confirmDialog.show = false;
  349. if (this.confirmDialog.resolve) {
  350. this.confirmDialog.resolve(true);
  351. }
  352. this.confirmDialog.resolve = null;
  353. },
  354. // warnMsg 确认弹窗 - 确认
  355. handleWarnConfirmOk() {
  356. this.warnConfirm.show = false;
  357. if (this.warnConfirm.resolve) {
  358. this.warnConfirm.resolve(true);
  359. }
  360. this.warnConfirm.resolve = null;
  361. },
  362. // warnMsg 确认弹窗 - 取消(maskClosable=false 正常不会触发)
  363. handleWarnConfirmCancel() {
  364. this.warnConfirm.show = false;
  365. if (this.warnConfirm.resolve) {
  366. this.warnConfirm.resolve(false);
  367. }
  368. this.warnConfirm.resolve = null;
  369. },
  370. showWarnConfirm(message) {
  371. return new Promise((resolve) => {
  372. this.warnConfirm = {
  373. show: true,
  374. message,
  375. resolve,
  376. };
  377. });
  378. },
  379. // 账号密码登录
  380. async handleAccountLogin() {
  381. if (this.isLogging) {
  382. console.log("正在登录中,请勿重复点击");
  383. return;
  384. }
  385. if (!this.agreed) {
  386. // 使用自定义确认对话框替换原生confirm
  387. const userConfirmed = await this.showConfirm(
  388. "是否同意用户协议和隐私协议?"
  389. );
  390. if (userConfirmed) {
  391. this.agreed = true; // 用户点击了“确定”,视为同意
  392. // 继续执行后续逻辑
  393. } else {
  394. return; // 用户点击了“取消”,中断操作
  395. }
  396. }
  397. // 提交前清理账号中的空格
  398. const normalizedUsername = (this.form.username || "").replace(
  399. /\s+/g,
  400. ""
  401. );
  402. this.form.username = normalizedUsername;
  403. if (!this.form.username || !this.form.password) {
  404. this.showToast("请输入用户名和密码", "warning");
  405. return;
  406. }
  407. try {
  408. this.isLogging = true;
  409. this.showLoadingMask("登录中...");
  410. // 获取URL参数中的wechatCode
  411. const urlParams = this.getUrlParams();
  412. const wechatCode = urlParams.wechatCode || "";
  413. const redirectUrl = urlParams.redirect || "";
  414. const entryScene = urlParams.entryScene || "";
  415. console.log("🔗 使用wechatCode:", wechatCode);
  416. // 使用真实的API进行登录
  417. const response = await h5UserApi.accountLogin({
  418. yhm: this.form.username,
  419. mm: this.form.password,
  420. wdConfirmationCaptchaService: "0",
  421. wechatCode: wechatCode, // 传递wechatCode
  422. });
  423. // 检查是否有错误信息
  424. if (response && response.data && response.data.msg) {
  425. // 检测是否需要修改初始密码
  426. if (
  427. response.data.msg.includes("请修改初始密码") ||
  428. response.data.msg.includes("请修改密码")
  429. ) {
  430. this.hideLoadingMask();
  431. this.isLogging = false;
  432. // 显示修改密码弹窗
  433. this.openResetPwdModal(response.data);
  434. return;
  435. }
  436. // 登录失败,显示错误信息
  437. console.error("❌ 登录失败:", response.data.msg);
  438. this.showToast(response.data.msg, "error");
  439. return;
  440. }
  441. // 检查是否有告警信息(先关闭 loading,再用 ss-confirm 确认后继续)
  442. if (response && response.data && response.data.warnMsg) {
  443. this.hideLoadingMask();
  444. const confirmed = await this.showWarnConfirm(
  445. response.data.warnMsg
  446. );
  447. if (!confirmed) {
  448. return;
  449. }
  450. }
  451. console.log("response:", response);
  452. // 检查登录是否成功
  453. if (response && response.data) {
  454. if (
  455. typeof response.data === "string" &&
  456. response.data.includes("页面执行时错误")
  457. ) {
  458. throw new Error("服务器处理错误");
  459. }
  460. const userData = {
  461. devId: response.data.devId,
  462. sbmc: response.data.sbmc,
  463. sessId: response.data.sessId,
  464. xm: response.data.xm,
  465. yhsbToken: response.data.yhsbToken,
  466. onlineToken: response.data.onlineToken,
  467. syList: response.data.sylist,
  468. yhid: response.data.yhid,
  469. yhm: response.data.yhm,
  470. };
  471. // 保存用户信息到H5本地存储
  472. h5UserApi.saveUserInfo(userData);
  473. // 准备返回数据给小程序
  474. const loginResult = {
  475. success: true,
  476. userInfo: userData,
  477. redirectUrl,
  478. entryScene,
  479. };
  480. console.log("✅ 登录成功,准备返回数据:", loginResult);
  481. // this.showToast('登录成功!', 'success')
  482. // 延迟一下让用户看到成功提示
  483. setTimeout(() => {
  484. // 通过h5-bridge返回登录结果给小程序
  485. this.returnLoginResult(loginResult);
  486. }, 1000);
  487. } else {
  488. throw new Error("登录响应数据无效");
  489. }
  490. } catch (error) {
  491. console.error("❌ 登录失败:", error);
  492. this.showToast("登录失败: " + error.message, "error");
  493. } finally {
  494. this.isLogging = false;
  495. this.hideLoadingMask();
  496. }
  497. },
  498. // 返回登录结果给小程序
  499. returnLoginResult(result) {
  500. // console.log('🔄 返回登录结果给小程序:', result)
  501. // 使用h5-bridge的数据传递功能
  502. // 这里需要跳转到h5-controller中转页来传递数据
  503. callNative("loginSuccess", "登录成功", result);
  504. },
  505. // 打开协议页面
  506. openAgreement(type) {
  507. const agreementData = {
  508. user: {
  509. title: "用户协议",
  510. content: `
  511. <h3>用户协议</h3>
  512. <p>欢迎使用本平台服务。在使用本平台服务前,请您仔细阅读并充分理解本协议内容。</p>
  513. <h4>1. 服务条款的接受</h4>
  514. <p>您使用本平台服务即视为您已阅读并同意接受本协议的全部条款。</p>
  515. <h4>2. 账号注册和使用</h4>
  516. <p>用户在注册账号时,应提供真实、准确、完整的个人信息。</p>
  517. <h4>3. 用户权利和义务</h4>
  518. <p>用户有权使用本平台提供的各项服务,但应遵守相关法律法规。</p>
  519. <h4>4. 隐私保护</h4>
  520. <p>我们承诺保护用户的个人信息安全,不会泄露用户隐私。</p>
  521. <p style="margin-top: 20px; color: #999;">本协议最终解释权归本平台所有。</p>
  522. `,
  523. },
  524. privacy: {
  525. title: "隐私协议",
  526. content: `
  527. <h3>隐私协议</h3>
  528. <p>本指引是海丰县德成中英文学校小程序开发者 海丰县德成中英文学校(以下简称"开发者")为处理你的个人信息而制定。</p>
  529. <h4>开发者处理的信息</h4>
  530. <p>根据法律规定,开发者仅处理实现小程序功能所必要的信息。</p>
  531. <p>开发者收集你的设备信息,用于识别你的账号登录设备。</p>
  532. <p>开发者将在获取你的明示同意后,收集你的微信昵称、头像,用途是【更新OA系统中你的头像信息】</p>
  533. <h4>你的权益</h4>
  534. <p>关于你的个人信息,你可以通过以下方式与开发者联系,行使查阅、复制、更正、删除等法定权利。</p>
  535. <p>若你在小程序中注,不会对外公开披露你的信息,如必须公开披露时,开发者应当向你告知公开披露的目的、披露信息的类型及可能涉及的信息,并征得你的单独同意。</p>
  536. <p>你认为开发者未遵守上述约定,或有其他的投诉建议、或未成年人个人信息保护相关问题,可通过以下方式与开发者联系;或者向微信进行投诉。</p>
  537. <p><strong>邮箱:</strong> DC1612356478@163.com</p>
  538. <p style="margin-top: 20px; color: #999;">更新日期:2025-10-11</p>
  539. `,
  540. },
  541. };
  542. const agreement = agreementData[type];
  543. if (agreement) {
  544. this.agreementDrawer = {
  545. show: true,
  546. title: agreement.title,
  547. content: agreement.content,
  548. };
  549. }
  550. },
  551. // 关闭协议抽屉
  552. closeAgreementDrawer() {
  553. this.agreementDrawer.show = false;
  554. },
  555. // 打开修改初始密码弹窗
  556. openResetPwdModal(data) {
  557. this.resetPwdModal = {
  558. show: true,
  559. yhid: data.yhid || "",
  560. yhm: data.yhm || "",
  561. pwdStrengthMsg:
  562. data.pwdStrengthMsg ||
  563. "密码不能包含账号,最小6个字符,最大16个字符",
  564. };
  565. // 清空表单
  566. this.resetPwdForm = {
  567. newPwd: "",
  568. confirmPwd: "",
  569. };
  570. },
  571. // 校验密码强度(前端校验,与PC端一致)
  572. validatePassword(password, yhm) {
  573. // 获取密码强度要求
  574. const msg = this.resetPwdModal.pwdStrengthMsg || "";
  575. // 检查最小长度
  576. if (msg.includes("最小6个字符") && password.length < 6) {
  577. return { valid: false, msg: "密码长度不能小于6位" };
  578. }
  579. // 检查最大长度
  580. if (msg.includes("最大16个字符") && password.length > 16) {
  581. return { valid: false, msg: "密码长度不能大于16位" };
  582. }
  583. // 检查必须包含大小写字母和数字
  584. if (
  585. msg.includes("必须含有和字母和大小写字母和数字") ||
  586. msg.includes("必须含有大小写字母和数字")
  587. ) {
  588. if (
  589. !/[a-z]/.test(password) ||
  590. !/[A-Z]/.test(password) ||
  591. !/\d/.test(password)
  592. ) {
  593. return {
  594. valid: false,
  595. msg: "密码必须同时包含大小写字母和数字",
  596. };
  597. }
  598. }
  599. // 检查不能包含账号
  600. if (msg.includes("密码不能包含账号") && yhm) {
  601. if (password.includes(yhm)) {
  602. return { valid: false, msg: "密码不能包含账号" };
  603. }
  604. }
  605. return { valid: true, msg: "" };
  606. },
  607. // 提交修改密码
  608. async handleResetPwd() {
  609. const { newPwd, confirmPwd } = this.resetPwdForm;
  610. const { yhid, yhm } = this.resetPwdModal;
  611. // 校验输入
  612. if (!newPwd) {
  613. this.showToast("请输入新密码", "warning");
  614. return;
  615. }
  616. if (!confirmPwd) {
  617. this.showToast("请确认新密码", "warning");
  618. return;
  619. }
  620. if (newPwd !== confirmPwd) {
  621. this.showToast("新密码与确认密码不一致", "error");
  622. return;
  623. }
  624. if (newPwd === this.form.password) {
  625. this.showToast("新密码不能与旧密码相同", "error");
  626. return;
  627. }
  628. // 前端校验密码强度
  629. const validateResult = this.validatePassword(newPwd, yhm);
  630. if (!validateResult.valid) {
  631. this.showToast(validateResult.msg, "error");
  632. return;
  633. }
  634. this.resetPwdLoading = true;
  635. try {
  636. const response = await $.ajax({
  637. url: "/service?ssServ=updPwd",
  638. data: {
  639. yhid: yhid,
  640. newPassword: newPwd,
  641. againNewPassword: confirmPwd,
  642. },
  643. type: "POST",
  644. dataType: "json",
  645. });
  646. console.log("修改密码响应:", response);
  647. // 判断是否成功(有msg且包含"成功",或没有错误信息)
  648. if (response.msg && response.msg.includes("成功")) {
  649. // 修改成功
  650. this.showToast(response.msg, "success");
  651. this.resetPwdModal.show = false;
  652. // 清空密码输入框,保留账号
  653. this.form.password = "";
  654. this.resetPwdForm.newPwd = "";
  655. this.resetPwdForm.confirmPwd = "";
  656. } else if (response.msg && response.msg.includes("失败")) {
  657. this.showToast(response.msg, "error");
  658. } else {
  659. this.showToast(
  660. response.msg || response.message || "密码修改失败",
  661. "error"
  662. );
  663. }
  664. } catch (error) {
  665. console.error("修改密码失败:", error);
  666. this.showToast("修改密码失败,请重试", "error");
  667. } finally {
  668. this.resetPwdLoading = false;
  669. }
  670. },
  671. },
  672. });
  673. console.log("✅ 登录页面初始化完成");
  674. });
  675. </script>
  676. <style>
  677. /* 防止Vue模板闪烁 */
  678. [v-cloak] {
  679. display: none !important;
  680. }
  681. /* 页面加载状态 */
  682. .page-loading {
  683. position: fixed;
  684. top: 0;
  685. left: 0;
  686. right: 0;
  687. bottom: 0;
  688. background: #f5f5f5;
  689. display: flex;
  690. align-items: center;
  691. justify-content: center;
  692. z-index: 9999;
  693. }
  694. .page-loading .loading-content {
  695. text-align: center;
  696. }
  697. .page-loading .loading-spinner {
  698. width: 40px;
  699. height: 40px;
  700. border: 4px solid #f3f3f3;
  701. border-top: 4px solid #40ac6d;
  702. border-radius: 50%;
  703. animation: page-spin 1s linear infinite;
  704. margin: 0 auto 15px;
  705. }
  706. @keyframes page-spin {
  707. 0% {
  708. transform: rotate(0deg);
  709. }
  710. 100% {
  711. transform: rotate(360deg);
  712. }
  713. }
  714. .page-loading .loading-text {
  715. color: #666;
  716. font-size: 14px;
  717. }
  718. * {
  719. margin: 0;
  720. padding: 0;
  721. box-sizing: border-box;
  722. }
  723. body {
  724. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
  725. sans-serif;
  726. background: #f5f5f5;
  727. overflow: hidden;
  728. }
  729. .login-popup {
  730. position: fixed;
  731. left: 0;
  732. right: 0;
  733. top: 0;
  734. bottom: 0;
  735. z-index: 9999;
  736. visibility: hidden;
  737. }
  738. .login-popup.show {
  739. visibility: visible;
  740. }
  741. .mask {
  742. position: absolute;
  743. left: 0;
  744. right: 0;
  745. top: 0;
  746. bottom: 0;
  747. background: rgba(0, 0, 0, 0.6);
  748. }
  749. .popup-content {
  750. width: calc(100% - 20px);
  751. position: absolute;
  752. left: 50%;
  753. top: 50%;
  754. background: #fff;
  755. border-radius: 4px;
  756. padding: 30px 20px;
  757. transform: translate(-50%, -50%);
  758. transition: transform 0.3s ease-out;
  759. border: 1px solid #d3d4d5;
  760. max-height: 80vh;
  761. overflow-y: auto;
  762. }
  763. .popup-header {
  764. display: flex;
  765. justify-content: space-between;
  766. align-items: center;
  767. margin-bottom: 20px;
  768. }
  769. .title {
  770. font-size: 18px;
  771. font-weight: bold;
  772. color: #333;
  773. }
  774. .close-btn {
  775. font-size: 24px;
  776. color: #999;
  777. padding: 10px;
  778. margin: -10px;
  779. cursor: pointer;
  780. user-select: none;
  781. }
  782. .close-btn:hover {
  783. color: #666;
  784. }
  785. .input-item {
  786. position: relative;
  787. margin-bottom: 15px;
  788. display: flex;
  789. }
  790. .input-icon {
  791. position: absolute;
  792. left: 18px;
  793. top: 50%;
  794. transform: translateY(-50%);
  795. z-index: 1;
  796. }
  797. .login-input {
  798. width: 100%;
  799. height: 44px;
  800. /* background: #f5f5f5; */
  801. border-radius: 4px;
  802. padding: 0 40px 0 50px;
  803. font-size: 16px;
  804. border: none;
  805. outline: none;
  806. border: 1px solid #d5d8dc;
  807. }
  808. .login-input:focus {
  809. /* background: #f0f0f0; */
  810. border: 1px solid #d0d2d6;
  811. }
  812. .eye-icon {
  813. position: absolute;
  814. right: 10px;
  815. top: 50%;
  816. transform: translateY(-50%);
  817. padding: 10px;
  818. display: flex;
  819. align-items: center;
  820. justify-content: center;
  821. cursor: pointer;
  822. z-index: 1000;
  823. }
  824. .account-btn {
  825. width: 100%;
  826. height: 44px;
  827. line-height: 44px;
  828. background: #575d6d;
  829. color: #fff;
  830. border-radius: 4px;
  831. font-size: 16px;
  832. border: none;
  833. margin-top: 35px;
  834. transition: all 0.3s ease;
  835. cursor: pointer;
  836. display: flex;
  837. align-items: center;
  838. justify-content: center;
  839. gap: 8px;
  840. }
  841. .btn-icon {
  842. display: inline-block;
  843. }
  844. .account-btn span {
  845. line-height: 1;
  846. }
  847. .account-btn:hover {
  848. background: #555;
  849. }
  850. .account-btn.disabled {
  851. background: #cccccc !important;
  852. color: #999999 !important;
  853. opacity: 0.6;
  854. cursor: not-allowed;
  855. }
  856. /* 用户协议 */
  857. .agreement {
  858. display: flex;
  859. align-items: center;
  860. justify-content: center;
  861. margin-bottom: 25px;
  862. }
  863. /* 自定义checkbox样式 */
  864. .agreement-checkbox {
  865. position: relative;
  866. margin-right: 8px;
  867. width: 20px;
  868. height: 20px;
  869. appearance: none;
  870. -webkit-appearance: none;
  871. border: 2px solid #d5d8dc;
  872. border-radius: 4px;
  873. outline: none;
  874. cursor: pointer;
  875. transition: all 0.2s;
  876. }
  877. .agreement-checkbox:hover {
  878. border-color: #575d6d;
  879. }
  880. .agreement-checkbox:checked {
  881. background-color: #575d6d;
  882. border-color: #575d6d;
  883. }
  884. .agreement-checkbox:checked::after {
  885. content: "";
  886. position: absolute;
  887. left: 5px;
  888. top: 0;
  889. width: 5px;
  890. height: 10px;
  891. border: solid white;
  892. border-width: 0 2px 2px 0;
  893. transform: rotate(45deg);
  894. }
  895. .agreement-text {
  896. font-size: 0.372rem;
  897. font-weight: 500;
  898. color: #999;
  899. cursor: pointer;
  900. }
  901. .link {
  902. /* color: #40ac6d; */
  903. cursor: pointer;
  904. }
  905. .link:hover {
  906. text-decoration: underline;
  907. }
  908. /* Loading 遮罩 */
  909. .loading-mask {
  910. position: fixed;
  911. top: 0;
  912. left: 0;
  913. right: 0;
  914. bottom: 0;
  915. background: rgba(0, 0, 0, 0.5);
  916. display: flex;
  917. align-items: center;
  918. justify-content: center;
  919. z-index: 10000;
  920. }
  921. .loading-content {
  922. background: white;
  923. padding: 20px;
  924. border-radius: 4px;
  925. text-align: center;
  926. min-width: 120px;
  927. }
  928. .loading-spinner {
  929. width: 30px;
  930. height: 30px;
  931. border: 3px solid #f3f3f3;
  932. border-top: 3px solid #40ac6d;
  933. border-radius: 50%;
  934. animation: spin 1s linear infinite;
  935. margin: 0 auto 10px;
  936. }
  937. @keyframes spin {
  938. 0% {
  939. transform: rotate(0deg);
  940. }
  941. 100% {
  942. transform: rotate(360deg);
  943. }
  944. }
  945. .loading-text {
  946. color: #333;
  947. font-size: 14px;
  948. }
  949. /* Toast 提示 */
  950. .toast {
  951. position: fixed;
  952. top: 50%;
  953. left: 50%;
  954. transform: translate(-50%, -50%);
  955. background: rgba(0, 0, 0, 0.8);
  956. color: white;
  957. padding: 12px 20px;
  958. border-radius: 4px;
  959. font-size: 14px;
  960. z-index: 10010;
  961. max-width: 80%;
  962. text-align: center;
  963. }
  964. .toast.success {
  965. background: rgba(40, 167, 69, 0.9);
  966. }
  967. .toast.warning {
  968. background: rgba(255, 193, 7, 0.9);
  969. color: #212529;
  970. }
  971. .toast.error {
  972. background: rgba(220, 53, 69, 0.9);
  973. }
  974. /* ss-confirm 内容样式(标题沿用组件默认,文本做适配) */
  975. .warn-confirm-text {
  976. text-align: center;
  977. padding: 12px 4px;
  978. font-size: 14px;
  979. line-height: 1.6;
  980. color: #333;
  981. }
  982. /* warnMsg 的 ss-confirm 仅保留确认按钮 */
  983. .ss-confirm .confirm-btn-cancel {
  984. display: none;
  985. }
  986. .ss-confirm .confirm-btn-confirm {
  987. width: 100%;
  988. }
  989. /* 自定义确认对话框 - 优化样式 */
  990. .confirm-dialog-mask {
  991. position: fixed;
  992. top: 0;
  993. left: 0;
  994. right: 0;
  995. bottom: 0;
  996. background: rgba(0, 0, 0, 0.6);
  997. display: flex;
  998. align-items: center;
  999. justify-content: center;
  1000. z-index: 10002;
  1001. }
  1002. .confirm-dialog {
  1003. background: white;
  1004. border-radius: 4px;
  1005. min-width: 280px;
  1006. max-width: 90%;
  1007. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  1008. overflow: hidden;
  1009. animation: confirmFadeIn 0.3s ease-out;
  1010. }
  1011. @keyframes confirmFadeIn {
  1012. from {
  1013. opacity: 0;
  1014. transform: scale(0.95) translateY(-20px);
  1015. }
  1016. to {
  1017. opacity: 1;
  1018. transform: scale(1) translateY(0);
  1019. }
  1020. }
  1021. .confirm-message {
  1022. font-size: 16px;
  1023. color: #333;
  1024. text-align: center;
  1025. margin-bottom: 24px;
  1026. line-height: 1.6;
  1027. }
  1028. .confirm-buttons {
  1029. display: flex;
  1030. gap: 10px;
  1031. }
  1032. .confirm-btn {
  1033. flex: 1;
  1034. height: 40px;
  1035. border: none;
  1036. border-radius: 4px;
  1037. font-size: 15px;
  1038. cursor: pointer;
  1039. transition: all 0.2s ease;
  1040. font-weight: 500;
  1041. }
  1042. .cancel-btn {
  1043. background: #f5f5f5;
  1044. color: #666;
  1045. border: 1px solid #e5e5e5;
  1046. }
  1047. .cancel-btn:hover {
  1048. background: #eeeeee;
  1049. border-color: #d5d5d5;
  1050. }
  1051. .confirm-btn-primary {
  1052. background: #575d6d;
  1053. color: white;
  1054. }
  1055. .confirm-btn-primary:hover {
  1056. background: #494e5b;
  1057. }
  1058. .confirm-btn:active {
  1059. transform: scale(0.98);
  1060. }
  1061. /* 底部抽屉样式 */
  1062. .drawer-mask {
  1063. position: fixed;
  1064. top: 0;
  1065. left: 0;
  1066. right: 0;
  1067. bottom: 0;
  1068. background: rgba(0, 0, 0, 0.6);
  1069. z-index: 10003;
  1070. animation: drawerMaskFadeIn 0.3s ease-out;
  1071. }
  1072. @keyframes drawerMaskFadeIn {
  1073. from {
  1074. opacity: 0;
  1075. }
  1076. to {
  1077. opacity: 1;
  1078. }
  1079. }
  1080. .drawer-content {
  1081. position: absolute;
  1082. left: 0;
  1083. right: 0;
  1084. bottom: 0;
  1085. max-height: 80vh;
  1086. background: white;
  1087. border-radius: 4px 4px 0 0;
  1088. animation: drawerSlideUp 0.3s ease-out;
  1089. display: flex;
  1090. flex-direction: column;
  1091. }
  1092. @keyframes drawerSlideUp {
  1093. from {
  1094. transform: translateY(100%);
  1095. }
  1096. to {
  1097. transform: translateY(0);
  1098. }
  1099. }
  1100. .drawer-header {
  1101. display: flex;
  1102. align-items: center;
  1103. justify-content: space-between;
  1104. padding: 16px 20px;
  1105. border-bottom: 1px solid #f0f0f0;
  1106. flex-shrink: 0;
  1107. }
  1108. .drawer-title {
  1109. font-size: 18px;
  1110. font-weight: 600;
  1111. color: #333;
  1112. }
  1113. .drawer-close {
  1114. width: 32px;
  1115. height: 32px;
  1116. display: flex;
  1117. align-items: center;
  1118. justify-content: center;
  1119. cursor: pointer;
  1120. border-radius: 4px;
  1121. transition: background 0.2s;
  1122. }
  1123. .drawer-close:hover {
  1124. background: #f5f5f5;
  1125. }
  1126. .drawer-body {
  1127. flex: 1;
  1128. overflow-y: auto;
  1129. padding: 20px;
  1130. -webkit-overflow-scrolling: touch;
  1131. }
  1132. .drawer-body h3 {
  1133. font-size: 18px;
  1134. color: #333;
  1135. margin-bottom: 16px;
  1136. }
  1137. .drawer-body h4 {
  1138. font-size: 16px;
  1139. color: #555;
  1140. margin-top: 20px;
  1141. margin-bottom: 12px;
  1142. }
  1143. .drawer-body p {
  1144. font-size: 14px;
  1145. color: #666;
  1146. line-height: 1.8;
  1147. margin-bottom: 12px;
  1148. }
  1149. /* 修改初始密码弹窗样式 */
  1150. .reset-pwd-mask {
  1151. position: fixed;
  1152. top: 0;
  1153. left: 0;
  1154. right: 0;
  1155. bottom: 0;
  1156. background: rgba(0, 0, 0, 0.7);
  1157. display: flex;
  1158. align-items: center;
  1159. justify-content: center;
  1160. z-index: 10005;
  1161. }
  1162. .reset-pwd-modal {
  1163. width: calc(100% - 20px);
  1164. position: absolute;
  1165. left: 50%;
  1166. top: 50%;
  1167. background: #fff;
  1168. border-radius: 4px;
  1169. transform: translate(-50%, -50%);
  1170. border: 1px solid #d3d4d5;
  1171. overflow: hidden;
  1172. }
  1173. .reset-pwd-header {
  1174. padding: 20px;
  1175. text-align: left;
  1176. border-bottom: 1px solid #f0f0f0;
  1177. }
  1178. .reset-pwd-title {
  1179. font-size: 18px;
  1180. font-weight: 600;
  1181. color: #333;
  1182. }
  1183. .reset-pwd-body {
  1184. padding: 20px;
  1185. }
  1186. .pwd-strength-msg {
  1187. font-size: 13px;
  1188. color: #ff6b6b;
  1189. margin-bottom: 15px;
  1190. padding: 10px;
  1191. background: #fff5f5;
  1192. border-radius: 4px;
  1193. line-height: 1.5;
  1194. }
  1195. .reset-pwd-form {
  1196. margin-bottom: 20px;
  1197. }
  1198. .reset-pwd-input-item {
  1199. position: relative;
  1200. margin-bottom: 12px;
  1201. display: flex;
  1202. }
  1203. .reset-pwd-input {
  1204. width: 100%;
  1205. height: 44px;
  1206. padding: 0 40px 0 15px;
  1207. border: 1px solid #d5d8dc;
  1208. border-radius: 4px;
  1209. font-size: 15px;
  1210. outline: none;
  1211. transition: border-color 0.2s;
  1212. }
  1213. .reset-pwd-input:focus {
  1214. border-color: #575d6d;
  1215. }
  1216. .reset-pwd-input-item .eye-icon {
  1217. position: absolute;
  1218. right: 10px;
  1219. top: 50%;
  1220. transform: translateY(-50%);
  1221. padding: 10px;
  1222. display: flex;
  1223. align-items: center;
  1224. justify-content: center;
  1225. cursor: pointer;
  1226. z-index: 10;
  1227. }
  1228. .reset-pwd-btn {
  1229. width: 100%;
  1230. height: 44px;
  1231. background: #575d6d;
  1232. color: white;
  1233. border: none;
  1234. border-radius: 4px;
  1235. font-size: 16px;
  1236. cursor: pointer;
  1237. transition: background 0.2s;
  1238. }
  1239. .reset-pwd-btn:hover {
  1240. background: #494e5b;
  1241. }
  1242. .reset-pwd-btn.disabled {
  1243. background: #cccccc;
  1244. cursor: not-allowed;
  1245. }
  1246. /* 响应式设计 */
  1247. /* @media (max-width: 480px) {
  1248. .popup-content {
  1249. padding: 15px 10px;
  1250. }
  1251. .login-input {
  1252. height: 40px;
  1253. font-size: 13px;
  1254. }
  1255. .account-btn {
  1256. height: 40px;
  1257. line-height: 40px;
  1258. font-size: 14px;
  1259. }
  1260. } */
  1261. </style>
  1262. </body>
  1263. </html>