index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="tab-bar-wrap">
  3. <!-- 统一TabBar:4 Tab(首页/健康/成长/我的),所有人同一套入口 -->
  4. <view class="tab-bar">
  5. <view
  6. v-for="(item, index) in normalTabs"
  7. :key="index"
  8. class="tab-item"
  9. :class="{ active: isActive(item) }"
  10. @click="switchTab(item)"
  11. >
  12. <image
  13. class="tab-icon"
  14. :src="isActive(item) ? item.selectedIcon : item.icon"
  15. mode="aspectFit"
  16. ></image>
  17. <text class="tab-text">{{ item.text }}</text>
  18. </view>
  19. </view>
  20. <!-- 五维横排展开(五维按钮已移除,保留dim-fan弹窗) -->
  21. <view class="dim-fan-overlay" v-if="showDimPanel" @click="closeDimPanel">
  22. <view class="dim-fan-row">
  23. <view
  24. v-for="(dim, idx) in dimensions"
  25. :key="idx"
  26. :class="['dim-fan-item', { 'dim-fan-item-up': dim.code === 'mind', 'dim-fan-item-mid': dim.code === 'action' || dim.code === 'body' }]"
  27. @click.stop="goDimension(dim)"
  28. >
  29. <view
  30. class="dim-fan-circle"
  31. :class="{ 'fan-active': fanActive }"
  32. :style="{ backgroundColor: dim.color, transitionDelay: (0.05 * idx) + 's' }"
  33. >
  34. <text class="dim-fan-emoji">{{ dim.icon }}</text>
  35. </view>
  36. <text
  37. class="dim-fan-label"
  38. :class="{ 'fan-active': fanActive }"
  39. :style="{ transitionDelay: (0.05 * idx) + 's' }"
  40. >{{ dim.name }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. currentIndex: 0,
  51. showDimPanel: false,
  52. fanActive: false,
  53. normalTabs: [
  54. { text: '首页', pagePath: '/pages/index-home/index', icon: '/static/tab-home.png', selectedIcon: '/static/tab-home-active.png' },
  55. { text: '健康', pagePath: '/pages/health-main/index', icon: '/static/tab-health.png', selectedIcon: '/static/tab-health-active.png' },
  56. { text: '成长', pagePath: '/pages/growth-main/index', icon: '/static/tab-growth.png', selectedIcon: '/static/tab-growth-active.png' },
  57. { text: '我的', pagePath: '/pages/profile-main/profile', icon: '/static/tab-profile.png', selectedIcon: '/static/tab-profile-active.png' }
  58. ],
  59. dimensions: [
  60. { code: 'wealth', name: '富', desc: '利他创富', icon: '💧', color: '#F59E0B', bgColor: 'rgba(245,158,11,0.15)' },
  61. { code: 'action', name: '行', desc: '知行合一', icon: '🌿', color: '#10B981', bgColor: 'rgba(16,185,129,0.15)' },
  62. { code: 'mind', name: '心', desc: '大爱传承', icon: '🔥', color: '#FF6B9D', bgColor: 'rgba(255,107,157,0.15)' },
  63. { code: 'body', name: '身', desc: '主动健康', icon: '🌏', color: '#FF8C42', bgColor: 'rgba(255,140,66,0.15)' },
  64. { code: 'wisdom', name: '智', desc: '赋能未来', icon: '⚡', color: '#6366F1', bgColor: 'rgba(99,102,241,0.15)' }
  65. ]
  66. }
  67. },
  68. mounted() {
  69. this.updateSelected()
  70. },
  71. methods: {
  72. isActive(item) {
  73. var pages = getCurrentPages()
  74. if (!pages.length) return false
  75. var currentPath = '/' + pages[pages.length - 1].route
  76. return item.pagePath === currentPath
  77. },
  78. updateSelected() {
  79. var pages = getCurrentPages()
  80. if (pages.length) {
  81. var currentPage = pages[pages.length - 1]
  82. var currentPath = '/' + currentPage.route
  83. var idx = this.normalTabs.findIndex(function(t) { return t.pagePath === currentPath })
  84. this.currentIndex = idx >= 0 ? idx : 0
  85. }
  86. },
  87. switchTab(item) {
  88. var tabBarPages = ['/pages/index-home/index', '/pages/health-main/index', '/pages/growth-main/index', '/pages/profile-main/profile']
  89. if (tabBarPages.indexOf(item.pagePath) !== -1) {
  90. uni.switchTab({ url: item.pagePath })
  91. } else {
  92. uni.redirectTo({ url: item.pagePath })
  93. }
  94. },
  95. goDimension(dim) {
  96. var dimMap = {
  97. action: '/pages/action-detail/index',
  98. mind: '/pages/mind-detail/index',
  99. body: '/pages/body-detail/index',
  100. wisdom: '/pages/wisdom-detail/index',
  101. wealth: '/pages/wealth/index'
  102. }
  103. var url = dimMap[dim.code]
  104. if (!url) return
  105. var tabBarPages = ['/pages/index-home/index', '/pages/health-main/index', '/pages/growth-main/index', '/pages/profile-main/profile']
  106. if (tabBarPages.indexOf(url) !== -1) {
  107. uni.switchTab({ url: url })
  108. } else {
  109. uni.navigateTo({ url: url })
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped>
  116. .tab-bar-wrap {
  117. position: fixed;
  118. bottom: 0;
  119. left: 0;
  120. right: 0;
  121. z-index: 999;
  122. }
  123. .tab-bar {
  124. display: flex;
  125. height: 100rpx;
  126. background: #fff;
  127. padding-bottom: env(safe-area-inset-bottom);
  128. border-top: 1rpx solid #eee;
  129. }
  130. .tab-item {
  131. flex: 1;
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. justify-content: center;
  136. }
  137. .tab-icon {
  138. width: 48rpx;
  139. height: 48rpx;
  140. margin-bottom: 4rpx;
  141. }
  142. .tab-text {
  143. font-size: 22rpx;
  144. color: #999;
  145. }
  146. .tab-item.active .tab-text {
  147. color: #F97316;
  148. }
  149. /* 五维横排展开 */
  150. .dim-fan-overlay {
  151. position: fixed;
  152. top: 0;
  153. left: 0;
  154. right: 0;
  155. bottom: 0;
  156. z-index: 1000;
  157. background: rgba(0,0,0,0.4);
  158. animation: fadeIn 0.2s ease;
  159. }
  160. .dim-fan-row {
  161. position: absolute;
  162. bottom: 140rpx;
  163. left: 0;
  164. right: 0;
  165. display: flex;
  166. justify-content: center;
  167. padding: 0 16rpx;
  168. }
  169. .dim-fan-item {
  170. display: flex;
  171. flex-direction: column;
  172. align-items: center;
  173. width: 120rpx;
  174. }
  175. .dim-fan-item.dim-fan-item-up {
  176. margin-top: -120rpx;
  177. }
  178. .dim-fan-item.dim-fan-item-mid {
  179. margin-top: -60rpx;
  180. }
  181. .dim-fan-circle {
  182. width: 88rpx;
  183. height: 88rpx;
  184. border-radius: 50%;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. opacity: 0;
  189. transform: scale(0);
  190. transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  191. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.15);
  192. }
  193. .dim-fan-circle.fan-active {
  194. opacity: 1;
  195. transform: scale(1);
  196. }
  197. .dim-fan-emoji {
  198. font-size: 40rpx;
  199. line-height: 1;
  200. }
  201. .dim-fan-label {
  202. font-size: 22rpx;
  203. color: #fff;
  204. font-weight: 600;
  205. margin-top: 8rpx;
  206. text-align: center;
  207. opacity: 0;
  208. transform: translateY(-10rpx);
  209. transition: all 0.3s ease;
  210. }
  211. .dim-fan-label.fan-active {
  212. opacity: 1;
  213. transform: translateY(0);
  214. }
  215. @keyframes fadeIn {
  216. from { opacity: 0; }
  217. to { opacity: 1; }
  218. }
  219. </style>