Authored by htoooth

add shop

// api调用列表
let domainApis = {
login: '/login'
login: '/login',
brand: '/SellerProductController/getSellerBrandInfo',
category: '/SellerProductController/getSellerSortInfo'
};
export default domainApis;
... ...
... ... @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>YOHO大数据平台</title>
<title>YOHO商铺管理平台</title>
</head>
<body>
<div id="app"></div>
... ...
... ... @@ -17,7 +17,11 @@
</Input>
</Form-item>
<Form-item class="login-btn">
<Button type="primary" @click="handleSubmit('formInline')">登录</Button>
<Button type="primary"
@click="handleSubmit('formInline')"
@keyup.enter="handleSubmit('formInline')">
登录
</Button>
</Form-item>
</Form>
</Card>
... ...
import apiUrl from '../../../../config/api-domain'
const request = require('axios');
function getBrand(shopId) {
return request.get(apiUrl.brand, {shopsId:shopId})
}
function getCategory(shopId, brandId, level , sortId) {
let opts = {
shopsId: shopId,
brandId: brandId,
level: level
};
if (sortId) {
Object.assign(opts, {sortId});
}
return request.get(apiUrl.category, opts);
}
export default {
getBrand,
getCategory
}
... ...
... ... @@ -9,22 +9,21 @@
</Row>
<Row>
<router-view :step="step"></router-view>
<router-view :step="step" :product="product"></router-view>
</Row>
</div>
</template>
<script>
import makeProduct from './store'
export default {
data() {
return {
step: {
value: 0
}
}
},
methods: {
handleStep(step) {
this.step = step
},
product: makeProduct()
}
}
}
... ...
... ... @@ -2,6 +2,9 @@
* Created by TaoHuang on 2017/4/18.
*/
export default {
step: 0
export default function () {
return {
brand: {},
sort: {}
};
}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@
<Row>
<Form :model="formItem" :label-width="80">
<Form-item label="品 牌*">
<Select v-model="formItem.select" placeholder="请选择">
<Select v-model="formItem.sort" placeholder="请选择">
<Option value="beijing">北京市</Option>
<Option value="shanghai">上海市</Option>
<Option value="shenzhen">深圳市</Option>
... ... @@ -11,7 +11,7 @@
</Form-item>
<Form-item label="类目*">
<Select v-model="formItem.select" placeholder="请选择">
<Select v-model="formItem.sort" placeholder="请选择">
<Option value="beijing">北京市</Option>
<Option value="shanghai">上海市</Option>
<Option value="shenzhen">深圳市</Option>
... ... @@ -27,12 +27,18 @@
</template>
<script>
import api from '../api'
export default {
props: ['step'],
props: ['step', 'product'],
mounted : function() {
},
data() {
return {
formItem: {
brand: '',
sort: ''
}
}
},
... ... @@ -40,6 +46,12 @@
nextStep: function() {
this.step.value = 1;
this.$router.push({name:'product.create.step2'});
},
selectBrand: function() {
},
selectSort: function() {
}
}
}
... ...
... ... @@ -103,7 +103,7 @@
<script>
export default {
props: ['step'],
props: ['step', 'product'],
data() {
return {
formItem: {
... ...
... ... @@ -29,7 +29,7 @@
<script>
export default {
props: ['step'],
props: ['step', 'product'],
data() {
return {
formItem: {
... ...
/**
* Created by TaoHuang on 2017/4/19.
*/
const _ = require('lodash');
module.exports = {
isAllowdShopId: (shopId, req) => {
return _.find(req.user.allowedShops, {shopsId: shopId}) ? true: false;
}
};
\ No newline at end of file
... ...
... ... @@ -7,6 +7,8 @@
const Context = require('../common/context');
const UserService = require('../service/user-service');
const _ = require('lodash');
const config = global.yoho.config;
class UserController extends Context {
... ... @@ -18,7 +20,11 @@ class UserController extends Context {
return res.json({
code: 200,
data: {
name: result.data.account
name: result.data.account,
shop: {
shopId: req.session.CURRENT_SHOP.shopsId,
shopName: req.session.CURRENT_SHOP.shopName
}
}
});
} else {
... ... @@ -29,6 +35,7 @@ class UserController extends Context {
}
}).catch(next);
}
logout(req, res) {
delete res.session.LOGIN_UID;
delete res.session.USER;
... ... @@ -43,6 +50,7 @@ class UserController extends Context {
syncSession(req, res, user) {
req.session.USER = user;
req.session.LOGIN_UID = user.pid; // pid 为用户名
req.session.CURRENT_SHOP = _.first(user.allowedShops); // 取第一个为当前进入的店铺
res.cookie('USER_NAME', user.account, {
domain: config.cookieDomain
... ...
... ... @@ -22,6 +22,11 @@ module.exports = (req, res, next) => {
_.merge(req.user, userData);
}
// 当前选择的店铺
if (req.session && req.session.CURRENT_SHOP) {
_.merge(req.user, {currentShop: req.session.CURRENT_SHOP});
}
Object.assign(req.yoho, yoho);
next();
... ...
... ... @@ -14,7 +14,7 @@ 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])).catch(console.log);
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: '登录服务器错误'});
... ... @@ -26,7 +26,7 @@ class loginModel extends Context {
return Promise.reject({code: 500, message: '用户获取店铺错误'});
}
let user = Object.assign(userInfo.data, {allowShops: shopInfo.data});
let user = Object.assign(userInfo.data, {allowedShops: shopInfo.data});
return {
code: 200,
... ...