From 15ffbb22edfa51d293c4dc4074006464a46395a8 Mon Sep 17 00:00:00 2001 From: denghaohaoya <1725652099@qq.com> Date: Sat, 28 Mar 2026 22:33:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E8=AF=B7=E6=B1=82=E6=8E=A5=E5=8F=A3=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/product.js | 53 ++++++++++--------- api/store.js | 3 +- api/translation.js | 3 +- .../batchDeleteProduct/batchDeleteProduct.vue | 6 ++- package_a/edit/edit.vue | 3 +- package_a/import/import.vue | 2 +- package_a/product/product.vue | 10 ++-- 7 files changed, 46 insertions(+), 34 deletions(-) diff --git a/api/product.js b/api/product.js index a2d361e..9833577 100644 --- a/api/product.js +++ b/api/product.js @@ -1,5 +1,6 @@ import { getToken } from '@/utils/auth' import { toast } from '@/utils/common' +import apiUrl from '@/utils/api' // 参数转URL查询字符串 function tansParams(params) { @@ -24,6 +25,8 @@ function tansParams(params) { return result } +import store from '@/store' + // 专门用于8081端口的请求 const request8081 = config => { config.header = config.header || {} @@ -94,15 +97,18 @@ const request8081 = config => { console.log('响应数据:', res.data) console.log('响应数据类型:', typeof res.data) - const code = res.data.code || 200 + const code = res.data.code const msg = res.data.msg || '请求失败' // console.log('业务状态码:', code) // console.log('业务消息:', msg) - if (code === 401) { - toast('认证失败,请重新登录') - reject('401') + if (res.statusCode === 401 || code === 401) { + store.dispatch('LogOut').then(() => { + uni.reLaunch({ url: '/pages/login' }) + }) + reject(new Error('无效的会话,或者会话已过期,请重新登录。')) + return } else if (code === 403) { // console.log('=== 403错误详细信息 ===') // console.log('完整响应:', JSON.stringify(res, null, 2)) @@ -132,11 +138,11 @@ export function getProductList(params) { // console.log('1. Token值:', token) // console.log('2. Token长度:', token ? token.length : 0) // console.log('3. Token前缀:', token ? token.substring(0, 20) + '...' : '无') - // console.log('4. 请求URL:', 'http://193.112.94.36:8081/mall/product/list') + // console.log('4. 请求URL:', apiUrl + '/mall/product/list') // console.log('5. 认证方式:', 'Bearer Token (与8080共享)') return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/product/list', method: 'get', params: params @@ -146,7 +152,7 @@ export function getProductList(params) { // 删除商品 export function deleteProduct(id) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/product/delete/${id}`, method: 'delete' }) @@ -155,7 +161,7 @@ export function deleteProduct(id) { // 新增商品 export function addProduct(data) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/product/add', method: 'post', data: data @@ -166,7 +172,7 @@ export function addProduct(data) { export function addProductWithFile(filePath, formData) { return new Promise((resolve, reject) => { uni.uploadFile({ - url: 'http://193.112.94.36:8081/mall/product/add', + url: apiUrl + '/mall/product/add', filePath: filePath, name: 'file', formData: formData, @@ -187,7 +193,7 @@ export function addProductWithFile(filePath, formData) { // 获取商品详情 export function getProductDetail(id) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/product/${id}`, method: 'get' }) @@ -197,7 +203,7 @@ export function getProductDetail(id) { export function updateProductWithFile(filePath, formData) { return new Promise((resolve, reject) => { uni.uploadFile({ - url: 'http://193.112.94.36:8081/mall/product/update', + url: apiUrl + '/mall/product/update', filePath: filePath, name: 'file', formData: formData, @@ -218,7 +224,6 @@ export function updateProductWithFile(filePath, formData) { // 修改商品 export function updateProduct(data) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', url: '/mall/product/update', method: 'post', data: data @@ -229,7 +234,7 @@ export function updateProduct(data) { export function importProductData(filePath, formData) { return new Promise((resolve, reject) => { uni.uploadFile({ - url: 'http://193.112.94.36:8081/mall/product/importData', + url: apiUrl + '/mall/product/importData', filePath: filePath, name: 'file', formData: formData, @@ -250,7 +255,7 @@ export function importProductData(filePath, formData) { // 获取导入记录 export function getImportRecord() { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/product/importRecord', method: 'get' }); @@ -259,7 +264,7 @@ export function getImportRecord() { // 批量删除商品 export function batchDeleteProduct(ids) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/product/batchDelete', method: 'delete', data: { ids: ids } @@ -269,7 +274,7 @@ export function batchDeleteProduct(ids) { // 添加品牌 export function addBrand(data) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/brand/add', method: 'post', data: data @@ -279,7 +284,7 @@ export function addBrand(data) { // 获取品牌列表 export function getBrandList(params) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/brand/list', method: 'get', params: params @@ -289,7 +294,7 @@ export function getBrandList(params) { // 获取品牌树状结构 export function getBrandTree(storeId, brandName) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/brand/getTree/${storeId}`, method: 'get', params: { brandName } @@ -299,7 +304,7 @@ export function getBrandTree(storeId, brandName) { // 删除品牌 export function deleteBrand(brandId) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/brand/delete/${brandId}`, method: 'delete' }) @@ -308,7 +313,7 @@ export function deleteBrand(brandId) { // 修改品牌名称 export function updateBrand(data) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/brand/update', method: 'post', data: data @@ -318,7 +323,7 @@ export function updateBrand(data) { // 新增分类 export function addClassification(data) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/classification/add', method: 'post', data: data @@ -328,7 +333,7 @@ export function addClassification(data) { // 获取分类树状结构 export function getClassificationTree(storeId, classificationName) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/classification/getTree/${storeId}`, method: 'get', params: { classificationName } @@ -338,7 +343,7 @@ export function getClassificationTree(storeId, classificationName) { // 修改分类名称 export function updateClassification(data) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: '/mall/classification/update', method: 'post', data: data @@ -348,7 +353,7 @@ export function updateClassification(data) { // 删除分类 export function deleteClassification(classificationId) { return request8081({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/classification/delete/${classificationId}`, method: 'delete' }) diff --git a/api/store.js b/api/store.js index 6d27ad5..3e3f26f 100644 --- a/api/store.js +++ b/api/store.js @@ -1,9 +1,10 @@ import request from '@/utils/request' +import apiUrl from '@/utils/api' // 根据用户ID查询门店列表 export function getStoreList(userId) { return request({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/store/getUserStore/${userId}`, method: 'get' }) diff --git a/api/translation.js b/api/translation.js index 7f04f12..8c4e716 100644 --- a/api/translation.js +++ b/api/translation.js @@ -1,9 +1,10 @@ import request from '@/utils/request' +import apiUrl from '@/utils/api' // 根据用户ID查询门店列表 export function PostData(data) { return request({ - baseUrl: 'http://193.112.94.36:8081', + baseUrl: apiUrl, url: `/mall/product/getByBarcodes`, method: 'post', data:data diff --git a/package_a/batchDeleteProduct/batchDeleteProduct.vue b/package_a/batchDeleteProduct/batchDeleteProduct.vue index b6bce9d..4315c90 100644 --- a/package_a/batchDeleteProduct/batchDeleteProduct.vue +++ b/package_a/batchDeleteProduct/batchDeleteProduct.vue @@ -52,7 +52,7 @@ @@ -88,6 +88,7 @@