update: 对接金币相关

This commit is contained in:
2026-08-20 14:37:08 +08:00
parent 82c360f1b1
commit d2571854bc
10 changed files with 494 additions and 158 deletions
+56 -2
View File
@@ -26,8 +26,9 @@ try {
}
const ADDONS_BASE_URL = BASE_URL.replace(/\/api\/shoot$/, "/api/shoot");
const API_ROOT_URL = BASE_URL.replace(/\/api\/shoot$/, "");
// 统一处理业务接口请求,包含登录态、业务错误和特定接口空响应兼容。
function request(method, url, data = {}, baseUrl = BASE_URL) {
function request(method, url, data = {}, baseUrl = BASE_URL, successCodes = [0]) {
const token = uni.getStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
@@ -51,7 +52,7 @@ function request(method, url, data = {}, baseUrl = BASE_URL) {
}
if (res.data) {
const {code, data, message} = res.data;
if (code === 0) resolve(data);
if (successCodes.includes(code)) resolve(data);
else if (message) {
const error = {code, data, message};
if (message.indexOf("登录身份已失效") !== -1) {
@@ -698,3 +699,56 @@ export const getMyTenRingRank = (seasonId) => {
if (seasonId !== undefined && seasonId !== null) data.seasonId = seasonId;
return request("GET", "/index/myTenRingRank", data);
};
// 获取当前用户的金币统计,可按门店查询。
export const getMyGoldAPI = (storeId) => {
const data = {};
if (storeId !== undefined && storeId !== null) data.storeId = storeId;
return request("GET", "/index/gold/my", data);
};
// 分页获取当前用户的金币流水,type:1=获得,2=兑换。
export const getGoldLogAPI = ({page = 1, pageSize = 20, type, storeId} = {}) => {
const data = {page, pageSize};
if (type !== undefined && type !== null) data.type = type;
if (storeId !== undefined && storeId !== null) data.storeId = storeId;
return request("GET", "/index/gold/log", data);
};
// 前台礼品接口位于站点根路径,并使用 code=200 表示成功。
export const getGiftListAPI = ({page = 1, pageSize = 20, sort = "coin_desc"} = {}) => {
return request(
"GET",
"/gin/api/v1/gift/list",
{page, page_size: pageSize, sort},
API_ROOT_URL,
[0, 200]
);
};
export const getGiftDetailAPI = (id) => {
return request(
"GET",
`/gin/api/v1/gift/${id}`,
{},
API_ROOT_URL,
[0, 200]
);
};
// 根据用户定位分页获取附近门店。
export const getNearbyStoresAPI = ({
longitude,
latitude,
radius = 65535,
page = 1,
pageSize = 20,
} = {}) => {
return request("GET", "/store/nearby", {
longitude,
latitude,
radius,
page,
pageSize,
});
};