Tabbar.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. if(process.jphelp.NODE_ENV=='dev'){
  59. //this.findStationByGun("YQ202207150011001")
  60. this.findStationByGun("E50")
  61. }else{
  62. this.getScanCode()
  63. }
  64. return false;
  65. }
  66. },
  67. findStationByGun(id){
  68. uni.showLoading({
  69. title: "加载中",
  70. mask: true,
  71. })
  72. WxJsApi.findStationByNo({
  73. no:id,
  74. }).then((response) => {
  75. uni.hideLoading();
  76. var chargingStation=response.data.chargingStation
  77. if(chargingStation){
  78. uni.navigateTo({
  79. url:"/pages/inspection/add?stationId="+chargingStation.id
  80. })
  81. }else{
  82. uni.showToast({
  83. title: "未查询到充电站",
  84. icon: "none"
  85. })
  86. }
  87. }).catch(error => {
  88. uni.hideLoading();
  89. })
  90. },
  91. //微信扫二维码
  92. getScanCode() {
  93. WxJsApi.scanQRCode(1).then(res => {
  94. var url=res;
  95. var gunId="";
  96. if(url&&url.indexOf("#/?jpcode=")>-1){
  97. gunId=url.split("#/?jpcode=")[1]
  98. }
  99. if(url&&url.indexOf("#/?gunId=")>-1){
  100. gunId=url.split("#/?gunId=")[1].trim()
  101. }
  102. if(url&&url.indexOf("&gunId=")>-1){
  103. gunId=url.split("&gunId=")[1].trim()
  104. }
  105. if(gunId){
  106. }else{
  107. gunId=res
  108. }
  109. this.findStationByGun(gunId)
  110. }).catch(error => {
  111. })
  112. },
  113. },
  114. mounted() {
  115. console.log(111+"mounted")
  116. WxJsApi.getWxConfig(['scanQRCode']).then((res) => {
  117. // //(res)
  118. }).catch(error => {
  119. //(res)
  120. })
  121. },
  122. destroyed() {
  123. }
  124. }
  125. </script>
  126. <style>
  127. </style>