index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="page">
  3. <!-- 用户信息卡片 -->
  4. <view class="user-card">
  5. <view class="user-info">
  6. <image v-if="userStore.userInfo?.avatar" :src="userStore.userInfo.avatar" class="avatar" mode="aspectFill" />
  7. <view v-else class="avatar-placeholder">
  8. <text class="avatar-text">👤</text>
  9. </view>
  10. <view class="user-text">
  11. <text class="nickname">{{ userStore.userInfo?.nickname || '未登录' }}</text>
  12. <view class="member-badge" :class="memberClass">
  13. <text class="member-text">{{ memberText }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 使用统计 -->
  18. <view class="stats-row" v-if="userStore.memberStatus">
  19. <view class="stat-item">
  20. <text class="stat-value">{{ userStore.memberStatus.quota.dailyRemaining }}</text>
  21. <text class="stat-label">今日剩余次数</text>
  22. </view>
  23. <view class="stat-divider" />
  24. <view class="stat-item">
  25. <text class="stat-value">{{ userStore.memberStatus.quota.wordLimit === 0 ? '∞' : userStore.memberStatus.quota.wordLimit }}</text>
  26. <text class="stat-label">单次字数上限</text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 功能入口 -->
  31. <view class="menu-section">
  32. <view class="menu-item" @click="goMember">
  33. <text class="menu-icon">👑</text>
  34. <text class="menu-text">会员中心</text>
  35. <text class="menu-arrow">›</text>
  36. </view>
  37. <view class="menu-item" @click="goHistory">
  38. <text class="menu-icon">📜</text>
  39. <text class="menu-text">历史记录</text>
  40. <text class="menu-arrow">›</text>
  41. </view>
  42. <view class="menu-item" @click="showAbout">
  43. <text class="menu-icon">ℹ️</text>
  44. <text class="menu-text">关于我们</text>
  45. <text class="menu-arrow">›</text>
  46. </view>
  47. <view class="menu-item" @click="showFeedback">
  48. <text class="menu-icon">💬</text>
  49. <text class="menu-text">意见反馈</text>
  50. <text class="menu-arrow">›</text>
  51. </view>
  52. </view>
  53. <!-- 退出登录 -->
  54. <view class="logout-section" v-if="userStore.isLoggedIn">
  55. <button class="logout-btn" @click="handleLogout">退出登录</button>
  56. </view>
  57. </view>
  58. </template>
  59. <script setup lang="ts">
  60. import { computed, onMounted } from 'vue';
  61. import { onShow } from '@dcloudio/uni-app';
  62. import { useUserStore } from '../../store/user';
  63. const userStore = useUserStore();
  64. // 计算属性
  65. const memberClass = computed(() => {
  66. const level = userStore.memberStatus?.level || 0;
  67. return `level-${level}`;
  68. });
  69. const memberText = computed(() => {
  70. return userStore.memberStatus?.levelName || '免费用户';
  71. });
  72. // 页面显示
  73. onShow(() => {
  74. if (userStore.isLoggedIn) {
  75. userStore.fetchMemberStatus();
  76. }
  77. });
  78. // 跳转会员页
  79. function goMember() {
  80. uni.navigateTo({ url: '/pages/member/index' });
  81. }
  82. // 跳转历史页
  83. function goHistory() {
  84. uni.switchTab({ url: '/pages/history/index' });
  85. }
  86. // 关于我们
  87. function showAbout() {
  88. uni.showModal({
  89. title: '关于AI有声书',
  90. content: 'AI有声书是一款智能文本转语音工具,帮助您轻松制作高质量音频内容。\n\n版本: 1.0.0',
  91. showCancel: false,
  92. });
  93. }
  94. // 意见反馈
  95. function showFeedback() {
  96. uni.showModal({
  97. title: '意见反馈',
  98. content: '如有问题或建议,请联系客服:\n邮箱:support@example.com',
  99. showCancel: false,
  100. });
  101. }
  102. // 退出登录
  103. function handleLogout() {
  104. uni.showModal({
  105. title: '确认退出',
  106. content: '确定要退出登录吗?',
  107. success: (res) => {
  108. if (res.confirm) {
  109. userStore.logout();
  110. uni.showToast({ title: '已退出登录', icon: 'success' });
  111. // 关闭所有页面,打开登录页
  112. uni.reLaunch({ url: '/pages/login/index' });
  113. }
  114. },
  115. });
  116. }
  117. </script>
  118. <style scoped>
  119. .page {
  120. min-height: 100vh;
  121. background: #f9fafb;
  122. padding-bottom: 120rpx;
  123. }
  124. .user-card {
  125. margin: 32rpx;
  126. background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
  127. border-radius: 24rpx;
  128. padding: 48rpx 32rpx;
  129. box-shadow: 0 8rpx 32rpx rgba(79, 70, 229, 0.3);
  130. }
  131. .user-info {
  132. display: flex;
  133. align-items: center;
  134. margin-bottom: 32rpx;
  135. }
  136. .avatar {
  137. width: 96rpx;
  138. height: 96rpx;
  139. border-radius: 50%;
  140. border: 4rpx solid rgba(255, 255, 255, 0.3);
  141. }
  142. .avatar-placeholder {
  143. width: 96rpx;
  144. height: 96rpx;
  145. border-radius: 50%;
  146. background: rgba(255, 255, 255, 0.2);
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. border: 4rpx solid rgba(255, 255, 255, 0.3);
  151. }
  152. .avatar-text {
  153. font-size: 48rpx;
  154. }
  155. .user-text {
  156. margin-left: 24rpx;
  157. }
  158. .nickname {
  159. display: block;
  160. font-size: 36rpx;
  161. font-weight: 600;
  162. color: #ffffff;
  163. margin-bottom: 8rpx;
  164. }
  165. .member-badge {
  166. display: inline-block;
  167. padding: 4rpx 16rpx;
  168. border-radius: 16rpx;
  169. background: rgba(255, 255, 255, 0.2);
  170. }
  171. .member-badge.level-1 {
  172. background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  173. }
  174. .member-badge.level-2 {
  175. background: linear-gradient(135deg, #fbbf24 0%, #fcd34d 100%);
  176. }
  177. .member-text {
  178. font-size: 22rpx;
  179. color: #ffffff;
  180. }
  181. .stats-row {
  182. display: flex;
  183. align-items: center;
  184. background: rgba(255, 255, 255, 0.1);
  185. border-radius: 16rpx;
  186. padding: 24rpx;
  187. }
  188. .stat-item {
  189. flex: 1;
  190. text-align: center;
  191. }
  192. .stat-value {
  193. display: block;
  194. font-size: 40rpx;
  195. font-weight: 700;
  196. color: #ffffff;
  197. }
  198. .stat-label {
  199. display: block;
  200. font-size: 22rpx;
  201. color: rgba(255, 255, 255, 0.8);
  202. margin-top: 4rpx;
  203. }
  204. .stat-divider {
  205. width: 2rpx;
  206. height: 60rpx;
  207. background: rgba(255, 255, 255, 0.2);
  208. }
  209. .menu-section {
  210. margin: 32rpx;
  211. background: #ffffff;
  212. border-radius: 24rpx;
  213. overflow: hidden;
  214. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  215. }
  216. .menu-item {
  217. display: flex;
  218. align-items: center;
  219. padding: 32rpx;
  220. border-bottom: 1rpx solid #f3f4f6;
  221. }
  222. .menu-item:last-child {
  223. border-bottom: none;
  224. }
  225. .menu-icon {
  226. font-size: 40rpx;
  227. margin-right: 24rpx;
  228. }
  229. .menu-text {
  230. flex: 1;
  231. font-size: 30rpx;
  232. color: #1f2937;
  233. }
  234. .menu-arrow {
  235. font-size: 32rpx;
  236. color: #9ca3af;
  237. }
  238. .logout-section {
  239. margin: 48rpx 32rpx;
  240. }
  241. .logout-btn {
  242. width: 100%;
  243. height: 88rpx;
  244. background: #ffffff;
  245. border-radius: 16rpx;
  246. border: 2rpx solid #ef4444;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. }
  251. .logout-btn::after {
  252. border: none;
  253. }
  254. .logout-btn text {
  255. font-size: 30rpx;
  256. color: #ef4444;
  257. }
  258. </style>