<template>
    <view class="">
        <view class="bg-white mx32 box">
            <view class="mt20 px20">
                <input class="p20 border-tb" name="alipay_name" type="text" v-model="form.gmfnsrsbh" placeholder-class="grary" placeholder="请输入税号" />
            </view>      
            <view class="mt20 px20">
                <input class="p20 border-tb" name="alipay_name" type="text" v-model="form.gmfmc" placeholder-class="grary" placeholder="请输入抬头" />
            </view>      
            <view class="mt20 px20">
                <input class="p20 border-tb" name="alipay_name" type="text" v-model="form.emials" placeholder-class="grary" placeholder="请输入邮箱" />
            </view>
        </view>

        <view class="w-full d-c-c mt100 mb50">
            <view class="again-btn" @click="submit">提交</view>
        </view>
    </view>
   
</template>
<script>
    export default {
        data() {
            return {
                order_id: 0,
                form: {
                    gmfnsrsbh: '',
                    gmfmc: '',
                    emials: '',
                }
            };
        },
        onLoad(args) {
            this.order_id = args.order_id;
            console.log('order_id', this.order_id);
        },
        methods: {
            submit() {
                if (!this.form.gmfnsrsbh) {
                    uni.showToast({
                        title: '请输入税号',
                        icon: 'none'
                    });
                    return;
                }

                if (!this.form.gmfmc) {
                    uni.showToast({
                        title: '请输入抬头',
                        icon: 'none'
                    });
                    return;
                }

                if (!this.form.emials) {
                    uni.showToast({
                        title: '请输入邮箱',
                        icon: 'none'
                    });
                    return;
                }

                uni.showLoading({
					title: '正在处理'
				});
                let self = this;
				self._post(
					'invoice.invoice/getInvoice',
					{
						order_id: self.order_id,
                        emails: self.form.emials,
                        gmfmc: self.form.gmfmc,
                        gmfnsrsbh: self.form.gmfnsrsbh
					},
					function(res) {
						uni.hideLoading();
                        setTimeout(() => {
                            uni.showToast({
                                title: '开票成功',
                                duration: 2000,
                                icon: 'success'
                            });
                        }, 800)
				
                        uni.navigateBack();
					}
				);
            }
        }
    };
</script>

<style lang="scss">
    .box {
        margin-top: 32rpx;
        border-radius: 16rpx;
    }

    .mx32 {
        margin-left: 32rpx;
        margin-right: 32rpx;
    }

    .mt100 {
        margin-top: 100rpx;
    }

    .px20 {
        padding-left: 20rpx;
        padding-right: 20rpx;
    }

    .again-btn {
        width: 630rpx;
        height: 90rpx;
        text-align: center;
        line-height: 90rpx;
        background: #365A9A;
        border-radius: 8rpx;
        font-size: 32rpx;
        color: #FFFFFF;
    }

</style>