home.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import type { AccountCount, CouponList, CouponSituation } from '@/api/types/coupon'
  2. import { http } from '@/http/alova'
  3. import { ContentTypeEnum } from '@/http/tools/enum'
  4. /**
  5. *
  6. * @returns 获取首页优惠券数据
  7. */
  8. export function getCouponList(limit: number = 3) {
  9. return http.Get('/couponCenter/APP/couponTemplate/queryByType', {
  10. meta: {
  11. ignoreAuth: true,
  12. },
  13. transform(data, headers) {
  14. const respondedData = data as CouponList
  15. const discountCoupon = respondedData?.discountCoupon || []
  16. const couponList = respondedData?.fullReduceCoupon || []
  17. return {
  18. discountVoucherList: discountCoupon.slice(0, limit),
  19. couponList: couponList.slice(0, limit),
  20. }
  21. },
  22. })
  23. }
  24. /**
  25. *
  26. * @returns 获取首页收益总数
  27. */
  28. export function getAccountCount() {
  29. return http.Get<AccountCount>('/couponCenter/APP/couponIssuerAccount/queryByUserId', {
  30. shareRequest: true,
  31. })
  32. }
  33. /**
  34. *
  35. * @returns 获取首页优惠券领取情况
  36. */
  37. export function getCouponSituation(params = {}) {
  38. return http.Get<CouponSituation>('/couponCenter/APP/couponUserAsset/queryBySendUserId', {
  39. params: {
  40. ...params,
  41. }
  42. })
  43. }
  44. /**
  45. * 根据优惠券类型获取优惠券数据
  46. * @param params
  47. * @returns
  48. */
  49. export function getCouponByType(params) {
  50. return http.Get('/couponCenter/APP/couponTemplate/getTemplatesPageByType', {
  51. params,
  52. })
  53. }
  54. export function getHomeCouponRedemptionList(params) {
  55. return http.Post('/couponCenter/APP/couponUserAsset/detail', {
  56. ...params,
  57. })
  58. }
  59. export function getShareInfo(params) {
  60. return http.Post('/couponCenter/APP/shareRecord/add', {
  61. ...params,
  62. })
  63. }
  64. export function getCouponDetail(params) {
  65. return http.Get('/couponCenter/APP/couponTemplate/queryById', {
  66. params,
  67. })
  68. }
  69. export function getIssuerDetail() {
  70. return http.Get('/couponCenter/APP/couponIssuerApply/queryById')
  71. }
  72. export function getIssuerStatus() {
  73. return http.Get('/couponCenter/APP/couponIssuerApply/queryStatusById')
  74. }
  75. export function getCityList() {
  76. return http.Post('/customer/city/homelist', {}, {
  77. transform: (data) => {
  78. const cityData = data || [];
  79. const letters = cityData.map(item => item.letter)
  80. const cityList = cityData.map(item => {
  81. if (Array.isArray(item.cityList)) {
  82. return item.cityList.map(city => ({
  83. name: city.areaCname,
  84. value: city.areaCode,
  85. }))
  86. }
  87. return []
  88. })
  89. return {
  90. letters,
  91. cityList
  92. }
  93. },
  94. cacheFor: 1000 * 60 * 5,
  95. })
  96. }
  97. export function getCategoryList() {
  98. return http.Get('/couponCenter/APP/couponTemplate/queryCategoryListByCode', {
  99. transform(data, headers) {
  100. const respondedData = data || []
  101. return [{
  102. name: '按摩',
  103. value: '0',
  104. }, ...respondedData.map(item => ({
  105. name: item.title,
  106. value: item.key,
  107. }))]
  108. },
  109. })
  110. }
  111. export function getNewCouponList(params) {
  112. return http.Post('/couponCenter/APP/couponTemplate/getTemplatesPageByCondition', params, {
  113. headers: {
  114. 'Content-Type': ContentTypeEnum.FORM_URLENCODED,
  115. },
  116. })
  117. }