TabbarFinance.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template >
  2. <view>
  3. <u-tabbar v-model="myCurrent" :list="tabbarList"
  4. :before-switch="beforeSwitch"
  5. active-color="#1677ff"></u-tabbar>
  6. </view>
  7. </template>
  8. <script>
  9. import * as API from '@/apis/role.js'
  10. export default {
  11. name:"tabbarJob",
  12. props:{
  13. current: 0,
  14. },
  15. data() {
  16. return {
  17. tabbarList:API.getList(this.carhelp.getPersonInfo()),
  18. activeColor:"#5098FF",
  19. oldindex:0,
  20. myCurrent:0,
  21. };
  22. },computed:{
  23. currentNum(){
  24. const pages = getCurrentPages();
  25. // 获取当前页面实例
  26. const currentPage = pages[pages.length - 1];
  27. // 获取当前路由路径(格式如 /pages/index/index)
  28. const currentRoute = currentPage.route;
  29. for(var i in this.tabbarList){
  30. var item=this.tabbarList[i]
  31. if(item.pagePath2.indexOf(currentRoute)!=-1){
  32. return i;
  33. }
  34. }
  35. return -1;
  36. },
  37. },
  38. methods:{
  39. relist(){
  40. this.tabbarList=API.getList(this.carhelp.getPersonInfo());
  41. this.myCurrent=this.currentNum;
  42. },
  43. setcount(){
  44. // console.log(index)
  45. this.myCurrentt=this.currentNum;
  46. },
  47. beforeSwitch(index){
  48. if(index==this.currentNum){
  49. return false
  50. }
  51. var url =this.tabbarList[index].pagePath2;
  52. uni.navigateTo({
  53. url: url
  54. })
  55. if(index==1){
  56. this.myCurrent=this.oldindex;
  57. return false;
  58. }else{
  59. return true;
  60. }
  61. },
  62. },create(){
  63. }
  64. ,mounted(){
  65. console.log("mounted")
  66. this.myCurrent=this.currentNum;
  67. },destroyed(){
  68. }
  69. }
  70. </script>
  71. <style>
  72. </style>