let app = getApp()
Page({
    data: {
        currentTab: 0
    },

    onLoad(options) {
        // 页面初始化 options为页面跳转所带来的参数
        wx.setNavigationBarTitle({
            title: options.name
        })
    },

    onShow() {
        this.getList()
    },

    getList(status) {
        let that = this
        let url = ''
        if (that.data.currentTab == 0) {
            url = '/suggestion/list'
        } else if (that.data.currentTab == 1) {
            url = '/suggestion/list?status=1'
        } else if (that.data.currentTab == 2) {
            url = '/suggestion/list?status=2'
        } else if (that.data.currentTab == 3) {
            url = '/suggestion/list?status=3'
        }
        app.AjaxRequest('GET', {
            'content-type': 'application/json',
            'Authorization': 'Bearer ' + app.Getopenid()
        }, url, {}, function (res) {
            if (res.code == 0) {
                that.setData({
                    list: res.data
                })
            }
        })
    },

    //滑动切换
    swiperTab(e) {
        var that = this
        that.setData({
            currentTab: e.detail.current
        })
        that.getList()
    },

    //点击切换
    clickTab(e) {
        var that = this
        if (this.data.currentTab === e.target.dataset.current) {
            return false
        } else {
            that.setData({
                currentTab: e.target.dataset.current
            })
        }
    },

    scrollToLower() {

    },

    create() {
        wx.navigateTo({
            url: '/pages/complaint/newComplaint/newComplaint',
        })
    },

    repairDetail(e) {
        wx.navigateTo({
            url: '/pages/complaint/complaintDetail/complaintDetail?id=' + e.currentTarget.dataset.id,
        })
    }
})