index.vue
1.99 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
<!--
* @Date: 2025-08-27 17:47:03
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-09 15:16:59
* @FilePath: /lls_program/src/pages/RewardCategories/index.vue
* @Description: 积分兑换分类
-->
<template>
<view class="min-h-screen flex flex-col bg-white">
<view class="flex-1 pb-20">
<view class="p-4 space-y-4">
<view v-for="(category, index) in categories" :key="category.id" class="rounded-lg overflow-hidden shadow-sm" @click="goToRewards(category)">
<view class="relative" style="height: 380rpx;">
<view class="absolute inset-0 flex flex-col justify-end p-4 text-white" style="background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.6) 100%);">
<h3 class="text-xl font-bold mb-1">{{ category.title }}</h3>
<p class="text-sm text-white text-opacity-90">
{{ category.note }}
</p>
</view>
<image mode="aspectFill" :src="category.background_url" :alt="category.title" class="w-full h-full object-cover" />
</view>
</view>
</view>
</view>
<BottomNav />
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import Taro from '@tarojs/taro';
import BottomNav from '../../components/BottomNav.vue';
// 导入接口
import { getCouponHomeAPI } from '@/api/coupon';
const categories = ref([]);
const goToRewards = (category) => {
if (!category.tips) {
Taro.navigateTo({ url: '/pages/Rewards/index?id=' + category.id + '&category=' + category.id });
} else {
// 弹出确认提示框, 不用进行操作, 只是文本提示用户进行线下兑换
Taro.showModal({
title: '温馨提示',
content: category.tips,
showCancel: false
}).then(res => {
if (res.confirm) {
// 点击了确认按钮
}
})
}
};
onMounted(async () => {
const { code, data } = await getCouponHomeAPI();
if (code) {
categories.value = data;
}
})
</script>