<template>
    <div>
        <van-nav-bar :title='appTitle'>
            <template #left>
                <van-icon name='wap-home-o' size='1.5em' color='#000' @click='backApp' />
            </template>
            <template #right>
                <van-icon name='scan' size='1.5em' color='#000' @click='scan' />
                <van-icon name='search' size='1.5em' color='#000' style='margin-left:0.5em' @click='query' />
            </template>
        </van-nav-bar>
    </div>
</template>
<script>
import Vue from 'vue'
import { NavBar, Icon, Tabbar, TabbarItem } from 'vant'
Vue.use(NavBar).use(Icon)
import { mapGetters } from 'vuex'
import store from '@/store'
window.__scanCallback = function (data) {
    console.log('__scanCallback')
    console.log(data)
    alert(data.text)
}
window.scanCallback = function (data) {
    console.log('scanCallback')
    console.log(data)
    alert(data.text)
}
export default {
    name: 'navbar',
    props: {},
    components: {},
    data() {
        return {}
    },
    computed: {
        ...mapGetters(['appTitle']),
    },
    beforeMount() {},
    mounted() {},
    methods: {
        // 返回工程信息化主菜单
        backApp() {
            console.log('backApp')
            webkit.messageHandlers.cordova_iab.postMessage(
                JSON.stringify({
                    method: 'close',
                })
            )
        },
        // 扫码
        scan() {
            console.log('扫码')
            webkit.messageHandlers.cordova_iab.postMessage(
                JSON.stringify({
                    method: 'scan',
                })
            )
        },
        // 扫码回调函数
        scanCallback(s) {
            alert(s.text)
        },
        // 全局搜索
        query() {
            this.$router.push({ name: 'GlobalSearch' })
        },
    },
}
</script>
<style lang='less' scoped>
</style>