const BASE_URL = 'http://localhost:18080/api/hss'; function getHeaders() { const token = uni.getStorageSync('token'); return { 'Authorization': token ? 'Bearer ' + token : '', 'X-User-Role': 'STAFF', 'Content-Type': 'application/json' }; } function generateIdempotencyKey() { return 'idem-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9); } function apiGet(path, params = {}) { return uni.request({ url: BASE_URL + path, method: 'GET', data: params, header: getHeaders() }); } function apiPost(path, data = {}) { const headers = getHeaders(); headers['Idempotency-Key'] = generateIdempotencyKey(); return uni.request({ url: BASE_URL + path, method: 'POST', data, header: headers }); } module.exports = { BASE_URL, apiGet, apiPost, generateIdempotencyKey };