<template>
	<view class="container">
		<view class="input-box flex-y-center">
			<textarea @input="getVideo" type="text" value="" placeholder="请粘贴分享链接,支持某音、某山、某瓜等" />
			</view>
		<view class="btm-btn" @click="getup">一键抓取</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num: ""
			}
		},
		onLoad() {
			
		},
		methods: {
					getVideo(e){
						 this.video_url=e.detail.value;
						},
						getup(e){
							this.request({
								url: "videofuneng/video_down",
								data:{
									 url:this.video_url,
								},
							}).then(res => {
								console.log(res, "res")
								if (res.code === '200') {
									 var video_url=res.data.video_url,
									     video_otherurl=res.data.video_otherurl;
									  uni.setStorageSync("video_url",video_url);	
									  var pages = getCurrentPages();
									  var prevPage = pages[pages.length - 2]; //上一个页面
									  //直接调用上一个页面的setData()方法，把数据存到上一个页面中去
									  // 上一个页面最后设置userdata
									 //小程序用setData带参
									// #ifdef H5
										prevPage.$vm.is_video = 2;
										prevPage.$vm.video_otherurl=video_otherurl;
									// #endif
									// #ifdef MP-WEIXIN 
										prevPage.setData({
											 is_video:2,
											 video_otherurl,
										})
									// #endif
									uni.navigateBack();
								}
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: 'none'
								})
							});
						},	
			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 {
		width: 670rpx;
		margin: 0 auto;
	}
	
	.input-box textarea {
		background: #ffffff;
		border-radius: 8rpx;
		box-shadow: 0px 0px 14rpx 0px rgba(162, 180, 203, 0.25);
		height: 250rpx;
		width: 100%;
		padding: 20rpx;
	}
/* 	
	.input-box {
		width: 670rpx;
		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>
