Commit 9eaf2db3 authored by Menethil's avatar Menethil
Browse files

修复上传TOKEN问题

parent 23311bab
...@@ -10,7 +10,7 @@ import org.springframework.web.method.support.ModelAndViewContainer; ...@@ -10,7 +10,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
public class LoginAdminHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { public class LoginAdminHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
public static final String LOGIN_TOKEN_KEY = "X-Token"; public static final String LOGIN_TOKEN_KEY = "Admin-Token";
@Override @Override
public boolean supportsParameter(MethodParameter parameter) { public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterType().isAssignableFrom(Integer.class)&&parameter.hasParameterAnnotation(LoginAdmin.class); return parameter.getParameterType().isAssignableFrom(Integer.class)&&parameter.hasParameterAnnotation(LoginAdmin.class);
......
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"',
ENV_CONFIG: '"dep"', ENV_CONFIG: '"dep"',
BASE_API: '"http://122.152.206.172:8080/admin"' BASE_API: '"http://localhost:8080/admin"'
} }
<template> <template>
<div class="upload-container"> <div class="upload-container">
<el-upload class="image-uploader" :data="dataObj" drag :multiple="false" :show-file-list="false" action="https://httpbin.org/post" <el-upload class="image-uploader" :data="dataObj" :headers="headers" drag :multiple="false" :show-file-list="false" action="https://httpbin.org/post"
:on-success="handleImageScucess"> :on-success="handleImageScucess">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
...@@ -28,6 +28,11 @@ export default { ...@@ -28,6 +28,11 @@ export default {
computed: { computed: {
imageUrl() { imageUrl() {
return this.value return this.value
},
headers() {
return {
'Admin-Token': getToken()
}
} }
}, },
data() { data() {
......
<template> <template>
<div class="singleImageUpload2 upload-container"> <div class="singleImageUpload2 upload-container">
<el-upload class="image-uploader" :data="dataObj" drag :multiple="false" :show-file-list="false" action="https://httpbin.org/post" <el-upload class="image-uploader" :data="dataObj" :headers="headers" drag :multiple="false" :show-file-list="false" action="https://httpbin.org/post"
:on-success="handleImageScucess"> :on-success="handleImageScucess">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">Drag或<em>点击上传</em></div> <div class="el-upload__text">Drag或<em>点击上传</em></div>
...@@ -27,6 +27,11 @@ export default { ...@@ -27,6 +27,11 @@ export default {
computed: { computed: {
imageUrl() { imageUrl() {
return this.value return this.value
},
headers() {
return {
'Admin-Token': getToken()
}
} }
}, },
data() { data() {
......
<template> <template>
<div class="upload-container"> <div class="upload-container">
<el-upload class="image-uploader" :data="dataObj" drag :multiple="false" :show-file-list="false" action="https://httpbin.org/post" <el-upload class="image-uploader" :data="dataObj" :headers="headers" drag :multiple="false" :show-file-list="false" action="https://httpbin.org/post"
:on-success="handleImageScucess"> :on-success="handleImageScucess">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
...@@ -35,6 +35,11 @@ export default { ...@@ -35,6 +35,11 @@ export default {
computed: { computed: {
imageUrl() { imageUrl() {
return this.value return this.value
},
headers() {
return {
'Admin-Token': getToken()
}
} }
}, },
data() { data() {
......
...@@ -13,7 +13,7 @@ const service = axios.create({ ...@@ -13,7 +13,7 @@ const service = axios.create({
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
// Do something before request is sent // Do something before request is sent
if (store.getters.token) { if (store.getters.token) {
config.headers['X-Token'] = getToken() // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改 config.headers['Admin-Token'] = getToken() // 让每个请求携带token-- ['Admin-Token']为自定义key 请根据实际情况自行修改
} }
return config return config
}, error => { }, error => {
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</el-form-item> </el-form-item>
<el-form-item label="评论图片" prop="picUrls"> <el-form-item label="评论图片" prop="picUrls">
<!-- <el-input v-model="dataForm.picUrls"></el-input> --> <!-- <el-input v-model="dataForm.picUrls"></el-input> -->
<el-upload action="#" list-type="picture" :show-file-list="false" :limit="5" :http-request="uploadPicUrls"> <el-upload action="#" list-type="picture" :headers="headers" :show-file-list="false" :limit="5" :http-request="uploadPicUrls">
<el-button size="small" type="primary">点击上传</el-button> <el-button size="small" type="primary">点击上传</el-button>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
...@@ -98,9 +98,17 @@ ...@@ -98,9 +98,17 @@
<script> <script>
import { listComment, createComment, updateComment, deleteComment } from '@/api/comment' import { listComment, createComment, updateComment, deleteComment } from '@/api/comment'
import { createStorage } from '@/api/storage' import { createStorage } from '@/api/storage'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'Comment', name: 'Comment',
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
return { return {
list: undefined, list: undefined,
...@@ -260,4 +268,4 @@ export default { ...@@ -260,4 +268,4 @@ export default {
} }
} }
} }
</script> </script>
\ No newline at end of file
<template> <template>
<div class="app-container calendar-list-container"> <div class="app-container calendar-list-container">
<el-card class="box-card"> <el-card class="box-card">
<h3>商品介绍</h3> <h3>商品介绍</h3>
<el-form :rules="rules" ref="goods" :model="goods" label-width="150px"> <el-form :rules="rules" ref="goods" :model="goods" label-width="150px">
<el-form-item label="商品编号" prop="goodsSn"> <el-form-item label="商品编号" prop="goodsSn">
<el-input v-model="goods.goodsSn"></el-input> <el-input v-model="goods.goodsSn"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="商品名称" prop="name"> <el-form-item label="商品名称" prop="name">
<el-input v-model="goods.name"></el-input> <el-input v-model="goods.name"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="专柜价格" prop="counterPrice"> <el-form-item label="专柜价格" prop="counterPrice">
<el-input v-model="goods.counterPrice" placeholder="0.00"> <el-input v-model="goods.counterPrice" placeholder="0.00">
<template slot="append"></template> <template slot="append"></template>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<el-input v-model="goods.retailPrice" placeholder="0.00"> <el-input v-model="goods.retailPrice" placeholder="0.00">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="是否新品" prop="isNew"> <el-form-item label="是否新品" prop="isNew">
<el-radio-group v-model="goods.isNew"> <el-radio-group v-model="goods.isNew">
<el-radio :label="true">新品</el-radio> <el-radio :label="true">新品</el-radio>
...@@ -31,44 +31,47 @@ ...@@ -31,44 +31,47 @@
<el-radio :label="false">普通</el-radio> <el-radio :label="false">普通</el-radio>
<el-radio :label="true">热卖</el-radio> <el-radio :label="true">热卖</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="是否在售" prop="isOnSale"> <el-form-item label="是否在售" prop="isOnSale">
<el-radio-group v-model="goods.isOnSale"> <el-radio-group v-model="goods.isOnSale">
<el-radio :label="true">在售</el-radio> <el-radio :label="true">在售</el-radio>
<el-radio :label="false">未售</el-radio> <el-radio :label="false">未售</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="商品图片"> <el-form-item label="商品图片">
<el-upload class="avatar-uploader" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl"> <el-upload class="avatar-uploader" :action="uploadPath" list-type="picture-card" :show-file-list="false" :headers="headers"
<img v-if="goods.picUrl" :src="goods.picUrl" class="avatar"> accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <img v-if="goods.picUrl" :src="goods.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="宣传画廊"> <el-form-item label="宣传画廊">
<el-upload :action="uploadPath" :limit="5" multiple accept=".jpg,.jpeg,.png,.gif" list-type="picture-card" :on-exceed="uploadOverrun" :on-success="handleGalleryUrl" :on-remove="handleRemove"> <el-upload :action="uploadPath" :limit="5" multiple accept=".jpg,.jpeg,.png,.gif" list-type="picture-card" :headers="headers"
<i class="el-icon-plus"></i> :on-exceed="uploadOverrun" :on-success="handleGalleryUrl" :on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="商品单位"> <el-form-item label="商品单位">
<el-input v-model="goods.unit" placeholder="件 / 个 / 盒"></el-input> <el-input v-model="goods.unit" placeholder="件 / 个 / 盒"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="关键字"> <el-form-item label="关键字">
<el-tag :key="tag" v-for="tag in keywords" closable type="primary" @close="handleClose(tag)"> <el-tag :key="tag" v-for="tag in keywords" closable type="primary" @close="handleClose(tag)">
{{tag}} {{tag}}
</el-tag> </el-tag>
<el-input class="input-new-keyword" v-if="newKeywordVisible" v-model="newKeyword" ref="newKeywordInput" size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm"> <el-input class="input-new-keyword" v-if="newKeywordVisible" v-model="newKeyword" ref="newKeywordInput"
size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
</el-input> </el-input>
<el-button v-else class="button-new-keyword" size="small" type="primary" @click="showInput">+ 增加</el-button> <el-button v-else class="button-new-keyword" size="small" type="primary" @click="showInput">+ 增加</el-button>
</el-form-item> </el-form-item>
<el-form-item label="所属分类"> <el-form-item label="所属分类">
<el-cascader expand-trigger="hover" :options="categoryList" @change="handleCategoryChange"></el-cascader> <el-cascader expand-trigger="hover" :options="categoryList" @change="handleCategoryChange"></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="所属品牌商"> <el-form-item label="所属品牌商">
<el-select v-model="goods.brandId"> <el-select v-model="goods.brandId">
<el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value"> <el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value">
...@@ -78,20 +81,20 @@ ...@@ -78,20 +81,20 @@
<el-form-item label="商品简介"> <el-form-item label="商品简介">
<el-input v-model="goods.brief"></el-input> <el-input v-model="goods.brief"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="商品详细介绍"> <el-form-item label="商品详细介绍">
<editor :init="editorInit" v-model="goods.detail"></editor> <editor :init="editorInit" v-model="goods.detail"></editor>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card">
<h3>商品规格</h3> <h3>商品规格</h3>
<el-row type="flex" align="middle" :gutter="20" style="padding:20px 0;"> <el-row type="flex" align="middle" :gutter="20" style="padding:20px 0;">
<el-col :span="10" > <el-col :span="10">
<el-radio-group v-model="multipleSpec" @change="specChanged"> <el-radio-group v-model="multipleSpec" @change="specChanged">
<el-radio-button :label="false" >默认标准规格</el-radio-button> <el-radio-button :label="false">默认标准规格</el-radio-button>
<el-radio-button :label="true">多规格支持</el-radio-button> <el-radio-button :label="true">多规格支持</el-radio-button>
</el-radio-group> </el-radio-group>
</el-col> </el-col>
...@@ -101,8 +104,8 @@ ...@@ -101,8 +104,8 @@
</el-row> </el-row>
<el-table :data="specifications"> <el-table :data="specifications">
<el-table-column property="specification" label="规格名" ></el-table-column> <el-table-column property="specification" label="规格名"></el-table-column>
<el-table-column property="value" label="规格值" > <el-table-column property="value" label="规格值">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="primary"> <el-tag type="primary">
{{scope.row.value}} {{scope.row.value}}
...@@ -114,39 +117,42 @@ ...@@ -114,39 +117,42 @@
<img :src="scope.row.picUrl" width="40" v-if="scope.row.picUrl"/> <img :src="scope.row.picUrl" width="40" v-if="scope.row.picUrl"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width" v-if="multipleSpec"> <el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width"
v-if="multipleSpec">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" size="mini" @click="handleSpecificationDelete(scope.row)">删除</el-button> <el-button type="danger" size="mini" @click="handleSpecificationDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog title="设置规格" :visible.sync="specVisiable"> <el-dialog title="设置规格" :visible.sync="specVisiable">
<el-form :rules="rules" ref="specForm" :model="specForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'> <el-form :rules="rules" ref="specForm" :model="specForm" status-icon label-position="left" label-width="100px"
<el-form-item label="规格名" prop="specification"> style='width: 400px; margin-left:50px;'>
<el-input v-model="specForm.specification"></el-input> <el-form-item label="规格名" prop="specification">
</el-form-item> <el-input v-model="specForm.specification"></el-input>
<el-form-item label="规格值" prop="value"> </el-form-item>
<el-input v-model="specForm.value"></el-input> <el-form-item label="规格值" prop="value">
</el-form-item> <el-input v-model="specForm.value"></el-input>
<el-form-item label="规格图片" prop="picUrl"> </el-form-item>
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadSpecPicUrl"> <el-form-item label="规格图片" prop="picUrl">
<img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar"> <el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" :headers="headers"
<i v-else class="el-icon-plus avatar-uploader-icon"></i> accept=".jpg,.jpeg,.png,.gif" :on-success="uploadSpecPicUrl">
</el-upload> <img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar">
</el-form-item> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-form> </el-upload>
<div slot="footer" class="dialog-footer"> </el-form-item>
<el-button @click="specVisiable = false">取消</el-button> </el-form>
<el-button type="primary" @click="handleSpecificationAdd">确定</el-button> <div slot="footer" class="dialog-footer">
</div> <el-button @click="specVisiable = false">取消</el-button>
<el-button type="primary" @click="handleSpecificationAdd">确定</el-button>
</div>
</el-dialog> </el-dialog>
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card">
<h3>商品库存</h3> <h3>商品库存</h3>
<el-table :data="products"> <el-table :data="products">
<el-table-column property="value" label="货品规格" > <el-table-column property="value" label="货品规格">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :key="tag" v-for="tag in scope.row.specifications"> <el-tag :key="tag" v-for="tag in scope.row.specifications">
{{tag}} {{tag}}
...@@ -166,33 +172,35 @@ ...@@ -166,33 +172,35 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleProductShow(scope.row)">设置</el-button> <el-button type="primary" size="mini" @click="handleProductShow(scope.row)">设置</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog title="设置货品" :visible.sync="productVisiable"> <el-dialog title="设置货品" :visible.sync="productVisiable">
<el-form ref="productForm" :model="productForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'> <el-form ref="productForm" :model="productForm" status-icon label-position="left" label-width="100px"
<el-form-item label="货品规格列" prop="specifications"> style='width: 400px; margin-left:50px;'>
<el-tag :key="tag" v-for="tag in productForm.specifications"> <el-form-item label="货品规格列" prop="specifications">
{{tag}} <el-tag :key="tag" v-for="tag in productForm.specifications">
</el-tag> {{tag}}
</el-form-item> </el-tag>
<el-form-item label="货品售价" prop="price"> </el-form-item>
<el-input v-model="productForm.price"></el-input> <el-form-item label="货品售价" prop="price">
</el-form-item> <el-input v-model="productForm.price"></el-input>
<el-form-item label="货品数量" prop="number"> </el-form-item>
<el-input v-model="productForm.number"></el-input> <el-form-item label="货品数量" prop="number">
</el-form-item> <el-input v-model="productForm.number"></el-input>
<el-form-item label="货品图片" prop="url"> </el-form-item>
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadProductUrl"> <el-form-item label="货品图片" prop="url">
<img v-if="productForm.url" :src="productForm.url" class="avatar"> <el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" :headers="headers"
<i v-else class="el-icon-plus avatar-uploader-icon"></i> accept=".jpg,.jpeg,.png,.gif" :on-success="uploadProductUrl">
</el-upload> <img v-if="productForm.url" :src="productForm.url" class="avatar">
</el-form-item> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-form> </el-upload>
<div slot="footer" class="dialog-footer"> </el-form-item>
<el-button @click="productVisiable = false">取消</el-button> </el-form>
<el-button type="primary" @click="handleProductEdit">确定</el-button> <div slot="footer" class="dialog-footer">
</div> <el-button @click="productVisiable = false">取消</el-button>
<el-button type="primary" @click="handleProductEdit">确定</el-button>
</div>
</el-dialog> </el-dialog>
</el-card> </el-card>
...@@ -206,24 +214,25 @@ ...@@ -206,24 +214,25 @@
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" size="mini" @click="handleAttributeDelete(scope.row)">删除</el-button> <el-button type="danger" size="mini" @click="handleAttributeDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog title="设置商品参数" :visible.sync="attributeVisiable"> <el-dialog title="设置商品参数" :visible.sync="attributeVisiable">
<el-form ref="attributeForm" :model="attributeForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'> <el-form ref="attributeForm" :model="attributeForm" status-icon label-position="left" label-width="100px"
<el-form-item label="商品参数名称" prop="attribute"> style='width: 400px; margin-left:50px;'>
<el-input v-model="attributeForm.attribute"></el-input> <el-form-item label="商品参数名称" prop="attribute">
</el-form-item> <el-input v-model="attributeForm.attribute"></el-input>
<el-form-item label="商品参数值" prop="value"> </el-form-item>
<el-input v-model="attributeForm.value"></el-input> <el-form-item label="商品参数值" prop="value">
</el-form-item> <el-input v-model="attributeForm.value"></el-input>
</el-form> </el-form-item>
<div slot="footer" class="dialog-footer"> </el-form>
<el-button @click="attributeVisiable = false">取消</el-button> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleAttributeAdd">确定</el-button> <el-button @click="attributeVisiable = false">取消</el-button>
</div> <el-button type="primary" @click="handleAttributeAdd">确定</el-button>
</div>
</el-dialog> </el-dialog>
</el-card> </el-card>
...@@ -239,305 +248,321 @@ ...@@ -239,305 +248,321 @@
.el-card { .el-card {
margin-bottom: 10px; margin-bottom: 10px;
} }
.el-tag + .el-tag { .el-tag + .el-tag {
margin-left: 10px; margin-left: 10px;
} }
.input-new-keyword { .input-new-keyword {
width: 90px; width: 90px;
margin-left: 10px; margin-left: 10px;
vertical-align: bottom; vertical-align: bottom;
} }
.avatar-uploader .el-upload { .avatar-uploader .el-upload {
border: 1px dashed #d9d9d9; border: 1px dashed #d9d9d9;
border-radius: 6px; border-radius: 6px;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.avatar-uploader .el-upload:hover {
border-color: #20a0ff; .avatar-uploader .el-upload:hover {
} border-color: #20a0ff;
.avatar-uploader-icon { }
font-size: 28px;
color: #8c939d; .avatar-uploader-icon {
width: 120px; font-size: 28px;
height: 120px; color: #8c939d;
line-height: 120px; width: 120px;
text-align: center; height: 120px;
} line-height: 120px;
.avatar { text-align: center;
width: 120px; }
height: 120px;
display: block; .avatar {
} width: 120px;
height: 120px;
display: block;
}
</style> </style>
<script> <script>
import { publishGoods, listCatAndBrand } from '@/api/goods' import { publishGoods, listCatAndBrand } from '@/api/goods'
import { createStorage, uploadPath } from '@/api/storage' import { createStorage, uploadPath } from '@/api/storage'
import Editor from '@tinymce/tinymce-vue' import Editor from '@tinymce/tinymce-vue'
import { MessageBox } from 'element-ui' import { MessageBox } from 'element-ui'
import { getToken } from '@/utils/auth'
export default {
name: 'GoodsCreate', export default {
components: { Editor }, name: 'GoodsCreate',
data() { components: { Editor },
return { computed: {
uploadPath, headers() {
newKeywordVisible: false, return {
newKeyword: '', 'Admin-Token': getToken()
keywords: [],
categoryList: [],
brandList: [],
goods: { picUrl: '', gallery: [] },
specVisiable: false,
specForm: { specification: '', value: '', picUrl: '' },
multipleSpec: false,
specifications: [{ specification: '规格', value: '标准', picUrl: '' }],
productVisiable: false,
productForm: { id: 0, specifications: [], price: 0.00, number: 0, url: '' },
products: [{ id: 0, specifications: ['标准'], price: 0.00, number: 0, url: '' }],
attributeVisiable: false,
attributeForm: { attribute: '', value: '' },
attributes: [],
rules: {
goodsSn: [{ required: true, message: '商品编号不能为空', trigger: 'blur' }],
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }]
},
editorInit: {
language: 'zh_CN',
plugins: ['advlist anchor autolink autoresize autosave emoticons fullscreen hr image imagetools importcss insertdatetime legacyoutput link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace tabfocus table template textcolor textpattern visualblocks visualchars wordcount'],
toolbar: ['bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript ', 'hr bullist numlist link image charmap preview anchor pagebreak fullscreen media table emoticons forecolor backcolor'],
images_upload_handler: function(blobInfo, success, failure) {
const formData = new FormData()
formData.append('file', blobInfo.blob())
createStorage(formData).then(res => {
success(res.data.data.url)
}).catch(() => {
failure('上传失败,请重新上传')
})
} }
} }
}
},
created() {
this.init()
},
methods: {
init: function() {
listCatAndBrand().then(response => {
this.categoryList = response.data.data.categoryList
this.brandList = response.data.data.brandList
})
}, },
handleCategoryChange(value) {
this.goods.categoryId = value[value.length - 1] data() {
return {
uploadPath,
newKeywordVisible: false,
newKeyword: '',
keywords: [],
categoryList: [],
brandList: [],
goods: { picUrl: '', gallery: [] },
specVisiable: false,
specForm: { specification: '', value: '', picUrl: '' },
multipleSpec: false,
specifications: [{ specification: '规格', value: '标准', picUrl: '' }],
productVisiable: false,
productForm: { id: 0, specifications: [], price: 0.00, number: 0, url: '' },
products: [{ id: 0, specifications: ['标准'], price: 0.00, number: 0, url: '' }],
attributeVisiable: false,
attributeForm: { attribute: '', value: '' },
attributes: [],
rules: {
goodsSn: [{ required: true, message: '商品编号不能为空', trigger: 'blur' }],
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }]
},
editorInit: {
language: 'zh_CN',
plugins: ['advlist anchor autolink autoresize autosave emoticons fullscreen hr image imagetools importcss insertdatetime legacyoutput link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace tabfocus table template textcolor textpattern visualblocks visualchars wordcount'],
toolbar: ['bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript ', 'hr bullist numlist link image charmap preview anchor pagebreak fullscreen media table emoticons forecolor backcolor'],
images_upload_handler: function(blobInfo, success, failure) {
const formData = new FormData()
formData.append('file', blobInfo.blob())
createStorage(formData).then(res => {
success(res.data.data.url)
}).catch(() => {
failure('上传失败,请重新上传')
})
}
}
}
}, },
handleCancel: function() { created() {
this.$router.push({ path: '/goods/goods' }) this.init()
}, },
handlePublish: function() {
const finalGoods = { methods: {
goods: this.goods, init: function() {
specifications: this.specifications, listCatAndBrand().then(response => {
products: this.products, this.categoryList = response.data.data.categoryList
attributes: this.attributes this.brandList = response.data.data.brandList
}
publishGoods(finalGoods).then(response => {
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
}) })
this.$router.push({ path: '/goods/list' }) },
}).catch(response => { handleCategoryChange(value) {
MessageBox.alert('业务错误:' + response.data.errmsg, '警告', { this.goods.categoryId = value[value.length - 1]
confirmButtonText: '确定', },
type: 'error' handleCancel: function() {
this.$router.push({ path: '/goods/goods' })
},
handlePublish: function() {
const finalGoods = {
goods: this.goods,
specifications: this.specifications,
products: this.products,
attributes: this.attributes
}
publishGoods(finalGoods).then(response => {
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
this.$router.push({ path: '/goods/list' })
}).catch(response => {
MessageBox.alert('业务错误:' + response.data.errmsg, '警告', {
confirmButtonText: '确定',
type: 'error'
})
}) })
}) },
}, handleClose(tag) {
handleClose(tag) { this.keywords.splice(this.keywords.indexOf(tag), 1)
this.keywords.splice(this.keywords.indexOf(tag), 1)
this.goods.keywords = this.keywords.toString()
},
showInput() {
this.newKeywordVisible = true
this.$nextTick(_ => {
this.$refs.newKeywordInput.$refs.input.focus()
})
},
handleInputConfirm() {
const newKeyword = this.newKeyword
if (newKeyword) {
this.keywords.push(newKeyword)
this.goods.keywords = this.keywords.toString() this.goods.keywords = this.keywords.toString()
} },
this.newKeywordVisible = false showInput() {
this.newKeyword = '' this.newKeywordVisible = true
}, this.$nextTick(_ => {
uploadPicUrl: function(response) { this.$refs.newKeywordInput.$refs.input.focus()
this.goods.picUrl = response.data.url })
}, },
uploadOverrun: function() { handleInputConfirm() {
this.$message({ const newKeyword = this.newKeyword
type: 'error', if (newKeyword) {
message: '上传文件个数超出限制!最多上传5张图片!' this.keywords.push(newKeyword)
}) this.goods.keywords = this.keywords.toString()
}, }
handleGalleryUrl(response, file, fileList) { this.newKeywordVisible = false
if (response.errno === 0) { this.newKeyword = ''
this.goods.gallery.push(response.data.url) },
} uploadPicUrl: function(response) {
}, this.goods.picUrl = response.data.url
handleRemove: function(file, fileList) { },
for (var i = 0; i < this.goods.gallery.length; i++) { uploadOverrun: function() {
// 这里存在两种情况 this.$message({
// 1. 如果所删除图片是刚刚上传的图片,那么图片地址是file.response.data.url type: 'error',
// 此时的file.url虽然存在,但是是本机地址,而不是远程地址。 message: '上传文件个数超出限制!最多上传5张图片!'
// 2. 如果所删除图片是后台返回的已有图片,那么图片地址是file.url })
var url },
if (file.response === undefined) { handleGalleryUrl(response, file, fileList) {
url = file.url if (response.errno === 0) {
} else { this.goods.gallery.push(response.data.url)
url = file.response.data.url
} }
},
handleRemove: function(file, fileList) {
for (var i = 0; i < this.goods.gallery.length; i++) {
// 这里存在两种情况
// 1. 如果所删除图片是刚刚上传的图片,那么图片地址是file.response.data.url
// 此时的file.url虽然存在,但是是本机地址,而不是远程地址。
// 2. 如果所删除图片是后台返回的已有图片,那么图片地址是file.url
var url
if (file.response === undefined) {
url = file.url
} else {
url = file.response.data.url
}
if (this.goods.gallery[i] === url) { if (this.goods.gallery[i] === url) {
this.goods.gallery.splice(i, 1) this.goods.gallery.splice(i, 1)
}
} }
} },
}, specChanged: function(label) {
specChanged: function(label) { if (label === false) {
if (label === false) { this.specifications = [{ specification: '规格', value: '标准', picUrl: '' }]
this.specifications = [{ specification: '规格', value: '标准', picUrl: '' }] this.products = [{ id: 0, specifications: ['标准'], price: 0.00, number: 0, url: '' }]
this.products = [{ id: 0, specifications: ['标准'], price: 0.00, number: 0, url: '' }] } else {
} else { this.specifications = []
this.specifications = [] this.products = []
this.products = [] }
} },
}, uploadSpecPicUrl: function(response) {
uploadSpecPicUrl: function(response) { this.specForm.picUrl = response.data.url
this.specForm.picUrl = response.data.url },
}, handleSpecificationShow() {
handleSpecificationShow() { this.specForm = { specification: '', value: '', picUrl: '' }
this.specForm = { specification: '', value: '', picUrl: '' } this.specVisiable = true
this.specVisiable = true },
}, handleSpecificationAdd() {
handleSpecificationAdd() { var index = this.specifications.length - 1
var index = this.specifications.length - 1 for (var i = 0; i < this.specifications.length; i++) {
for (var i = 0; i < this.specifications.length; i++) { const v = this.specifications[i]
const v = this.specifications[i] if (v.specification === this.specForm.specification) {
if (v.specification === this.specForm.specification) { index = i
index = i }
} }
}
this.specifications.splice(index + 1, 0, this.specForm) this.specifications.splice(index + 1, 0, this.specForm)
this.specVisiable = false this.specVisiable = false
this.specToProduct() this.specToProduct()
}, },
handleSpecificationDelete(row) { handleSpecificationDelete(row) {
const index = this.specifications.indexOf(row) const index = this.specifications.indexOf(row)
this.specifications.splice(index, 1) this.specifications.splice(index, 1)
this.specToProduct() this.specToProduct()
}, },
specToProduct() { specToProduct() {
if (this.specifications.length === 0) { if (this.specifications.length === 0) {
return return
} }
// 根据specifications创建临时规格列表 // 根据specifications创建临时规格列表
var specValues = [] var specValues = []
var spec = this.specifications[0].specification var spec = this.specifications[0].specification
var values = [] var values = []
values.push(0) values.push(0)
for (var i = 1; i < this.specifications.length; i++) { for (var i = 1; i < this.specifications.length; i++) {
const aspec = this.specifications[i].specification const aspec = this.specifications[i].specification
if (aspec === spec) { if (aspec === spec) {
values.push(i) values.push(i)
} else { } else {
specValues.push(values) specValues.push(values)
spec = aspec spec = aspec
values = [] values = []
values.push(i) values.push(i)
}
} }
} specValues.push(values)
specValues.push(values)
// 根据临时规格列表生产货品规格
// 根据临时规格列表生产货品规格 // 算法基于 https://blog.csdn.net/tyhj_sf/article/details/53893125
// 算法基于 https://blog.csdn.net/tyhj_sf/article/details/53893125 var productsIndex = 0
var productsIndex = 0 var products = []
var products = [] var combination = []
var combination = [] var n = specValues.length
var n = specValues.length for (var s = 0; s < n; s++) {
for (var s = 0; s < n; s++) { combination[s] = 0
combination[s] = 0
}
var index = 0
var isContinue = false
do {
var specifications = []
for (var x = 0; x < n; x++) {
var z = specValues[x][combination[x]]
specifications.push(this.specifications[z].value)
} }
products[productsIndex] = { id: productsIndex, specifications: specifications, price: 0.00, number: 0, url: '' } var index = 0
productsIndex++ var isContinue = false
do {
index++ var specifications = []
combination[n - 1] = index for (var x = 0; x < n; x++) {
for (var j = n - 1; j >= 0; j--) { var z = specValues[x][combination[x]]
if (combination[j] >= specValues[j].length) { specifications.push(this.specifications[z].value)
combination[j] = 0 }
index = 0 products[productsIndex] = { id: productsIndex, specifications: specifications, price: 0.00, number: 0, url: '' }
if (j - 1 >= 0) { productsIndex++
combination[j - 1] = combination[j - 1] + 1
index++
combination[n - 1] = index
for (var j = n - 1; j >= 0; j--) {
if (combination[j] >= specValues[j].length) {
combination[j] = 0
index = 0
if (j - 1 >= 0) {
combination[j - 1] = combination[j - 1] + 1
}
} }
} }
} isContinue = false
isContinue = false for (var p = 0; p < n; p++) {
for (var p = 0; p < n; p++) { if (combination[p] !== 0) {
if (combination[p] !== 0) { isContinue = true
isContinue = true }
} }
} } while (isContinue)
} while (isContinue)
this.products = products this.products = products
}, },
handleProductShow(row) { handleProductShow(row) {
this.productForm = Object.assign({}, row) this.productForm = Object.assign({}, row)
this.productVisiable = true this.productVisiable = true
}, },
uploadProductUrl: function(response) { uploadProductUrl: function(response) {
this.productForm.url = response.data.url this.productForm.url = response.data.url
}, },
handleProductEdit() { handleProductEdit() {
for (var i = 0; i < this.products.length; i++) { for (var i = 0; i < this.products.length; i++) {
const v = this.products[i] const v = this.products[i]
if (v.id === this.productForm.id) { if (v.id === this.productForm.id) {
this.products.splice(i, 1, this.productForm) this.products.splice(i, 1, this.productForm)
break break
}
} }
this.productVisiable = false
},
handleAttributeShow() {
this.attributeForm = {}
this.attributeVisiable = true
},
handleAttributeAdd() {
this.attributes.unshift(this.attributeForm)
this.attributeVisiable = false
},
handleAttributeDelete(row) {
const index = this.attributes.indexOf(row)
this.attributes.splice(index, 1)
} }
this.productVisiable = false
},
handleAttributeShow() {
this.attributeForm = {}
this.attributeVisiable = true
},
handleAttributeAdd() {
this.attributes.unshift(this.attributeForm)
this.attributeVisiable = false
},
handleAttributeDelete(row) {
const index = this.attributes.indexOf(row)
this.attributes.splice(index, 1)
} }
} }
} </script>
</script>
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</el-form-item> </el-form-item>
<el-form-item label="商品名称" prop="name"> <el-form-item label="商品名称" prop="name">
<el-input v-model="goods.name"></el-input> <el-input v-model="goods.name"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="专柜价格" prop="counterPrice"> <el-form-item label="专柜价格" prop="counterPrice">
<el-input v-model="goods.counterPrice" placeholder="0.00"> <el-input v-model="goods.counterPrice" placeholder="0.00">
<template slot="append"></template> <template slot="append"></template>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<el-input v-model="goods.retailPrice" placeholder="0.00"> <el-input v-model="goods.retailPrice" placeholder="0.00">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="是否新品" prop="isNew"> <el-form-item label="是否新品" prop="isNew">
<el-radio-group v-model="goods.isNew"> <el-radio-group v-model="goods.isNew">
<el-radio :label="true">新品</el-radio> <el-radio :label="true">新品</el-radio>
...@@ -31,31 +31,31 @@ ...@@ -31,31 +31,31 @@
<el-radio :label="false">普通</el-radio> <el-radio :label="false">普通</el-radio>
<el-radio :label="true">热卖</el-radio> <el-radio :label="true">热卖</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="是否在售" prop="isOnSale"> <el-form-item label="是否在售" prop="isOnSale">
<el-radio-group v-model="goods.isOnSale"> <el-radio-group v-model="goods.isOnSale">
<el-radio :label="true">在售</el-radio> <el-radio :label="true">在售</el-radio>
<el-radio :label="false">未售</el-radio> <el-radio :label="false">未售</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="商品图片"> <el-form-item label="商品图片">
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl"> <el-upload class="avatar-uploader" :headers="headers" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl">
<img v-if="goods.picUrl" :src="goods.picUrl" class="avatar"> <img v-if="goods.picUrl" :src="goods.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="宣传画廊"> <el-form-item label="宣传画廊">
<el-upload :action='uploadPath' :limit='5' multiple accept=".jpg,.jpeg,.png,.gif" :file-list="galleryFileList" list-type="picture-card" :on-exceed='uploadOverrun' :on-success="handleGalleryUrl" :on-remove="handleRemove"> <el-upload :action='uploadPath' :headers="headers" :limit='5' multiple accept=".jpg,.jpeg,.png,.gif" :file-list="galleryFileList" list-type="picture-card" :on-exceed='uploadOverrun' :on-success="handleGalleryUrl" :on-remove="handleRemove">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="商品单位"> <el-form-item label="商品单位">
<el-input v-model="goods.unit" placeholder="件 / 个 / 盒"></el-input> <el-input v-model="goods.unit" placeholder="件 / 个 / 盒"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="关键字"> <el-form-item label="关键字">
<el-tag :key="tag" v-for="tag in keywords" closable type="primary" @close="handleClose(tag)"> <el-tag :key="tag" v-for="tag in keywords" closable type="primary" @close="handleClose(tag)">
{{tag}} {{tag}}
...@@ -64,11 +64,11 @@ ...@@ -64,11 +64,11 @@
</el-input> </el-input>
<el-button v-else class="button-new-keyword" size="small" type="primary" @click="showInput">+ 增加</el-button> <el-button v-else class="button-new-keyword" size="small" type="primary" @click="showInput">+ 增加</el-button>
</el-form-item> </el-form-item>
<el-form-item label="所属分类"> <el-form-item label="所属分类">
<el-cascader expand-trigger="hover" :options="categoryList" v-model="categoryIds" @change="handleCategoryChange"></el-cascader> <el-cascader expand-trigger="hover" :options="categoryList" v-model="categoryIds" @change="handleCategoryChange"></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="所属品牌商"> <el-form-item label="所属品牌商">
<el-select v-model="goods.brandId"> <el-select v-model="goods.brandId">
<el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value"> <el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value">
...@@ -78,11 +78,11 @@ ...@@ -78,11 +78,11 @@
<el-form-item label="商品简介"> <el-form-item label="商品简介">
<el-input v-model="goods.brief"></el-input> <el-input v-model="goods.brief"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="商品详细介绍"> <el-form-item label="商品详细介绍">
<editor :init="editorInit" v-model="goods.detail"></editor> <editor :init="editorInit" v-model="goods.detail"></editor>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
...@@ -120,11 +120,11 @@ ...@@ -120,11 +120,11 @@
<el-input v-model="specForm.value"></el-input> <el-input v-model="specForm.value"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="规格图片" prop="picUrl"> <el-form-item label="规格图片" prop="picUrl">
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadSpecPicUrl"> <el-upload class="avatar-uploader" :headers="headers" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadSpecPicUrl">
<img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar"> <img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="specVisiable = false">取消</el-button> <el-button @click="specVisiable = false">取消</el-button>
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
</div> </div>
</el-dialog> </el-dialog>
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card">
<h3>商品库存</h3> <h3>商品库存</h3>
<el-table :data="products"> <el-table :data="products">
...@@ -173,11 +173,11 @@ ...@@ -173,11 +173,11 @@
<el-input v-model="productForm.number"></el-input> <el-input v-model="productForm.number"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="货品图片" prop="url"> <el-form-item label="货品图片" prop="url">
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadProductUrl"> <el-upload class="avatar-uploader" :headers="headers" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadProductUrl">
<img v-if="productForm.url" :src="productForm.url" class="avatar"> <img v-if="productForm.url" :src="productForm.url" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="productVisiable = false">取消</el-button> <el-button @click="productVisiable = false">取消</el-button>
...@@ -208,7 +208,7 @@ ...@@ -208,7 +208,7 @@
</el-form-item> </el-form-item>
<el-form-item label="商品参数值" prop="value"> <el-form-item label="商品参数值" prop="value">
<el-input v-model="attributeForm.value"></el-input> <el-input v-model="attributeForm.value"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="attributeVisiable = false">取消</el-button> <el-button @click="attributeVisiable = false">取消</el-button>
...@@ -267,10 +267,18 @@ import { detailGoods, editGoods, listCatAndBrand } from '@/api/goods' ...@@ -267,10 +267,18 @@ import { detailGoods, editGoods, listCatAndBrand } from '@/api/goods'
import { createStorage, uploadPath } from '@/api/storage' import { createStorage, uploadPath } from '@/api/storage'
import Editor from '@tinymce/tinymce-vue' import Editor from '@tinymce/tinymce-vue'
import { MessageBox } from 'element-ui' import { MessageBox } from 'element-ui'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'GoodsEdit', name: 'GoodsEdit',
components: { Editor }, components: { Editor },
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
return { return {
uploadPath, uploadPath,
...@@ -551,4 +559,4 @@ export default { ...@@ -551,4 +559,4 @@ export default {
} }
} }
} }
</script> </script>
\ No newline at end of file
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</el-table-column> </el-table-column>
<el-table-column align="center" label="底价" prop="floorPrice"> <el-table-column align="center" label="底价" prop="floorPrice">
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
<el-input v-model="dataForm.desc"></el-input> <el-input v-model="dataForm.desc"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="品牌商图片" prop="picUrl"> <el-form-item label="品牌商图片" prop="picUrl">
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl"> <el-upload class="avatar-uploader" :headers="headers" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl">
<img v-if="dataForm.picUrl" :src="dataForm.picUrl" class="avatar"> <img v-if="dataForm.picUrl" :src="dataForm.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="底价" prop="floorPrice"> <el-form-item label="底价" prop="floorPrice">
<el-input v-model="dataForm.floorPrice"></el-input> <el-input v-model="dataForm.floorPrice"></el-input>
</el-form-item> </el-form-item>
...@@ -106,9 +106,17 @@ ...@@ -106,9 +106,17 @@
<script> <script>
import { listBrand, createBrand, updateBrand, deleteBrand } from '@/api/brand' import { listBrand, createBrand, updateBrand, deleteBrand } from '@/api/brand'
import { uploadPath } from '@/api/storage' import { uploadPath } from '@/api/storage'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'Brand', name: 'Brand',
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
return { return {
uploadPath, uploadPath,
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<el-table-column align="center" label="关键字" prop="keyword"> <el-table-column align="center" label="关键字" prop="keyword">
</el-table-column> </el-table-column>
<el-table-column align="center" min-width="100" label="简介" prop="desc"> <el-table-column align="center" min-width="100" label="简介" prop="desc">
</el-table-column> </el-table-column>
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.level === 'L1' ? 'primary' : 'info' ">{{scope.row.level === 'L1' ? '一级类目' : '二级类目'}}</el-tag> <el-tag :type="scope.row.level === 'L1' ? 'primary' : 'info' ">{{scope.row.level === 'L1' ? '一级类目' : '二级类目'}}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="父类目ID" prop="pid"> <el-table-column align="center" label="父类目ID" prop="pid">
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -88,20 +88,20 @@ ...@@ -88,20 +88,20 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="类目图标" prop="iconUrl"> <el-form-item label="类目图标" prop="iconUrl">
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadIconUrl"> <el-upload class="avatar-uploader" :headers="headers" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadIconUrl">
<img v-if="dataForm.iconUrl" :src="dataForm.iconUrl" class="avatar"> <img v-if="dataForm.iconUrl" :src="dataForm.iconUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="类目图片" prop="picUrl"> <el-form-item label="类目图片" prop="picUrl">
<el-upload class="avatar-uploader" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl"> <el-upload class="avatar-uploader" :headers="headers" :action='uploadPath' list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl">
<img v-if="dataForm.picUrl" :src="dataForm.picUrl" class="avatar"> <img v-if="dataForm.picUrl" :src="dataForm.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="类目简介" prop="desc"> <el-form-item label="类目简介" prop="desc">
<el-input v-model="dataForm.desc"></el-input> <el-input v-model="dataForm.desc"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button> <el-button @click="dialogFormVisible = false">取消</el-button>
...@@ -142,9 +142,17 @@ ...@@ -142,9 +142,17 @@
<script> <script>
import { listCategory, listCatL1, createCategory, updateCategory, deleteCategory } from '@/api/category' import { listCategory, listCatL1, createCategory, updateCategory, deleteCategory } from '@/api/category'
import { uploadPath } from '@/api/storage' import { uploadPath } from '@/api/storage'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'Category', name: 'Category',
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
return { return {
uploadPath, uploadPath,
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<el-input v-model="dataForm.content"></el-input> <el-input v-model="dataForm.content"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="广告图片" prop="url"> <el-form-item label="广告图片" prop="url">
<el-upload class="avatar-uploader" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadUrl"> <el-upload class="avatar-uploader" :headers="headers" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadUrl">
<img v-if="dataForm.url" :src="dataForm.url" class="avatar"> <img v-if="dataForm.url" :src="dataForm.url" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<el-option label="首页" :value="1"> <el-option label="首页" :value="1">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="活动链接" prop="link"> <el-form-item label="活动链接" prop="link">
<el-input v-model="dataForm.link"></el-input> <el-input v-model="dataForm.link"></el-input>
</el-form-item> </el-form-item>
...@@ -130,9 +130,17 @@ ...@@ -130,9 +130,17 @@
<script> <script>
import { listAd, createAd, updateAd, deleteAd } from '@/api/ad' import { listAd, createAd, updateAd, deleteAd } from '@/api/ad'
import { uploadPath } from '@/api/storage' import { uploadPath } from '@/api/storage'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'Ad', name: 'Ad',
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
return { return {
uploadPath, uploadPath,
...@@ -289,4 +297,4 @@ export default { ...@@ -289,4 +297,4 @@ export default {
} }
} }
} }
</script> </script>
\ No newline at end of file
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<el-tooltip placement="top" content="返回顶部"> <el-tooltip placement="top" content="返回顶部">
<back-to-top :visibilityHeight="100" ></back-to-top> <back-to-top :visibilityHeight="100" ></back-to-top>
</el-tooltip> </el-tooltip>
<!-- 添加或修改对话框 --> <!-- 添加或修改对话框 -->
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible"> <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'> <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
...@@ -70,14 +70,14 @@ ...@@ -70,14 +70,14 @@
<el-input v-model="dataForm.subtitle"></el-input> <el-input v-model="dataForm.subtitle"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="专题图片" prop="picUrl"> <el-form-item label="专题图片" prop="picUrl">
<el-upload class="avatar-uploader" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl"> <el-upload class="avatar-uploader" :headers="headers" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadPicUrl">
<img v-if="dataForm.picUrl" :src="dataForm.picUrl" class="avatar"> <img v-if="dataForm.picUrl" :src="dataForm.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item style="width: 700px;" label="专题内容"> <el-form-item style="width: 700px;" label="专题内容">
<editor :init="editorInit" v-model="dataForm.content"></editor> <editor :init="editorInit" v-model="dataForm.content"></editor>
</el-form-item> </el-form-item>
<el-form-item label="商品低价" prop="price"> <el-form-item label="商品低价" prop="price">
<el-input v-model="dataForm.price"></el-input> <el-input v-model="dataForm.price"></el-input>
</el-form-item> </el-form-item>
...@@ -129,10 +129,18 @@ import { listTopic, createTopic, updateTopic, deleteTopic } from '@/api/topic' ...@@ -129,10 +129,18 @@ import { listTopic, createTopic, updateTopic, deleteTopic } from '@/api/topic'
import { createStorage, uploadPath } from '@/api/storage' import { createStorage, uploadPath } from '@/api/storage'
import BackToTop from '@/components/BackToTop' import BackToTop from '@/components/BackToTop'
import Editor from '@tinymce/tinymce-vue' import Editor from '@tinymce/tinymce-vue'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'Topic', name: 'Topic',
components: { BackToTop, Editor }, components: { BackToTop, Editor },
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
return { return {
uploadPath, uploadPath,
...@@ -311,4 +319,4 @@ export default { ...@@ -311,4 +319,4 @@ export default {
} }
} }
} }
</script> </script>
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<img :src="scope.row.avatar" width="40" v-if="scope.row.avatar"/> <img :src="scope.row.avatar" width="40" v-if="scope.row.avatar"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -50,9 +50,9 @@ ...@@ -50,9 +50,9 @@
</el-form-item> </el-form-item>
<el-form-item label="确认密码" prop="checkPassword"> <el-form-item label="确认密码" prop="checkPassword">
<el-input type="password" v-model="dataForm.checkPassword" auto-complete="off"></el-input> <el-input type="password" v-model="dataForm.checkPassword" auto-complete="off"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="管理员头像" prop="avatar"> <el-form-item label="管理员头像" prop="avatar">
<el-upload class="avatar-uploader" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadAvatar"> <el-upload class="avatar-uploader" :headers="headers" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadAvatar">
<img v-if="dataForm.avatar" :src="dataForm.avatar" class="avatar"> <img v-if="dataForm.avatar" :src="dataForm.avatar" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
...@@ -97,9 +97,17 @@ ...@@ -97,9 +97,17 @@
<script> <script>
import { listAdmin, createAdmin, updateAdmin, deleteAdmin } from '@/api/admin' import { listAdmin, createAdmin, updateAdmin, deleteAdmin } from '@/api/admin'
import { uploadPath } from '@/api/storage' import { uploadPath } from '@/api/storage'
import { getToken } from '@/utils/auth'
export default { export default {
name: 'Admin', name: 'Admin',
computed: {
headers() {
return {
'Admin-Token': getToken()
}
}
},
data() { data() {
var validatePass = (rule, value, callback) => { var validatePass = (rule, value, callback) => {
if (value === '') { if (value === '') {
...@@ -276,4 +284,4 @@ export default { ...@@ -276,4 +284,4 @@ export default {
} }
} }
} }
</script> </script>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment