Commit e902050a authored by yaya's avatar yaya

feat:回退代码

parent 15b56b0a
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<div class="list"> <div class="list">
<div v-for="(item, index) in imageList" :key="item + index" class="select_item"> <div v-for="(item, index) in imageList" :key="item + index" class="select_item">
<img :src="item" class="gallery" @click="handleShowLargeDialog(item)"> <img :src="item" class="gallery" @click="handleShowLargeDialog(item)">
<div class="edit" @click="handleRemoveLama(item)">编辑</div> <div class="edit" @click="handlerChangeImage(item)">编辑</div>
<div v-if="imageList.length > 0" class="set" @click="handlerSetMainImage(item, index)"> <div v-if="imageList.length > 0" class="set" @click="handlerSetMainImage(item, index)">
{{ imageMainPosition === index ? '主图' : '设为主图' }} {{ imageMainPosition === index ? '主图' : '设为主图' }}
</div> </div>
...@@ -168,11 +168,13 @@ ...@@ -168,11 +168,13 @@
@cutImageDialogClose="cutImageDialogVisible = false" @cutImageDialogClose="cutImageDialogVisible = false"
@cutSuccess="handleCutSuccess" @cutSuccess="handleCutSuccess"
@uploadImage="handleUploadImage" /> @uploadImage="handleUploadImage" />
<LamaImageDialog <CutEditImageDialog
v-if="showLamaImageDialog" v-if="cutEditImageDialogVisible"
:show-lama-dialog="showLamaImageDialog" :edit-image-url="editImageUrl"
@closeLamaDialog="handleCloseLamaDialog" :show-cut-dialog="cutImageDialogVisible"
@imageBase64="handleSaveImageBase64" /> @cutEditImageDialogClose="cutEditImageDialogVisible = false"
@cutEditSuccess="handleSaveImageBase64"
@uploadEditImage="handleUploadImage" />
</div> </div>
</template> </template>
...@@ -193,12 +195,12 @@ import { ...@@ -193,12 +195,12 @@ import {
} from '@/api/business/goodsNew' } from '@/api/business/goodsNew'
import CheckLargeImageDialog from './components/CheckLargeImageDialog' import CheckLargeImageDialog from './components/CheckLargeImageDialog'
import CutImageDialog from './components/CutImageDialog' import CutImageDialog from './components/CutImageDialog'
import LamaImageDialog from './components/lamaImageDialog' import CutEditImageDialog from './components/CutEditImageDialog'
export default { export default {
name: 'InfoSet', name: 'InfoSet',
components: { components: {
LamaImageDialog, CutEditImageDialog,
CutImageDialog, CutImageDialog,
CheckLargeImageDialog, CheckLargeImageDialog,
SelectImageDialog, SelectImageDialog,
...@@ -234,14 +236,14 @@ export default { ...@@ -234,14 +236,14 @@ export default {
currentGoodId: '', currentGoodId: '',
cutImageDialogVisible: false, // 钱币正反面图片操作 cutImageDialogVisible: false, // 钱币正反面图片操作
imageType: 0, // 1正面 2反面 imageType: 0, // 1正面 2反面
cutEditImageDialogVisible: false, // 钱币图片编辑
editImageUrl: '', // 用于处理是否合成或者替换原图, editImageUrl: '', // 用于处理是否合成或者替换原图,
imageMainPosition: -1, // 用于设置主图位置 imageMainPosition: -1, // 用于设置主图位置
rules: { rules: {
name: [ name: [
{ required: true, message: '请输入标题', trigger: 'blur' } { required: true, message: '请输入标题', trigger: 'blur' }
] ]
}, }
showLamaImageDialog: false
} }
}, },
computed: { computed: {
...@@ -452,8 +454,8 @@ export default { ...@@ -452,8 +454,8 @@ export default {
this.cutImageDialogVisible = false this.cutImageDialogVisible = false
}, },
handleSaveImageBase64(base64Url) { handleSaveImageBase64(url, base64Url) {
this.showLamaImageDialog = false this.cutEditImageDialogVisible = false
const params = { const params = {
id: this.currentGoodId, id: this.currentGoodId,
imgBaseStr: base64Url imgBaseStr: base64Url
...@@ -461,28 +463,27 @@ export default { ...@@ -461,28 +463,27 @@ export default {
saveImageBase64(params).then((response) => { saveImageBase64(params).then((response) => {
this.$message.success('替换成功') this.$message.success('替换成功')
this.src = '' this.src = ''
this.editImageUrl = null
const resultImage = response.data.data const resultImage = response.data.data
this.imageList = this.imageList.map((item) => { this.imageList = this.imageList.map((item) => {
if (item === this.editImageUrl) { if (item === url) {
return resultImage return resultImage
} else { } else {
return item return item
} }
}) })
if (this.goodsParams.topImage === this.editImageUrl) { if (this.goodsParams.topImage === url) {
this.goodsParams.topImage = resultImage this.goodsParams.topImage = resultImage
} else if (this.goodsParams.images && this.goodsParams.images.indexOf(this.editImageUrl) !== -1) { } else if (this.goodsParams.images && this.goodsParams.images.indexOf(url) !== -1) {
this.goodsParams.images = this.goodsParams.images.map((item) => { this.goodsParams.images = this.goodsParams.images.map((item) => {
if (item === this.editImageUrl) { if (item === url) {
return resultImage return resultImage
} else { } else {
return item return item
} }
}) })
} }
this.editImageUrl = null
}) })
}, },
handleUploadImage(param) { handleUploadImage(param) {
...@@ -590,6 +591,10 @@ export default { ...@@ -590,6 +591,10 @@ export default {
this.imageUrl = imageUrl this.imageUrl = imageUrl
this.showLargeDialog = true this.showLargeDialog = true
}, },
handlerChangeImage(imageUrl) {
this.editImageUrl = imageUrl
this.cutEditImageDialogVisible = true
},
handlerSetMainImage(imageUrl, index) { handlerSetMainImage(imageUrl, index) {
if (index === this.imageMainPosition) { if (index === this.imageMainPosition) {
this.$message.info('已经是主图了哦~') this.$message.info('已经是主图了哦~')
...@@ -609,72 +614,6 @@ export default { ...@@ -609,72 +614,6 @@ export default {
message: response.data.errmsg || '请求失败' message: response.data.errmsg || '请求失败'
}) })
}) })
},
/**
* 关闭去水印弹窗
*/
handleCloseLamaDialog() {
this.showLamaImageDialog = false
this.editImageUrl = ''
},
/**
* 去除水印
*/
handleRemoveLama(imageUrl) {
this.editImageUrl = imageUrl
this.copyContent(this.editImageUrl)
this.$message.success('复制链接成功,粘贴链接去水印吧')
this.showLamaImageDialog = true
},
/**
* 复制链接
*/
copyContent(content) {
// 复制结果
let copyResult = true
// 设置想要复制的文本内容
const text = content || ''
// 判断是否支持clipboard方式
if (window.navigator.clipboard) {
// 利用clipboard将文本写入剪贴板(这是一个异步promise)
window.navigator.clipboard.writeText(text).then((res) => {
console.log('复制成功')
// 返回复制操作的最终结果
return copyResult
}).catch((err) => {
copyResult = false
console.log('复制失败', err)
// 返回复制操作的最终结果
return copyResult
})
} else {
// 不支持clipboard方式 则采用document.execCommand()方式
// 创建一个input元素
const inputDom = document.createElement('textarea')
// 设置为只读 防止移动端手机上弹出软键盘
inputDom.setAttribute('readonly', 'readonly')
// 给input元素赋值
inputDom.value = text
// 将创建的input添加到body
document.body.appendChild(inputDom)
// 选中input元素的内容
inputDom.select()
// 执行浏览器复制命令
// 复制命令会将当前选中的内容复制到剪切板中(这里就是创建的input标签中的内容)
// Input要在正常的编辑状态下原生复制方法才会生效
const result = document.execCommand('copy')
// 判断是否复制成功
if (result) {
console.log('复制成功')
} else {
console.log('复制失败')
copyResult = false
}
// 复制操作后再将构造的标签 移除
document.body.removeChild(inputDom)
// 返回复制操作的最终结果
return copyResult
}
} }
} }
} }
......
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