Tabbar.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view>
  3. <u-tabbar v-model="myCurrent" :list="tabbarList" :before-switch="beforeSwitch" mid-button-size="72" :mid-button="true" inactive-color="#ADB8C2" active-color="#5098FF">
  4. </u-tabbar>
  5. </view>
  6. </template>
  7. <script>
  8. var img1=require('@/assets/img/tabbarImg/item1a.svg')
  9. var img2=require('@/assets/img/tabbarImg/item1b.svg')
  10. var img7=require('@/assets/img/tabbarImg/item4a.svg')
  11. var img8=require('@/assets/img/tabbarImg/item4b.svg')
  12. var img0=require('@/assets/img/tabbarImg/item0.png')
  13. import * as WxJsApi from '@/apis/utils/wxJsApi.js'
  14. export default {
  15. name: "Tabbar",
  16. props: {
  17. current: 0,
  18. elderStatus: false
  19. },
  20. data() {
  21. return {
  22. oldindex: this.current,
  23. myCurrent: this.current,
  24. tabbarList: [{
  25. iconPath: img2,
  26. selectedIconPath: img1,
  27. text: '主页 ',
  28. pagePath: "/pages/index/index",
  29. },
  30. {
  31. iconPath: img0,
  32. selectedIconPath: img0,
  33. text: '',
  34. midButton: true,
  35. pagePath2: "",
  36. },
  37. // {
  38. // iconPath: img6,
  39. // selectedIconPath: img5,
  40. // text: '用户',
  41. // pagePath: "/pages/userTab/index",
  42. // },
  43. {
  44. iconPath: img8,
  45. selectedIconPath: img7,
  46. text: '我的',
  47. pagePath: "/pages/myTab/index",
  48. }
  49. ],
  50. };
  51. },
  52. methods: {
  53. beforeSwitch(index){
  54. var item=this.tabbarList[index]
  55. if(item.pagePath){
  56. return true;
  57. }else{
  58. console.log(111)
  59. return false;
  60. }
  61. },
  62. //微信扫二维码
  63. getScanCode() {
  64. console.log("getScanCode")
  65. if (this.userId) {
  66. WxJsApi.scanQRCode(1).then(res => {
  67. var url=res;
  68. //("scanQRCode------" + res)
  69. if(res&&this.branchParameterBl()&&url.indexOf('youdian.hbjp.com.cn')!=-1){
  70. if(url.indexOf('?code=')!=-1){
  71. url=url.replace('?code=','?code1233=')
  72. }
  73. if(process.car.NODE_ENV=='test'){
  74. url='https://youdian.hbjp.com.cn/charging-prod/mobile-charging-car-test/#/'
  75. +url.split("#/")[1]
  76. }else{
  77. url='https://youdian.hbjp.com.cn/charging-prod/mobile-charging-car/#/'
  78. +url.split("#/")[1]
  79. }
  80. console.log(url)
  81. //window.location.href=url;
  82. this.youdianurl=url
  83. this.youdianshow=true
  84. }else if (res) {
  85. API.scanCode(res).then((response) => {
  86. }).catch(error => {
  87. uni.showToast({
  88. title: error,
  89. icon: "none"
  90. })
  91. })
  92. }
  93. }).catch(error => {
  94. })
  95. } else {
  96. uni.navigateTo({
  97. url: '/pages/login/login'
  98. })
  99. }
  100. },
  101. },
  102. mounted() {
  103. console.log(111+"mounted")
  104. WxJsApi.getWxConfig(['scanQRCode']).then((res) => {
  105. // //(res)
  106. }).catch(error => {
  107. //(res)
  108. })
  109. },
  110. destroyed() {
  111. }
  112. }
  113. </script>
  114. <style>
  115. </style>