Commit dc5fc299 authored by yaya's avatar yaya

feat:钱币设置添加设置主图功能功能

parent 3844e140
......@@ -47,3 +47,10 @@ export function holdOver(params) {
data: params
})
}
export function setTopImage(params) {
return request({
url: '/item/setTopImage',
method: 'post',
data: params
})
}
......@@ -31,6 +31,7 @@
<div v-for="(item, index) in imageList" :key="item + index" class="select_item">
<img :src="item" class="gallery" @click="handleShowLargeDialog(item)">
<div class="edit" @click="handlerChangeImage(item)">编辑</div>
<div v-if="imageList.length > 0" class="set" @click="handlerSetMainImage(item, index)">{{ imageMainPosition === index ? '主图' : '设为主图' }}</div>
</div>
</div>
</div>
......@@ -185,7 +186,7 @@ import { VuePictureCut, VuePictureCutMask, VuePictureCutMenu } from 'vue-picture
import { getToken } from '@/utils/auth'
import SelectImageDialog from './components/selectImageDialog'
import { listCategories } from '@/api/business/goods'
import { detailGoods, editGoods, saveImageBase64, saveCroppingRecord, deleteGood, holdOver } from '@/api/business/goodsNew'
import { detailGoods, editGoods, saveImageBase64, saveCroppingRecord, deleteGood, holdOver, setTopImage } from '@/api/business/goodsNew'
import CheckLargeImageDialog from './components/CheckLargeImageDialog'
import CutImageDialog from './components/CutImageDialog'
import CutEditImageDialog from './components/CutEditImageDialog'
......@@ -230,7 +231,8 @@ export default {
cutImageDialogVisible: false, // 钱币正反面图片操作
imageType: 0, // 1正面 2反面
cutEditImageDialogVisible: false, // 钱币图片编辑
editImageUrl: '' // 用于处理是否合成或者替换原图
editImageUrl: '', // 用于处理是否合成或者替换原图,
imageMainPosition: -1 // 用于设置主图位置
}
},
computed: {
......@@ -300,6 +302,7 @@ export default {
idExcludeList: this.goodIdList || []
}
detailGoods(param).then(response => {
this.imageMainPosition = -1
this.currentGoodId = response.data.data.id
this.handleClearInfo()
if (type === 1) { // 上一个
......@@ -575,6 +578,25 @@ export default {
handlerChangeImage(imageUrl) {
this.editImageUrl = imageUrl
this.cutEditImageDialogVisible = true
},
handlerSetMainImage(imageUrl, index) {
if (index === this.imageMainPosition) {
this.$message.info('已经是主图了哦~')
return
}
const params = {
id: this.goodsParams.id,
topImage: imageUrl
}
setTopImage(params).then(response => {
this.$message.success('设置成功')
this.imageMainPosition = index
}).catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg || '请求失败'
})
})
}
}
}
......@@ -685,6 +707,18 @@ export default {
background: #000000;
opacity: 0.6;
}
.set {
width: 100px;
position: absolute;
bottom: 0;
right: 0;
padding: 5px 8px;
font-size: 12px;
color: white;
background: #000000;
opacity: 0.6;
text-align: center;
}
}
}
}
......
Markdown is supported
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