This commit is contained in:
liushiwei
2023-11-24 01:04:54 +08:00
parent fe6fd6cfdc
commit 15cd54a44e
17 changed files with 1340 additions and 39 deletions

View File

@@ -18,6 +18,7 @@
"vue-json-excel": "^0.3.0",
"vue-qr": "^4.0.9",
"vue-router": "^3.2.0",
"crypto-js": "^4.0.0",
"vuex": "^3.4.0",
"vuex-persistedstate": "^4.1.0"
},

BIN
src/assets/free.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -157,8 +157,9 @@ export default {
goods_id: this.goodsId
}}).then((res) => {
if (!res.goods) {
this.isCopying = false
Message.error("获取商品信息失败,采集失败")
//this.isCopying = false
//Message.error("获取商品信息失败,采集失败")
this.addToDraft()
return
}
this.goods = res.goods

View File

@@ -28,7 +28,7 @@ import { DualAxes } from '@antv/g2plot'
export default {
name: "AiProductDetail",
props: ['params'],
props: ['params', 'url'],
components: {
AiProductDropDown
},
@@ -47,7 +47,7 @@ export default {
},
methods: {
init() {
this.$http.post('/api/monitorDetail/queryProductDetail',null,{
this.$http.post(this.url ? this.url: '/api/monitorDetail/queryProductDetail',null,{
params: {
goodsId: this.params.goodsId,
monitorId: this.params.monitorId

View File

@@ -8,6 +8,7 @@
<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 v-if="isShowGroup" :command="beforeAddGroup(params.goodsId)">加入分组</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>
@@ -24,6 +25,32 @@
@close="handleClose">
<ai-copy-from-temu v-if="copyFromDlgShow" :params="temuParams" @onClose="handleClose" @onSuccess="handleSuccess"></ai-copy-from-temu>
</ai-dialog>
<ai-dialog
title="添加到分组"
:visible.sync="addGroupDlgShow"
:close-on-click-modal="false"
width="790px"
customFooter
:append-to-body="true"
@close="handleClose">
<el-form class="ai-form" :model="addGroupForm" label-width="120px" ref="addGroupForm">
<el-form-item label="分组" style="width: 100%;" prop="groupId" :rules="[{ required: true, message: '请选择分组', trigger: 'blur' }]">
<el-select style="width: 380px" v-model="addGroupForm.groupId" placeholder="请选择分组">
<el-option
v-for="item in groupList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="addGroupDlgShow = false">取消</el-button>
<el-button type="primary" @click="addToGroup">确定</el-button>
</div>
</ai-dialog>
</div>
</template>
<script>
@@ -33,12 +60,18 @@ import { Message } from 'element-ui'
export default {
name: "AiProductDropDown",
components: {AiCopyFromTemu},
props: ['params', 'isShowDetail', 'isShowAddFavorite', 'isShowDelFavorite'],
props: ['params', 'isShowDetail', 'isShowAddFavorite', 'isShowDelFavorite', 'isShowGroup'],
data() {
return {
info: {},
copyFromDlgShow: false,
temuParams: {}
addGroupDlgShow: false,
temuParams: {},
addGroupForm: {
groupId: '',
goodsId: ''
},
groupList: []
}
},
computed: {
@@ -69,6 +102,14 @@ export default {
this.$emit('onDelFavoriteSuccess')
}
})
} else if (e.type == 'addGroup') {
this.addGroupForm.goodsId = e.goodsId
this.$http.post('/api/newProductGroup/myPage?size=1000').then(res => {
if (res.code == 0) {
this.addGroupDlgShow = true
this.groupList = res.data.records
}
})
} else if (e.type == 'goMall') {
window.open('https://www.temu.com/mall.html?mall_id=' + e.mallId, '_blank');
} else if (e.type == 'goWeb') {
@@ -88,6 +129,9 @@ export default {
beforeDelFavorite(id) {
return {type: 'delFavorite', id: id}
},
beforeAddGroup(goodsId) {
return {type: 'addGroup', goodsId: goodsId}
},
beforeCopy(url) {
return {type: 'copy', url: url}
},
@@ -102,6 +146,18 @@ export default {
},
handleSuccess() {
this.copyFromDlgShow = false
},
addToGroup() {
this.$refs.addGroupForm.validate((valid) => {
if (valid) {
this.$http.post('/api/newProductGroupDetail/add', {...this.addGroupForm}).then(res => {
if (res.code == 0) {
this.addGroupDlgShow = false
Message.success("商品成功添加到分组")
}
})
}
})
}
}
}

View File

@@ -41,6 +41,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
'mode': 'cors'
})).then((res) => {
resolve(res.json());
}).catch(() => {
resolve({success: false, errorCode: -1})
});
}).then(sendResponse);
} else if (request.type == 'temu') {

View File

@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "TEMU助手",
"description": "TEMU助手 - 自动化提高生产效率",
"version": "3.0.8",
"version": "3.1.0",
"background": {
"service_worker": "/background.js"
},

View File

@@ -67,7 +67,6 @@ const router = new VueRouter({
name: 'copyProduct',
component: () => import('../view/product/CopyProduct.vue')
},
{
path: 'niubiCopy',
name: 'niubiCopy',
@@ -93,6 +92,16 @@ const router = new VueRouter({
name: 'indexTrack',
component: () => import('../view/selection/indextrack/Index.vue')
},
{
path: 'newProduct',
name: 'newProduct',
component: () => import('../view/selection/newproducttrack/newproduct/Index.vue')
},
{
path: 'newProductGroup',
name: 'newProductGroup',
component: () => import('../view/selection/newproducttrack/newproductgroup/Index.vue')
},
{
path: 'message',
@@ -121,7 +130,20 @@ const router = new VueRouter({
path: 'learning',
name: 'learning',
component: () => import('../view/Learning.vue')
}
},
{
path: 'qualification',
name: 'qualification',
children: [
{
path: 'oushuitong',
name: 'oushuitong',
meta: {
activeMenu:'/qualification'
}
}
]
},
]
},
{

View File

@@ -81,12 +81,36 @@
<span slot="title">选品采集</span>
</template>
<el-menu-item index="/niubiCopy">商品采集</el-menu-item>
<el-menu-item index="/storeTrack">店铺跟踪</el-menu-item>
<el-menu-item index="/keywordTrack">关键字跟踪</el-menu-item>
<el-menu-item index="/favoriteTrack">我的收藏</el-menu-item>
<el-submenu index="/track" style="padding-left: 15px;">
<template slot="title">
<span slot="title">选品跟踪</span>
</template>
<el-menu-item index="/storeTrack">店铺跟踪</el-menu-item>
<el-menu-item index="/keywordTrack">关键字跟踪</el-menu-item>
<el-menu-item index="/favoriteTrack">我的收藏</el-menu-item>
</el-submenu>
<el-submenu index="/newproductTrack" style="padding-left: 15px;">
<template slot="title">
<span slot="title">新品跟踪免费</span>
</template>
<el-menu-item index="/newProduct">上架新品</el-menu-item>
<el-menu-item index="/newProductGroup">我的分组</el-menu-item>
</el-submenu>
<el-menu-item index="/indexTrack">首页商品跟踪</el-menu-item>
</el-submenu>
<el-submenu index="/qualification">
<template slot="title">
<i class="el-icon-s-check"></i>
<span slot="title">资质合规</span>
</template>
<el-menu-item>
<template #title>
<a style="color: white" :href="'https://www.evatmaster.com/ost/registered?channelNo=SCBFWYSHZTEMUXZSQDHZ'" target="_blank">
<span>欧税通</span>
</a>
</template>
</el-menu-item>
</el-submenu>
<el-menu-item index="/saleData">
<i class="el-icon-s-data"></i>
<span slot="title">销售数据</span>
@@ -144,6 +168,7 @@ import AiPayment from "@/components/AiPayment.vue";
}
},
computed: {
freeLogo: () => require("../assets/free.png"),
getStateInfo() {
if (this.$store.state.userInfo.flag == 0) {
return '未激活';

View File

@@ -52,6 +52,7 @@
</template>
<script>
import CryptoJS from 'crypto-js'
export default {
data () {
return {
@@ -118,6 +119,23 @@
}
})
},
encryptPhone (phone) {
const u = navigator.userAgent
const isIos = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
var key = 'thanks,temulll11'
var iv = CryptoJS.enc.Latin1.parse(key)
var encrypted = CryptoJS.AES.encrypt(phone, iv, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
})
if (isIos) {
return encodeURIComponent(encrypted.toString())
} else {
return encrypted.toString()
}
},
getCode () {
if (this.isSend) {
@@ -126,9 +144,10 @@
this.$refs.form.validateField('phone', e => {
if (!e) {
let phone = this.encryptPhone(this.form.phone)
this.isSend = true
this.btnLoading = true
this.$http.post(`/api/sms/getRegSmsCode?phone=${this.form.phone}`, {}, {
this.$http.post(`/api/sms/getRegSmsCodeNew?phone=${phone}`, {}, {
withoutToken: true
}).then(res => {
if (res.code === 0) {

View File

@@ -45,7 +45,7 @@
<template #left>
<div class="search-item">
<label style="width:90px">店铺</label>
<el-select v-model="productPage.mallId" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductList()" placeholder="请选择">
<el-select v-model="productPage.mallId" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductOrDraftList()" placeholder="请选择">
<el-option
v-for="item in $store.state.mallList"
:key="item.mallId"
@@ -54,6 +54,21 @@
</el-option>
</el-select>
</div>
<div class="search-item">
<label style="width:90px">模板来源</label>
<el-select v-model="productPage.from" @change="productTableData = [], productPage.total = 0, productPage.page =1, getProductOrDraftList()" placeholder="请选择">
<el-option
key="0"
label="商品列表"
value="0">
</el-option>
<el-option
key="1"
label="草稿箱列表"
value="1">
</el-option>
</el-select>
</div>
<div class="search-item">
<label style="width:90px">SKC</label>
<el-input size="small" placeholder="请输入SKC多个用,隔开" v-model="productPage.productSkcIds" @keyup.enter.native="productPage.page =1, getProductList()"></el-input>
@@ -67,10 +82,11 @@
<el-button @click="productPage= {
page: 1,
pageSize: 10,
from: '0',
productName: '',
productSkcIds: ''
}, getProductList()">重置</el-button>
<el-button type="primary" @click="productPage.page =1, getProductList()">查询</el-button>
}, getProductOrDraftList()">重置</el-button>
<el-button type="primary" @click="productPage.page =1, getProductOrDraftList()">查询</el-button>
</template>
</ai-search-bar>
<ai-table
@@ -80,7 +96,7 @@
:current.sync="productPage.page" :size.sync="productPage.pageSize"
style="margin-top: 8px;"
@selection-change="productHandleSelectionChange"
@getList="getProductList">
@getList="getProductOrDraftList">
</ai-table>
</div>
</template>
@@ -98,7 +114,7 @@
width="790px"
customFooter
@close="handleClose">
<el-form class="ai-form" :model="form" label-width="120px" ref="form">
<el-form class="ai-form" :model="form" label-width="160px" ref="form">
<el-form-item label="店铺" style="width: 100%;" prop="targetMallId" :rules="[{ required: true, message: '请选择店铺', trigger: 'blur' }]">
<el-select style="width: 380px" v-model="form.targetMallId" placeholder="请选择">
<el-option
@@ -109,7 +125,16 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="商品分类" style="width: 100%;" prop="targetCatId" :rules="[{ required: true, message: '请选择商品分类', trigger: 'blur' }]">
<el-form-item
prop="isSameCategory"
label="是否保持相同类目:"
:rules="[{ required: true, message: '请选择是否保持相同类目', trigger: 'blur' }]">
<el-radio-group v-model="form.isSameCategory" size="medium">
<el-radio :label="false"></el-radio>
<el-radio :label="true"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="!form.isSameCategory" label="商品分类" style="width: 100%;" prop="targetCatId" :rules="[{ required: true, message: '请选择商品分类', trigger: 'blur' }]">
<ai-lazy-cascader
style="width: 380px"
v-model="form.targetCatId"
@@ -207,7 +232,7 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
dlgShow: false,
productTableData: [],
productPage: {page: 1, pageSize: 10, mallId: '', productName: '', productSkcIds: '', total: 0},
productPage: {page: 1, pageSize: 10, mallId: '', from: '0', productName: '', productSkcIds: '', total: 0},
productColConfigs: [
{ type: "selection", width: '70px', align: 'left', fixed: 'left'},
{ prop: 'productSpu', label: 'SPU ID', align: 'left' },
@@ -220,7 +245,8 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
productIds: [],
form: {
targetMallId: '',
targetCatId: []
targetCatId: [],
isSameCategory: true
}
}
},
@@ -270,7 +296,7 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
// 添加模板
handleClose() {
this.productTableData = []
this.productPage = {page: 1, pageSize: 10, total: 0}
this.productPage = {page: 1, pageSize: 10, from: '0', total: 0}
this.dlgShow = false
},
toAddTemplate() {
@@ -283,10 +309,46 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
return;
}
this.dlgShow = true
this.getProductList()
this.getProductOrDraftList()
}
})
},
getProductOrDraftList() {
if (this.productPage.from == '0') {
this.getProductList()
} else {
this.getDraftList()
}
},
getDraftList() {
let params = {};
params.page = this.productPage.page;
params.pageSize = this.productPage.pageSize;
if (this.productPage.productName) {
params.productName = this.productPage.productName
}
sendChromeAPIMessage({
url: 'bg-visage-mms/product/draft/pageQuery',
needMallId: true,
mallId: this.productPage.mallId,
data: {
...params
}}).then((res) => {
if (res.errorCode == 1000000) {
this.productPage.total = res.result.total
this.productTableData = res.result.pageItems.map((item) => {
return {
productSpu: item.productDraftId,
productSkc: '',
productName: item.productName,
createTime: timestampToTime(item.updatedAt)
};
})
} else {
this.getDraftList()
}
});
},
getProductList() {
let params = {};
params.page = this.productPage.page;
@@ -332,11 +394,15 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
}
this.productIds.map((productSpu, index) => {
setTimeout(() => {
this.saveTemplate(productSpu, index)
if (this.productPage.from == '0') {
this.saveProductTemplate(productSpu, index)
} else {
this.saveDraftTemplate(productSpu, index)
}
}, 200 * index)
})
},
saveTemplate(spu, index) {
saveProductTemplate(spu, index) {
sendChromeAPIMessage({
url: 'bg-visage-mms/product/query',
needMallId: true,
@@ -365,7 +431,39 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
}
})
} else {
this.saveTemplate(spu, index)
this.saveProductTemplate(spu, index)
}
})
},
saveDraftTemplate(spu, index) {
sendChromeAPIMessage({
url: 'bg-visage-mms/product/draft/query',
needMallId: true,
mallId: this.productPage.mallId,
data: {
productDraftId: spu
}}).then((res) => {
if (res.errorCode == 1000000) {
let content = transform(res.result)
let mallInfo = this.$store.state.mallList.filter(item => {
return item.mallId == this.productPage.mallId
})
this.$http.post('/api/product/add', {
mallId: mallInfo[0].mallId,
mallName: mallInfo[0].mallName,
productSpu: spu,
productName: res.result.productName,
content: content
}).then(res1 => {
if (res1.code == 0) {
Message.success("商品【" + res.result.productName + "】成功添加为商品模板")
if (index == this.productIds.length - 1) {
this.getList()
}
}
})
} else {
this.saveDraftTemplate(spu, index)
}
})
},
@@ -383,23 +481,38 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
let product = this.tableData.filter((item) => {
return item.id == id
})
let content = JSON.parse(product[0].content)
let category = null
if (this.form.isSameCategory) {
let i = 1
while(true) {
if (!content['cat'+i+'Id']) {
break
}
i++
}
category = content['cat'+(i-1)+'Id']
} else {
category = this.form.targetCatId[this.form.targetCatId.length - 1]
}
setTimeout(() => {
sendChromeAPIMessage({
url: 'bg-visage-mms/product/draft/add',
needMallId: true,
mallId: this.form.targetMallId,
data: {
catId: this.form.targetCatId[this.form.targetCatId.length - 1]
catId: category
}}).then((res) => {
if (res.errorCode == 1000000) {
let draftId = res.result.productDraftId
let content = JSON.parse(product[0].content)
let i = 0
for (; i < this.form.targetCatId.length; i++) {
content['cat' + (i+1) + 'Id'] = this.form.targetCatId[i]
}
for (; i < 10; i++) {
content['cat' + (i+1) + 'Id'] = ''
if (!this.form.isSameCategory) {
let i = 0
for (; i < this.form.targetCatId.length; i++) {
content['cat' + (i+1) + 'Id'] = this.form.targetCatId[i]
}
for (; i < 10; i++) {
content['cat' + (i+1) + 'Id'] = ''
}
}
content.productDraftId = draftId
sendChromeAPIMessage({
@@ -411,6 +524,8 @@ import AiLazyCascader from "@/components/AiLazyCascader.vue"
}}).then((res) => {
if (res.errorCode == 1000000) {
Message.success("商品【" + product[0].productName + "】成功添加到草稿箱")
} else {
Message.error(res.errorMsg)
}
})
} else {

View File

@@ -0,0 +1,42 @@
<template>
<div style="height: 100%;">
<transition name="fade-transform" mode="out-in">
<keep-alive :include="['Detail']">
<component ref="component" :is="component" @change="onChange" :params="params"></component>
</keep-alive>
</transition>
</div>
</template>
<script>
import Detail from './components/Detail.vue'
export default {
name: 'NewProduct',
label: '新品上架',
components: {
Detail
},
data () {
return {
component: 'Detail',
params: {}
}
},
methods: {
onChange (data) {
if (data.type === 'Detail') {
this.component = 'Detail'
this.params = data.params
}
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,412 @@
<template>
<div>
<ai-list class="list" v-loading="isLoading" element-loading-text="拼命加载中">
<ai-title
slot="title"
title="上架新品"
isShowBottomBorder>
<template #rightBtn>
<div class="title-right">
上次更新时间{{ lastUpdateTime }}
<div>
<el-button type="button" :class="'el-button el-button--primary'" @click="beginSync">同步</el-button>
</div>
</div>
</template>
</ai-title>
<template #left>
<div class="categoryTree">
<el-tree ref="tree" lazy :load="loadCategory" node-key="optId" :props="props"
:default-expanded-keys="defaultExpanded"
:expand-on-click-node="false"
:check-on-click-node="true"
:highlight-current="true"
@node-click="handleNodeClick"/>
</div>
</template>
<template slot="content">
<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-image :src="item.imgUrl" class="image" :preview-src-list="[item.imgUrl]" />
<div style="padding: 14px;">
<div class="bottom clearfix">
<div style="margin-bottom: 5px;">
<div style="display: inline; margin-left: 5px;">${{ item.price }}</div>
<ai-product-drop-down :params="item" :isShowGroup="true" :isShowDetail="false" :isShowAddFavorite="false" :isShowDelFavorite="false"
style="float: right;"></ai-product-drop-down>
</div>
</div>
</div>
</el-card>
<el-pagination
layout="prev, pager, next"
style="position: absolute; bottom: 0px; right: 40px;"
:total="total"
:page-size.sync="form.size"
:current-page.sync="form.current"
@current-change="getList">
<div class="paginationPre-total"><label class="color-primary">{{ total }}</label>条记录
</div>
</el-pagination>
</div>
</template>
</ai-list>
<ai-dialog
title="提示"
:visible.sync="isTipDlgShow"
:close-on-click-modal="false"
width="790px"
customFooter
@close="isDlgShow = false">
<div style="display: block;height: 30px;">商品链接可能出现图形验证码导致采集失败是否前往验证</div>
<div class="dialog-footer" slot="footer">
<el-button @click="isTipDlgShow = false">取消</el-button>
<el-button style="width: 180px;" @click="isTipDlgShow = false, isLoading = true, toCollect()">已验证继续采集</el-button>
<el-button type="primary" @click="gotoValid">前往验证</el-button>
</div>
</ai-dialog>
</div>
</template>
<script>
import AiProductDropDown from '@/components/AiProductDropDown.vue'
import {sendTemuAPIMessage, sendChromeWebReqMessage} from '@/api/chromeApi'
import { Message } from 'element-ui'
export default {
name: 'DetailPage',
props: ['params'],
components: {AiProductDropDown},
data () {
return {
props: {
label: 'name',
isLeaf: data => data.parentId != 0
},
search: {
current: 1,
size: 120
},
form: {
current: 1,
size: 18,
category: null
},
defaultExpanded: [],
tableData: [],
total: 0,
offset: 0,
pageSize: 120,
currentData: null,
isLoading: false,
isOptApi: true,
goodsList: [],
currentIndex: 0,
errorUrl: '',
isTipDlgShow: false,
lastUpdateTime: '',
treeNode: null,
treeResolve: null
}
},
created () {
this.getList()
this.getLastUpdateTime()
},
methods: {
loadCategory(node, resolve) {
this.$http.post('/api/category/listByParent_newProduct',null,{
params: {
parentId: node.data?.optId || "0"
}
}).then(res => {
if (res?.data) {
if (!node.data) {
this.treeNode = node
this.treeResolve = resolve
}
let data = res.data.map(item => {
return {
name: item.name + '(' + item.total + ')',
optId: item.optId,
parentId: item.parentId
}
})
data = data.filter(item => {
return item.optId != -13
})
resolve(data)
} else {
resolve([])
}
})
},
getLastUpdateTime() {
this.$http.post('/api/newProduct/getLastUpdateTime').then(res => {
if (res?.data) {
this.lastUpdateTime = res.data
}
})
},
beginSync() {
this.isLoading = true
this.offset = 0
this.getNewProductData()
},
async getNewProductData() {
let res = await sendTemuAPIMessage({
url: 'api/poppy/v1/title_bar_recommend?scene=home_title_bar_new_in',
anti: true,
data: {
scene: "home_title_bar_new_in",
offset: this.offset,
pageSize: this.pageSize,
filterItems: null
}})
if (res.success) {
let arr = []
for (let i = 0;i < res.result.data.goods_list.length; i++) {
let item = res.result.data.goods_list[i]
let data = {
goodsId: item.goods_id,
price: item.price_info.price_schema,
saleTotal: 0,
url: 'https://www.temu.com/goods.html?goods_id=' + item.goods_id,
imgUrl: item.thumb_url,
mallId: item.mall_id
}
arr.push(data)
}
let res2 = await this.$http.post('/api/newProduct/addBatch', arr)
if (res2.code == 0 && res2.data != 1) {
if (res.result.data.goods_list.length == this.pageSize) {
this.offset = this.offset + this.pageSize
this.getNewProductData()
} else {
this.updateCategory()
}
} else {
this.updateCategory()
}
} else {
this.isLoading = false
Message.error("同步新上架商品失败")
}
},
async updateCategory() {
let res = await this.$http.post('/api/newProduct/getAllGoodsNoCategory')
if (res.code == 0) {
this.goodsList = res.data
this.currentIndex = 0
this.toCollect()
} else {
Message.error("采集失败")
}
},
async toCollect() {
if (this.currentIndex == this.goodsList.length) {
this.isLoading = false
Message.success("采集成功")
this.treeNode.childNodes = []
this.loadCategory(this.treeNode,this.treeResolve)
this.getLastUpdateTime()
return
}
let res1 = null
let opts = null
if (this.isOptApi) {
res1 = await sendTemuAPIMessage({
url: 'api/poppy/v1/opt',
anti: true,
data: {
offset: 0,
page_size: -1,
mainGoodsId: this.goodsList[this.currentIndex].goods_id,
scene: "pc_crumb_list"
}
})
if (res1.success && res1.result.data.crumb_opt_list) {
opts = res1.result.data.crumb_opt_list.map(item1 => {
return item1.opt_id
})
} else {
this.isOptApi = false
}
}
if (!this.isOptApi) {
res1 = await sendChromeWebReqMessage({
type: 'temu',
url: 'https://www.temu.com/goods.html?goods_id=' + this.goodsList[this.currentIndex].goods_id,
})
if (res1.indexOf("window.rawData") == -1) {
this.isLoading = false
this.errorUrl = 'https://www.temu.com/goods.html?goods_id=' + this.goodsList[this.currentIndex].goods_id
this.isTipDlgShow = true
return
}
let str = res1.substring(res1.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)
let crumbOptList = goodsObj.store.crumbOptList
opts = crumbOptList.map(item1 => {
return item1.optId
})
}
if (opts) {
this.$http.post('/api/newProduct/updateGoodsCategory', null, {params: {goodsId: this.goodsList[this.currentIndex].goods_id,category: opts.join(',')}})
} else {
this.isLoading = false
Message.error("同步类目失败")
return
}
this.currentIndex ++
this.toCollect()
},
getList() {
this.$http.post('/api/newProduct/page',null,{
params: {
category: this.currentData?.optId || '',
current: this.form.current,
size: this.form.size
}
}).then(res => {
this.tableData = res.data.records
this.total = res.data.total
})
},
handleNodeClick(data) {
this.currentData = data
this.form.current = 1
this.getList()
},
gotoValid() {
window.open(this.errorUrl, '_blank');
}
}
}
</script>
<style scoped lang="scss">
.list {
.title-right {
display: flex;
align-items: center;
& > div:first-child {
margin-right: 20px;
}
}
}
.categoryTree {
.gap {
width: 100%;
height: 17px;
}
:deep( .el-tree ) {
background: #fff;
.el-tree-node__expand-icon.is-leaf {
color: transparent !important;
}
.el-tree-node__content {
display: inline-flex;
min-width: 100%;
}
.el-tree-node__content > .el-tree-node__expand-icon {
padding: 4px;
}
.el-tree-node__content {
height: 32px;
}
.el-tree__empty-text {
color: #222;
font-size: 14px;
}
.el-tree-node__children .el-tree-node__content {
height: 32px;
}
.el-tree-node__content:hover {
background: #E8EFFF;
color: #222222;
border-radius: 2px;
}
.is-current > .el-tree-node__content {
&:hover {
background: #000;
color: #fff;
}
background: #000;
span {
color: #fff;
font-weight: bold;
}
}
}
}
.time {
font-size: 13px;
color: #999;
}
.bottom {
margin-top: 13px;
line-height: 12px;
}
.button {
padding: 0;
float: right;
}
.image {
width: 100%;
display: block;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
.el-dropdown-link {
cursor: pointer;
color: #409EFF;
}
.el-icon-arrow-down {
font-size: 12px;
}
</style>

View File

@@ -0,0 +1,57 @@
<template>
<div style="height: 100%;">
<transition name="fade-transform" mode="out-in">
<keep-alive :include="['List']">
<component ref="component" :is="component" @change="onChange" :params="params"></component>
</keep-alive>
</transition>
</div>
</template>
<script>
import List from './components/List.vue'
import Detail from './components/Detail.vue'
export default {
name: 'NewProductGroup',
label: '我的分组',
components: {
List,
Detail
},
data () {
return {
component: 'List',
params: {}
}
},
methods: {
onChange (data) {
if (data.type === 'Detail') {
this.component = 'Detail'
this.params = data.params
}
if (data.type === 'List') {
this.component = 'List'
this.params = data.params
this.$nextTick(() => {
if (data.isRefresh) {
setTimeout(() => {
this.$refs.component.getList()
}, 600)
}
})
}
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,235 @@
<template>
<div>
<ai-list class="list">
<ai-title
slot="title"
title="分组商品列表"
isShowBottomBorder isShowBack @onBackClick="cancel(false)">
</ai-title>
<template slot="content">
<ai-search-bar>
<template #left>
<label style="width:80px">排序方式</label>
<el-select v-model="search.orderBy" :clearable="true" @change="search.current =1, getList()" placeholder="请选择排序方式" size="small">
<el-option
v-for="item in orderBys"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<label style="width:80px">价格区间</label>
<el-input :clearable="true" size="small" style="width: 80px" v-model="search.priceBegin" ></el-input>
~
<el-input :clearable="true" size="small" style="width: 80px" v-model="search.priceEnd" ></el-input>
<label style="width:80px">销量区间</label>
<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>
</template>
<template #right>
<el-button type="primary" @click="search.current =1, getList()">查询</el-button>
</template>
</ai-search-bar>
<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' }">
<span class="nav-label labelBadge">
<el-image :src="item.imgUrl" class="image" :preview-src-list="[item.imgUrl]" />
</span>
<div style="padding: 14px;">
<div class="bottom clearfix">
<div style="margin-bottom: 5px;">
<div style="display: inline; margin-left: 5px;">${{ item.price }}<sub style="margin-left: 2px;" v-html="getPricePercent(item.priceChange)"></sub></div>
<div style="display: inline; margin-right: 5px; float: right;">{{ item.saleTotal }}<sub style="margin-left: 2px;" v-html="getSalePercent(item.saleChange)"></sub></div>
</div>
<div>
<div style="display: inline">日均销量: <span style="color: red; font-weight: bold">{{ item.averageSale }}</span></div>
<ai-product-drop-down :params="item" :isShowDetail="true" :isShowAddFavorite="false" :isShowDelFavorite="false" @onGoDetail="goDetail(item.goodsId)" style="float: right;"></ai-product-drop-down>
</div>
</div>
</div>
</el-card>
<el-pagination
layout="prev, pager, next"
style="position: absolute; bottom: 0px; right: 40px;"
:total="total"
:page-size.sync="search.size"
:current-page.sync="search.current"
@current-change="getList">
</el-pagination>
</div>
</template>
</ai-list>
<div class="productDetail">
<el-dialog
title="商品详情"
:visible="isShowDetailDlg"
:close-on-click-modal="false"
width="80%"
:before-close="handleClose">
<ai-product-detail v-if="isShowDetailDlg" :params="detailParams" :url="'/api/newProductDetail/queryDetail'"/>
</el-dialog>
</div>
</div>
</template>
<script>
import AiProductDetail from "@/components/AiProductDetail.vue";
import AiProductDropDown from '@/components/AiProductDropDown.vue';
export default {
name: 'DetailPage',
props: ['params'],
components: {AiProductDetail, AiProductDropDown},
data () {
return {
groupId: '',
search: {
current: 1,
type: '1',
size: 120,
orderBy: '',
priceBegin: '',
priceEnd: '',
saleBegin: '',
saleEnd: ''
},
orderBys: [{
value: '0',
label: '按销量涨辐排序'
},{
value: '1',
label: '按价格涨辐排序'
},{
value: '2',
label: '按销量排序'
},{
value: '3',
label: '按价格排序'
},{
value: '4',
label: '按日均销量排序'
}],
tableData: [],
total: 0,
isShowDetailDlg: false,
detailParams: {}
}
},
created () {
this.groupId = this.params.id
this.getList()
},
methods: {
getList () {
this.$http.post('/api/newProductGroupDetail/myPage',null,{
params: {
groupId: this.groupId,
...this.search
}
}).then(res => {
this.tableData = res.data.records
this.total = res.data.total
})
},
cancel (isRefresh) {
this.$emit('change', {
type: 'List',
isRefresh: !!isRefresh
})
},
getPricePercent(data) {
if (data < 0) {
return '<div style="display: inline; color: green">↓' + data + '%</div>'
} else if (data > 0) {
return '<div style="display: inline; color: red">↑' + data + '%</div>'
}
return ''
},
getSalePercent(data) {
if (data < 0) {
return '<div style="display: inline; color: green">↓' + data + '%</div>'
} else if (data > 0) {
return '<div style="display: inline; color: red">↑' + data + '%</div>'
}
return ''
},
handleClose() {
this.isShowDetailDlg = false
},
goDetail (goodsId) {
this.detailParams = {goodsId: goodsId}
this.isShowDetailDlg = true
}
}
}
</script>
<style scoped lang="scss">
.productDetail {
:deep(.el-dialog) {
height: 78vh;
overflow: auto;
}
}
.time {
font-size: 13px;
color: #999;
}
.bottom {
margin-top: 13px;
line-height: 12px;
}
.button {
padding: 0;
float: right;
}
.image {
width: 100%;
display: block;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
.el-dropdown-link {
cursor: pointer;
color: #409EFF;
}
.el-icon-arrow-down {
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>

View File

@@ -0,0 +1,318 @@
<template>
<div>
<ai-list class="list" v-loading="isLoading" element-loading-text="正在采集中……" element-loading-spinner="el-icon-loading">
<ai-title
slot="title"
title="我的分组"
isShowBottomBorder>
</ai-title>
<template slot="content">
<div class="content">
<ai-search-bar>
<template #left>
<el-button type="button" :class="'el-button el-button--primary'" @click="addStore()">添加分组</el-button>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
style="margin-top: 8px;"
:current.sync="search.current" :size.sync="search.size"
@getList="getList">
<el-table-column slot="options" label="操作" width="240px" show-overflow-tooltip align="center" fixed="right">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click="deleteGroup(row.id)">删除</el-button>
<el-button type="text" @click="toUpdateGroup(row)">修改</el-button>
<el-button type="text" @click="toDetail(row.id)">详情</el-button>
<el-button type="text" @click="toBegin(row)">采集数据</el-button>
</div>
</template>
</el-table-column>
</ai-table>
</div>
</template>
</ai-list>
<ai-dialog
title="添加分组"
:visible.sync="isDlgShow"
:close-on-click-modal="false"
width="790px"
customFooter
@close="isDlgShow = false">
<el-form class="ai-form" style="margin-top: 20px" :model="form" label-width="120px" ref="form">
<el-form-item
prop="name"
label="分组名称"
:rules="[{ required: true, message: '请输入分组名称', trigger: 'blur' }]">
<el-input placeholder="请输入分组名称" v-model="form.name"></el-input>
</el-form-item>
<el-form-item
prop="remark"
label="备注"
:rules="[{ required: true, message: '请输入备注', trigger: 'blur' }]">
<el-input placeholder="请输入备注" v-model="form.remark"></el-input>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="isDlgShow = false"> </el-button>
<el-button type="primary" @click="saveStore">确定</el-button>
</div>
</ai-dialog>
<ai-dialog
title="修改分组"
:visible.sync="isUpdateDlgShow"
:close-on-click-modal="false"
width="790px"
customFooter
@close="isDlgShow = false">
<el-form class="ai-form" :model="updateForm" label-width="120px" ref="updateForm">
<el-form-item
prop="name"
label="分组名称"
:rules="[{ required: true, message: '请输入分组名称', trigger: 'blur' }]">
<el-input placeholder="请输入分组名称" v-model="updateForm.name"></el-input>
</el-form-item>
<el-form-item
prop="remark"
label="备注"
:rules="[{ required: true, message: '请输入备注', trigger: 'blur' }]">
<el-input placeholder="请输入备注" v-model="updateForm.remark"></el-input>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="isUpdateDlgShow = false">取消</el-button>
<el-button type="primary" @click="updateGroup">确定</el-button>
</div>
</ai-dialog>
<ai-dialog
title="提示"
:visible.sync="isTipDlgShow"
:close-on-click-modal="false"
width="790px"
customFooter
@close="isDlgShow = false">
<div style="display: block;height: 30px;">商品链接可能出现图形验证码导致采集失败是否前往验证</div>
<div class="dialog-footer" slot="footer">
<el-button @click="isTipDlgShow = false">取消</el-button>
<el-button style="width: 180px;" @click="isTipDlgShow = false, isLoading = true, beginCollect()">已验证继续采集</el-button>
<el-button type="primary" @click="gotoValid">前往验证</el-button>
</div>
</ai-dialog>
</div>
</template>
<script>
import {sendChromeWebReqMessage} from '@/api/chromeApi'
import { Message } from 'element-ui';
export default {
name: 'List',
data () {
return {
search: {
current: 1,
size: 10
},
colConfigs: [
{ prop: 'name', label: '分组名称', align: 'left' },
{ prop: 'remark', label: '备注', align: 'left'},
{ prop: 'lastUpdateTime', label: '最后一次更新时间', align: 'left' },
{ prop: 'createTime', label: '添加时间', width: '180px', fixed: 'right'}
],
tableData: [],
total: 0,
form: {
name: '',
remark: ''
},
updateObj: {},
isUpdateDlgShow: false,
updateForm: {
id: '',
name: '',
remark: ''
},
isDlgShow: false,
detailsVo: {},
pageNo: 1,
pageSize: 120,
isLoading: false,
currentRow: {},
goodsList: [],
currentIndex: 0,
isTipDlgShow: false
}
},
created () {
this.$dict.load('monitor_status');
this.getList()
},
methods: {
getList () {
this.$http.post('/api/newProductGroup/myPage',null,{
params: {
...this.search
}
}).then(res => {
this.tableData = res.data.records
this.total = res.data.total
})
},
onChooseChange (val) {
this.selectRows = val;
},
saveStore () {
this.$refs.form.validate((valid) => {
if (valid) {
this.$http.post(`/api/newProductGroup/add`, {name: this.form.name, remark: this.form.remark}).then(res => {
if (res.code == 0) {
this.$message.success('添加成功!')
this.$store.dispatch('getUserInfo')
this.getList()
this.isDlgShow = false
}
})
}
})
},
toUpdateGroup (obj) {
this.updateObj = obj
this.updateForm.name = obj.name
this.updateForm.remark = obj.remark
this.isUpdateDlgShow = true
},
updateGroup () {
this.$refs.updateForm.validate((valid) => {
if (valid) {
this.$http.post(`/api/newProductGroup/update`, {id: this.updateObj.id, name: this.updateForm.name, remark: this.updateForm.remark}).then(res => {
if (res.code == 0) {
this.$message.success('修改成功!')
this.getList()
this.isUpdateDlgShow = false
}
})
}
})
},
renew(id) {
this.$confirm('确定要续费?', '温馨提示', {
type: 'warning'
}).then(() => {
this.$http.post('/api/newProductGroup/renew',null, {
params: {
id: id
}
}
).then(res => {
if (res.code == 0) {
this.$message.success('续费成功!')
this.$store.dispatch('getUserInfo')
this.getList()
}
})
})
},
deleteGroup(id) {
this.$confirm('确定要删除?', '温馨提示', {
type: 'warning'
}).then(() => {
this.$http.post('/api/newProductGroup/del',null, {
params: {
id: id
}
}
).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
toDetail (id) {
this.$emit('change', {
type: 'Detail',
params: {
id: id || ''
}
})
},
addStore() {
this.form.name = ''
this.form.remark = ''
this.isDlgShow = true
},
toBegin(row) {
this.currentRow = row
this.isLoading = true
this.$http.post('/api/newProductGroupDetail/getGoodsList',null,{
params: {
groupId: row.id
}
}).then(res => {
this.goodsList = res.data
this.currentIndex = 0
this.beginCollect()
})
},
async beginCollect() {
if (this.currentIndex >= this.goodsList.length) {
Message.success("采集成功")
this.isLoading = false
this.getList()
return
}
let res = await sendChromeWebReqMessage({
type: 'temu',
url: 'https://www.temu.com/goods.html?goods_id=' + this.goodsList[this.currentIndex].goodsId,
})
if (res.indexOf("window.rawData") == -1) {
this.isLoading = false
this.errorUrl = 'https://www.temu.com/goods.html?goods_id=' + this.goodsList[this.currentIndex].goodsId
this.isTipDlgShow = true
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)
let sku = goodsObj.store.sku[0]
await this.$http.post('/api/newProductDetail/addDetail',null,{
params: {
groupId: this.goodsList[this.currentIndex].groupId,
goodsId: this.goodsList[this.currentIndex].goodsId,
price: sku.normalPrice/100,
saleTotal: goodsObj.store.goods.soldQuantity
}
})
this.currentIndex ++
this.beginCollect()
},
gotoValid() {
window.open(this.errorUrl, '_blank')
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -33,10 +33,6 @@
<el-button type="primary" @click="search.current =1, getList()">查询</el-button>
</template>
</ai-search-bar>
<div style="margin-right: 0px; margin-bottom: 10px;">
</div>
<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' }">
<span class="nav-label labelBadge">