Tabbar.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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("E5011")
  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?back=1&stationId="+chargingStation.id
  80. })
  81. }else{
  82. uni.showToast({
  83. title: "未查询到充电站",
  84. icon: "none"
  85. })
  86. }
  87. }).catch(error => {
  88. uni.showToast({
  89. title: "查询失败,"+error,
  90. icon: "none"
  91. })
  92. uni.hideLoading();
  93. })
  94. },
  95. //微信扫二维码
  96. getScanCode() {
  97. WxJsApi.scanQRCode(1).then(res => {
  98. var url=res;
  99. var gunId="";
  100. if(url&&url.indexOf("#/?jpcode=")>-1){
  101. gunId=url.split("#/?jpcode=")[1]
  102. }
  103. if(url&&url.indexOf("#/?gunId=")>-1){
  104. gunId=url.split("#/?gunId=")[1].trim()
  105. }
  106. if(url&&url.indexOf("&gunId=")>-1){
  107. gunId=url.split("&gunId=")[1].trim()
  108. }
  109. if(gunId){
  110. }else{
  111. gunId=res
  112. }
  113. if(url&&url.indexOf("stationId=")>-1){
  114. var stationId=url.split("stationId=")[1]
  115. uni.navigateTo({
  116. url:"/pages/inspection/add?back=1&stationId="+stationId
  117. })
  118. }else{
  119. this.findStationByGun(gunId)
  120. }
  121. }).catch(error => {
  122. })
  123. },
  124. },
  125. mounted() {
  126. console.log(111+"mounted")
  127. WxJsApi.getWxConfig(['scanQRCode']).then((res) => {
  128. // //(res)
  129. }).catch(error => {
  130. //(res)
  131. })
  132. },
  133. destroyed() {
  134. }
  135. }
  136. </script>
  137. <style>
  138. </style>