<template>
	<view>
		<van-radio-group >
		   <van-cell-group 
		   v-for="(item, index) in list"
		   :key="index"
		   >
			 <van-cell
		       :title="item.title"
			   @click="onChange(index)" 
		     >
			 <template slot="icon" style="padding-right: 10upx;">
			    <van-radio-group :value="radio" >
			      <van-radio checked-color="#D9332E" :name="index" >
				  </van-radio>
			    </van-radio-group>
			 </template>
		     </van-cell>
		   </van-cell-group>
		 </van-radio-group>
		 <view class="payMoney" @click="payMoney">支付({{prices}})</view>
		 <Dialog  :orderCancel="orderCancel"
		     :titles="titles"
			 :values="values"
		     @colseDialog="cancelDialog" 
		     @confirmPay="confirmOrder"
		  />
	</view>
</template>

<script>
	import Dialog from '@/component/Dialog.vue'
	export default {
		components: {
			Dialog
		},
		data() {
			return {
				values:'',
				orderCancel:　false,
				titles:'',
				list:[
					{title:'微信支付'},
					{title:'支付宝支付'},
					{title:'圈币支付'}
				],
				radio: 0,
				prices: '',
				order_id:''
			}
		},
		onLoad(e) {
			this.prices = e.prices;
			this.order_id = e.order_id;
		},
		methods: {
			cancelDialog() {
				this.orderCancel = false;
			},
			confirmOrder() {
				this.orderCancel = false;
				this.request({
					url:'/v1/payment/pay',
					method:'POST',
					data: {
						pay_code: 'point',
						order_id: this.order_id
					},
					success: (res) => {
						console.log(res);
						
					}
				})
			},
			onChange(index) {
				this.radio = index;
			},
			payMoney() {
				console.log("kkk")
				if(this.radio == 0) {
					// 微信支付
				}else if(this.radio == 1) {
					// 支付宝支付
				}else {
					this.titles = "圈币支付";
					this.values = "使用圈币支付"+this.prices;
					this.orderCancel = true;
					// 圈币支付
					// this.request({
					// 	url:'/v1/payment/pay',
					// 	method:'POST',
					// 	data: {
					// 		pay_code: 'point',
					// 		order_id: this.order_id
					// 	},
					// 	success: (res) => {
					// 		console.log(res);
							
					// 	}
					// })
				}
			}
		}
	}
</script>

<style>
  .payMoney {
	  width: 90%;
	  color: #fff;
	  background-color: #D9332E;
	  position: fixed;
	  text-align: center;
	  padding: 20upx 0;
	  bottom: 5%;
	  left: 5%;
  }
</style>
