coupon.js
6.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* @Date: 2024-01-01 00:00:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-08 16:23:23
* @FilePath: /lls_program/src/api/coupon.js
* @Description: 优惠券相关接口
*/
import { fn, fetch } from './fn';
const Api = {
COUPON_HOME: '/srv/?a=coupon&t=home',
POINT_RANGES: '/srv/?a=coupon&t=point_ranges',
COUPON_LIST: '/srv/?a=coupon&t=list',
COUPON_DETAIL: '/srv/?a=coupon&t=detail',
REDEEM_COUPON: '/srv/?a=coupon&t=redeem',
MY_COUPON_LIST: '/srv/?a=redemption&t=list',
MY_COUPON_DETAIL: '/srv/?a=redemption&t=detail',
USE_COUPON: '/srv/?a=redemption&t=use',
}
/**
* @description: 积分兑换首页
* @returns {Promise} 返回首页数据
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data[] - 响应数据
* @returns {string} response.data[].id - id
* @returns {string} response.data[].title - 标题
* @returns {string} response.data[].note - 描述
* @returns {string} response.data[].background_url - 背景图
* @returns {string} response.data[].tips - 银龄购提示
*/
export const getCouponHomeAPI = (params) => fn(fetch.get(Api.COUPON_HOME, params));
/**
* @description: 获取筛选积分范围
* @returns {Promise} 返回积分范围数据
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Array} response.data[] - 响应数据 积分范围,例如:100-200
*/
export const getPointRangesAPI = (params) => fn(fetch.get(Api.POINT_RANGES, params));
/**
* @description: 获取优惠券列表
* @param {Object} params - 查询参数
* @param {string} params.category_id - 优惠模块ID
* @param {string} params.keyword - 搜索关键词(可选)
* @param {string} params.point_range - 积分范围(可选)
* @param {string} params.sort - 排序字段(可选)ASC=从小到大,DESC=从大到小
* @param {number} params.page - 页码(可选)从 0 开始
* @param {number} params.limit - 每页数量(可选)默认值是10
* @returns {Promise} 返回优惠券列表
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data[] - 响应数据
* @returns {string} response.data[].id - 优惠券ID
* @returns {string} response.data[].title - 优惠券标题
* @returns {string} response.data[].thumbnail - 优惠券缩略图
* @returns {string} response.data[].points_cost - 需要多少积分兑换
* @returns {Boolean} response.data[].can_redeem - 是否可以兑换:true=可以,false=不可以
*/
export const getCouponListAPI = (params = {}) => fn(fetch.get(Api.COUPON_LIST, params));
/**
* @description: 获取优惠券详情
* @param {string} id - 优惠券ID
* @returns {Promise} 返回优惠券详情
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data - 响应数据
* @returns {Object} response.data.id - 优惠券ID
* @returns {string} response.data.title - 优惠券标题
* @returns {string} response.data.banner - 优惠券banner图
* @returns {string} response.data.points_cost - 需要多少积分兑换
* @returns {Array} response.data.applicable_stores[string] - 可用门店
* @returns {Array} response.data.redeem_rules[string] - 兑换规则
* @returns {Array} response.data.usage_rules[string] - 使用规则
* @returns {Boolean} response.data.can_redeem - 是否可以兑换:true=可以,false=不可以
*/
export const getCouponDetailAPI = (params) => fn(fetch.get(Api.COUPON_DETAIL, params));
/**
* @description: 兑换优惠券
* @param {string} id - 优惠券ID
* @returns {Promise} 返回兑换结果
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data - 响应数据
*/
export const redeemCouponAPI = (params) => fn(fetch.post(Api.REDEEM_COUPON, params));
/**
* @description: 获取我的优惠券列表
* @param {Object} params - 查询参数
* @param {string} params.status - 优惠券状态:UNUSED=未使用, USED=已使用, EXPIRED=已过期,为空表示全部状态
* @param {number} params.page - 页码(可选)
* @param {number} params.limit - 每页数量(可选)
* @returns {Promise} 返回我的优惠券列表
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data - 响应数据
* @returns {string} response.data.id - 我的优惠券ID
* @returns {string} response.data.title - 优惠券标题
* @returns {string} response.data.thumbnail - 优惠券缩略图
* @returns {string} response.data.status - 优惠券状态, UNUSED=未使用, USED=已使用, EXPIRED=已过期
* @returns {string} response.data.expire_time - 有效期截止时间
* @returns {string} response.data.used_time - 核销时间
*/
export const getMyCouponListAPI = (params = {}) => fn(fetch.get(Api.MY_COUPON_LIST, params));
/**
* @description: 获取我的优惠券详情
* @param {string} id - 我的优惠券ID
* @returns {Promise} 返回我的优惠券详情
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data - 响应数据
* @returns {string} response.data.id - 我的优惠券ID
* @returns {string} response.data.title - 优惠券标题
* @returns {string} response.data.banner - 优惠券banner图
* @returns {string} response.data.status - 优惠券状态, UNUSED=未使用, USED=已使用, EXPIRED=已过期
* @returns {string} response.data.expire_time - 有效期截止时间
* @returns {string} response.data.expiration_rules[string] - 有效期
* @returns {Array} response.data.applicable_stores[string] - 可用门店
* @returns {Array} response.data.usage_rules[string] - 使用规则
*/
export const getMyCouponDetailAPI = (params) => fn(fetch.get(Api.MY_COUPON_DETAIL, params));
/**
* @description: 核销优惠券
* @param {string} id - 我的优惠券ID
* @returns {Promise} 返回核销结果
* @returns {Object} response - 响应对象
* @returns {number} response.code - 响应状态码
* @returns {string} response.msg - 响应消息
* @returns {Object} response.data - 响应数据
*/
export const useCouponAPI = (params) => fn(fetch.post(Api.USE_COUPON, params));