<template>
  <div class="container">
    <span style="font-size : small;display: inline-block;">{{$t('confirmOrder.confirmPaying')}}</span>
    <vue-loading type="spin" color="#333" :size="{ width: '50px', height: '50px' }"></vue-loading>
  </div>
</template>

<script>
import { VueLoading } from 'vue-loading-template'
import { confirm } from "@/api/comp/home.js";
import {
  getInfo
} from '@/api/login'
export default {
    data() {
        return {
            loading: true,
            requestUrl: process.env.VUE_APP_BASE_API,
            submitType:false,
        };
    },
    mounted() {
        this.confirm();
    },
    methods: {
        confirm: function () {
            let require = {
                transactionId:this.$route.query.transactionId,
                orderId:this.$route.query.orderId,
            };
            confirm(require).then((res) => {
                if (res.code == 200) {
                    getInfo().then((res1) => {
                        if (res1.code == 200) {
                            let userInfo = Object.assign(
                                {},
                                this.$store.state.user.userInfo
                            );
                            console.log(userInfo,1)
                            userInfo.integral = res1.data.integral;
                            this.$store.commit("user/SET_USERINFO", userInfo);
                            console.log(userInfo,2)
                            this.$toast({
                                type: "success",
                                message: res.msg,
                            });
                            console.log(res);
                            this.$router.push({
                                path: "/toBePaid",
                                query: { type: 2 },
                            });
                        }
                    });
                }
            });
        },
    },
    components: {
        VueLoading,
    },
};
</script>
