<template>
	<view>
		<mescroll-body ref="mescrollRef" @down="downCallback" :down="downOpt" style="min-height: 645px;">

			<!-- 商品信息 -->
			<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>
							<view class="flex justify-between">
								<text class="block margin-top-sm text-gray text-sm">数量</text>
								<view class="flex align-center margin-top-sm">
									<text class="cuIcon-move" @tap="reduce"></text>
									<input type="number" v-model="num" class="text-center margin-lr-sm radius" style="width: 60rpx; height: 50rpx;background-color: #f7f7fb;" />
									<text class="cuIcon-add" @tap="add"></text>
								</view>
							</view>
							
							<view class="flex justify-between margin-top-sm">
								<view class="text-red text-price text-lg">
									<amount :value="Number(19.90*num || 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">申请退款</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">
					<text class="text-gray">优惠</text>
					<text>暂无优惠</text>
				</view>
			</view>
			<self-line/>
		</mescroll-body>
		<view class="btn-bottom">
			<view class="padding flex justify-around align-center">
				<view class="margin-right">
					<checkbox :class="checkbox[0].checked?'checked':''" :checked="checkbox[0].checked?true:false" value="A"></checkbox>
				</view>
				<view class="text-sm text-gray">请认真阅读并同意《时空网协议》，在小程序下单购买即表示您已默认同意《时空网协议》的所有条款。</view>
			</view>
			<self-line/>
			<view class="padding-lr padding-tb-sm bg-white flex justify-between align-center solid-top shadow">
				<view class="flex align-center">
					<text class="">应付款：</text>
					<view class="text-lg text-price text-red">
						<amount :value="Number(total || 0)" :is-round-up="false" :precision="2" :duration="800" transition></amount>
					</view>
				</view>
				<button class="cu-btn block bg-orange round shadow" @tap="submit">
					<text class="cuIcon-loading2 cuIconfont-spin  margin-right-xs text-white" v-if="loading"></text>
					<text class="text-df text-white">{{ loading ? '支付中...' : '下单付款' }}</text>
				</button>
			</view>
		</view>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				num: 1,
				area: '币种地址',
				base64Img: '',	//
				skeletonLoading: true,
				payCur: 0, //支付方式下标
				loading: false,
				address: {},
				shopData: {},
				payPwd: '',
				price: '',	//价格
				checkbox: [{
					value: 'A',
					checked: true
				}, {
					value: 'B',
					checked: true
				}, {
					value: 'C',
					checked: false
				}],
			}
		},
		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: {
			reduce() {
				if (this.num === 1) return
				this.num--
			},
			add() {
				this.num++
			},
			CheckboxChange(e) {
				var items = this.checkbox,
					values = e.detail.value;
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
					items[i].checked = false;
					for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
						if (items[i].value == values[j]) {
							items[i].checked = true;
							break
						}
					}
				}
			},
			//二维码回调
			qrR(data) {
				this.base64Img = data;
			},
			// 点击复制
			copy(text) {
				uni.setClipboardData({
					data: text
				});
			},
			submit(){
				this.$routerGo('/pages/order/pay-success')
			},
			//下拉刷新
			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>
