| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import type { AccountCount, CouponList, CouponSituation } from '@/api/types/coupon'
- import { http } from '@/http/alova'
- import { ContentTypeEnum } from '@/http/tools/enum'
- /**
- *
- * @returns 获取首页优惠券数据
- */
- export function getCouponList(limit: number = 3) {
- return http.Get('/couponCenter/APP/couponTemplate/queryByType', {
- meta: {
- ignoreAuth: true,
- },
- transform(data, headers) {
- const respondedData = data as CouponList
- const discountCoupon = respondedData?.discountCoupon || []
- const couponList = respondedData?.fullReduceCoupon || []
- return {
- discountVoucherList: discountCoupon.slice(0, limit),
- couponList: couponList.slice(0, limit),
- }
- },
- })
- }
- /**
- *
- * @returns 获取首页收益总数
- */
- export function getAccountCount() {
- return http.Get<AccountCount>('/couponCenter/APP/couponIssuerAccount/queryByUserId', {
- shareRequest: true,
- })
- }
- /**
- *
- * @returns 获取首页优惠券领取情况
- */
- export function getCouponSituation(params = {}) {
- return http.Get<CouponSituation>('/couponCenter/APP/couponUserAsset/queryBySendUserId', {
- params: {
- ...params,
- }
- })
- }
- /**
- * 根据优惠券类型获取优惠券数据
- * @param params
- * @returns
- */
- export function getCouponByType(params) {
- return http.Get('/couponCenter/APP/couponTemplate/getTemplatesPageByType', {
- params,
- })
- }
- export function getHomeCouponRedemptionList(params) {
- return http.Post('/couponCenter/APP/couponUserAsset/detail', {
- ...params,
- })
- }
- export function getShareInfo(params) {
- return http.Post('/couponCenter/APP/shareRecord/add', {
- ...params,
- })
- }
- export function getCouponDetail(params) {
- return http.Get('/couponCenter/APP/couponTemplate/queryById', {
- params,
- })
- }
- export function getIssuerDetail() {
- return http.Get('/couponCenter/APP/couponIssuerApply/queryById')
- }
- export function getIssuerStatus() {
- return http.Get('/couponCenter/APP/couponIssuerApply/queryStatusById')
- }
- export function getCityList() {
- return http.Post('/customer/city/homelist', {}, {
- transform: (data) => {
- const cityData = data || [];
- const letters = cityData.map(item => item.letter)
- const cityList = cityData.map(item => {
- if (Array.isArray(item.cityList)) {
- return item.cityList.map(city => ({
- name: city.areaCname,
- value: city.areaCode,
- }))
- }
- return []
- })
- return {
- letters,
- cityList
- }
- },
- cacheFor: 1000 * 60 * 5,
- })
- }
- export function getCategoryList() {
- return http.Get('/couponCenter/APP/couponTemplate/queryCategoryListByCode', {
- transform(data, headers) {
- const respondedData = data || []
- return [{
- name: '按摩',
- value: '0',
- }, ...respondedData.map(item => ({
- name: item.title,
- value: item.key,
- }))]
- },
- })
- }
- export function getNewCouponList(params) {
- return http.Post('/couponCenter/APP/couponTemplate/getTemplatesPageByCondition', params, {
- headers: {
- 'Content-Type': ContentTypeEnum.FORM_URLENCODED,
- },
- })
- }
|