<template>
	<view class="home" :style="'padding-top:'+padtop+'px'">
		<!-- 头部 -->
		<navbar :back="false" title="首页" :bgcolor="backgroundColor" color="#fff" fixed zIndex="1010" :center="true"	:custom='true' @getTop="getTop"/>
		<view class="main">
			<!-- <swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
				:duration="duration">
				<swiper-item>
					<image :src="swipeimg" class="mainswip"></image>
				</swiper-item>
			</swiper> -->
			<image v-if="photoPath" :src="photoPath" class="mainswip" @click="getYouFn"></image>
			<view class="flexcj  mainus">
				<view class="mainuse flex" @click="getUse">
					<view class="mainusea">
						<view class="mainuseb">使用指南</view>
						<view class="mainusec overtwo">查看使用指南了 解核销操作方法</view>
					</view>
					<image :src="znimg" class="mainused flex0"></image>
				</view>
				<view class="mainuse flex" @click="getRecord">
					<view class="mainusea">
						<view class="mainuseb">核销记录</view>
						<view class="mainusec overtwo">查看核销记录了 解核销记录信息</view>
					</view>
					<image :src="znhimg" class="mainused flex0"></image>
				</view>
			</view>
			<view class="hbox" @click="getCode">
				<view class="flex1"><view class="htit">核销操作</view>
				<view class="htxt">扫描用户出示的二维码即可实现核销</view></view>
				<image :src="rimg" class="himg"></image>
			</view>
		</view>


		<!-- 底部 导航栏  currentPage 当前页面ID -->
		<tab-bar :currentPage="0"></tab-bar>
	</view>
</template>

<script>
	import url from "@/util/url";
	let {host} = url
	//导入组件
	// import tabBar from '@/components/tabbar/tabbar.vue'
	import tabBar from "@/components/tabbar/tabbar.vue"
	export default {
		data() {
			return {
				padtop:this.$http._GET.customBarH||0,
				backgroundColor: 'linear-gradient(90deg, #A00517, #E93030)',
				swipeimg: require('static/images/banner.png'),
				znimg: require('static/images/use.png'),
				znhimg: require('static/images/hicon.png'),
				rimg:require('static/images/rico.png'),
				
				
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				photoPath:''
			};
		},
		components: {
			tabBar
		},
		mounted() {
			// console.log(7)
		},
		onLoad() {
			this.getDataFn()
		},
		methods: {
			checkLogin() {
				var token = uni.getStorageSync('token')
				// var token = "df057579-73c8-4bdd-8312-f64db8efd699"
				if (token == undefined || token == '') {
					uni.reLaunch({
						url: '/pages/login/login'
					})
					return false
				}
				return true
			},
			getDataFn(){
				var that=this;
				that.$http.get("system/welfare/new").then(res => {
					if (res.code == 200) {
						if(res.data.photoPath){
							that.photoPath=host + res.data.photoPath
						}else{
							that.photoPath=""
						}
						
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
				
					}
				})
			},
			goBack() {
				// console.log(5)
			},
			getCode(){
				// 判断是否能核销
				if (!this.checkLogin()) {
					return
				}
				// 判断是否能核销
				var businessId=uni.getStorageSync('businessId');
				if(businessId&&businessId=='-1'){
					uni.showToast({
						title:'暂无扫码核销权限',
						icon:"none"
					})
				}else{
					uni.navigateTo({
						url:'/pages/code/code'
					})
				}
			},
			getYouFn(){
				// 判断是否能核销
				if (!this.checkLogin()) {
					return
				}
				this.$http.routePage('/pages/index/guidedetail?type=welfare','nav')
			},
			getUse(){
				// 判断是否能核销
				if (!this.checkLogin()) {
					return
				}
				this.$http.routePage('/pages/index/guidedetail?type=use','nav')
			},
			getRecord(){
				// 判断是否能核销
				if (!this.checkLogin()) {
					return
				}
				var businessId=uni.getStorageSync('businessId')
				if(businessId&&businessId=='-1'){
					uni.showToast({
						title:'暂无核销记录',
						icon:"none"
					})
				}else{
					this.$http.routePage('/pages/index/record','nav')
				}
				
			},
			getTop(e){
				this.padtop=e;
			}
		}
	};
</script>
<style scoped>
	image{display: block;}
	.pl16{padding: 0 32rpx;}
	.mb14{margin-bottom: 28rpx;}
.flex{display: flex;}
.flex1{flex: 1;}
.flex0{flex: 0 0 auto;}
.flexcj{display: flex;align-items: center;justify-content: space-between;}
.ovone{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.overtwo{word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;white-space: normal;}
	.home{min-height: 100vh;background: #f5f5f5;box-sizing: border-box;}
	.main{padding-top: 28rpx;}
	.mainswip{width: 686rpx;height: 260rpx;margin:0 auto 32rpx;box-shadow: 0px 4rpx 14rpx 0px rgba(97,96,95,0.3600);border-radius: 20rpx;}
	
	.mainus{width: 686rpx;margin: 0 auto 28rpx;}
	.mainuse{width: 328rpx;min-height: 170rpx;background: #FFFFFF;box-shadow: 0px 4rpx 14rpx 0px rgba(97,96,95,0.3600);
border-radius: 6rpx;padding: 30rpx 18rpx 30rpx 26rpx;box-sizing: border-box;}
	.mainuseb{font-size: 22rpx;background: linear-gradient(0deg, #B54A1D 0%, #FFB97D 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;font-weight: bold;position: relative;margin-bottom: 20rpx;}
.mainuseb::after{width: 22rpx;
height: 2rpx;
background: #A70919;content: "";position: absolute;left: 0;bottom: -15rpx;}
.mainusec{font-size: 24rpx;color: #666666;}
.mainused{width: 86rpx;height: 86rpx;margin-top: 16rpx;}

.hbox{width: 684rpx;min-height: 128rpx;background: linear-gradient(90deg, #A00517, #E93030);
box-shadow: 0px 4rpx 14rpx 0px rgba(131,46,15,0.3600);border-radius: 14rpx;display: flex;align-items: center;margin: auto;padding: 20rpx 26rpx 20rpx 30rpx;box-sizing: border-box;}
.htit{font-size: 34rpx;font-weight: bold;color: #FFFFFF;margin-bottom: 14rpx;}
.htxt{font-size: 24rpx;color: #FFC5CB;}
.himg{width: 16rpx;height: 28rpx;flex: 0 0 auto;}
</style>
