diff --git a/src/api/chromeApi.js b/src/api/chromeApi.js index 8585ff0..0e1611f 100644 --- a/src/api/chromeApi.js +++ b/src/api/chromeApi.js @@ -24,6 +24,17 @@ export async function sendChromeAPIMessage(message) { }) } +/** + * 向Chrome发送消息 + * @param message 消息 + */ +export async function sendChromeWebReqMessage(message) { + return new Promise((resolve) => { + // @ts-ignore + chrome.runtime.sendMessage(message, resolve) + }) +} + /** * 向Chrome发送消息 * @param message 消息 diff --git a/src/entry/background.js b/src/entry/background.js index 786f24f..99a2946 100644 --- a/src/entry/background.js +++ b/src/entry/background.js @@ -24,6 +24,72 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { resolve(res.json()); }); }).then(sendResponse); + } else if (request.type == 'temu') { + new Promise((resolve) => { + let headers = {}; + headers['Content-Type'] = 'text/html'; + headers.cookie = getTemuCookie(); + Promise.resolve().then(() => fetch(request.url, { + 'headers': headers, + 'method': 'GET', + 'referrerPolicy': 'no-referrer', + 'credentials': 'include', + 'mode': 'cors' + })).then((res) => { + // 创建了一个数据读取器 + const reader = res.body.getReader(); + // 创建了一个文本解码器 + const decoder = new TextDecoder(); + + let text = "" + reader.read().then(function processText({ done, value }) { + // Result 对象包含了两个属性: + // done - 当 stream 传完所有数据时则变成 true + // value - 数据片段。当 done 为 true 时始终为 undefined + if (done) { + resolve(text); + return; + } + // 将字节流转换为字符 + text = text + decoder.decode(value) + // 再次调用这个函数以读取更多数据 + return reader.read().then(processText); + }); + }); + }).then(sendResponse); + } else if (request.type == 'aliexpress') { + new Promise((resolve) => { + let headers = {}; + headers['Content-Type'] = 'text/html'; + headers.cookie = getAliexpressCookie(); + Promise.resolve().then(() => fetch(request.url, { + 'headers': headers, + 'method': 'GET', + 'referrerPolicy': 'no-referrer', + 'credentials': 'include', + 'mode': 'cors' + })).then((res) => { + // 创建了一个数据读取器 + const reader = res.body.getReader(); + // 创建了一个文本解码器 + const decoder = new TextDecoder(); + + let text = "" + reader.read().then(function processText({ done, value }) { + // Result 对象包含了两个属性: + // done - 当 stream 传完所有数据时则变成 true + // value - 数据片段。当 done 为 true 时始终为 undefined + if (done) { + resolve(text); + return; + } + // 将字节流转换为字符 + text = text + decoder.decode(value) + // 再次调用这个函数以读取更多数据 + return reader.read().then(processText); + }); + }); + }).then(sendResponse); } else if (request.type == 'notify') { chrome.notifications.create( "" + Math.random(), { @@ -84,3 +150,25 @@ function getCookie() { }); return cStr; } + +function getTemuCookie() { + const url = new URL("https://www.temu.com/"); + let cStr = ''; + chrome.cookies.getAll({domain: url.host}, (cookie) => { + cookie.map((c) => { + cStr += c.name + '=' + c.value + ';'; + }); + }); + return cStr; +} + +function getAliexpressCookie() { + const url = new URL("https://www.aliexpress.us/"); + let cStr = ''; + chrome.cookies.getAll({domain: url.host}, (cookie) => { + cookie.map((c) => { + cStr += c.name + '=' + c.value + ';'; + }); + }); + return cStr; +} \ No newline at end of file diff --git a/src/manifest.development.json b/src/manifest.development.json index ee3fcfc..f3775dd 100644 --- a/src/manifest.development.json +++ b/src/manifest.development.json @@ -14,7 +14,9 @@ "action": { }, "host_permissions": [ - "*://*.pinduoduo.com/" + "*://*.pinduoduo.com/", + "*://*.temu.com/", + "*://*.aliexpress.us/" ], "permissions": [ "cookies", diff --git a/src/manifest.production.json b/src/manifest.production.json index 7b0b9b7..f3c09d0 100644 --- a/src/manifest.production.json +++ b/src/manifest.production.json @@ -14,7 +14,9 @@ "action": { }, "host_permissions": [ - "*://*.pinduoduo.com/" + "*://*.pinduoduo.com/", + "*://*.temu.com/", + "*://*.aliexpress.us/" ], "permissions": [ "cookies", diff --git a/src/router/index.js b/src/router/index.js index aad8e94..d66f67a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -40,6 +40,11 @@ const router = new VueRouter({ name: 'shippingList', component: () => import('../view/shipping/ShippingList.vue') }, + { + path: 'waitPackageList', + name: 'waitPackageList', + component: () => import('../view/shipping/WaitPackageList.vue') + }, { path: 'waitShippingList', name: 'waitShippingList', @@ -51,6 +56,11 @@ const router = new VueRouter({ name: 'copyProduct', component: () => import('../view/product/CopyProduct.vue') }, + { + path: 'niubiCopy', + name: 'niubiCopy', + component: () => import('../view/product/NiubiCopy.vue') + }, { path: 'reducePrice', name: 'reducePrice', diff --git a/src/view/ExportSaleData.vue b/src/view/ExportSaleData.vue index e2d68a6..e82f51e 100644 --- a/src/view/ExportSaleData.vue +++ b/src/view/ExportSaleData.vue @@ -160,7 +160,7 @@ import { Message } from 'element-ui' mallName: '', type: '0', isLoading: false, - pageSize: 10, + pageSize: 100, currentPage: 1, todayTotal: 0, todayMoney: 0.0, @@ -171,9 +171,11 @@ import { Message } from 'element-ui' allProductList: [], startDate: '', endDate: '', + skuIds: [], jsonFields: { "商品名称": "productName", "店铺名称": "mallName", + "评分": "mark", "SPU": "productId", "SKC": "productSkcId", "SKU ID": "productSkuId", @@ -241,6 +243,13 @@ import { Message } from 'element-ui' width: '120px', align: 'left' }, + { + prop: 'mark', + label: '评分', + "show-overflow-tooltip": true, + width: '80px', + align: 'left' + }, { prop: 'productId', label: 'SPU', @@ -596,6 +605,7 @@ import { Message } from 'element-ui' data.skcExtCode = item.skcExtCode; data.purchaseConfig = item.purchaseConfig; data.productSkcPicture = item.productSkcPicture; + data.mark = item.mark.toFixed(1) data.mallName = this.mallName; this.last30DaySkcList.push({ @@ -678,7 +688,10 @@ import { Message } from 'element-ui' } return temp }) - this.getSkuDetailList() + this.skuIds = this.list.map(item => { + return item.productSkuId + }) + this.getSkuDetailList(0) } } else { setTimeout(() => { @@ -690,17 +703,24 @@ import { Message } from 'element-ui' this.isLoading = false }) }, - getSkuDetailList () { - let skuIds = this.list.map(item => { - return item.productSkuId - }) + getSkuDetailList (page) { + let tempSkuId = [] + let i = page * 500 + let j = 0 + for (; i < this.skuIds.length; i++) { + tempSkuId.push(this.skuIds[i]) + j ++ + if (j == 500) break + } + if (tempSkuId.length == 0) return sendChromeAPIMessage({ url: 'oms/bg/venom/api/supplier/sales/management/querySkuSalesNumber', needMallId: true, mallId: this.mallId, data: { - "productSkuIds": skuIds, + "productSkuIds": tempSkuId, "startDate": this.startDate, + // "startDate": '2023-01-17', "endDate": this.endDate }}).then((res) => { if (res.errorCode == 1000000) { @@ -719,9 +739,10 @@ import { Message } from 'element-ui' } } } + this.getSkuDetailList(page + 1) } else { setTimeout(() => { - this.getSkuDetailList() + this.getSkuDetailList(page) }, 1500) } }) diff --git a/src/view/Home.vue b/src/view/Home.vue index f45a0e5..a575d24 100644 --- a/src/view/Home.vue +++ b/src/view/Home.vue @@ -47,6 +47,7 @@ 抢仓发货 发货台管理 + 待装箱发货单 待收货发货单 已收货发货单 @@ -57,6 +58,7 @@ 商品管理 商品复制 + 智能复制 diff --git a/src/view/product/CopyProduct.vue b/src/view/product/CopyProduct.vue index 4faf82f..c80ee11 100644 --- a/src/view/product/CopyProduct.vue +++ b/src/view/product/CopyProduct.vue @@ -70,7 +70,7 @@ productName: '', productSkcIds: '' }, getProductList()">重置 - 查询 + 查询 { - setTimeout(() => { - sendChromeAPIMessage({ - url: 'bg-visage-mms/product/query', - needMallId: true, - mallId: this.productPage.mallId, - data: { - productEditTaskUid: '', - productId: productSpu - }}).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: res.result.productId, - 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() - } - } - }) + setTimeout(() => { + this.saveTemplate(productSpu, index) + }, 200 * index) + }) + }, + saveTemplate(spu, index) { + sendChromeAPIMessage({ + url: 'bg-visage-mms/product/query', + needMallId: true, + mallId: this.productPage.mallId, + data: { + productEditTaskUid: '', + productId: 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: res.result.productId, + 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() + } } }) - }, 200 * index) + } else { + this.saveTemplate(spu, index) + } }) }, beforeAddToDraft() { diff --git a/src/view/product/NiubiCopy.vue b/src/view/product/NiubiCopy.vue new file mode 100644 index 0000000..8bb157f --- /dev/null +++ b/src/view/product/NiubiCopy.vue @@ -0,0 +1,290 @@ + + + + + diff --git a/src/view/shipping/WaitPackageList.vue b/src/view/shipping/WaitPackageList.vue new file mode 100644 index 0000000..95d9a4a --- /dev/null +++ b/src/view/shipping/WaitPackageList.vue @@ -0,0 +1,268 @@ + + + + + diff --git a/src/view/shipping/WaitShippingList.vue b/src/view/shipping/WaitShippingList.vue index 0714015..c779517 100644 --- a/src/view/shipping/WaitShippingList.vue +++ b/src/view/shipping/WaitShippingList.vue @@ -61,6 +61,7 @@ import { Message } from 'element-ui' list: [], mallId: '', colConfigs: [ + { prop: 'subPurchaseOrderSn', label: '备货单号', align: 'left' }, { prop: 'productName', label: '商品名称', align: 'left' }, { prop: 'skcExtCode', label: '货号', align: 'left' }, { prop: 'productSkcId', label: 'SKC ID', align: 'left' }, @@ -71,9 +72,11 @@ import { Message } from 'element-ui' { prop: 'expressDeliverySn', label: '物流单号', align: 'left' }, { prop: 'deliveryOrderSn', label: '发货单号', align: 'left' }, { prop: 'subWarehouseName', label: '收货仓库', align: 'left' }, + { prop: 'deliverTime', label: '发货时间', align: 'left' }, { prop: 'expectPickUpGoodsTime', label: '预约取货时间', align: 'left' } ], jsonFields: { + "备货单号": "subPurchaseOrderSn", "商品名称": "productName", "货号": "skcExtCode", "SKC ID": "productSkcId", @@ -84,6 +87,7 @@ import { Message } from 'element-ui' "物流单号": "expressDeliverySn", "发货单号": "deliveryOrderSn", "收货仓库": "subWarehouseName", + "发货时间": "deliverTime", "预约取货时间": "expectPickUpGoodsTime" }, @@ -138,13 +142,15 @@ import { Message } from 'element-ui' data.expressDeliverySn = item.expressDeliverySn data.subWarehouseName = item.subWarehouseName data.expectPickUpGoodsTime = timestampToTime(item.expectPickUpGoodsTime) - + for(let j = 0;j < item.deliveryOrderList.length; j++) { let item1 = item.deliveryOrderList[j] data = {...data, + subPurchaseOrderSn: item1.subPurchaseOrderSn, deliveryOrderSn: item1.deliveryOrderSn, productName: item1.subPurchaseOrderBasicVO.productName, skcExtCode: item1.subPurchaseOrderBasicVO.skcExtCode, + deliverTime: timestampToTime(item1.deliverTime), productSkcId: item1.productSkcId} for(let k = 0; k < item1.packageDetailList.length; k++) { @@ -162,15 +168,13 @@ import { Message } from 'element-ui' }, 200 * i) } } - if (this.pageSize == res.result.deliveryOrderList.length) { + if (100 == res.result.list.length) { this.currentPage ++ setTimeout(() => { this.getList() }, 1500) } else { - if (this.currentPage == 1 && res.result.list.length == 0) { - this.isLoading = false - } + this.isLoading = false } } else { setTimeout(() => {