<template>
	<view>
		<view class="con">
			<view class="title">支付金额</view>
			<view class="price">
				<text>￥</text>
				{{ payMoney }}
			</view>
			<view v-if="isPayFail" class="btn" @click="pay()">重新支付</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	const req = require('../../utils/request.js');
	const api = require('../../utils/api.js');
	const utils = require('../../utils/util.js');
	const route = require('../../utils/route.js');
	export default {
		data() {
			return {
				orderId: '',
				orderDetail: '',
				openId: '',
				payMoney: '',
				// status: ''
				payType: '', //普通支付为空，钱包充值4
				isPayFail: false,
			};
		},

		onLoad(options) {
			var tha = this;
			this.options = options;
			this.orderId = options.orderId;
			this.payMoney = options.payMoney;
			this.payType = options.payType;
			// this.status = options.status;
			// this.getDetail();

			app.globalData.getCheckSessoin(json => {
				this.openId = json.openid;
				// //vip的支付
				// if (options.vip) {
				// 	tha.vipPay();
				// } else {
				// 	//其他订单的支付
				tha.pay();
				// }
			});
		},
		onShow() {},

		methods: {
			// getDetail() {
			// 	req.getRequest(
			// 		'/api/order/v2/detail', {
			// 			id: this.orderId
			// 		},
			// 		data => {
			// 			this.orderDetail = data;
			// 		},
			// 		true
			// 	);
			// },

			/**	
			 * 统一下单支付下单
			 */
			pay() {
				// console.log('openId', this.openId);
				req.payAppOrder(this.orderId, this.openId, this.payType, res => {
					 console.log('支付状态》》》》》res=', res);
					if (res) {
						this.isPayFail = false;
						uni.redirectTo({
							url: '/pay/wxPaySuccess/index'
						});
					} else {
						this.isPayFail = true;
					}
				});
			},
		}
	};
</script>

<style>
	@import './index.css';
</style>