<template>
	<view class="container">
		<!-- <image src="../../static/images/jihuo_bg.png" mode="widthFix" class="bg-img"></image> -->
		<view class="input-box flex-y-center">
			<input type="text" maxlength="500" v-model="num" placeholder="请输入激活编号"  class="input-box-put" />
			<image class="saoma" @click="saoma" mode="widthFix" src="../../static/images/saoma.png" ></image>
		</view>
		<view class="btm-btn" @click="jihuo">立即激活</view>
	</view>
</template>

<script>
	// #ifdef H5
	import getWXSign from "@/static/js/config.js";
	// #endif 
	export default {
		data() {
			return {
				num: ""
			}
		},
		onLoad() {
			// this.jcdetail();
		},
		methods: {
			saoma(e) {
				// #ifdef MP-WEIXIN
				uni.scanCode({
					success: (res) => {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						this.num = res.result;
					}
				});
				// #endif
				// #ifdef H5
				getWXSign().then(res => {
					console.log('wx_getLocation');
					this.$wx.scanQRCode({
						needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
						scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
						success: (res) => {
							console.log(res, "qrCode")
							this.num = res.resultStr;
						}
					})
				})
				// #endif	
			},
			jihuo() {
				if (this.num === '') {
					uni.showToast({
						title: "请输入账号",
						icon: "none"
					})
					return false
				}
				this.request({
					url: "user/bind",
					data: {
						code: this.num,
						token: uni.getStorageSync("token"),
					},
				}).then(res => {
					console.log(res, "res")
					if (res.code === '200') {
						uni.showToast({
							title: "激活成功",
							icon: 'none'
						})
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							})
						}, 2000)
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				});
			}


		}
	}
</script>

<style>
	page {
		background-color: #FDFDFE;
	}

	.container {
		height: calc(100vh - var(--window-top));
		position: relative;

	}

	.bg-img {
		display: block;
		width: 100%;
		height: 317rpx;
	}

	.input-box-put {
		width: 600rpx;
		height: 100%;
	}

	.input-box {
		width: 670rpx;
		height: 110rpx;
		background: #ffffff;
		border-radius: 8rpx;
		box-shadow: 0 0 14rpx 0 rgba(162, 180, 203, 0.25);
		margin: 10rpx auto;
		box-sizing: border-box;
		padding: 0 40rpx;
		font-size: 30rpx;
	}

	.btm-btn {
		width: 670rpx;
		height: 98rpx;
		background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);
		border-radius: 8rpx;
		box-shadow: 0px 0px 8rpx 0px rgba(51, 135, 255, 0.2);
		font-size: 32rpx;
		font-weight: 500;
		text-align: center;
		color: #fff;
		line-height: 98rpx;
		position: absolute;
		left: 40rpx;
		bottom: 120rpx;
	}

	.saoma {
		width: 50rpx;
		height: 50rpx;margin-left: 20rpx;

	}
</style>
