From 952f2a7030067f632f553d087a777774bca9e688 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Sat, 6 Jun 2026 14:11:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:syncBook=E6=88=90=E5=8A=9F=E5=90=8E?= =?UTF-8?q?=E8=B0=83=E7=94=A8pushToShop=E6=8E=A8=E9=80=81=E5=88=B0?= =?UTF-8?q?=E5=BA=97=E9=93=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index e2e9528..e0365b1 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -2210,6 +2210,44 @@ export default { throw new Error(respData && respData.msg || '上传失败') } + // syncBook 成功后调用 pushToShop 推送到店铺 + try { + const warehouseData = this.noIsbnWarehouseData + const conditionDisplay = this.noIsbnConditionValue.replace('~', '') + const userId = uni.getStorageSync('aboutId') || '' + const tokenPush = uni.getStorageSync('token') || '' + const pushUrl = 'https://psi.api.buzhiyushu.cn/api/product/pushToShop' + const pushData = { + user_id: userId, + warehouse_id: String(warehouseData.warehouseId || ''), + location_id: String(warehouseData.locationId || ''), + isbn: this.noIsbnIsbn || this.noIsbnUnifyIsbn || '', + price: this.noIsbnPrice ? String(Math.round(parseFloat(this.noIsbnPrice) * 100)) : '', + stock: String(this.noIsbnStock ?? ''), + appearance: conditionDisplay, + product_name: this.noIsbnBookName || '', + photos: imageUrls.join(',') + } + console.log('【syncBook】pushToShop请求地址:', pushUrl) + console.log('【syncBook】pushToShop请求参数:', pushData) + const pushRes = await new Promise(function (resolve, reject) { + uni.request({ + url: pushUrl, + method: 'POST', + header: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': 'Bearer ' + tokenPush + }, + data: pushData, + success: function (r) { resolve(r) }, + fail: function (e) { reject(e) } + }) + }) + console.log('【syncBook】pushToShop返回值:', pushRes.statusCode, pushRes.data) + } catch (ePush) { + console.warn('【syncBook】pushToShop失败:', ePush) + } + // 保存上传记录到本地 const uploadHistory = uni.getStorageSync('uploadHistory') || [] uploadHistory.unshift({