const $ = global;

new $.Page({
    onLoad() {

    },
    toPay() {
        $.wx.showToast({
            title: '加载中'
        }, 'loading');
        $.request('reward', 'POST', {}).then((res) => {
            const {
                timestamp,
                paySign,
                nonceStr,
                signType
            } = res.msg;
            const pck = res.msg.package;
            wx.requestPayment({
                timeStamp: timestamp + '',
                nonceStr,
                package: pck,
                signType,
                paySign,
                success(res) {
                    $.wx.showToast({
                        title: '多谢打赏！'
                    });
                },
                fail() {
                    $.wx.showToast({
                        title: '打赏失败'
                    });
                }
            });
        });
    }
});