Authored by htoooth

add

... ... @@ -40,10 +40,15 @@ export default {
this.$refs[name].validate((valid) => {
if (valid) {
this.$Message.success('提交成功!');
this.login(this.formInline.user, this.formInline.password).then((userInfo) => {
this.login(this.formInline.user, this.formInline.password).then((result) => {
let userInfo = result.data;
if (userInfo.code !== 200) {
this.$Message.error('用户名或密码错误');
}
this.$cookie.set('USER_NAME', userInfo.data.name);
this.$cookie.set('SHOP_ID', userInfo.data.shop.shopId);
this.$cookie.set('SHOP_NAME', userInfo.data.shop.shopName);
this.$router.push('/');
});
... ...
... ... @@ -2,7 +2,7 @@
* Created by TaoHuang on 2017/4/18.
*/
export default function () {
export default () => {
return {
brand: {},
sort: {}
... ...
... ... @@ -33,13 +33,16 @@
export default {
props: ['step', 'product'],
mounted : function() {
this.getBrand();
},
data() {
return {
formItem: {
brand: '',
sort: ''
}
},
brands: [],
sorts: []
}
},
methods: {
... ... @@ -52,6 +55,11 @@
},
selectSort: function() {
},
getBrand: function() {
api.getBrand(this.$cookie.get('SHOP_ID')).then((result) => {
console.log(result);
});
}
}
}
... ...
... ... @@ -25,6 +25,7 @@
"moment": "^2.18.1",
"request": "^2.81.0",
"request-promise": "^4.2.0",
"serve-favicon": "^2.4.2",
"uuid": "^3.0.1",
"vue": "^2.2.2",
"vue-cookie": "^1.1.4",
... ...
... ... @@ -9,6 +9,8 @@ const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const Express = require('express');
const session = require('express-session');
const favicon = require('serve-favicon');
const path = require('path');
const config = require('./common/config');
const logger = require('yoho-node-lib/lib/logger').init(config);
... ... @@ -32,6 +34,8 @@ app.use(session({
saveUninitialized: true
}));
app.use(favicon(path.join(__dirname, '/favicon.ico')));
app.use(Express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
... ...
... ... @@ -15,7 +15,7 @@ module.exports = (req, res, next) => {
// IP 地址
yoho.clientIp = util.getClientIp(req);
if (req.session && _.isNumber(req.session.LOGIN_UID)) {
if (req.session && req.session.LOGIN_UID) {
req.user.uid = req.session.LOGIN_UID;
let userData = _.get(req.session, 'USER', {});
... ...
... ... @@ -14,13 +14,13 @@ class loginModel extends Context {
let self = this;
return co(function * () {
let userInfo = yield self.instance(Api).post(apiDomain.auth.login, JSON.stringify([username, password, 2]));
let userInfo = yield self.instance(Api).post(apiDomain.auth.login, JSON.stringify([username, password, 2]))
if (userInfo.code !== 200 || !userInfo.data.pid) {
return Promise.reject({code: 500, message: '登录服务器错误'});
}
let shopInfo = yield self.profile(userInfo.data.pid);
let shopInfo = yield self.profile(userInfo.data.pid)
if (shopInfo.code !== 200) {
return Promise.reject({code: 500, message: '用户获取店铺错误'});
... ...