index.vue 2.72 KB
<!--
 * @Date: 2025-08-27 17:47:03
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2025-09-05 17:23:10
 * @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 bg-black bg-opacity-30 flex flex-col justify-end p-4 text-white">
                <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([
  {
    id: 'health',
    title: '银龄健康特色兑换区',
    note: '南京商圈线下实体店消费积分兑换',
    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",
    tips: ''
  },
  {
    id: 'online',
    title: '民政领域网上商城"银龄购"',
    note: '线上康复健康购物积分兑换',
    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',
    tips: '请在"银龄购"线上商城进行积分兑换'
  },
  {
    id: 'merchants',
    title: '人驻商户多元场景广覆盖',
    note: '丰富商户积分兑换',
    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',
    tips: ''
  }
]);

const goToRewards = (category) => {
  if (!category.tips) {
    Taro.navigateTo({ url: '/pages/Rewards/index?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;
    console.warn(data);
  }
})
</script>