111 lines
3.5 KiB
Vue
111 lines
3.5 KiB
Vue
<template>
|
|
<div>
|
|
<el-dropdown @command="handleClick">
|
|
<span class="el-dropdown-link">
|
|
操作<i class="el-icon-arrow-down el-icon--right"></i>
|
|
</span>
|
|
<el-dropdown-menu slot="dropdown">
|
|
<el-dropdown-item v-if="isShowDetail" :command="beforeGoDetail(params.goodsId)">查看详情</el-dropdown-item>
|
|
<el-dropdown-item v-if="isShowAddFavorite" :command="beforeAddFavorite(params.goodsId, params.monitorId)">加入收藏</el-dropdown-item>
|
|
<el-dropdown-item v-if="isShowDelFavorite" :command="beforeDelFavorite(params.id)">取消收藏</el-dropdown-item>
|
|
<el-dropdown-item divided :command="beforeCopy(params.url)">商品采集</el-dropdown-item>
|
|
<el-dropdown-item divided :command="beforeGoWeb(params.url)">访问商品</el-dropdown-item>
|
|
<el-dropdown-item :command="beforeGoMal(params.mallId)">访问店铺</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</el-dropdown>
|
|
|
|
<ai-dialog
|
|
title="复制"
|
|
:visible.sync="copyFromDlgShow"
|
|
:close-on-click-modal="false"
|
|
width="790px"
|
|
customFooter
|
|
:append-to-body="true"
|
|
@close="handleClose">
|
|
<ai-copy-from-temu v-if="copyFromDlgShow" :params="temuParams" @onClose="handleClose" @onSuccess="handleSuccess"></ai-copy-from-temu>
|
|
</ai-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import AiCopyFromTemu from "./AiCopyFromTemu.vue";
|
|
import { Message } from 'element-ui'
|
|
|
|
export default {
|
|
name: "AiProductDropDown",
|
|
components: {AiCopyFromTemu},
|
|
props: ['params', 'isShowDetail', 'isShowAddFavorite', 'isShowDelFavorite'],
|
|
data() {
|
|
return {
|
|
info: {},
|
|
copyFromDlgShow: false,
|
|
temuParams: {}
|
|
}
|
|
},
|
|
computed: {
|
|
},
|
|
created() {
|
|
},
|
|
methods: {
|
|
handleClick(e) {
|
|
if (e.type == 'detail') {
|
|
this.$emit('onGoDetail')
|
|
} else if (e.type == 'copy') {
|
|
if (e.url.startsWith('http')) {
|
|
this.temuParams = {url: e.url}
|
|
} else {
|
|
this.temuParams = {url: 'https://www.temu.com/' + e.url}
|
|
}
|
|
this.copyFromDlgShow = true
|
|
} else if (e.type == 'addFavorite') {
|
|
this.$http.post('/api/monitorFavorite/add',{goodsId: e.goodsId, monitorId: e.monitorId}).then(res => {
|
|
if (res.code == 0) {
|
|
Message.success('收藏成功')
|
|
}
|
|
})
|
|
} else if (e.type == 'delFavorite') {
|
|
this.$http.post('/api/monitorFavorite/del?id=' + e.id).then(res => {
|
|
if (res.code == 0) {
|
|
Message.success('删除收藏成功')
|
|
this.$emit('onDelFavoriteSuccess')
|
|
}
|
|
})
|
|
} else if (e.type == 'goMall') {
|
|
window.open('https://www.temu.com/mall.html?mall_id=' + e.mallId, '_blank');
|
|
} else if (e.type == 'goWeb') {
|
|
if (e.url.startsWith('http')) {
|
|
window.open(e.url, '_blank');
|
|
} else {
|
|
window.open('https://www.temu.com/' + e.url, '_blank');
|
|
}
|
|
}
|
|
},
|
|
beforeGoDetail(goodsId) {
|
|
return {type: 'detail', goodsId: goodsId}
|
|
},
|
|
beforeAddFavorite(goodsId, monitorId) {
|
|
return {type: 'addFavorite', goodsId: goodsId, monitorId: monitorId}
|
|
},
|
|
beforeDelFavorite(id) {
|
|
return {type: 'delFavorite', id: id}
|
|
},
|
|
beforeCopy(url) {
|
|
return {type: 'copy', url: url}
|
|
},
|
|
beforeGoMal(mallId) {
|
|
return {type: 'goMall', mallId: mallId}
|
|
},
|
|
beforeGoWeb (url) {
|
|
return {type: 'goWeb', url: url}
|
|
},
|
|
handleClose() {
|
|
this.copyFromDlgShow = false
|
|
},
|
|
handleSuccess() {
|
|
this.copyFromDlgShow = false
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped lang="scss">
|
|
</style>
|