<template>
	<view style="padding: 30rpx;" >
		<view class="bd">
			<text class="font2">付款金额</text>
			<text class="font1">¥{{price}}</text>
			<view class="flex">
				<view class="flex_item">付款方式</view>
				<view>微信支付</view>
			</view>
			<button type="button" class="btn" @click="pay">立即支付</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				price:0.01
			}
		},
		onLoad(option) {
			
		},
		onShow(){
		},
		methods: {
			pay(){
				this.wxPayment({})
			},
			wxPayment(param){
				let self = this
				this.$api.order(param).then(res => {
					if (res.data.code == 200){
						let data = res.data.data
						uni.requestPayment({
						    provider: data.provider,
						    nonceStr: data.nonceStr,
						    package: data.package,
						    signType: data.signType,
						    paySign: data.sign,
							timeStamp: String(data.timeStamp),
						    success: function (res) {
						        console.log('success:' + JSON.stringify(res));
						    },
						    fail: function (err) {
						        console.log('fail:' + JSON.stringify(err));
						    }
						});
					}	
				})
			},
		},
		
	}
</script>

<style scope>
	
page {
		background: #f3f3f3;
		font-size: 28rpx;
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.flex_item {
		flex: 1;
	}

	.container {
		padding: 30rpx;
	}

	.container .bd {
		background: #fff;
		border-radius: 10rpx;
		padding: 100rpx 30rpx 50rpx;
	}

	.container .bd .font1 {
		display: block;
		text-align: center;
		font-size: 88rpx;
	}

	.container .bd .font2 {
		display: block;
		text-align: center;
		font-size: 30rpx;
		margin: 30rpx 0 60rpx;
		color: #525252;
	}

	.container .bd .flex {
		border-bottom: 1px solid #eee;
		padding: 30rpx 0;
		margin-bottom: 30rpx;
	}

	.container .bd .btn {
		color: #fff;
		font-size: 28rpx;
		padding: 10rpx 0;
		background: #eb3b2f;
	}
</style>
