hookehuyr

feat(积分兑换): 重构积分兑换分类页面并添加优惠券接口

- 重构积分兑换分类页面,调整数据结构并优化点击事件处理
- 新增优惠券相关API接口文件,包含首页数据获取等功能
- 修改页面描述字段从description变为note,背景图字段从image变为background_url
1 <!-- 1 <!--
2 * @Date: 2025-08-27 17:47:03 2 * @Date: 2025-08-27 17:47:03
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-05 14:08:51 4 + * @LastEditTime: 2025-09-05 17:18:30
5 * @FilePath: /lls_program/src/pages/RewardCategories/index.vue 5 * @FilePath: /lls_program/src/pages/RewardCategories/index.vue
6 - * @Description: 文件描述 6 + * @Description: 积分兑换分类
7 --> 7 -->
8 <template> 8 <template>
9 <view class="min-h-screen flex flex-col bg-white"> 9 <view class="min-h-screen flex flex-col bg-white">
10 - <!-- <AppHeader title="积分兑换" :showBack="false" /> -->
11 <view class="flex-1 pb-20"> 10 <view class="flex-1 pb-20">
12 <view class="p-4 space-y-4"> 11 <view class="p-4 space-y-4">
13 - <view v-for="(category, index) in categories" :key="category.id" class="rounded-lg overflow-hidden shadow-sm" @click="goToRewards(index)"> 12 + <view v-for="(category, index) in categories" :key="category.id" class="rounded-lg overflow-hidden shadow-sm" @click="goToRewards(category)">
14 <view class="relative" style="height: 380rpx;"> 13 <view class="relative" style="height: 380rpx;">
15 <view class="absolute inset-0 bg-black bg-opacity-30 flex flex-col justify-end p-4 text-white"> 14 <view class="absolute inset-0 bg-black bg-opacity-30 flex flex-col justify-end p-4 text-white">
16 <h3 class="text-xl font-bold mb-1">{{ category.title }}</h3> 15 <h3 class="text-xl font-bold mb-1">{{ category.title }}</h3>
17 <p class="text-sm text-white text-opacity-90"> 16 <p class="text-sm text-white text-opacity-90">
18 - {{ category.description }} 17 + {{ category.note }}
19 </p> 18 </p>
20 </view> 19 </view>
21 - <image mode="aspectFill" :src="category.image" :alt="category.title" class="w-full h-full object-cover" /> 20 + <image mode="aspectFill" :src="category.background_url" :alt="category.title" class="w-full h-full object-cover" />
22 - <view v-if="category.iconUrl" class="absolute top-4 left-4 w-12 h-12 bg-white bg-opacity-90 rounded-full flex items-center justify-center">
23 - <image :src="category.iconUrl" alt="" class="w-8 h-8" />
24 - </view>
25 </view> 21 </view>
26 </view> 22 </view>
27 </view> 23 </view>
...@@ -31,44 +27,44 @@ ...@@ -31,44 +27,44 @@
31 </template> 27 </template>
32 28
33 <script setup> 29 <script setup>
34 -import { ref } from 'vue'; 30 +import { ref, onMounted } from 'vue';
35 import Taro from '@tarojs/taro'; 31 import Taro from '@tarojs/taro';
36 import BottomNav from '../../components/BottomNav.vue'; 32 import BottomNav from '../../components/BottomNav.vue';
33 +// 导入接口
34 +import { getCouponHomeAPI } from '@/api/coupon';
37 35
38 const categories = ref([ 36 const categories = ref([
39 { 37 {
40 id: 'health', 38 id: 'health',
41 title: '银龄健康特色兑换区', 39 title: '银龄健康特色兑换区',
42 - description: '南京商圈线下实体店消费积分兑换', 40 + note: '南京商圈线下实体店消费积分兑换',
43 - image: "https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg", 41 + background_url: "https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg",
44 - bgPosition: 'center' 42 + tips: ''
45 }, 43 },
46 { 44 {
47 id: 'online', 45 id: 'online',
48 title: '民政领域网上商城"银龄购"', 46 title: '民政领域网上商城"银龄购"',
49 - description: '线上康复健康购物积分兑换', 47 + note: '线上康复健康购物积分兑换',
50 - image: 'https://cdn.ipadbiz.cn/lls_prog/images/%E6%97%A0%E5%AD%97-%E9%93%B6%E9%BE%84%E8%B4%AD.jpeg', 48 + background_url: 'https://cdn.ipadbiz.cn/lls_prog/images/%E6%97%A0%E5%AD%97-%E9%93%B6%E9%BE%84%E8%B4%AD.jpeg',
51 - bgPosition: 'center', 49 + tips: '请在"银龄购"线上商城进行积分兑换'
52 - bgColor: 'linear-gradient(135deg, #0ea5e9, #2563eb)',
53 }, 50 },
54 { 51 {
55 id: 'merchants', 52 id: 'merchants',
56 title: '人驻商户多元场景广覆盖', 53 title: '人驻商户多元场景广覆盖',
57 - description: '丰富商户积分兑换', 54 + note: '丰富商户积分兑换',
58 - image: 'https://cdn.ipadbiz.cn/lls_prog/images/%E6%97%A0%E5%AD%97-%E7%A7%AF%E5%88%86%E5%95%86%E5%9F%8E.jpg', 55 + background_url: 'https://cdn.ipadbiz.cn/lls_prog/images/%E6%97%A0%E5%AD%97-%E7%A7%AF%E5%88%86%E5%95%86%E5%9F%8E.jpg',
59 - bgPosition: 'bottom center', 56 + tips: ''
60 - bgColor: 'linear-gradient(135deg, #007bff, #0056b3)',
61 } 57 }
62 ]); 58 ]);
63 59
64 -const goToRewards = (idx) => { 60 +const goToRewards = (category) => {
65 - if (idx !== 1) { 61 + if (!category.tips) {
66 - Taro.navigateTo({ url: '/pages/Rewards/index?category=' + categories.value[idx]?.id }); 62 + Taro.navigateTo({ url: '/pages/Rewards/index?category=' + category.id });
67 } else { 63 } else {
68 // 弹出确认提示框, 不用进行操作, 只是文本提示用户进行线下兑换 64 // 弹出确认提示框, 不用进行操作, 只是文本提示用户进行线下兑换
69 Taro.showModal({ 65 Taro.showModal({
70 title: '提示', 66 title: '提示',
71 - content: '请联系客服进行线下兑换', 67 + content: category.tips,
72 showCancel: false 68 showCancel: false
73 }).then(res => { 69 }).then(res => {
74 if (res.confirm) { 70 if (res.confirm) {
...@@ -77,4 +73,12 @@ const goToRewards = (idx) => { ...@@ -77,4 +73,12 @@ const goToRewards = (idx) => {
77 }) 73 })
78 } 74 }
79 }; 75 };
76 +
77 +onMounted(async () => {
78 + const { code, data } = await getCouponHomeAPI();
79 + if (code) {
80 + // categories.value = data;
81 + console.warn(data);
82 + }
83 +})
80 </script> 84 </script>
......