<template>
	<view :class="[AppTheme]" class="all_box">
		<image class="live_thumbnails" lazy-load="true" mode="scaleToFill" :src="writedetails.activity_img"></image>
		<view class="order_information">
			<view class="lable">
				<text class="lable_name">活动名称:</text>
				<text>{{writedetails.activity_title}}</text>
			</view>
			<view class="lable">
				<text class="lable_name">开始时间:</text>
				<text>{{writedetails.start_time}}</text>
			</view>
			<view class="lable">
				<text class="lable_name">结束时间:</text>
				<text>{{writedetails.end_time}}</text>
			</view>
			<view class="lable">
				<text class="lable_name">金额:</text>
				<text>{{writedetails.order_money}}元</text>
			</view>
			<view class="lable">
				<text class="lable_name">订单号:</text>
				<text>{{writedetails.order_sn}}</text>
			</view>
			<view class="lable">
				<text class="lable_name">核销码:</text>
				<text>{{hx_sn}}</text>
			</view>
		</view>
		<button @click="surecode" class="writesure bg-linear-gradient">确认核销</button>
	</view>
</template>
<script>
	import mallApi from '@/api/mall/index.js';
	import untiljs from '@/common/until.js';
	export default {
		data() {
			return {
				primary:this.$theme.primary,
				settingFile:getApp().globalData.siteinfo,
				hx_sn:'',   //核销码
				//详细信息
				writedetails: {},
				// 坐标地址
				latitude: 39.909,
				longitude: 116.39742
			};
		},
		onLoad(options) {
			this.hx_sn = options.code
			console.log(options,"options")
			this.vueinit()
		},
		methods: {
			surecode(){  //确认核销
				mallApi.writeoff({
					hx_sn:this.hx_sn
				}).then(res=>{
					if(res.status==1){
						uni.navigateTo({
							url:"/pagesB/pages/activorderdails/showactivitydetails/showactivitydetails"
						})
					}else{
						uni.showToast({
							title:res.msg,
							icon:"none"
						})
					}
				})
			},
			// 返回指定格式时间
			retushorttime(time) {
				if (time !== undefined && time !== null) {
					let date = new Date(time);
					return untiljs.formatDate(date, 'yyyy.MM.dd');
				}
			},
			vueinit() {
				let that = this;
				let params = {
					hx_sn:this.hx_sn
				};
				mallApi.writeindex(params).then(res => {
					if (res.status == 1) {
						that.writedetails = res.data;
						that.writedetails.create_time = that.retushorttime(that.writedetails.create_time)
						that.writedetails.end_time = that.retushorttime(that.writedetails.end_time)
						that.writedetails.pay_time = that.retushorttime(that.writedetails.pay_time)
						that.writedetails.use_time = that.retushorttime(that.writedetails.use_time)
						that.writedetails.start_time = that.retushorttime(that.writedetails.start_time)
					} else {
						that.writedetails = res.data;
						that.$api.msg(res.msg);
					}
				});
			}
		}
	};
</script>
<style lang="scss">
	.all_box {
		background-color: #fafafa;
		min-height: 100vh;

		.order_information {
			width: 95%;
			background-color: #f4f4f4;
			margin: auto;
			margin-top: 30rpx;
			padding: 20rpx;
			border-radius: 20rpx;

			.lable {
				display: flex;
				justify-content: space-between;
				align-items: center;
				line-height: 70rpx;
				color: #1d1d1d;

				text {
					color: #999;
				}

				.lable_name {
					color: #1d1d1d;
				}
			}
		}

		.live_thumbnails {
			width: 100%;
			height: 420rpx;
			// box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.08);
		}


		.writesure {
			width: 600rpx;
			margin: 40rpx auto;
			border-radius: 50rpx;
			color: white;
		}

		.padd_bottom {
			height: calc(env(safe-area-inset-bottom) + 130rpx);
			width: 100%;
		}
	}
</style>
