Vue.config.devtools = true;
var v = new Vue({
    el: ".wizardmain",

    data: {
        memToken: 'H5_HQ2RRR.Vw87oBWZqtYDg_waofbMfkjDtc5BorX21pXNw7R5_wY3ogXZaJZ8Gzom9wy5p2oi_K98hI.NdPAKBJA%3D%3D',
        memCard: 'bf524aec007f4f58b8835c211f846269',
        timer: null,
        timerNumber: null, // 跳转时间定时器
        ifSuccess: false, // 是否支付成功
        number: 5, // 跳转时间
    },
    created: function () {

    },
    mounted: function () {
        // 每个3秒调用后台方法，查看订单是否已经支付成功
        var that = this
        that.timer = setInterval(that.checkPayResult, 3000);
    },
    destroy: function () {
        console.log('销毁')
        clearInterval(this.timerNumber);
        clearInterval(that.timer);
    },
    methods: {
        // 查询是否支付成功
        checkPayResult() {
            var that = this
            console.log('定时查询')
            $.get("/weixin/queryPayStatus?orderNo=" + out_trade_no, function (data) {
                console.log(data);
                if (data.data == '支付成功') {
                    that.ifSuccess = true
                    //支付成功 清除定时器
                    clearInterval(that.timer);
                    that.timerNumber = setInterval(function () {

                        if (that.number == 0) {
                            window.location.href = "/weixin/payFinish?out_trade_no=" + out_trade_no;
                        } else {
                            that.number--;
                        }
                    }, 1000);
                }
                // if (data.code == false) {
                //     alert("支付失败")
                // }
            });
        },
        // 返回
        back(){
            window.location.href = "/weixin/payFinish?out_trade_no=" + out_trade_no;
        },
        // 查看订单
        lookOrder(){
            window.location.href = "/user/buyRecord"
        },
    }
})