<template>
  <div class="mianBox" v-if="state">
    <van-row class="contentBox">
     <van-row @tap="amount()" class="amount">
        <image :src="require('../img/recharge.png')" class="amount_img" mode="widthFix" />
        <van-col :span="24" class="amount_txt1 amount_txt">充值</van-col>
        <!-- <van-col :span="24" class="amount_txt2 amount_txt">对余额进行充值</van-col> -->
      </van-row>
	  
	  <van-toast id="van-toast" />
	</van-row>
  </div>
</template>
<script>
	import Toast from '../../wxcomponents/vant/weapp/dist/toast/toast';
	export default {
		data() {
			return {
				state:false,
				data:{}
			}
		},
		onLoad(options) {
			//Toast("该用户未暂未录入充值系统...")
			// 对接app测试代码
					// let userId ='0001T110000000002HBL'
					// var  a = {
					// 	money:1,
					// 	channelId:null,
					// 	userId:'0001T110000000002HBL',
					// 	scene:3,
					// 	openid:null
					// }
					// var options = {}
					// options = a
			if(JSON.stringify(options) !="{}"){
				//app或扫码进入
				//console.log("app进入")
				options = JSON.stringify(options)
				const data = JSON.parse(options)
				if(data){
					this.data={
						money:data.money,
						channelId:data.channelId,
						userId:data.userId,
						scene:data.scene,
						openid:null,
					}
					uni.redirectTo({
					    url: `../order/index?params=${JSON.stringify(data)}`
					});
				}
			}else{
				this.state = true
				//微信小程序历史记录进入
				//console.log("微信小程序历史记录进入")
				this.data={
					money:null,
					channelId:null,
					userId:null,
					scene:2
				}
			}
		},
		methods: {
			amount(){
				let parmas = {
					money:this.data.money,
					channelId:this.data.channelId,
					userId:this.data.userId,
					scene:this.data.scene
				}
				if(this.data.money){
					//console.log("app或扫码进入 -->授权页")
					uni.navigateTo({
					    url: `../login/index?params=${JSON.stringify(parmas)}`
					});
				}else{
					//console.log("微信小程序历史记录进入 -->就选择充值金额页")
					uni.navigateTo({
					    url: `../amount/index?params=${JSON.stringify(parmas)}`
					});
				}
			}
		}
	}
</script>
<style lang="scss" scoped>
.mianBox{
    height: 100%;
    width: 100%;
    color: #000;
    padding-top: 20px;
    box-sizing: border-box;
    .contentBox{
      width: 100%;
      height: auto;
      padding: 15px 20px;
      box-sizing: border-box;
      overflow: hidden;
      .amount{
		position: absolute;
        width: 100%;
        padding: 15px 20px;
		box-sizing: border-box;
        image{
          width:100%;
		  height:auto
        }
		.amount_txt{
			margin-top:30px;
			position: absolute;
			left:26%;
			color:#fff;
		}
      }
    }
}
</style>

