<template>
    <view class="content">
		<image :src="actionImg" mode="widthFix" class="action-img"></image>
		<view class="action-wrap">
			<image src="../../static/image/action-top.png" mode="" class="action-top"></image>
			<view class="">
				请拍下您与爱车的合照,点击下方按钮上传照片即可获得奖励。
			</view>
			<image :src="upimg" mode="widthFix" class="up-img" v-if="upimg" @click="upActionImg"></image>
			<image src="../../static/image/upimg-g.png" mode="widthFix" class="up-img" v-else @click="upActionImg"></image>
			<view class="action-btn" @click="joinAction">
				上传照片
			</view>
		</view>
    </view>
</template>
<script>
	import { upload } from '@/api/order.js'
export default {
    data() {
        return {
			upimg: '',
			loading:false
        };
    },
	computed: {
		actionImg() {
			return this.$store.state.baseURL + '/static/img/action.png'
		}
	},
    onLoad(opt) {

    },
    onShow() {

    },
    onReachBottom() {

    },
    methods: {
		upActionImg() {
			upload().then(res => {
				this.upimg = res[0].url
			})
		},
		joinAction() {
			if(this.loading) {
				return
			}
			if(this.upimg == '') {
				this.$api.msg('请上传合影照片')
			}
			this.loading = true
			joinAction({
				img: this.upimg
			}).then(res => {
				this.loading = false
				uni.showToast({
					title: '提交成功',
					duration: 2000
				});
			}).catch(err => {
				this.loading = false
			})
		}
    }
};
</script>
<style lang="scss" scoped>
	.content {
		padding-bottom: 50px;
	}
	page {
		background-color: #fff;
		height: auto;
		min-height: 100%;
	}
.action-img {
	width: 750rpx;
}
.action-wrap {
	width: 690rpx;
	margin:50rpx auto 0;
	// height: 560rpx;
	background-color: #dcf4ef;
	border-radius: 20rpx;
	padding: 60px 35rpx;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	align-items: center;
	text-align: justify;
	color: #333;
	font-weight: bold;
	font-size: 28rpx;
	position: relative;
	.up-img {
		width: 160rpx;
		height: 160rpx;
		margin: 45rpx auto;
	}
	.action-btn {
		width: 580rpx;
		height: 90rpx;
		color: #fff;
		font-weight: 500;
		background-color: #ffc43d;
		text-align: center;
		border-radius: 45rpx;
		line-height: 90rpx;
	}
	.action-top {
		width: 345rpx;
		height: 60rpx;
		position: absolute;
		top: -30rpx;
		left: 0;
		right: 0;
		margin: auto;
	}
}

</style>