<template>
  <view class="Message">
	  <view class="upload" style="height: 300rpx;overflow: hidden;">
			<u-upload ref="uUpload1" width="600rpx" height="300rpx"  @on-change="progress1" :action="action" ></u-upload>
		</view>
	<input type="number" style="border-radius: 30rpx;border: 1px solid #ececec; text-align: center;font-size: 30rpx;color: #333" v-model="inputChanId" placeholder="请输入渠道号">
	<view class="btn" @click="button">
		立即提交
	</view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
		action:'',
		url:'',
		inputChanId:'',//渠道输入框内容
		imageUrl:'', //分享图地址
    };
  },
  onLoad(option) {
	  this.action=this.$httpUrl+'/api/common/upload'
    if (option.url) {
      this.url = option.url;
    }
  },
  onShareAppMessage(shareInfo){
  	const { from, type } = shareInfo;
  	return {
  		imageUrl: this.imageUrl,
  		// title: '',
  		path: this.url+'?chanId='+this.inputChanId,
  	}
  },
  methods: {
    progress1(res, index, lists, name){
		// console.log(JSON.parse(res.data))
		if(JSON.parse(res.data).code==0){
			this.$refs.uToast.show({
				title: JSON.parse(res.data).msg,
				type: 'error ',
			})
			this.$refs.uUpload1.clear()
		}
	},
	button(){
		let files1 = [];
		files1 = this.$refs.uUpload1.lists.filter(val => {
			return val.progress == 100;
		})
		this.imageUrl=files1[0].response.data.url
			console.log(this.imageUrl)
			console.log(this.url+'?chanId='+this.inputChanId)
			uni.showToast({
				title: '内容已修改,请点击添加到直播按钮',
				duration: 500,
				icon: 'none'
			});
	}
  },
};
</script>

<style lang="scss">
.Message {
	text-align: center;
	padding-top: 200rpx;
	width: 600rpx;
	margin: 0 auto;
	input{
		margin: 30rpx 0;
	}
	.btn{
		border-radius: 20rpx;
		box-sizing: border-box;
		height: 76rpx;
		line-height: 76rpx;
		text-align: center;
		font-size: 30rpx;
		background-color: #C53A47;
		color: #fff;
	}
}
</style>
