<template>
	<view class="u-flex-col u-col-center node-wrap">
		<w-navbar></w-navbar>
		<u-gap height="200"></u-gap>
		<u-image width="224rpx" height="224rpx" :src="qnFile(nodeInfo.icon)"></u-image>
		<view class="title">{{nodeInfo.title}}</view>
		<view v-show="isReturn" class="return">
			<u-divider color="#F4F5F7" half-width="345" margin-top="30" :use-slot="false"></u-divider>
			<view class="return-title u-text-center">退件编号</view>
			<view class="u-flex u-row-between return-row">
				<view class="return-no">{{returnNo}}</view>
				<view class="vertical-bar"></view>
				<button class="copy-btn" @tap="copyText" :data-text="returnNo">复制</button>
			</view>
		</view>
		<view class="message">{{nodeInfo.message}}</view>
		<u-gap v-show="isParts" height="192"></u-gap>
		<u-gap v-show="isReturn" height="160"></u-gap>
		<button class="back-btn" @click="goBack">{{nodeInfo.btnTxt}}</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curType: 0,
				returnNo: '',
				nodes: [
					{
						type: 'parts',
						icon: 'successful.png',
						title: '您的物料申请已提交成功',
						message: '工作人员正在加紧审核中',
						btnTxt: '我知道了'
					},
					{
						type: 'return',
						icon: 'successful.png',
						title: '您的退件信息已提交成功',
						message: '请将退件编号复制发给唯修汇对接人',
						btnTxt: '我知道了'
					}
				]
			}
		},
		onLoad(e) {
			if(e) {
				if(!this.$u.test.isEmpty(e.type)) {
					this.curType = Number(e.type)
				}
				if(!this.$u.test.isEmpty(e.returnNo)) {
					this.returnNo = e.returnNo
				}
			}
			getApp().trackPage(this.title)
		},
		computed: {
			title() {
				if (this.nodeInfo.type == 'parts') return '物料申请结果页'
				if (this.nodeInfo.type == 'return') return '退件结果页'
				return '物料申请结果页'
			},
			nodeInfo() {
				return this.nodes[this.curType]
			},
			isReturn() {
				return this.nodes[this.curType].type == 'return'
			},
			isParts() {
				return this.nodes[this.curType].type == 'parts'
			}
		},
		methods: {
			qnFile(src) {
				return process.uniEnv.qn_base_url + src
			},
			goBack() {
				var pages = getCurrentPages();
				if(pages.length >= 2) {
					var prevPage = pages[pages.length - 2];
					prevPage.needRefresh = true
				}
				if(this.isParts){ // 添加物料
					this.$u.route({type:'back'})
				}
				if(this.isReturn){ // 退件
					uni.redirectTo({
					    url: 'pages/mine/warehouse/return'
					});

				}
			},
			copyText(e) {
				console.log(e)
				uni.setClipboardData({
				  data: e.currentTarget.dataset.text,
				  success: function (res) {
					uni.getClipboardData({
					  success: function (res) {
						uni.showToast({
						  title: '复制成功'
						})
					  }
					})
				  }
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.node-wrap {
	width: 750rpx;
	height: 100vh;
	overflow: auto;
	background-color: #FFFFFF;
	.title {
		font-size: 40rpx;
		font-weight: bold;
		color: #2272FF;
		line-height: 40rpx;
		margin-bottom: 30rpx;
	}
	.return {
		.return-title {
			margin-top: 60rpx;
			font-size: 40rpx;
			font-weight: bold;
			color: #333333;
		}
		.return-row {
			margin: 52rpx 38rpx;
			.return-no {
				font-size: 40rpx;
				font-weight: 500;
				color: #2272FF;
				line-height: 60rpx;
			}
			.vertical-bar {
				width: 4rpx;
				height: 60rpx;
				background: #F4F5F7;
			}
			.copy-btn {
				width: 120rpx;
				height: 48rpx;
				border-radius: 24rpx;
				border: 2rpx solid #999999;
				font-size: 26rpx;
				font-weight: 400;
				color: #999999;
				line-height: 48rpx;
				margin: 0;
			}
		}
	}
	.message {
		font-size: 26rpx;
		font-weight: 400;
		color: #999999;
		line-height: 26rpx;
	}
	.back-btn {
		width: 400rpx;
		height: 104rpx;
		background: #2272FF;
		border-radius: 52rpx;
		font-size: 32rpx;
		font-weight: 600;
		color: #FFFFFF;
		line-height: 104rpx;
	}
}
</style>
