<template>
	<view>
		<view class="btn-box">
			<view class="btn" @click="payOrder()">支付</view>
		</view>
	</view>
</template>
<script>
export default {
	 
 	data() {
 		return {
			payData:null,
			payExtraData:null,
 		}
 	},
	onLoad(options) {
		console.log(options)
		this.payData=JSON.parse(decodeURIComponent(options.openid));
		var json=uni.getStorageSync("payExtraData")
		this.payExtraData=JSON.parse(json)
		console.log(this.payExtraData)
		console.log(this.payData)
		this.payOrder()
	},
	methods:{
		payOrder(){
			var that=this;
			uni.showLoading({
				title:"处理中..."
			})
			uni.requestPayment({
			 	provider: 'wxpay',
			 	timeStamp: that.payData.timeStamp,
			 	nonceStr: that.payData.nonceStr,
			 	package: that.payData.package,
			 	signType: that.payData.signType,
			 	paySign: that.payData.paySign,
			 	success: function(res) {
			 		 uni.hideLoading();
					 if(that.payExtraData.orderType==1){
					 	uni.redirectTo({
					 		url:"/pages_order/inquiryOrderPaySuccess?orderId="+that.payExtraData.orderId
					 	})
					 }
					 else if(that.payExtraData.orderType==2){
					 	uni.redirectTo({
					 		url:"/pages_order/storeOrderPaySuccess?orderId="+that.payExtraData.orderId
					 	})
					 }
					 else if(that.payExtraData.orderType==3){
					 	uni.redirectTo({
					 		url:"/pages_order/packageOrderPaySuccess?orderId="+that.payExtraData.orderId
					 	})
					 }
					 else if(that.payExtraData.orderType==4){
					 	uni.redirectTo({
					 		url:"/pages_order/courseOrderPaySuccess?orderId="+that.payExtraData.orderId
					 	})
					 }
					 else if(that.payExtraData.orderType==5){
					 	uni.redirectTo({
					 		url:"/pages_order/userVipOrderOrderPaySuccess?orderId="+that.payExtraData.orderId
					 	})
					 }
					 
			 	},
			 	fail: function(err) {
					uni.showToast({
						icon:'none',
						title:'fail:' + JSON.stringify(err),
					});
			 		uni.hideLoading();
					
			 	}
			});
		},
	}
 	 
 }
 
 
</script>


<style scoped lang="scss">
page{
	height: 100%;
}
.content{
	height: 100%;
}
.btn-box{
	height: 140upx;
	z-index: 9999;
	width: 100%;
	padding: 0rpx 30upx;
	position: fixed;
	bottom: 0;
	left: 0;
	box-sizing: border-box;
	background-color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	.btn{
		width: 100%;
		height: 88upx;
		line-height: 88upx;
		text-align: center;
		font-size: 34upx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		background: #C39A58;
		border-radius: 10upx;
	}
}
</style>
