<template>
	<view class="g-components-panel-tabbar">
		<u-tabbar v-model="current" :list="list" active-color="#3578f6" @change='handleTab'></u-tabbar>
	</view>
</template>

<script>
	export default {
		props: {
			tip:{
				default:()=>{
					return 0;
				}
			}
		},
		data() {
			return {
				cdnBaseImg:this.G.store().cdnBaseImg,
				list: [],
				current: 0,
				isTip:0,
			}
		},
		watch:{
			'tip'(val){
				this.isTip = val
			}
		},
		created() {
			let that = this;
			that.isTip = that.tip;
			console.log('creatd tabbar',this.tip)
			that.init();
		},
		methods:{
			init(){
				let that = this;
				if (uni.getStorageSync("apply-supplierAccount") == 1) {
					// 有
					that.list = [
						{
							iconPath: this.cdnBaseImg + 'home.png',
							selectedIconPath: this.cdnBaseImg + 'homeActive.png',
							text: '首页',
							customIcon: false,
							pagePath:"/pages/home/index",
						},
						{
							iconPath: this.cdnBaseImg + 'bill.png',
							selectedIconPath: this.cdnBaseImg + 'billActive.png',
							text: '发单',
							customIcon: false,
							pagePath:"/pages/bill/index",
						},
						{
							iconPath: this.cdnBaseImg + 'apply.png',
							selectedIconPath: this.cdnBaseImg + 'applyActive.png',
							text: '工单',
							customIcon: false,
							pagePath:"/pages/apply/index",
						},
						{
							iconPath: this.cdnBaseImg + 'person.png',
							selectedIconPath: this.cdnBaseImg + 'personActive.png',
							text: '我的',
							customIcon: false,
							pagePath:"/pages/person/index",
							isDot: that.isTip ? true : false,
						},
					]
				} else {
					// 无
					that.list = [
						{
							iconPath: this.cdnBaseImg + 'home.png',
							selectedIconPath: this.cdnBaseImg + 'homeActive.png',
							text: '首页',
							customIcon: false,
							pagePath:"/pages/home/index",
						},
						{
							iconPath: this.cdnBaseImg + 'apply.png',
							selectedIconPath: this.cdnBaseImg + 'applyActive.png',
							text: '工单',
							customIcon: false,
							pagePath:"/pages/apply/index",
						},
						{
							iconPath: this.cdnBaseImg + 'person.png',
							selectedIconPath: this.cdnBaseImg + 'personActive.png',
							text: '我的',
							customIcon: false,
							pagePath:"/pages/person/index",
							isDot: that.isTip ? true : false,
						},
					]
				}
			},
			handleTab(e){
				let that = this;
				that.G.Get(
					that.api.bind_getWaitNum + "/" + 2,
					{
						type: 2,
					},
					(res) => {
						that.isTip = res.unread;
						that.init();
					}
				);
			}
		}
	}
</script>

<style lang="scss">
	.g-components-panel-tabbar {}
</style>