index.vue 2.77 KB
<template>
  <view class="index-page">
    <view class="index-header">
      <text class="title">觉林寺</text>
    </view>
    <view class="index-body">
      <text class="tip">授权和支付最小测试入口</text>
      <view class="status-card">
        <text class="status-label">当前授权状态</text>
        <text class="status-value" :class="{ authed: is_authed }">
          {{ is_authed ? '已授权' : '未授权' }}
        </text>
      </view>
      <button class="primary-btn" @tap="goToPayTest">进入支付测试页</button>
      <button class="secondary-btn" @tap="goToWebviewPreview">打开 WebView 预览页</button>
      <button class="secondary-btn" @tap="refreshAuthStatus">刷新授权状态</button>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import Taro, { useDidShow } from '@tarojs/taro'
import { hasAuth } from '@/utils/authRedirect'

Taro.setNavigationBarTitle({ title: '首页' })

const is_authed = ref(false)

const refreshAuthStatus = () => {
  is_authed.value = hasAuth()
}

const goToPayTest = () => {
  Taro.navigateTo({
    url: '/pages/pay-test/index',
  })
}

const goToWebviewPreview = () => {
  Taro.navigateTo({
    url: '/pages/webview-preview/index',
  })
}

useDidShow(() => {
  refreshAuthStatus()
})
</script>

<style lang="less">
.index-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #f5f5f5;

  .index-header {
    width: 100%;
    padding: 80rpx 0 40rpx;
    display: flex;
    justify-content: center;

    .title {
      font-size: 48rpx;
      font-weight: bold;
      color: #333;
    }
  }

  .index-body {
    flex: 1;
    display: flex;
    width: 100%;
    padding: 0 48rpx 80rpx;
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24rpx;

    .tip {
      font-size: 28rpx;
      color: #999;
    }

    .status-card {
      width: 100%;
      padding: 32rpx;
      border-radius: 24rpx;
      background: #fff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      box-sizing: border-box;
      box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.04);

      .status-label {
        font-size: 28rpx;
        color: #666;
      }

      .status-value {
        font-size: 30rpx;
        font-weight: 600;
        color: #d9485f;
      }

      .authed {
        color: #2d8c4d;
      }
    }

    .primary-btn,
    .secondary-btn {
      width: 100%;
      border-radius: 999rpx;
      font-size: 30rpx;
      line-height: 88rpx;
    }

    .primary-btn {
      color: #fff;
      background: linear-gradient(135deg, #111827, #374151);
    }

    .secondary-btn {
      color: #374151;
      background: #fff;
      border: 2rpx solid #d1d5db;
    }
  }
}
</style>