<template>
	<view>
		<mescroll-body ref="mescrollRef" @down="downCallback" :down="downOpt">

			<!-- 商品信息 -->
			<self-line/>
			<view class="bg-white padding-tb-sm">
				<skeleton :loading="skeletonLoading" :row="2" :showAvatar="false" :showTitle="true">

					<view class="flex justify-between align-start padding-top-sm padding-lr">
						<image src="@/static/tu.png" mode="aspectFill" style="width: 150rpx; height: 150rpx;"></image>
						<view class="flex-sub padding-left-sm">
							<view class="bref-box margin-top-xs">
								网红辣椒棒 魔鬼辣椒挑战全网第一辣 网红优惠季 
							</view>
							<text class="block margin-top-sm text-gray text-sm">网红辣椒棒 500g <text class="margin-left text-gray">x1</text></text>
							
							<view class="flex justify-between margin-top-sm">
								<view class="text-red text-price text-lg">
									<amount :value="Number(19.90 || 0)" :is-round-up="false" :precision="2" :duration="800" transition></amount>
								</view>
								<view>
									<button v-if="true" class="cu-btn line-orange round margin-left-sm text-sm" @tap="$routerGo('/pages/order/apply-refund')">申请退款</button>
									<button v-else class="cu-btn line-gray bg-gray round margin-left-sm text-sm">退款中</button>
								</view>
							</view>
						</view>
					</view>

				</skeleton>
			</view>
			
			<self-line/>
			<!-- 表单 -->
			<view class="bg-white">
				<view class="cu-bar padding-lr solid-bottom flex justify-between align-center text-center">
					<text class="text-gray">订单编号</text>
					<view>
						<text class="margin-right">67432428794847982374</text>
						<text class="text-orange text-sm">复制</text>
					</view>
				</view>
				<view class="cu-bar padding-lr solid-bottom">
					<text class="text-gray">下单时间</text>
					<text>2021-6-17  15:35:46</text>
				</view>
				<view class="cu-bar padding-lr solid-bottom">
					<text class="text-gray">付款时间</text>
					<text>微信支付</text>
				</view>
				<view class="cu-bar padding-lr solid-bottom">
					<text class="text-gray">支付方式</text>
					<text>2021-6-17  15:35:46</text>
				</view>
			</view>
			
			<self-line/>
			<view class="bg-white">
				<view class="cu-bar padding-lr solid-bottom">
					<text class="text-gray">优惠</text>
					<text>暂无优惠</text>
				</view>
			</view>
			
			<self-line/>
			<view class="bg-white flex flex-direction justify-around align-center text-center padding-tb">
				<view>
					<tki-qrcode ref="qrcode" @result="qrR" :val="area" :size="120" unit="px" background="#fff" foreground="#000"
					 pdground="#000" :onval="true" :loadMake="true" :icon="require('@/static/images/system/user-default.jpg')" />
				</view>
				<view class="flex justify-around align-center text-center margin-top-sm">
					<view>
						<image class="margin-right" src="@/static/images/system/refresh.png" mode="widthFix" style="width: 20px;height: 20px;"></image>
					</view>
					<view class="text-lg">SP738644872</view>
					<view class="text-orange text-sm margin-left" @tap="copy('SP738644872')">复制</view>
				</view>
				<view class="margin-top-sm text-green text-sm">
					待使用
				</view>
			</view>
			<view class="padding-lr padding-tb-sm bg-white flex justify-between align-center solid-top">
				<view class="flex align-center">
					<text class="text-gray text-sm">已付款：</text>
					<view class="text-lg text-price text-red">
						<amount :value="Number(19.90 || 0)" :is-round-up="false" :precision="2" :duration="800" transition></amount>
					</view>
				</view>
				<view>
					已付款
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import tkiQrcode from "tki-qrcode" // 二维码生成器
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				area: '币种地址',
				base64Img: '',	//
				skeletonLoading: true,
				payCur: 0, //支付方式下标
				loading: false,
				address: {},
				shopData: {},
				num: 0,
				payPwd: '',
				price: '',	//价格
			}
		},
		components: {
			tkiQrcode
		},
		computed: {
			disabled() {
				// 必须输入 邮箱和验证码 才能点击下一步
				if (this.payPwd) return false
				return true
			},
			total(){
				return this.num * this.price
			}
		},
		onLoad(e) {
			setTimeout(()=>{
				this.skeletonLoading = false
				this.mescroll.endSuccess(); // 请求成功,隐藏加载状态
			},1000)
		},
		methods: {
			//二维码回调
			qrR(data) {
				this.base64Img = data;
			},
			// 点击复制
			copy(text) {
				//app的复制方法
				// #ifdef APP-PLUS
				uni.setClipboardData({
					data: text
				});
				// #endif
			
				//html的复制方法
				// #ifdef H5
				this.$copyText(text)
					.then(res => {
						uni.showToast({
							title: '复制成功'
						});
					})
					.catch(err => {
						uni.showToast({
							icon: 'none',
							title: '复制失败，您的浏览器不支持'
						});
					});
				// #endif
			},
			submit(){
				this.$routerGo('/pages/order/order?type=all')
			},
			//下拉刷新
			downCallback() {
				setTimeout(()=>{
					this.mescroll.endSuccess(); // 请求成功,隐藏加载状态
					this.mescroll.endErr(); // 请求失败,隐藏加载状态
				},1000)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.address-box {
		// background-image: url(../../static/images/shop/envelope.png);
		background-repeat: repeat-x;
		background-position: left bottom;
		background-size: auto 8rpx;
	}

	.self-img-sm {
		width: 40rpx;
		height: 40rpx;
	}

	.bref-box {
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.order-bottom {
		position: relative;

		.cuIcon-fold {
			position: absolute;
			right: 50rpx;
			top: -19rpx;
			color: rgba(0, 0, 0, 0.1)
		}
	}
</style>
