123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view>
- <u-tabbar v-model="myCurrent" :list="tabbarList" :before-switch="beforeSwitch" mid-button-size="72" :mid-button="true" inactive-color="#ADB8C2" active-color="#5098FF">
- </u-tabbar>
- </view>
- </template>
- <script>
- var img1=require('@/assets/img/tabbarImg/item1a.svg')
- var img2=require('@/assets/img/tabbarImg/item1b.svg')
- var img7=require('@/assets/img/tabbarImg/item4a.svg')
- var img8=require('@/assets/img/tabbarImg/item4b.svg')
-
- var img0=require('@/assets/img/tabbarImg/item0.png')
-
- import * as WxJsApi from '@/apis/utils/wxJsApi.js'
-
- export default {
- name: "Tabbar",
- props: {
- current: 0,
- elderStatus: false
- },
- data() {
- return {
- oldindex: this.current,
- myCurrent: this.current,
- tabbarList: [{
- iconPath: img2,
- selectedIconPath: img1,
- text: '主页 ',
- pagePath: "/pages/index/index",
- },
- {
- iconPath: img0,
- selectedIconPath: img0,
- text: '',
- midButton: true,
- pagePath2: "",
-
- },
- // {
- // iconPath: img6,
- // selectedIconPath: img5,
- // text: '用户',
- // pagePath: "/pages/userTab/index",
-
- // },
-
- {
- iconPath: img8,
- selectedIconPath: img7,
- text: '我的',
- pagePath: "/pages/myTab/index",
- }
- ],
- };
- },
- methods: {
- beforeSwitch(index){
- var item=this.tabbarList[index]
- if(item.pagePath){
- return true;
- }else{
- if(process.jphelp.NODE_ENV=='dev'){
- //this.findStationByGun("YQ202207150011001")
- this.findStationByGun("E50")
-
- }else{
- this.getScanCode()
- }
-
- return false;
- }
-
- },
-
- findStationByGun(id){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
-
- WxJsApi.findStationByNo({
- no:id,
-
-
- }).then((response) => {
- uni.hideLoading();
- var chargingStation=response.data.chargingStation
- if(chargingStation){
- uni.navigateTo({
- url:"/pages/inspection/add?stationId="+chargingStation.id
- })
- }else{
- uni.showToast({
- title: "未查询到充电站",
- icon: "none"
- })
- }
-
-
- }).catch(error => {
-
- uni.hideLoading();
-
- })
- },
-
- //微信扫二维码
- getScanCode() {
- WxJsApi.scanQRCode(1).then(res => {
- var url=res;
-
- var gunId="";
- if(url&&url.indexOf("#/?jpcode=")>-1){
- gunId=url.split("#/?jpcode=")[1]
- }
- if(url&&url.indexOf("#/?gunId=")>-1){
- gunId=url.split("#/?gunId=")[1].trim()
-
- }
- if(url&&url.indexOf("&gunId=")>-1){
- gunId=url.split("&gunId=")[1].trim()
- }
-
- if(gunId){
-
- }else{
- gunId=res
- }
- this.findStationByGun(gunId)
-
- }).catch(error => {
-
- })
- },
-
- },
- mounted() {
- console.log(111+"mounted")
- WxJsApi.getWxConfig(['scanQRCode']).then((res) => {
- // //(res)
- }).catch(error => {
- //(res)
- })
-
- },
- destroyed() {
- }
- }
- </script>
- <style>
- </style>
|