Conflicts: config/index.jswulanhaote
| @@ -0,0 +1,30 @@ | |||
| import JSEncrypt from 'jsencrypt/bin/jsencrypt.min' | |||
| // 密钥对生成 http://web.chacuo.net/netrsakeypair | |||
| const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' + | |||
| 'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==' | |||
| const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' + | |||
| '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' + | |||
| 'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' + | |||
| 'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' + | |||
| 'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' + | |||
| 'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' + | |||
| 'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' + | |||
| 'UP8iWi1Qw0Y=' | |||
| // 加密 | |||
| export function encrypt(txt) { | |||
| const encryptor = new JSEncrypt() | |||
| encryptor.setPublicKey(publicKey) // 设置公钥 | |||
| return encryptor.encrypt(txt) // 对数据进行加密 | |||
| } | |||
| // 解密 | |||
| export function decrypt(txt) { | |||
| const encryptor = new JSEncrypt() | |||
| encryptor.setPrivateKey(privateKey) // 设置私钥 | |||
| return encryptor.decrypt(txt) // 对数据进行解密 | |||
| } | |||
| @@ -50,6 +50,9 @@ | |||
| <img class="code-img" :src="codeUrl" @click="getCode" /> | |||
| </template> | |||
| </van-field> | |||
| <van-checkbox style="float: left;margin-top:10px;margin-left:20px;" v-model="formData.rememberMe" shape="square">{{showMessage ? "记住手机号" : "记住密码"}}</van-checkbox> | |||
| <p style="float: right;margin-top:10px;margin-right:20px;color:#1D6FE9 ">忘记密码</p> | |||
| <div class="clear"></div> | |||
| </div> | |||
| <div v-show="isSmsLogin"> | |||
| <van-field | |||
| @@ -108,6 +111,7 @@ | |||
| <script> | |||
| import { getCodeImg, getSmsCode } from "@/api/login"; | |||
| import Cookies from "js-cookie"; | |||
| import { encrypt, decrypt } from "../utils/jsencrypt"; | |||
| //引用wx sdk | |||
| import wx from "weixin-js-sdk"; | |||
| export default { | |||
| @@ -123,6 +127,7 @@ export default { | |||
| uuid: null, //识别uuid | |||
| mobile: null, //手机号 | |||
| smsCode: null, //短信验证码 | |||
| rememberMe:false | |||
| }, | |||
| loading: false, | |||
| codeUrl: "", //验证码 | |||
| @@ -134,6 +139,7 @@ export default { | |||
| created() { | |||
| this.getCode(); | |||
| this.height = document.body.clientHeight | |||
| this.getCookie(); | |||
| //调用微信公众号方法 | |||
| // wx.config({ | |||
| // debug: true, // 开启调试模式, | |||
| @@ -152,6 +158,17 @@ export default { | |||
| this.codeUrl = "data:image/gif;base64," + res.img; | |||
| }); | |||
| }, | |||
| getCookie() { | |||
| const username = Cookies.get("username"); | |||
| const password = Cookies.get("password"); | |||
| const rememberMe = Cookies.get("rememberMe"); | |||
| this.formData = { | |||
| username: username === undefined ? this.formData.username : username, | |||
| password: | |||
| password === undefined ? this.formData.password : decrypt(password), | |||
| rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), | |||
| }; | |||
| }, | |||
| getSmsCode() { | |||
| if (!this.computeTime) { | |||
| let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/; | |||
| @@ -203,6 +220,15 @@ export default { | |||
| this.loading = false; | |||
| }); | |||
| } else { | |||
| if (this.formData.rememberMe) { | |||
| Cookies.set("username", this.formData.username, { expires: 30 }); | |||
| Cookies.set("password", encrypt(this.formData.password), { expires: 30 }); | |||
| Cookies.set("rememberMe", this.formData.rememberMe, { expires: 30 }); | |||
| } else { | |||
| Cookies.remove("username"); | |||
| Cookies.remove("password"); | |||
| Cookies.remove("rememberMe"); | |||
| } | |||
| //账号密码登录 | |||
| if (this.formData.username == "") { | |||
| this.$dialog.alert({ | |||
| @@ -30,7 +30,9 @@ | |||
| <img style="width: 100px" :src="codeUrl" @click="getCode" /> | |||
| </template> | |||
| </van-field> | |||
| <p style="text-align: right;margin-top:10px;margin-right:20px;color:#1D6FE9 ">忘记密码</p> | |||
| <van-checkbox style="float: left;margin-top:10px;margin-left:20px;" v-model="formData.rememberMe" shape="square">{{showMessage ? "记住手机号" : "记住密码"}}</van-checkbox> | |||
| <p style="float: right;margin-top:10px;margin-right:20px;color:#1D6FE9 ">忘记密码</p> | |||
| <div class="clear"></div> | |||
| <div style="margin: 50px 16px 16px;"> | |||
| <van-button block type="info" native-type="submit" @click="handleLogin">登录</van-button> | |||
| <p style="text-align: center;margin-top: 20px;color:#878787 " @click="showMessagePop">短信验证码登录</p> | |||
| @@ -193,6 +195,7 @@ | |||
| <script> | |||
| import { getCodeImg, getSmsCode ,getRegisterSmsCode,registerCheck,registerOn} from "../api/login"; | |||
| import Cookies from "js-cookie"; | |||
| import { encrypt, decrypt } from "../utils/jsencrypt"; | |||
| //引用wx sdk | |||
| import wx from "weixin-js-sdk"; | |||
| export default { | |||
| @@ -211,6 +214,7 @@ export default { | |||
| smsCode: null, //短信验证码 | |||
| memberName:null, //身份信息 | |||
| idcard:null, //身份号码 | |||
| rememberMe:false | |||
| }, | |||
| loading: false, | |||
| codeUrl: "", //验证码 | |||
| @@ -221,6 +225,7 @@ export default { | |||
| }, | |||
| created() { | |||
| this.getCode(); | |||
| this.getCookie(); | |||
| this.reset(); | |||
| }, | |||
| methods: { | |||
| @@ -239,6 +244,17 @@ export default { | |||
| this.codeUrl = "data:image/gif;base64," + res.img; | |||
| }); | |||
| }, | |||
| getCookie() { | |||
| const username = Cookies.get("username"); | |||
| const password = Cookies.get("password"); | |||
| const rememberMe = Cookies.get("rememberMe"); | |||
| this.formData = { | |||
| username: username === undefined ? this.formData.username : username, | |||
| password: | |||
| password === undefined ? this.formData.password : decrypt(password), | |||
| rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), | |||
| }; | |||
| }, | |||
| getSmsCode() { | |||
| if (this.formData.code == "") { | |||
| this.$dialog.alert({ | |||
| @@ -297,6 +313,15 @@ export default { | |||
| this.loading = false; | |||
| }); | |||
| } else { | |||
| if (this.formData.rememberMe) { | |||
| Cookies.set("username", this.formData.username, { expires: 30 }); | |||
| Cookies.set("password", encrypt(this.formData.password), { expires: 30 }); | |||
| Cookies.set("rememberMe", this.formData.rememberMe, { expires: 30 }); | |||
| } else { | |||
| Cookies.remove("username"); | |||
| Cookies.remove("password"); | |||
| Cookies.remove("rememberMe"); | |||
| } | |||
| //账号密码登录 | |||
| if (this.formData.username == "") { | |||
| this.$dialog.alert({ | |||