Commit d0267b07 authored by linlinjava's avatar linlinjava
Browse files

feat[litemall-admin]: 图片支持缩略图和点击放大

parent 27bf4fae
...@@ -35,6 +35,17 @@ export function parseTime(time, cFormat) { ...@@ -35,6 +35,17 @@ export function parseTime(time, cFormat) {
return time_str return time_str
} }
// NOTE: 这里的缩略图只用于阿里云存储。
// 开发者可以参考其他云存储的缩略图参数。
export function thumbnail(src) {
return src + '?x-oss-process=image/resize,m_lfit,h_250,w_250'
}
export function toPreview(item, url) {
item.preview = [url]
return item.preview
}
export function formatTime(time, option) { export function formatTime(time, option) {
time = +time * 1000 time = +time * 1000
const d = new Date(time) const d = new Date(time)
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<el-table-column align="center" property="iconUrl" label="图片"> <el-table-column align="center" property="iconUrl" label="图片">
<template slot-scope="scope"> <template slot-scope="scope">
<img :src="scope.row.picUrl" width="40"> <el-image :src="thumbnail(scope.row.picUrl)" :preview-src-list="toPreview(scope.row, scope.row.picUrl)" style="width: 40px; height: 40px" />
</template> </template>
</el-table-column> </el-table-column>
...@@ -132,12 +132,15 @@ ...@@ -132,12 +132,15 @@
import { listGoods, deleteGoods } from '@/api/goods' import { listGoods, deleteGoods } from '@/api/goods'
import BackToTop from '@/components/BackToTop' import BackToTop from '@/components/BackToTop'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import { thumbnail, toPreview } from '@/utils/index'
export default { export default {
name: 'GoodsList', name: 'GoodsList',
components: { BackToTop, Pagination }, components: { BackToTop, Pagination },
data() { data() {
return { return {
thumbnail,
toPreview,
list: [], list: [],
total: 0, total: 0,
listLoading: true, listLoading: true,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<el-table-column align="center" property="picUrl" label="品牌商图片"> <el-table-column align="center" property="picUrl" label="品牌商图片">
<template slot-scope="scope"> <template slot-scope="scope">
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" width="80"> <el-image :src="thumbnail(scope.row.picUrl)" :preview-src-list="toPreview(scope.row, scope.row.picUrl)" style="width: 40px; height: 40px" />
</template> </template>
</el-table-column> </el-table-column>
...@@ -104,12 +104,15 @@ import { listBrand, createBrand, updateBrand, deleteBrand } from '@/api/brand' ...@@ -104,12 +104,15 @@ import { listBrand, createBrand, updateBrand, deleteBrand } from '@/api/brand'
import { uploadPath } from '@/api/storage' import { uploadPath } from '@/api/storage'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import { thumbnail, toPreview } from '@/utils/index'
export default { export default {
name: 'Brand', name: 'Brand',
components: { Pagination }, components: { Pagination },
data() { data() {
return { return {
thumbnail,
toPreview,
uploadPath, uploadPath,
list: [], list: [],
total: 0, total: 0,
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<el-table-column align="center" property="picUrl" label="图片"> <el-table-column align="center" property="picUrl" label="图片">
<template slot-scope="scope"> <template slot-scope="scope">
<img :src="scope.row.picUrl" width="80"> <el-image :src="thumbnail(scope.row.picUrl)" :preview-src-list="toPreview(scope.row, scope.row.picUrl)" style="width: 40px; height: 40px" />
</template> </template>
</el-table-column> </el-table-column>
...@@ -95,12 +95,15 @@ import { listTopic, deleteTopic, batchDeleteTopic } from '@/api/topic' ...@@ -95,12 +95,15 @@ import { listTopic, deleteTopic, batchDeleteTopic } from '@/api/topic'
import BackToTop from '@/components/BackToTop' import BackToTop from '@/components/BackToTop'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import _ from 'lodash' import _ from 'lodash'
import { thumbnail, toPreview } from '@/utils/index'
export default { export default {
name: 'Topic', name: 'Topic',
components: { BackToTop, Pagination }, components: { BackToTop, Pagination },
data() { data() {
return { return {
thumbnail,
toPreview,
list: [], list: [],
total: 0, total: 0,
listLoading: true, listLoading: true,
......
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