From 3ec61f41bc864b22e63c783fe681f3ab915f7876 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Mon, 13 Jul 2026 16:51:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0API=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=BB=A5=E4=BD=BF=E7=94=A8buyer=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/address.js | 2 +- api/common.js | 12 +++++------ api/goods.js | 6 +++--- api/login.js | 2 +- components/verification/verification.vue | 4 ++-- config/api.js | 26 +++++++++--------------- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/api/address.js b/api/address.js index 42dbfd1..62da9ec 100644 --- a/api/address.js +++ b/api/address.js @@ -37,7 +37,7 @@ export function getLogistics() { */ export function getAddressCode(cityCode, townName) { return http.request({ - url: api.common + "/common/region/region", + url: `${api.buyer}/common/region/region`, method: Method.GET, needToken: true, params: { cityCode, townName }, diff --git a/api/common.js b/api/common.js index 3050efc..9ce9069 100644 --- a/api/common.js +++ b/api/common.js @@ -1,5 +1,5 @@ /** - * 公共API + * 公共 API(由 buyer-api 提供) */ import { http, Method } from "@/utils/request.js"; import api from "@/config/api.js"; @@ -10,16 +10,16 @@ import api from "@/config/api.js"; */ export function getRegionsById(id = 0) { return http.request({ - url: `${api.common}/common/region/item/${id}`, + url: `${api.buyer}/common/region/item/${id}`, method: Method.GET, message: false, }); } -// 获取IM接口前缀 +// 获取 IM 接口前缀 export function getIMDetail() { return http.request({ - url: `${api.common}/IM`, + url: `${api.buyer}/common/IM`, method: Method.GET, message: false, }); @@ -29,14 +29,14 @@ export function getIMDetail() { * 文件上传地址 * @type {string} */ -export const upload = api.common + "/common/upload/file"; +export const upload = `${api.buyer}/common/upload/file`; /** * 获取主题色配置 */ export function getThemeSetting() { return http.request({ - url: `${api.common}/common/common/site/theme`, + url: `${api.buyer}/common/site/theme`, method: Method.GET, message: false, }); diff --git a/api/goods.js b/api/goods.js index bc8ae30..06a2986 100644 --- a/api/goods.js +++ b/api/goods.js @@ -15,11 +15,11 @@ import { http, Method } from "@/utils/request.js"; } /** - * 从ES中获取相关商品品牌名称,分类名称及属性 + * 获取商品搜索筛选条件 */ export function getGoodsRelated(params) { return http.request({ - url: `/goods/goods/es/related`, + url: `/goods/goods/search/related`, method: Method.GET, params, }); @@ -56,7 +56,7 @@ export function getGoodsRelated(params) { */ export function getGoodsList(params) { return http.request({ - url: "/goods/goods/es", + url: "/goods/goods/search", method: Method.GET, params, }); diff --git a/api/login.js b/api/login.js index 4e40dc7..8052239 100644 --- a/api/login.js +++ b/api/login.js @@ -59,7 +59,7 @@ export function getAutoCoup(){ */ export function sendMobile(mobile,type='LOGIN') { return http.request({ - url: `${api.common}/common/sms/${type}/${mobile}`, + url: `${api.buyer}/common/sms/${type}/${mobile}`, method: "GET", }); } diff --git a/components/verification/verification.vue b/components/verification/verification.vue index 0a6cb29..057a50d 100644 --- a/components/verification/verification.vue +++ b/components/verification/verification.vue @@ -198,7 +198,7 @@ export default { storage.setUuid(uuid.v1()); } uni.request({ - url: api.common + "/common/slider/" + this.business, + url: api.buyer + "/common/slider/" + this.business, header: { uuid: storage.getUuid(), }, @@ -232,7 +232,7 @@ export default { uni.request({ method: "POST", url: - api.common + + api.buyer + "/common/slider/" + this.business + "?xPos=" + diff --git a/config/api.js b/config/api.js index c83d0db..7c5dd28 100644 --- a/config/api.js +++ b/config/api.js @@ -1,41 +1,35 @@ /** - * base : 基础业务API - * buyer : 买家API + * buyer : 买家 API(baseURL 为 buyer + /buyer) */ // 开发环境 const dev = { - im: "https://im-api.pickmall.cn", - common: "https://common-api.pickmall.cn", buyer: "https://buyer-api.pickmall.cn", + im: "https://im-api.pickmall.cn", mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt", - common: "http://192.168.31.244:8890", - buyer: "http://192.168.31.244:8888", - im: "http://192.168.0.113:8885", }; // 生产环境 const prod = { - im: "https://im-api.pickmall.cn", - common: "https://common-api.pickmall.cn", buyer: "https://buyer-api.pickmall.cn", - mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt" + im: "https://im-api.pickmall.cn", + mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt", }; -//默认生产环境 let api = dev; -//如果是开发环境 if (process.env.NODE_ENV == "development") { api = dev; } else { api = prod; } -//微信小程序,app的打包方式建议为生产环境,所以这块直接条件编译赋值 +// 微信小程序、App 打包使用生产环境配置 // #ifdef MP-WEIXIN || APP-PLUS api = prod; // #endif -api.buyer += "/buyer"; -api.common += "/common"; -api.im += "/im"; +const buyerHost = api.buyer; +api.buyer = buyerHost + "/buyer"; +api.im = api.im + "/im"; + export default { ...api, + buyerHost, };