1 line
4.0 KiB
JSON
1 line
4.0 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.json.stringify.js\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport md5 from 'js-md5';\nexport default {\n name: \"Login\",\n data: function data() {\n return {\n to: '/',\n //登陆成功跳转的页面\n user: {}\n };\n },\n created: function created() {\n this.to = this.$route.query.to ? this.$route.query.to : \"/\";\n },\n methods: {\n onSubmit: function onSubmit() {\n var _this = this;\n\n if (this.user.username === '' || this.user.password === '') {\n this.$message.error(\"账号或密码不能为空\");\n return false;\n }\n\n this.user.password = md5(this.user.password);\n this.request.post(\"/login\", this.user).then(function (res) {\n if (res.code === '200') {\n _this.$message.success({\n message: \"登陆成功\",\n showClose: true\n });\n\n _this.$router.push(_this.to);\n\n localStorage.setItem(\"user\", JSON.stringify(res.data));\n } else {\n _this.$message.error(res.msg);\n }\n });\n }\n }\n};","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA;AACA;AACAA,eADA;AAEAC,MAFA,kBAEA;AACA;AACAC,aADA;AACA;AACAC;AAFA;AAIA,GAPA;AAQAC,SARA,qBAQA;AACA;AACA,GAVA;AAWAC;AACAC,YADA,sBACA;AAAA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AAAAC;AAAAC;AAAA;;AACA;;AACAC;AACA,SAJA,MAIA;AACA;AACA;AACA,OARA;AASA;AAhBA;AAXA","names":["name","data","to","user","created","methods","onSubmit","message","showClose","localStorage"],"sourceRoot":"src/views","sources":["Login.vue"],"sourcesContent":["<template>\r\n<div class=\"wrapper\" >\r\n <div class=\"login-box\">\r\n\r\n <div class=\"title\">\r\n <b>欢迎登录在线商城</b>\r\n </div>\r\n <div style=\"margin-top: 30px\">\r\n <el-form label-width=\"70px\">\r\n <el-form-item label=\"用户名\">\r\n <el-input v-model.trim=\"user.username\" aria-required=\"true\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"密码\" style=\"margin-top: 25px\">\r\n <el-input v-model.trim=\"user.password\" show-password aria-required=\"true\"></el-input>\r\n </el-form-item>\r\n <el-form-item style=\"margin: 30px 80px\">\r\n <el-button type=\"success\" @click=\"onSubmit\">登录</el-button>\r\n <el-button @click=\"$router.push('/register')\">注册</el-button>\r\n </el-form-item>\r\n </el-form>\r\n </div>\r\n\r\n\r\n\r\n </div>\r\n</div>\r\n</template>\r\n\r\n<script>\r\nimport md5 from 'js-md5'\r\nexport default {\r\n name: \"Login\",\r\n data(){\r\n return {\r\n to: '/',//登陆成功跳转的页面\r\n user: {},\r\n }\r\n },\r\n created() {\r\n this.to = this.$route.query.to ? this.$route.query.to : \"/\"\r\n },\r\n methods: {\r\n onSubmit() {\r\n if(this.user.username==='' || this.user.password===''){\r\n this.$message.error(\"账号或密码不能为空\")\r\n return false;\r\n }\r\n this.user.password = md5(this.user.password);\r\n this.request.post(\"/login\",this.user).then(res=>{\r\n if(res.code==='200'){\r\n this.$message.success({message: \"登陆成功\",showClose: true})\r\n this.$router.push(this.to)\r\n localStorage.setItem(\"user\",JSON.stringify(res.data))\r\n }else{\r\n this.$message.error(res.msg)\r\n }\r\n })\r\n }\r\n }\r\n}\r\n</script>\r\n\r\n<style scoped>\r\n.wrapper {\r\n height: 100vh;\r\n background-image: linear-gradient(to top right,lightblue,#B3C0D1);\r\n overflow: auto;\r\n}\r\n.login-box {\r\n margin: 220px auto;\r\n padding: 40px;\r\n width: 450px;\r\n height: 280px;\r\n background-color: #ffffff;\r\n border-radius: 10px;\r\n}\r\n.title {\r\n text-align: center;\r\n margin: 30px auto;\r\n font-size: 25px;\r\n}\r\n</style>"]},"metadata":{},"sourceType":"module"} |