123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import request from '@/sheep/request';
- import {
- t
- } from '@/locale';
- const CouponApi = {
- // 获得优惠劵模板列表
- getCouponTemplateListByIds: (ids) => {
- return request({
- url: '/promotion/coupon-template/list-by-ids',
- method: 'GET',
- params: { ids },
- custom: {
- showLoading: false, // 不展示 Loading,避免领取优惠劵时,不成功提示
- showError: false,
- },
- });
- },
- // 获得优惠劵模版列表
- getCouponTemplateList: (spuId, productScope, count) => {
- return request({
- url: '/promotion/coupon-template/list',
- method: 'GET',
- params: { spuId, productScope, count },
- });
- },
- // 获得优惠劵模版分页
- getCouponTemplatePage: (params) => {
- return request({
- url: '/promotion/coupon-template/page',
- method: 'GET',
- params,
- });
- },
- // 获得优惠劵模版
- getCouponTemplate: (id) => {
- return request({
- url: '/promotion/coupon-template/get',
- method: 'GET',
- params: { id },
- });
- },
- // 我的优惠劵列表
- getCouponPage: (params) => {
- return request({
- url: '/promotion/coupon/page',
- method: 'GET',
- params,
- });
- },
- // 领取优惠券
- takeCoupon: (templateId) => {
- return request({
- url: '/promotion/coupon/take',
- method: 'POST',
- data: { templateId },
- custom: {
- auth: true,
- showLoading: true,
- loadingMsg: t('common.claiming'),
- showSuccess: true,
- successMsg: t('common.claim_success'),
- },
- });
- },
- // 获得优惠劵
- getCoupon: (id) => {
- return request({
- url: '/promotion/coupon/get',
- method: 'GET',
- params: { id },
- });
- },
- // 获得未使用的优惠劵数量
- getUnusedCouponCount: () => {
- return request({
- url: '/promotion/coupon/get-unused-count',
- method: 'GET',
- custom: {
- showLoading: false,
- auth: true,
- },
- });
- },
- // 获得匹配指定商品的优惠劵列表
- getMatchCouponList: (price, spuIds, skuIds, categoryIds) => {
- return request({
- url: '/promotion/coupon/match-list',
- method: 'GET',
- params: {
- price,
- spuIds: spuIds.join(','),
- skuIds: skuIds.join(','),
- categoryIds: categoryIds.join(','),
- },
- custom: {
- showError: false,
- showLoading: false, // 避免影响 settlementOrder 结算的结果
- },
- });
- }
- };
- export default CouponApi;
|