<template>
	<view class="body"> 
		<view class="">
			<view class="header">
				<view class="top">
					<view class="desc">
						可提现奖励金(元)
					</view>
					<view class="balance">
						￥ {{form.realprice}}
					</view>
				</view>
				<view class="bottom">
					<view class="left">
						<view class="desc">
							已提现奖励金(元)
						</view>
						<view class="balance">
						￥ {{form.already_pay_money}}
						</view>
					</view>
					<view class="right">
						<view class="desc">
							累计会员数(人)
						</view>
						<view class="balance">
						  {{form.member_num}}
						</view>
					</view>
				</view>
				<view class="bottom">
					<view class="left">
						<view class="desc">
							分润金豆数(个)
						</view>
						<view class="balance">
						{{form.creditnum}}
						</view>
					</view>
					<view class="right">
						<view class="desc">
							分润订单数(笔)
						</view>
						<view class="balance">
						  {{form.order_num}}
						</view>
					</view>
				</view>
			</view>
			
			<view class="content" style="margin-top:30rpx;">
				<u-form :model="form">
					<u-form-item label-width="200" :label-position="labelPosition" label="收款人姓名:" prop="bankName">
						<u-input @click="go2Page('/pages/store/withdraw/alipay')" :border="border" placeholder="请输入收款人姓名" v-model="form.merch_payinfo.legalname" disabled></u-input>
					</u-form-item>
					<u-form-item label-width="200" :label-position="labelPosition" label="支付宝账号:" prop="bankName">
						<u-input @click="go2Page('/pages/store/withdraw/alipay')" :border="border" placeholder="请输入收款人支付宝账号" v-model="form.merch_payinfo.alipayinfo" disabled></u-input>
					</u-form-item>
				</u-form>
			</view>
			
			<view style="margin-top: 60rpx;">
				<u-button :disabled="false" class="button" @click="submit">提现</u-button>
			</view>

			<view class="bottom-tips">
				备注:奖励金为本店会员在其他店铺消费所得奖励
			</view>
			
		</view>
		
	</view>
</template>

<script>
	let that = {}
	export default {
		data() {
			return {
				form: {
					payType: '提现到银行',
					payTypeValue: 2,
					merch_payinfo: {}, //商户支付信息
					realprice:0, //可提现奖励金
					already_pay_money:0, //已提现奖励金
					member_num:0, //累计会员数
					creditnum:0, //分润金豆数
					order_num:0, //分润订单数
					
					
				},
				border: 'none',
				labelPosition: 'left',
			}
		},
		onLoad() {
			uni.showLoading({
				title: '加载中'
			});
		},
	
		onLoad: function () {
			that = this
			// this.init();
		},
		onPullDownRefresh() {
			that.init()
			setTimeout(function() {
				uni.showToast({
					title: '刷新成功',
					icon: 'none'
				})
				uni.stopPullDownRefresh({
					success: (result) => {},
					fail: (error) => {}
				})
			}, 688)
		},
		methods: {
			init() {
				// 获取奖励金信息
				this.$api.get({
					url: '/bonus/get',
					data: {
						merchid: uni.getStorageSync('merch_info').merch_id
					},
					success: res => {
						console.log(res);
						that.form=res;
					}
				});	
			},
			submit() {
				if(that.form.realprice<=0.1){ //提现金额
					this.$yld.msg('您当前可提现余额小于0.1元,满0.1元以上可提现')
				}
				if(that.form.merch_payinfo.legalname==''){ //收款人姓名
					this.$yld.msg('请填写姓名')
				}
				if(that.form.merch_payinfo.alipayinfo==''){ //支付宝账号
					this.$yld.msg('请先完善支付宝收款账号信息')
				}
				/* getApp().globalData.util.request({
					s: 'Merch.Bonus_Index.submit'
				}).then(res => {
					uni.hideLoading()
					uni.showModal({
						title: '提示',
						content: res.data.data.res_msg,
						showCancel: false,
						success: function (res) {
							that.init()
						}
					})
				}) */
	
			},
			go2Page(page){
				uni.navigateTo({
					url:page
				})
			},
	
			// /methods
		},
	
	}
	
	
</script>

<style lang="scss" scoped>
@import './bonus.scss';</style>
