<template>
	<view>
		<view class="cmain" v-for="(item,index) in list">
			<view class="box order_detail">
				<view class="item">
					<text class="label">车牌号</text>
					<text class="desc">{{ item.veNo }}</text>
				</view>
				<view class="item">
					<text class="label">商品</text>
					<text class="desc omit">{{ item.goodsNames }}</text>
				</view>
				<view class="item">
					<text class="label">数量</text>
					<text class="desc omit">{{ item.packNo }}</text>
				</view>

				<view class="item">
					<text class="label">店主</text>
					<text class="desc">{{ item.shopName }}</text>
				</view>
				<view class="item">
					<text class="label">互市区</text>
					<text class="desc">{{ item.fieldName }}</text>
				</view>
				<view class="item">
					<text class="label">发布时间</text>
					<text class="desc">{{ item.createTime }}</text>
				</view>
				<view class="item">
					<text class="label">商品价格</text>
					<text class="desc price">¥ {{ item.sumUpPrice }}</text>
				</view>
			</view>
		</view>
		<view style="height: 80px;"></view>
		<view class="mfooter">
			<view class="flex">
				<view class="total-price price">¥{{totalPrice}}</view>
				<view class="f">
					<button class="btn" @click="pay()">立即购买</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: this.getUser(),
				list: [],
				ids: ''
			};
		},
		onLoad(e) {
			if (e.ids) {
				this.ids = e.ids;
				this.http.request({
					url: '/level-one-server/app/HtTradeSettlement/getByIds',
					method: 'POST',
					data: {
						ids: this.ids
					},
					success: res => {
						this.list = res.data.data;
					}
				});

			}
		},
		computed: {
			totalPrice() {
				let list = this.list;
				let total = 0;
				list.map(item => total = Number(item.sumUpPrice) + Number(total));
				return Math.round(total * 100) / 100;
			}
		},
		methods: {
			pay() {
				uni.showModal({
					title: '提示',
					content: '我已核对订单信息无误',
					success: res => {
						if (res.confirm) {
							this.http.request({
								url: '/level-two-server/app/TbOrders/purchaserBuyWhole',
								method: 'POST',
								data: {
									ids: this.ids
								},
								success: res => {
									console.log(res);
									return;
									uni.redirectTo({
										url: '/pages/market/two/leader/success'
									});
								}
							});
						}
					}
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: $pg;
	}

	.price {
		color: red;
		font-weight: bold;
	}

	.total-price {
		line-height: 66px;
		padding: 0 0 0 10px;
		font-size: 18px;
	}
</style>