class ToPayOpre {
    toPay(info, callback) {
        var that = this;
        uni.requestPayment({
            ...info,
            success: function (res) {
                that.payReturn(false, callback);
            },
            fail: function (res) {
                that.payReturn(true, callback);
            }
        })
    }
    payReturn(isFail, callback) {
        uni.hideLoading();
        if (isFail) {
            // 支付失败
            uni.showToast({ title: "支付失败", duration: 3000, icon: "none" });
        } else {
            // 支付成功
            uni.showToast({ title: '支付成功', duration: 2000, icon: 'success' })
        }
        
        if (callback) {
            callback(isFail);
        }
    }
}

export { ToPayOpre }