index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">乐购</text>
  5. </view>
  6. <view class="content">
  7. <view class="placeholder">
  8. <text class="placeholder-text">🛍️</text>
  9. <text class="placeholder-title">乐购专区</text>
  10. <text class="placeholder-desc">精选商品,快乐购物...</text>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { requireAuth, PROTECTED_ACTIONS } from '@/utils/auth.js'
  17. export default {
  18. name: 'Legou',
  19. onLoad() {
  20. console.log('乐购页面加载')
  21. },
  22. onShow() {
  23. // 乐购页面需要登录权限,无论是否登录都进行权限检查
  24. this.checkAuthAccess()
  25. // 更新自定义tabBar选中状态
  26. this.updateTabBar()
  27. },
  28. methods: {
  29. // 更新tabBar选中状态
  30. updateTabBar() {
  31. try {
  32. if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  33. this.getTabBar().updateSelected(2) // 乐购索引为2
  34. }
  35. } catch (error) {
  36. console.log('更新tabBar状态失败:', error)
  37. }
  38. },
  39. checkAuthAccess() {
  40. requireAuth(() => {
  41. console.log('用户已登录,可以访问乐购')
  42. }, {
  43. action: PROTECTED_ACTIONS.VIEW_LEGOU,
  44. message: '访问乐购页面需要先登录'
  45. })
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .container {
  52. min-height: 100vh;
  53. background: #f5f5f5;
  54. padding: 20rpx;
  55. }
  56. .header {
  57. padding: 30rpx 0;
  58. text-align: center;
  59. .title {
  60. font-size: 36rpx;
  61. font-weight: bold;
  62. color: #333;
  63. }
  64. }
  65. .content {
  66. flex: 1;
  67. display: flex;
  68. align-items: center;
  69. justify-content: center;
  70. min-height: 60vh;
  71. }
  72. .placeholder {
  73. text-align: center;
  74. padding: 60rpx;
  75. .placeholder-text {
  76. font-size: 120rpx;
  77. display: block;
  78. margin-bottom: 30rpx;
  79. }
  80. .placeholder-title {
  81. font-size: 32rpx;
  82. color: #FF6600;
  83. font-weight: bold;
  84. display: block;
  85. margin-bottom: 20rpx;
  86. }
  87. .placeholder-desc {
  88. font-size: 28rpx;
  89. color: #666;
  90. display: block;
  91. }
  92. }
  93. </style>