登录和注册(四)重新修改密码页——清除session之sessionStorage.removeItem
效果
代码
src\views\changPasswordP.vue
<template> <div id="changPasswordP"> <p class="changPasswordPTop">请重新修改密码</p> <ul> <li> <p>账号</p><b>:</b><input type="text" disabled v-model="IphoneNumber"> </li> <li> <p><span>*</span>原密码</p><b>:</b><input type="password" @blur="pwd()" v-model="OldPassword"> </li> <p style="position:absolute;color: red;font-size: 12px;margin-left: 90px;margin-top: -9px;">{
{ yuanmi }}</p> <li> <p><span>*</span>新密码</p><b>:</b><input type="password" @blur="pwds()" v-model="NewPassword" id="xin"> </li> <p style="position:absolute;color: red;font-size: 12px;margin-left: 90px;margin-top: -9px;">{
{ xinmi }}</p> <li> <p><span>*</span>确认密码</p><b>:</b><input type="password" @blur="bul()" v-model="SurePassword" id="que"> </li> <p style="position:absolute;color: red;font-size: 12px;margin-left: 90px;margin-top: -9px;">{
{ quemi }}</p> </ul> <div class="changPasswordP"> <el-button type="primary" link @click="cancal">取消</el-button> <el-button type="primary" @click="reset">重置</el-button> </div> </div> </template> <script> import { inject } from "vue"; import { post } from "@/utils/path"; import * as allCookie from '../utils/utils.js'; export default { data() { return { yuanmi: "", xinmi: "", quemi: "", IphoneNumber: window.sessionStorage.getItem("IphoneNumber"), OldPassword: "", NewPassword: "", SurePassword: "", enPwd: "", enPwds: "", constant: inject('constant'), $message: inject('message') } }, methods: { pwd() { if (this.OldPassword == '') { this.yuanmi = '请输入原密码'; return false; } else { var pwd = this.OldPassword var key = generateSM4Key() var cipherText = SM4Encrypt(pwd, key); var cipherKey = SG_sm2Encrypt(key, "045305e570ba7c50795aadfeb1396f84cb22ec788d81e7bd1cd6b51c9e53680c942bf9b3614a658aa5921c0920bacf6a3070e007bf217d70"); this.enPwd = cipherKey + ',' + cipherText; this.yuanmi = '' return true } }, pwds() { var mys = /(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=([!-~]+)[^a-zA-Z0-9])/g; if (this.NewPassword == '') { this.xinmi = '请输入新密码'; return false; } else if (!mys.test(this.NewPassword)) { this.xinmi = '必须包含大小写字母、数字、特殊字符,长度为8-20'; return false; } else if (this.NewPassword.length < 8 || this.NewPassword.length > 20) { this.xinmi = '必须包含大小写字母、数字、特殊字符,长度为8-20'; return false; } else if (this.IphoneNumber == this.NewPassword) { this.xinmi = '用户名密码相同,请重新填写'; return false; } else if (this.NewPassword.indexOf(this.IphoneNumber) != '-1') { this.xinmi = '密码中含有用户名,请重新填写'; return false; } else if (this.OldPassword == this.NewPassword) { this.xinmi = '新密码和原密码相同' return false; } else { var pwd = this.NewPassword var key = generateSM4Key() var cipherText = SM4Encrypt(pwd, key); var cipherKey = SG_sm2Encrypt(key, "045305e570ba7c50795aadfeb1396f84cb22ec788d81e7bd1cd6b51c9e53680c942bf9b3614a658aa5921c0920bacf6a3070e007bf217d70"); this.enPwds = cipherKey + ',' + cipherText; this.xinmi = '' return true } }, bul() { var xin = document.getElementById("xin").value; var que = document.getElementById("que").value; if (this.SurePassword == '') { this.quemi = "请再次输入密码"; return false; } else if (xin == que) { this.quemi = ""; return true; } else { this.quemi = "两次输入的密码不一致"; return false; } }, // 取消 cancal() { window.sessionStorage.removeItem('roles'); window.sessionStorage.removeItem('tokenId'); window.sessionStorage.removeItem('userName'); window.sessionStorage.removeItem('userType'); window.sessionStorage.removeItem('companyType'); window.sessionStorage.removeItem('userId'); window.sessionStorage.removeItem('status'); window.sessionStorage.removeItem('isSgcc'); window.sessionStorage.removeItem('Web-Token'); window.sessionStorage.removeItem('ser'); window.sessionStorage.removeItem('userRealName'); window.sessionStorage.removeItem('deptname'); window.sessionStorage.removeItem('parentName'); window.sessionStorage.removeItem('parentId'); window.sessionStorage.removeItem('custId'); allCookie.CookieRemove("web_token"); this.$router.back() }, // 重置 reset() { if (!this.pwd() || !this.pwds() || !this.bul()) { return } else { var that = this; post(this.constant.publicCoop + "/users/primordialpass/edit", { "tokenId": window.sessionStorage.getItem("IphoneTokenId"), "oldCertificate": this.enPwd, "newCertificate": this.enPwds }).then(function (res) { if (res.data.result == 0) { window.sessionStorage.removeItem('roles'); window.sessionStorage.removeItem('tokenId'); window.sessionStorage.removeItem('userName'); window.sessionStorage.removeItem('userType'); window.sessionStorage.removeItem('companyType'); window.sessionStorage.removeItem('userId'); window.sessionStorage.removeItem('status'); window.sessionStorage.removeItem('isSgcc'); window.sessionStorage.removeItem('Web-Token'); window.sessionStorage.removeItem('ser'); window.sessionStorage.removeItem('userRealName'); window.sessionStorage.removeItem('deptname'); window.sessionStorage.removeItem('parentName'); window.sessionStorage.removeItem('parentId'); window.sessionStorage.removeItem('custId'); allCookie.CookieRemove("web_token"); if (that.isIsc) { that.$router.push("/loginOutSide") } else { that.$router.push("/login") } } else { that.$message.error(res.data.message) } }) } } } } </script> <style lang="scss"> #changPasswordP { width: 1200px; height: 450px; margin: 20px auto; .changPasswordPTop { width: 726px; height: 100px; line-height: 100px; margin: auto; color: red; font-weight: bold; font-size: 20px; } ul { width: 726px; margin: auto; position: relative; li { width: 100%; height: 60px; overflow: hidden; line-height: 60px; p { width: 73px; height: 60px; text-align: justify; float: left; display: inline-block; vertical-align: top; span { color: red; } } p::after { content: ""; display: inline-block; width: 100%; overflow: hidden; height: 0; } b { float: left; font-weight: 100; } input { width: 600px; float: left; height: 30px; border: 1px solid #e5e5e5; border-radius: 5px; margin-top: 15px; } } } .changPasswordP { width: 726px; margin: 30px auto; text-align: center; input { width: 88px; height: 36px; background: #009688; color: #fff; border-radius: 5px; cursor: pointer; } input:nth-of-type(1) { background: #fff; color: #000; margin-right: 25px; } } } </style>
到此这篇登录和注册(四)重新修改密码页——清除session之sessionStorage.removeItem的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!
版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/rfx/10680.html