更新
This commit is contained in:
@@ -35,13 +35,13 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<div class="bottom flex-center">
|
<div class="bottom flex-center">
|
||||||
<el-button @click="$emit('onClose')">取 消</el-button>
|
<el-button @click="$emit('onClose')">取 消</el-button>
|
||||||
<el-button type="primary" @click="addToDraft" :loading="isCopying">确定</el-button>
|
<el-button type="primary" @click="toAddToDraft" :loading="isCopying">确定</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {sendChromeAPIMessage, sendChromeWebReqMessage} from '@/api/chromeApi'
|
import {sendChromeAPIMessage, sendTemuAPIMessage, sendChromeWebReqMessage} from '@/api/chromeApi'
|
||||||
import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
import AiLazyCascader from "@/components/AiLazyCascader.vue"
|
||||||
import { Message } from 'element-ui'
|
import { Message } from 'element-ui'
|
||||||
|
|
||||||
@@ -109,7 +109,8 @@ export default {
|
|||||||
goods: {},
|
goods: {},
|
||||||
sku: {},
|
sku: {},
|
||||||
productDetail: {},
|
productDetail: {},
|
||||||
isCopying: false
|
isCopying: false,
|
||||||
|
goodsId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -118,102 +119,159 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async addToDraft() {
|
toAddToDraft() {
|
||||||
this.$refs.form.validate((valid) => {
|
if (!this.form.url.startsWith("http")) {
|
||||||
if (valid) {
|
this.goodsId = this.form.url
|
||||||
this.isCopying = true
|
this.addToDraftNew()
|
||||||
this.$http.post('/api/copyProduct/check',null, {params: {type: 0}}).then(res => {
|
} else {
|
||||||
if (res.code == 0) {
|
let t = this.form.url
|
||||||
let source
|
let urlParams = this.parseURL(t)
|
||||||
if (this.form.type == '1') {
|
t = t.substring(0,t.indexOf(".html"))
|
||||||
source = 'temu'
|
if (t.lastIndexOf("-g-") > 0) {
|
||||||
} else if (this.form.type == '2') {
|
t = t.substring(t.lastIndexOf("-g-"), t.length);
|
||||||
source = 'aliexpress'
|
t = t.substring(3, t.length);
|
||||||
}
|
this.goodsId = t
|
||||||
sendChromeWebReqMessage({
|
this.addToDraftNew()
|
||||||
type: source,
|
} else if(urlParams.params) {
|
||||||
url: this.form.url,
|
let goodsId = urlParams.params.goods_id
|
||||||
}).then((res) => {
|
if (!goodsId) {
|
||||||
if (this.form.type == '1') {
|
this.addToDraft()
|
||||||
if (res.indexOf("window.rawData") == -1) {
|
} else {
|
||||||
this.isCopying = false
|
this.goodsId = goodsId
|
||||||
Message.error("请检查地址是否正确,或者“TEMU”网站是否出现图形验证码")
|
this.addToDraftNew()
|
||||||
return
|
|
||||||
}
|
|
||||||
let str = res.substring(res.indexOf("window.rawData"))
|
|
||||||
str = str.substring(0, str.indexOf("<\/script>"))
|
|
||||||
str = str.substring(str.indexOf("{"))
|
|
||||||
str = str.substring(0, str.lastIndexOf("}"))
|
|
||||||
str = str + "}"
|
|
||||||
|
|
||||||
let goodsObj = JSON.parse(str)
|
|
||||||
this.goods = goodsObj.store.goods
|
|
||||||
this.sku = goodsObj.store.sku
|
|
||||||
this.productDetail = goodsObj.store.productDetail
|
|
||||||
|
|
||||||
let specIds = []
|
|
||||||
this.sku.forEach(item => {
|
|
||||||
item.specs.forEach(item1 => {
|
|
||||||
let flag = false
|
|
||||||
specIds.forEach(item2 => {
|
|
||||||
if (item2.specValue == item1.specValue) {
|
|
||||||
flag = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!flag) {
|
|
||||||
specIds.push({specKeyId: item1.specKeyId, specValue: item1.specValue})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
Promise.all(specIds.map(item => this.getSpecId(item).then(res => {
|
|
||||||
this.sku.forEach(item1 => {
|
|
||||||
item1.specs.forEach(item2 => {
|
|
||||||
if (item2.specValue == item.specValue) {
|
|
||||||
item2.specValueId = res.result.specId
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return 0
|
|
||||||
}))).then(() => {
|
|
||||||
this.$http.post('/api/copyProduct/translate',{type: 1, goods: this.goods, sku: this.sku, productDetail: this.productDetail}).then(res => {
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.createDraft(res.data)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} else if (this.form.type == '2') {
|
|
||||||
/*if (res.indexOf("runParams") == -1) {
|
|
||||||
Message.error("请检查地址是否正确,或者“速卖通”网站是否出现滑动条")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let str = res.substring(res.indexOf("runParams"))
|
|
||||||
str = str.substring(0, str.indexOf("<\/script>"))
|
|
||||||
str = str.substring(str.indexOf("{"))
|
|
||||||
str = str.substring(0, str.lastIndexOf("}"))
|
|
||||||
str = str.substring(str.indexOf('data'))
|
|
||||||
str = str.substring(5)
|
|
||||||
|
|
||||||
let obj = JSON.parse(str)
|
|
||||||
|
|
||||||
sendChromeWebReqMessage({
|
|
||||||
type: source,
|
|
||||||
url: obj.productDescComponent.descriptionUrl,
|
|
||||||
}).then((res1) => {
|
|
||||||
res1 = res1.substring(0, res1.indexOf("<script>"))
|
|
||||||
let str = res1.replace(/<img[^>]+src="([^">]+)"[^>]+>/g, '$1\n').replace(/<.*?>/g, '[||]')
|
|
||||||
let arr = str.split('[||]')
|
|
||||||
for (let i = 0; i < arr.length; i++) {
|
|
||||||
console.log(arr[i])
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.isCopying = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.addToDraft()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async addToDraftNew() {
|
||||||
|
this.$refs.form.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.isCopying = true
|
||||||
|
sendTemuAPIMessage({
|
||||||
|
url: 'api/oak/integration/render',
|
||||||
|
anti: true,
|
||||||
|
data: {
|
||||||
|
goods_id: this.goodsId
|
||||||
|
}}).then((res) => {
|
||||||
|
if (!res.goods) {
|
||||||
|
this.isCopying = false
|
||||||
|
Message.error("获取商品信息失败,采集失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.goods = res.goods
|
||||||
|
this.sku = res.sku
|
||||||
|
this.productDetail = res.product_detail
|
||||||
|
let specIds = []
|
||||||
|
this.sku.forEach(item => {
|
||||||
|
item.specs.forEach(item1 => {
|
||||||
|
let flag = false
|
||||||
|
specIds.forEach(item2 => {
|
||||||
|
if (item2.spec_value == item1.spec_value) {
|
||||||
|
flag = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!flag) {
|
||||||
|
specIds.push({spec_key_id: item1.spec_key_id, spec_value: item1.spec_value})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Promise.all(specIds.map(item => this.getSpecIdNew(item).then(res => {
|
||||||
|
this.sku.forEach(item1 => {
|
||||||
|
item1.specs.forEach(item2 => {
|
||||||
|
if (item2.spec_value == item.spec_value) {
|
||||||
|
item2.spec_value_id = res.result.specId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return 0
|
||||||
|
}))).then(() => {
|
||||||
|
this.$http.post('/api/copyProduct/translateNew',{type: 1, goods: this.goods, sku: this.sku, productDetail: this.productDetail}).then(res => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.createDraft(res.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async addToDraft() {
|
||||||
|
this.$refs.form.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.isCopying = true
|
||||||
|
this.$http.post('/api/copyProduct/check',null, {params: {type: 0}}).then(res => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
let source
|
||||||
|
if (this.form.type == '1') {
|
||||||
|
source = 'temu'
|
||||||
|
} else if (this.form.type == '2') {
|
||||||
|
source = 'aliexpress'
|
||||||
|
}
|
||||||
|
sendChromeWebReqMessage({
|
||||||
|
type: source,
|
||||||
|
url: this.form.url,
|
||||||
|
}).then((res) => {
|
||||||
|
if (this.form.type == '1') {
|
||||||
|
if (res.indexOf("window.rawData") == -1) {
|
||||||
|
this.isCopying = false
|
||||||
|
Message.error("请检查地址是否正确,或者“TEMU”网站是否出现图形验证码")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let str = res.substring(res.indexOf("window.rawData"))
|
||||||
|
str = str.substring(0, str.indexOf("<\/script>"))
|
||||||
|
str = str.substring(str.indexOf("{"))
|
||||||
|
str = str.substring(0, str.lastIndexOf("}"))
|
||||||
|
str = str + "}"
|
||||||
|
|
||||||
|
let goodsObj = JSON.parse(str)
|
||||||
|
this.goods = goodsObj.store.goods
|
||||||
|
this.sku = goodsObj.store.sku
|
||||||
|
this.productDetail = goodsObj.store.productDetail
|
||||||
|
|
||||||
|
let specIds = []
|
||||||
|
this.sku.forEach(item => {
|
||||||
|
item.specs.forEach(item1 => {
|
||||||
|
let flag = false
|
||||||
|
specIds.forEach(item2 => {
|
||||||
|
if (item2.specValue == item1.specValue) {
|
||||||
|
flag = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!flag) {
|
||||||
|
specIds.push({specKeyId: item1.specKeyId, specValue: item1.specValue})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Promise.all(specIds.map(item => this.getSpecId(item).then(res => {
|
||||||
|
this.sku.forEach(item1 => {
|
||||||
|
item1.specs.forEach(item2 => {
|
||||||
|
if (item2.specValue == item.specValue) {
|
||||||
|
item2.specValueId = res.result.specId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return 0
|
||||||
|
}))).then(() => {
|
||||||
|
this.$http.post('/api/copyProduct/translate',{type: 1, goods: this.goods, sku: this.sku, productDetail: this.productDetail}).then(res => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.createDraft(res.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else if (this.form.type == '2') {
|
||||||
|
console.log(1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.isCopying = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
createDraft(data) {
|
createDraft(data) {
|
||||||
@@ -263,6 +321,22 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getSpecIdNew(data) {
|
||||||
|
return sendChromeAPIMessage({
|
||||||
|
url: 'bg-anniston-mms/sku/spec/byName/queryOrAdd',
|
||||||
|
needMallId: true,
|
||||||
|
mallId: this.form.targetMallId,
|
||||||
|
data: {
|
||||||
|
parentSpecId: data.spec_key_id,
|
||||||
|
specName: data.spec_value
|
||||||
|
}}).then((res) => {
|
||||||
|
if (res.errorCode == 1000000) {
|
||||||
|
return res
|
||||||
|
} else {
|
||||||
|
this.getSpecIdNew(data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
getSpecId(data) {
|
getSpecId(data) {
|
||||||
return sendChromeAPIMessage({
|
return sendChromeAPIMessage({
|
||||||
url: 'bg-anniston-mms/sku/spec/byName/queryOrAdd',
|
url: 'bg-anniston-mms/sku/spec/byName/queryOrAdd',
|
||||||
@@ -294,6 +368,33 @@ export default {
|
|||||||
this.$emit('onSuccess')
|
this.$emit('onSuccess')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
parseURL(url) {
|
||||||
|
let a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
return {
|
||||||
|
source: url,
|
||||||
|
protocol: a.protocol.replace(':',''),
|
||||||
|
host: a.hostname,
|
||||||
|
port: a.port,
|
||||||
|
query: a.search,
|
||||||
|
params: (function(){
|
||||||
|
var ret = {},
|
||||||
|
seg = a.search.replace(/^\?/,'').split('&'),
|
||||||
|
len = seg.length, i = 0, s;
|
||||||
|
for (;i<len;i++) {
|
||||||
|
if (!seg[i]) { continue; }
|
||||||
|
s = seg[i].split('=');
|
||||||
|
ret[s[0]] = s[1];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
})(),
|
||||||
|
file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
|
||||||
|
hash: a.hash.replace('#',''),
|
||||||
|
path: a.pathname.replace(/^([^\/])/,'/$1'),
|
||||||
|
relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [,''])[1],
|
||||||
|
segments: a.pathname.replace(/^\//,'').split('/')
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "TEMU助手",
|
"name": "TEMU助手",
|
||||||
"description": "TEMU助手 - 自动化提高生产效率",
|
"description": "TEMU助手 - 自动化提高生产效率",
|
||||||
"version": "3.0.7",
|
"version": "3.0.8",
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "/background.js"
|
"service_worker": "/background.js"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,7 +45,8 @@
|
|||||||
@getList="getList">
|
@getList="getList">
|
||||||
<el-table-column slot="url" label="商品地址" align="left">
|
<el-table-column slot="url" label="商品地址" align="left">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<div><a class="el-link el-link--primary" :href="scope.row.url" target="_blank">{{ scope.row.url }}</a></div>
|
<div v-if="scope.row.url.startsWith('http')"><a class="el-link el-link--primary" :href="scope.row.url" target="_blank">{{ scope.row.url }}</a></div>
|
||||||
|
<div v-else><a class="el-link el-link--primary" :href="'https://www.temu.com/goods.html?goods_id=' + scope.row.url" target="_blank">{{ scope.row.url }}</a></div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</ai-table>
|
</ai-table>
|
||||||
|
|||||||
@@ -26,7 +26,8 @@
|
|||||||
<el-input :clearable="true" size="small" style="width: 80px" v-model="search.saleBegin" ></el-input>
|
<el-input :clearable="true" size="small" style="width: 80px" v-model="search.saleBegin" ></el-input>
|
||||||
~
|
~
|
||||||
<el-input :clearable="true" size="small" style="width: 80px" v-model="search.saleEnd" ></el-input>
|
<el-input :clearable="true" size="small" style="width: 80px" v-model="search.saleEnd" ></el-input>
|
||||||
|
<label style="width:100px">仅显示最新:</label>
|
||||||
|
<ai-select :selectList="$dict.getDict('mall_yesno')" v-model="search.isNew"></ai-select>
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<el-button type="primary" @click="search.current =1, getList()">查询</el-button>
|
<el-button type="primary" @click="search.current =1, getList()">查询</el-button>
|
||||||
@@ -38,7 +39,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr; gap: 16px;">
|
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr; gap: 16px;">
|
||||||
<el-card v-for="item in tableData" :key="item.id" :body-style="{ padding: '0px', margin: '5px' }">
|
<el-card v-for="item in tableData" :key="item.id" :body-style="{ padding: '0px', margin: '5px' }">
|
||||||
<el-image :src="item.imgUrl" class="image" :preview-src-list="[item.imgUrl]" />
|
<span class="nav-label labelBadge">
|
||||||
|
<span class="ii" v-if="item.isNew == 1">新</span>
|
||||||
|
<el-image :src="item.imgUrl" class="image" :preview-src-list="[item.imgUrl]" />
|
||||||
|
</span>
|
||||||
<div style="padding: 14px;">
|
<div style="padding: 14px;">
|
||||||
<div class="bottom clearfix">
|
<div class="bottom clearfix">
|
||||||
<div style="margin-bottom: 5px;">
|
<div style="margin-bottom: 5px;">
|
||||||
@@ -96,7 +100,8 @@ import AiProductDropDown from '@/components/AiProductDropDown.vue';
|
|||||||
priceBegin: '',
|
priceBegin: '',
|
||||||
priceEnd: '',
|
priceEnd: '',
|
||||||
saleBegin: '',
|
saleBegin: '',
|
||||||
saleEnd: ''
|
saleEnd: '',
|
||||||
|
isNew: ''
|
||||||
},
|
},
|
||||||
orderBys: [{
|
orderBys: [{
|
||||||
value: '0',
|
value: '0',
|
||||||
@@ -122,6 +127,7 @@ import AiProductDropDown from '@/components/AiProductDropDown.vue';
|
|||||||
},
|
},
|
||||||
|
|
||||||
created () {
|
created () {
|
||||||
|
this.$dict.load('mall_yesno');
|
||||||
this.monitorId = this.params.id
|
this.monitorId = this.params.id
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
@@ -215,4 +221,24 @@ import AiProductDropDown from '@/components/AiProductDropDown.vue';
|
|||||||
.el-icon-arrow-down {
|
.el-icon-arrow-down {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*徽标*/
|
||||||
|
.labelBadge {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ii {
|
||||||
|
background: #f00;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
top: -3px;
|
||||||
|
right: -5px;
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
color: #FFF;
|
||||||
|
z-index: 999;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user