|
@@ -1,16 +1,17 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { useRequest } from 'alova/client'
|
|
import { useRequest } from 'alova/client'
|
|
|
import { storeToRefs } from 'pinia'
|
|
import { storeToRefs } from 'pinia'
|
|
|
-import { ref, watch } from 'vue'
|
|
|
|
|
|
|
+import { ref, watch, computed } from 'vue'
|
|
|
import { getAccountCount, getCouponDetail, getCouponSituation, getShareInfo } from '@/api/home'
|
|
import { getAccountCount, getCouponDetail, getCouponSituation, getShareInfo } from '@/api/home'
|
|
|
import DiscountCoupon from '@/components/DiscountCoupon.vue'
|
|
import DiscountCoupon from '@/components/DiscountCoupon.vue'
|
|
|
import SpendAndSaveCoupon from '@/components/SpendAndSaveCoupon.vue'
|
|
import SpendAndSaveCoupon from '@/components/SpendAndSaveCoupon.vue'
|
|
|
import { useShare } from '@/hooks/useShare'
|
|
import { useShare } from '@/hooks/useShare'
|
|
|
-import { useCouponStore } from '@/store/coupon'
|
|
|
|
|
|
|
+import { useNewCouponStore as useCouponStore } from '@/store/coupon'
|
|
|
import { useTokenStore } from '@/store/token'
|
|
import { useTokenStore } from '@/store/token'
|
|
|
import { useUserStore } from '@/store/user'
|
|
import { useUserStore } from '@/store/user'
|
|
|
import { getImageUrl } from '@/utils/imageUtil'
|
|
import { getImageUrl } from '@/utils/imageUtil'
|
|
|
import { toLoginPage } from '@/utils/toLoginPage'
|
|
import { toLoginPage } from '@/utils/toLoginPage'
|
|
|
|
|
+import { delayLoadingMiddleware } from '@/http/tools/delayLoadingMiddleware'
|
|
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
|
name: 'Home',
|
|
name: 'Home',
|
|
@@ -31,19 +32,18 @@ const userStore = useUserStore()
|
|
|
|
|
|
|
|
const refreshing = ref(false)
|
|
const refreshing = ref(false)
|
|
|
|
|
|
|
|
-// 分享配置
|
|
|
|
|
-const shareConfig = ref(null)
|
|
|
|
|
-const shareButtonRef = ref<HTMLElement | null>(null)
|
|
|
|
|
-const currentCouponId = ref<string>('')
|
|
|
|
|
-
|
|
|
|
|
// 获取优惠券
|
|
// 获取优惠券
|
|
|
const couponStore = useCouponStore()
|
|
const couponStore = useCouponStore()
|
|
|
-const { couponList, discountVoucherList, loading } = storeToRefs(couponStore)
|
|
|
|
|
|
|
+const { loading, data } = storeToRefs(couponStore)
|
|
|
|
|
+const discountVoucherList = computed(() => data.value.discountVoucherList)
|
|
|
|
|
+const couponList = computed(() => data.value.couponList)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 获取首页收益
|
|
// 获取首页收益
|
|
|
const { send: getAccountCountRequest, data: accountCountData, loading: accountCountLoading } = useRequest(getAccountCount, {
|
|
const { send: getAccountCountRequest, data: accountCountData, loading: accountCountLoading } = useRequest(getAccountCount, {
|
|
|
immediate: false,
|
|
immediate: false,
|
|
|
dependencies: [],
|
|
dependencies: [],
|
|
|
|
|
+ middleware: delayLoadingMiddleware(150, 200)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 获取首页领券情况数据
|
|
// 获取首页领券情况数据
|
|
@@ -81,7 +81,6 @@ onShareTimeline(() => {
|
|
|
|
|
|
|
|
onShow((options) => {
|
|
onShow((options) => {
|
|
|
couponStore.getCouponListByType()
|
|
couponStore.getCouponListByType()
|
|
|
- console.log(hasLogin.value)
|
|
|
|
|
// 登录后查询收益数据
|
|
// 登录后查询收益数据
|
|
|
if (hasLogin.value) {
|
|
if (hasLogin.value) {
|
|
|
Promise.allSettled([getAccountCountRequest(), getCouponSituationRequest()])
|
|
Promise.allSettled([getAccountCountRequest(), getCouponSituationRequest()])
|
|
@@ -212,7 +211,7 @@ async function onRefresh() {
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="home-header-coupon-content">
|
|
<view class="home-header-coupon-content">
|
|
|
- <template v-for="item in couponList" :key="item.id">
|
|
|
|
|
|
|
+ <template v-for="(item, index) in couponList" :key="index">
|
|
|
<spend-and-save-coupon :coupon="item" />
|
|
<spend-and-save-coupon :coupon="item" />
|
|
|
</template>
|
|
</template>
|
|
|
<view v-if="loading" class="coupon-content-loading">
|
|
<view v-if="loading" class="coupon-content-loading">
|
|
@@ -247,7 +246,7 @@ async function onRefresh() {
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="home-coupon-content">
|
|
<view class="home-coupon-content">
|
|
|
- <template v-for="item in discountVoucherList" :key="item.id">
|
|
|
|
|
|
|
+ <template v-for="(item, index) in discountVoucherList" :key="index">
|
|
|
<discount-coupon :coupon="item" />
|
|
<discount-coupon :coupon="item" />
|
|
|
</template>
|
|
</template>
|
|
|
<view v-if="loading" class="home-coupon-content-loading">
|
|
<view v-if="loading" class="home-coupon-content-loading">
|