index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="tab-bar-wrap">
  3. <!-- 统一TabBar:4 Tab(首页/健康/成长/我的)5 等分,中间放五维按钮,所有人同一套入口 -->
  4. <view class="tab-bar">
  5. <view
  6. v-for="(item, index) in leftTabs"
  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. <!-- 中间五维按钮(占 20% 槽位) -->
  20. <view class="center-btn" @click="openDimPanel">
  21. <view class="center-btn-inner">
  22. <text class="center-btn-icon">⭐</text>
  23. </view>
  24. <text class="center-btn-label">五维</text>
  25. </view>
  26. <view
  27. v-for="(item, index) in rightTabs"
  28. :key="index"
  29. class="tab-item"
  30. :class="{ active: isActive(item) }"
  31. @click="switchTab(item)"
  32. >
  33. <image
  34. class="tab-icon"
  35. :src="isActive(item) ? item.selectedIcon : item.icon"
  36. mode="aspectFit"
  37. ></image>
  38. <text class="tab-text">{{ item.text }}</text>
  39. </view>
  40. </view>
  41. <!-- 五维横排展开 -->
  42. <view class="dim-fan-overlay" v-if="showDimPanel" @click="closeDimPanel">
  43. <view class="dim-fan-row">
  44. <view
  45. v-for="(dim, idx) in dimensions"
  46. :key="idx"
  47. :class="['dim-fan-item', { 'dim-fan-item-up': dim.code === 'mind', 'dim-fan-item-mid': dim.code === 'action' || dim.code === 'body' }]"
  48. @click.stop="goDimension(dim)"
  49. >
  50. <view
  51. class="dim-fan-circle"
  52. :class="{ 'fan-active': fanActive }"
  53. :style="{ backgroundColor: dim.color, transitionDelay: (0.05 * idx) + 's' }"
  54. >
  55. <text class="dim-fan-emoji">{{ dim.icon }}</text>
  56. </view>
  57. <text
  58. class="dim-fan-label"
  59. :class="{ 'fan-active': fanActive }"
  60. :style="{ transitionDelay: (0.05 * idx) + 's' }"
  61. >{{ dim.name }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. currentIndex: 0,
  72. showDimPanel: false,
  73. fanActive: false,
  74. normalTabs: [
  75. { text: '首页', pagePath: '/pages/index-home/index', icon: '/static/tab-home.png', selectedIcon: '/static/tab-home-active.png' },
  76. { text: '健康', pagePath: '/pages/health-main/index', icon: '/static/tab-health.png', selectedIcon: '/static/tab-health-active.png' },
  77. { text: '成长', pagePath: '/pages/growth-main/index', icon: '/static/tab-growth.png', selectedIcon: '/static/tab-growth-active.png' },
  78. { text: '我的', pagePath: '/pages/profile-main/profile', icon: '/static/tab-profile.png', selectedIcon: '/static/tab-profile-active.png' }
  79. ],
  80. dimensions: [
  81. { code: 'wealth', name: '富', desc: '利他创富', icon: '💧', color: '#F59E0B', bgColor: 'rgba(245,158,11,0.15)' },
  82. { code: 'action', name: '行', desc: '知行合一', icon: '🌿', color: '#10B981', bgColor: 'rgba(16,185,129,0.15)' },
  83. { code: 'mind', name: '心', desc: '大爱传承', icon: '🔥', color: '#FF6B9D', bgColor: 'rgba(255,107,157,0.15)' },
  84. { code: 'body', name: '身', desc: '主动健康', icon: '🌏', color: '#FF8C42', bgColor: 'rgba(255,140,66,0.15)' },
  85. { code: 'wisdom', name: '智', desc: '赋能未来', icon: '⚡', color: '#6366F1', bgColor: 'rgba(99,102,241,0.15)' }
  86. ]
  87. }
  88. },
  89. computed: {
  90. // 5 等分:左 2 Tab + 中间五维按钮 + 右 2 Tab
  91. leftTabs() {
  92. return this.normalTabs.slice(0, 2)
  93. },
  94. rightTabs() {
  95. return this.normalTabs.slice(2)
  96. }
  97. },
  98. mounted() {
  99. this.updateSelected()
  100. },
  101. methods: {
  102. isActive(item) {
  103. var pages = getCurrentPages()
  104. if (!pages.length) return false
  105. var currentPath = '/' + pages[pages.length - 1].route
  106. return item.pagePath === currentPath
  107. },
  108. updateSelected() {
  109. var pages = getCurrentPages()
  110. if (pages.length) {
  111. var currentPage = pages[pages.length - 1]
  112. var currentPath = '/' + currentPage.route
  113. var idx = this.normalTabs.findIndex(function(t) { return t.pagePath === currentPath })
  114. this.currentIndex = idx >= 0 ? idx : 0
  115. }
  116. },
  117. switchTab(item) {
  118. var tabBarPages = ['/pages/index-home/index', '/pages/health-main/index', '/pages/growth-main/index', '/pages/profile-main/profile']
  119. if (tabBarPages.indexOf(item.pagePath) !== -1) {
  120. uni.switchTab({ url: item.pagePath })
  121. } else {
  122. uni.redirectTo({ url: item.pagePath })
  123. }
  124. },
  125. openDimPanel() {
  126. this.showDimPanel = true
  127. this.fanActive = false
  128. var self = this
  129. setTimeout(function() {
  130. self.fanActive = true
  131. }, 30)
  132. },
  133. closeDimPanel() {
  134. this.fanActive = false
  135. var self = this
  136. setTimeout(function() {
  137. self.showDimPanel = false
  138. }, 200)
  139. },
  140. goDimension(dim) {
  141. this.closeDimPanel()
  142. var dimMap = {
  143. action: '/pages/action-detail/index',
  144. mind: '/pages/mind-detail/index',
  145. body: '/pages/body-detail/index',
  146. wisdom: '/pages/wisdom-detail/index',
  147. wealth: '/pages/wealth/index'
  148. }
  149. var url = dimMap[dim.code]
  150. if (!url) return
  151. var tabBarPages = ['/pages/index-home/index', '/pages/health-main/index', '/pages/growth-main/index', '/pages/profile-main/profile']
  152. if (tabBarPages.indexOf(url) !== -1) {
  153. uni.switchTab({ url: url })
  154. } else {
  155. uni.navigateTo({ url: url })
  156. }
  157. }
  158. }
  159. }
  160. </script>
  161. <style scoped>
  162. .tab-bar-wrap {
  163. position: fixed;
  164. bottom: 0;
  165. left: 0;
  166. right: 0;
  167. z-index: 999;
  168. }
  169. .tab-bar {
  170. display: flex;
  171. height: 100rpx;
  172. background: #fff;
  173. padding-bottom: env(safe-area-inset-bottom);
  174. border-top: 1rpx solid #eee;
  175. position: relative;
  176. }
  177. .tab-item {
  178. width: 20%;
  179. flex: none;
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. justify-content: center;
  184. position: relative;
  185. z-index: 1;
  186. }
  187. .tab-icon {
  188. width: 48rpx;
  189. height: 48rpx;
  190. margin-bottom: 4rpx;
  191. }
  192. .tab-text {
  193. font-size: 22rpx;
  194. color: #999;
  195. }
  196. .tab-item.active .tab-text {
  197. color: #F97316;
  198. }
  199. /* 中间五维按钮(占 20% 槽位) */
  200. .center-btn {
  201. width: 20%;
  202. flex: none;
  203. display: flex;
  204. flex-direction: column;
  205. align-items: center;
  206. justify-content: flex-start;
  207. padding-top: 0;
  208. position: relative;
  209. z-index: 2;
  210. }
  211. .center-btn-inner {
  212. width: 88rpx;
  213. height: 88rpx;
  214. border-radius: 50%;
  215. background: linear-gradient(135deg, #F97316, #FB923C);
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. margin-top: -20rpx;
  220. flex-shrink: 0;
  221. box-shadow: 0 4rpx 16rpx rgba(249,115,22,0.4);
  222. }
  223. .center-btn-icon {
  224. font-size: 40rpx;
  225. line-height: 1;
  226. }
  227. .center-btn-label {
  228. font-size: 20rpx;
  229. color: #999;
  230. text-align: center;
  231. margin-top: 2rpx;
  232. }
  233. /* 五维横排展开 */
  234. .dim-fan-overlay {
  235. position: fixed;
  236. top: 0;
  237. left: 0;
  238. right: 0;
  239. bottom: 0;
  240. z-index: 1000;
  241. background: rgba(0,0,0,0.4);
  242. animation: fadeIn 0.2s ease;
  243. }
  244. .dim-fan-row {
  245. position: absolute;
  246. bottom: 140rpx;
  247. left: 0;
  248. right: 0;
  249. display: flex;
  250. justify-content: center;
  251. padding: 0 16rpx;
  252. }
  253. .dim-fan-item {
  254. display: flex;
  255. flex-direction: column;
  256. align-items: center;
  257. width: 120rpx;
  258. }
  259. .dim-fan-item.dim-fan-item-up {
  260. margin-top: -120rpx;
  261. }
  262. .dim-fan-item.dim-fan-item-mid {
  263. margin-top: -60rpx;
  264. }
  265. .dim-fan-circle {
  266. width: 88rpx;
  267. height: 88rpx;
  268. border-radius: 50%;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. opacity: 0;
  273. transform: scale(0);
  274. transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  275. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.15);
  276. }
  277. .dim-fan-circle.fan-active {
  278. opacity: 1;
  279. transform: scale(1);
  280. }
  281. .dim-fan-emoji {
  282. font-size: 40rpx;
  283. line-height: 1;
  284. }
  285. .dim-fan-label {
  286. font-size: 22rpx;
  287. color: #fff;
  288. font-weight: 600;
  289. margin-top: 8rpx;
  290. text-align: center;
  291. opacity: 0;
  292. transform: translateY(-10rpx);
  293. transition: all 0.3s ease;
  294. }
  295. .dim-fan-label.fan-active {
  296. opacity: 1;
  297. transform: translateY(0);
  298. }
  299. @keyframes fadeIn {
  300. from { opacity: 0; }
  301. to { opacity: 1; }
  302. }
  303. </style>