<template>
	<view class="app-container">
		<uni-grid :column="2" style="margin-top: 20px;">
			<uni-grid-item>
				<button type="default" @click="jump(1)">入库登记</button>
			</uni-grid-item>
			<uni-grid-item>
				<button type="default" @click="jump(2)">出库登记</button>
			</uni-grid-item>
			<uni-grid-item>
				<button type="default" @click="jump(3)">油罐读数</button>
			</uni-grid-item>
			<uni-grid-item>
				<button type="default" @click="jump(4)">操作记录</button>
			</uni-grid-item>
		</uni-grid>
		<uni-col :span="24" style="margin-top: 20px;">
			<view @click="jump(5)">个人</view>
		</uni-col>
		</uni-row>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				href: '',
				gv: {},
				resinfo: ''
			}
		},
		onLoad() {
			this.initData()
		},
		methods: {
			initData() {
				this.gv = getApp().globalData
				console.log('hasLogin', this.$store.getters.hasLogin)
				console.log('token', this.$store.getters.token)
				console.log('uinfo', this.$store.getters.userinfo)
				console.log('uinfo-id', this.$store.getters.userinfo.userid)
				console.log('uinfo-name', this.$store.getters.userinfo.name)
				getApp().globalData.uinfo = this.$store.getters.userinfo
			},

			jump(index) {

				switch (index) {
					case 0: // 设置
						console.log('index', index)
						break;
					case 1: // 入库
						console.log('index', index)
						
						uni.navigateTo({
							url: '/pages/business/inBound',
						})
						
						break;
					case 2: // 出库
						console.log('index', index)
						uni.navigateTo({
							url: '/pages/business/outBound',
						})
						
						break;
					case 3: // 油罐库存
						console.log('index', index)
						uni.navigateTo({
							url: '/pages/business/inventoryRegistration',
						})
						
						break;
					case 4: // 操作记录
						console.log('index', index)
						break;
					case 5: // 个人中心
						console.log('index', index)
						break;


				}
			},

			sayhello() {
				this.$api.sayhello({
					name: 'mynameislll'
				}).then(res => {
					this.resinfo = res
				})
			},
			logout() {
				this.$store.dispatch('logout').then(() => {
					console.log('NNNN:退出 ')
				})
			},
			gologin() {
				uni.reLaunch({
					url: '/pages/login/index'
				})
			}
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>