<template>
	<view class="center">
		<view class="top"><image src="" mode=""></image></view>
		<view class="name-box">
			<view class="price-box">
				
				￥
				<text class="price">9800</text>
				<text class="yuan">￥229</text>
			</view>
			<view class="name clamp">西部数据 紫盘 4TB 移动监控硬盘</view>
			<view class="info">
				<view class="info-item">
					快递：￥0.00
				</view>
				<view class="info-item">
					销量：56件
				</view>
				<view class="info-item">
					浙江省台州市
				</view>
			</view>
		</view>
		<view class="tip-box">
			<view class="tip-titele">拼团玩法</view>
			<view class="tip-main">开团/参团-邀请好友-满员开团-拼中发货</view>
		</view>
		<view class="tip-box">
			<view class="tip-titele">拼团须知</view>
			<view class="tip-main">开团玩法详细介绍开团玩法详细介绍开团 玩法详细介绍开团玩法详细介绍开团玩法 详细介绍开团玩法详细介绍</view>
		</view>
		<view class="detail">
			<view class="detail-title">商品详情</view>
			<view class="systom"></view>
		</view>
		<view class="btn" @click="buy()">立即拼团</view>
	</view>
</template>
<script>
import { miningDateils, buyMining } from '@/api/market.js';
import uniNumberBox from '@/components/uni-number-box.vue';
export default {
	components: {
		uniNumberBox
	},
	data() {
		return {
			id: '',
			type: '',
			num: 1,
			step: 0,
			password: '',

			price: '',
			list: {},
			checked: false,
			current: 0
		};
	},
	onLoad(option) {
		this.id = option.id;
		this.type = option.type;
	},

	computed: {
		money() {
			return this.num * this.price * this.step;
		}
	},
	onShow() {},
	methods: {
		async loadData() {
			let obj = this;
			miningDateils({}, obj.id).then(({ data }) => {
				obj.list = data;
				// obj.money = obj.list.cost_money;
				obj.price = obj.list.cost_money;
				obj.step = obj.list.step;
				console.log(obj.list);
			});
		},
		//阅读并同意
		Getcheckbox() {
			let obj = this;
			obj.checked = !obj.checked;
		},
		ToIndex() {
			uni.navigateTo({
				url: '/pages/finance/xieyi'
			});
		},
		pay() {
			let obj = this;
			if (obj.password == '') {
				obj.$api.msg('请输入交易密码！');
				return;
			}
			if (obj.checked == false) {
				obj.$api.msg('请阅读并同意协议！');
				return;
			}
			buyMining(
				{
					num: obj.num * obj.step,
					trade_psw: obj.password
				},
				obj.id
			)
				.then(data => {
					obj.$api.msg(data.msg);
					obj.password = '';
					obj.num = 1;
				})
				.catch(e => {
					obj.password = '';
					obj.num = 1;
					if (e.msg == '交易密码错误') {
						return;
					}
					console.log(e);
					var reg = new RegExp('购买矿机所需的');
					if (e.msg.match(reg) == -1) {
					} else {
						setTimeout(function() {
							uni.navigateTo({
								url: '/pages/finance/recharge'
							});
						}, 1000);
					}
				});
		},
		numberChange(data) {
			let obj = this;
			obj.num = data.number;
		},
		buy() {
			// let list = JSON.stringify(this.list)
			uni.navigateTo({
				url: '/pages/order/createOrder'
			});
			// console.log(this.list,'--------------***********')
			// console.log('buy click')
		},
		changeCurrent(index) {
			this.current = index;
		},
		back() {
			uni.navigateBack({
				url: '/pages/calculation/buyCalculation'
			});
		}
	}
};
</script>

<style lang="scss" scoped>
page,
.center {
	background: #f8f6f6;
	height: 100%;
}
.top {
	background: #45969b;
	width: 750rpx;
	height: 710rpx;
}
.name-box {
	padding: 30rpx 26rpx;
	line-height: 1;
	background-color: #ffffff;
	.price-box {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #e83f30;
		.price {
			font-size: 48rpx;
		}
		.yuan {
			padding-left: 10rpx;
			font-size: 30rpx;
			font-weight: 500;
			text-decoration: line-through;
			color: #999999;
		}
	}
	.name {
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #1d2023;
		margin-top: 30rpx;
	}
	.info {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 30rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
	}
}
.tip-box {
	margin-top: 20rpx;
	padding: 34rpx 60rpx 50rpx 30rpx;
	display: flex;
	align-items: flex-start;
	background-color: #ffffff;
	.tip-titele {
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #3b3b3b;
	}
	.tip-main {
		margin-left: 30rpx;
		width: 500rpx;
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #8a8a8a;
	}
}
.detail {
	.detail-title {
		width: 750rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		font-size: 28rpx;
		font-family: PingFangSC;
		font-weight: bold;
		color: #1d2023;
	}
}
.btn {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	width: 750rpx;
	height: 98rpx;
	background: linear-gradient(0deg, #2e58ff, #32c6ff);
	text-align: center;
	line-height: 98rpx;
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #ffffff;
}
</style>
