初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
@@ -2,8 +2,14 @@ import {get, post} from '../request';
|
||||
|
||||
const prefix = 'list/'
|
||||
|
||||
export const getCartListApi = async () => {
|
||||
return await get(`${prefix}list`)
|
||||
/**
|
||||
* 我的清单列表
|
||||
* - 不传参数:返回全量数组(老调用方兼容)
|
||||
* - 传 { page, pageSize }:后端返回 { items, total, page, pageSize, has_more }
|
||||
* @param {{page?: number, pageSize?: number}} params
|
||||
*/
|
||||
export const getCartListApi = async (params) => {
|
||||
return await get(`${prefix}list`, params)
|
||||
}
|
||||
export const getCartItemApi = async (id) => {
|
||||
return await get(`${prefix}detail`, {id})
|
||||
@@ -21,10 +27,24 @@ export const deleteCartItemApi = async (id) => {
|
||||
ids: [id]
|
||||
})
|
||||
}
|
||||
export const toCartApi = async (listId, productId) => {
|
||||
export const toCartApi = async (listId, productId, extra = {}) => {
|
||||
return await post(`${prefix}to-cart`, {
|
||||
list_id: listId,
|
||||
product_id: productId
|
||||
product_id: productId,
|
||||
...extra
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 改清单明细的规格 / 数量 / 备注。
|
||||
* 对齐后端 wx/list/update-item(WxListService::updateItem),
|
||||
* 只传需要改的字段即可,后端按 array_key_exists 判断。
|
||||
* @param {number} id 明细 id(list_item.id,不是清单 id)
|
||||
* @param {{price_sheet_id?: number, quantity?: number, material_key?: string, remark?: string}} params
|
||||
*/
|
||||
export const updateItemApi = async (id, params = {}) => {
|
||||
return await post(`${prefix}update-item`, {
|
||||
id,
|
||||
...params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import {get, post} from '../request';
|
||||
|
||||
const prefix = 'w-oss/'
|
||||
|
||||
export const getImageApi = async (hash = '') => {
|
||||
return await get(`${prefix}getImage`, {
|
||||
hash
|
||||
})
|
||||
}
|
||||
export const uploadImageWatermarkApi = async (imageUrl = '', watermark = 'BRM') => {
|
||||
return await post(`${prefix}watermark`, {
|
||||
image_url: imageUrl,
|
||||
watermark
|
||||
})
|
||||
}
|
||||
96
api/page/order.js
Normal file
96
api/page/order.js
Normal file
@@ -0,0 +1,96 @@
|
||||
import {get, post} from '../request';
|
||||
import {API_BASE} from '../env';
|
||||
|
||||
/**
|
||||
* 订单 API(对齐后端 lgp-admin-plus-api/app/Service/wx/WxOrderService.php)
|
||||
* 前缀 wx/order,走鉴权组(nl.wx 中间件)。
|
||||
* 金额字段后端是整数分,详情接口会带 *_text 元字段,这里直接用。
|
||||
*/
|
||||
const prefix = 'order/'
|
||||
|
||||
/** 我的订单列表,可按状态筛,透传分页参数 {status, page, pageSize} */
|
||||
export const getOrderListApi = async (params = {}) => {
|
||||
return await get(`${prefix}list`, params)
|
||||
}
|
||||
|
||||
/** 订单详情(含明细、支付记录、发货记录) */
|
||||
export const getOrderDetailApi = async (id) => {
|
||||
return await get(`${prefix}detail`, {id})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清单转订单。
|
||||
* @param listId 清单 id
|
||||
* @param params 收货信息:receiver_name / receiver_phone / receiver_address / delivery_type / remark
|
||||
*/
|
||||
export const createOrderApi = async (listId, params = {}) => {
|
||||
return await post(`${prefix}create`, {list_id: listId, ...params})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传转账凭证。
|
||||
* @param orderId 订单 id
|
||||
* @param voucher 凭证图 URL(多张逗号分隔或数组)
|
||||
* @param amount 可选,本次转账金额(分),不传则按订单未付金额
|
||||
*/
|
||||
export const submitVoucherApi = async (orderId, voucher, amount) => {
|
||||
const body = {order_id: orderId, voucher}
|
||||
if (amount !== undefined && amount !== null) {
|
||||
body.amount = amount
|
||||
}
|
||||
return await post(`${prefix}voucher`, body)
|
||||
}
|
||||
|
||||
/** 调起微信 JSAPI 支付,后端返回 uni.requestPayment 所需参数 */
|
||||
export const wechatPayApi = async (orderId) => {
|
||||
return await post(`${prefix}wechat-pay`, {order_id: orderId})
|
||||
}
|
||||
|
||||
/** 取消订单(仅未付款/已付款未发货可用) */
|
||||
export const cancelOrderApi = async (id) => {
|
||||
return await post(`${prefix}cancel`, {id})
|
||||
}
|
||||
|
||||
/** 确认收货(已发货状态可用) */
|
||||
export const completeOrderApi = async (id) => {
|
||||
return await post(`${prefix}complete`, {id})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传转账凭证图片到 OSS(wx/upload/image)。
|
||||
*
|
||||
* uni.uploadFile 不走 request.js 拦截器,所以这里手动拼 baseURL + token + 解包 result。
|
||||
* 返回后端 result.url(可直接访问的图片地址),供 submitVoucher 拼成逗号串提交。
|
||||
*
|
||||
* @param filePath chooseImage 返回的本地 tempFilePath
|
||||
* @returns Promise<string> OSS 图片 URL
|
||||
*/
|
||||
export const uploadVoucherImageApi = (filePath) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = uni.getStorageSync('token')
|
||||
uni.uploadFile({
|
||||
url: `${API_BASE}upload/image`,
|
||||
filePath,
|
||||
name: 'file',
|
||||
header: token ? {Authorization: `Bearer ${token}`} : {},
|
||||
success: (res) => {
|
||||
try {
|
||||
const body = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
|
||||
if (body.code === 0 && body.result && body.result.url) {
|
||||
resolve(body.result.url)
|
||||
} else {
|
||||
uni.showToast({title: body.message || '上传失败', icon: 'none'})
|
||||
reject(new Error(body.message || '上传失败'))
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({title: '上传失败', icon: 'none'})
|
||||
reject(e)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({title: '上传失败', icon: 'none'})
|
||||
reject(err)
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
19
api/page/theme.js
Normal file
19
api/page/theme.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 主题 API(免鉴权)
|
||||
* baseURL 已含 /api/wx/,这里请求 theme → GET .../api/wx/theme
|
||||
*/
|
||||
import { get } from '../request'
|
||||
|
||||
/** 当前生效主题(含 tokens / layout / css_vars) */
|
||||
export const getThemeApi = async (code = '') => {
|
||||
const params = {}
|
||||
if (code) {
|
||||
params.code = code
|
||||
}
|
||||
return await get('theme', params)
|
||||
}
|
||||
|
||||
/** 可选风格列表 */
|
||||
export const getThemeGalleryApi = async () => {
|
||||
return await get('theme-gallery')
|
||||
}
|
||||
Reference in New Issue
Block a user