import {
    getWxQrcode,
} from '~/api/user'
const app = getApp()

Component({
    properties: {},
    data: {
        show: false,
        isIos: app.globalData.isIOS,
        qrCode: '',
    },
    methods: {
        async open() {
            if (!this.data.isIos) {
                wx.navigateTo({
                    url: '/pages/commodity/index',
                })
            } else {
                let qrCode = await getWxQrcode()
                this.setData({
                    qrCode: qrCode.ticketUrl
                })
                console.log(typeof this.getTabBar === 'function' &&
                    this.getTabBar());
                if (typeof this.getTabBar === 'function' &&
                    this.getTabBar()) {
                    this.getTabBar().setData({
                        mask: true
                    })
                }
                this.setData({
                    show: true,
                })
            }
        },
        closeModal() {
            this.setData({
                show: false
            })
            if (typeof this.getTabBar === 'function' &&
                this.getTabBar()) {
                this.getTabBar().setData({
                    mask: false
                })
            }
        },
    }
})