index.vue
2.77 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<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>