<template>
	<view class="se-m-40">
		<u--input v-model="money" type="number" class="se-bgc-f5 se-fs-32" placeholder="请输入充值金额">
			<text slot="prefix" class="se-ml-10 se-c-orange se-fs-32">￥</text>
		</u--input>
		<view class="se-flex se-flex-v se-pb-20 se-mt-80">
			<view class="se-ml-10 se-fs-26 se-c-black se-fw-5">
				充值说明
			</view>
			
			<view class="se-flex se-flex-v se-fs-24 se-c-66  se-mt-30">
				<u-parse :content="getValueByName('czsm')"></u-parse>
				<!-- <text class="se-hl-50">
					1、本次充值必须通过银行卡充值，暂不支持其他途径。</br>
					2、如若遇到24小时充值未到账，请联系客服。</br>
					3、充值金额至少不能低于10元。
				</text> -->
			</view>
		</view>
		<view class="se-pt-80 se-fs-20 se-flex">
			<view @click="onRecharge()"
				class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-orange">
				<text>立即充值</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		payRecharge
	} from "@/common/api.js"
	
	export default{
		props:["userId","myMoney"],
		data(){
			return{
				money:"",
				sysList:[]
			}
		},
		mounted() {
			this.sysList = uni.getStorageSync('sysList')
		},
		methods:{
			getValueByName(name) {
				const item = this.sysList.find((item) => item.name == name);
				return item ? item.value : "";
			},
			onRecharge(){
				let that = this
				let params = {
					id:that.userId,
					price:that.money
				}
				if(!that.money){
					return that.$u.toast("请填写金额！")
				}
				payRecharge(params).then(response=>{
					uni.requestPayment({
					    provider: "wxpay",
						nonceStr: response.result.nonceStr,
						package: response.result.package,
						timeStamp: response.result.timeStamp,
						signType: response.result.signType,
						paySign: response.result.paySign,
					    success(res) {
							that.money="";
							that.$u.toast("充值成功！")
							that.$emit("onParent")
						},
					    fail(e) {
							console.info(e)
						}
					})
					
				}).catch(error=>{
					
				})
			}
		}
	}
</script>

<style>
</style>