前端登录

This commit is contained in:
Administrator 2020-09-24 23:37:48 +08:00
parent 1e28ee7904
commit 7e5fa7696e
8 changed files with 78 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package com.ruoyi.business.ajax;
import com.ruoyi.business.domain.BizCashInfo; import com.ruoyi.business.domain.BizCashInfo;
import com.ruoyi.business.domain.BizMember; import com.ruoyi.business.domain.BizMember;
import com.ruoyi.business.domain.BizMemberAddress; import com.ruoyi.business.domain.BizMemberAddress;
import com.ruoyi.business.service.IBizCashInfoService;
import com.ruoyi.business.service.IBizMemberAddressService; import com.ruoyi.business.service.IBizMemberAddressService;
import com.ruoyi.business.service.IBizMemberService; import com.ruoyi.business.service.IBizMemberService;
import com.ruoyi.common.annotation.AjaxLogin; import com.ruoyi.common.annotation.AjaxLogin;
@ -27,6 +28,9 @@ public class AjaxMemberController extends AuthController {
@Resource @Resource
private IBizMemberAddressService bizMemberAddressService; private IBizMemberAddressService bizMemberAddressService;
@Resource
private IBizCashInfoService bizCashInfoService;
//个人中心 //个人中心
@PostMapping("/center") @PostMapping("/center")
public AjaxResult center() public AjaxResult center()

View File

@ -10,7 +10,15 @@ module.exports = {
// Paths // Paths
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '/', assetsPublicPath: '/',
proxyTable: {}, proxyTable: {
'/': {
target: 'http://192.168.1.101:80',
changeOrigin: true,
pathRewrite: {
'^/': ''
}
}
},
// Various Dev Server settings // Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST host: 'localhost', // can be overwritten by process.env.HOST

View File

@ -280,6 +280,14 @@
"postcss-value-parser": "^3.2.3" "postcss-value-parser": "^3.2.3"
} }
}, },
"axios": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
"integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"babel-code-frame": { "babel-code-frame": {
"version": "6.26.0", "version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@ -4090,8 +4098,7 @@
"follow-redirects": { "follow-redirects": {
"version": "1.13.0", "version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==", "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
"dev": true
}, },
"for-in": { "for-in": {
"version": "1.0.2", "version": "1.0.2",

View File

@ -0,0 +1,5 @@
module.exports = {
plugins: {
'autoprefixer': {browsers: 'last 5 version'}
}
}

View File

@ -20,6 +20,7 @@
</template> </template>
<script> <script>
export default { export default {
name: 'Header', name: 'Header',
props: { props: {
@ -40,6 +41,16 @@ export default {
return { return {
} }
}, },
created() {
//
if(this.$route.path == "/") return;
let token = localStorage.getItem("loginToken");
if(!token || token.length == 0){
this.$router.push({
path: '/',
});
}
},
methods: { methods: {
back() { back() {
if(this.type === 'close') { if(this.type === 'close') {
@ -47,7 +58,7 @@ export default {
} else { } else {
this.$router.back(); this.$router.back();
} }
}, }
} }
} }
</script> </script>

View File

@ -6,6 +6,7 @@ const verbs = {
mode: 'cors', mode: 'cors',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization' : localStorage.getItem("loginUser")
}, },
body: JSON.stringify(params), body: JSON.stringify(params),
}); });

View File

@ -0,0 +1,15 @@
import {MessageBox} from "mint-ui";
export default {
warnFunc: (res) => {
if (res.code == 301) {
MessageBox({
title: '提示',
message: res.msg,
showCancelButton: false
});
return true;
}
return false;
}
}

View File

@ -15,11 +15,13 @@
import { Field } from 'mint-ui'; import { Field } from 'mint-ui';
import { Button } from 'mint-ui'; import { Button } from 'mint-ui';
import request from '../utils/request.js'; import request from '../utils/request.js';
import util from '../utils/util.js';
import { Toast } from 'mint-ui'; import { Toast } from 'mint-ui';
import { MessageBox } from 'mint-ui'; import { MessageBox } from 'mint-ui';
import field from '../components/field'; import field from '../components/field';
import Header from '../components/header'; import Header from '../components/header';
export default { export default {
components: { components: {
Field, Field,
@ -31,14 +33,21 @@ export default {
}, },
data () { data () {
return { return {
username: '', shopPhone: '',
password: '', shopPwd: '',
} };
}, },
async created() { async created() {
const url = 'https://api.apiopen.top/getJoke?page=1&count=2&type=video'; const url = 'https://api.apiopen.top/getJoke?page=1&count=2&type=video';
const res = await request({}, url); const res = await request({}, url);
console.log('res >>> ', res); console.log('res >>> ', res);
let dataStr = localStorage.getItem("loginUser");
if(dataStr && dataStr.length > 0) {
let user = JSON.parse(dataStr);
this.$refs.shopPhone.val = user.mobile;
this.$refs.shopPwd.val = user.password;
}
}, },
methods: { methods: {
login() { login() {
@ -51,10 +60,19 @@ export default {
showCancelButton: false showCancelButton: false
}); });
} else { } else {
let data = {mobile:username, password:password};
request(data, "/ajax/login").then(res => {
window.top.resss = res;
if(util.warnFunc(res)) return;
if(res.code == 0){
localStorage.setItem("loginToken", res.msg);
localStorage.setItem("loginUser", JSON.stringify(data));
this.$router.push({ this.$router.push({
path: '/home', path: '/home',
}); });
} }
});
}
}, },
close() { close() {
alert('close'); alert('close');