// pages/all/index.js
import {getOpenidData} from '../../utils/getUserInfo.js'
import {getCityTree} from '../../api/feeddback.js'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // 列表数据筛选条件
        params: {
            name: ''
        },
        name: '',
        list: [],
        current: "/stream/index",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getTabBar().setData({
            selected: 1
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        
    },

    /* 输入河流名称搜索 */
    search(e) {
        let params = this.data.params
        params.name = this.data.name
        this.setData({ params: params })
    },

    /* 更新数据 */
    updateList(e) {
        let list = this.data.list.concat(e.detail || [])
        this.setData({ list })
    },
    /* 重置数据 */
    resetList() {
        this.setData({ list: [] })
    },

    /* 跳转上报问题页面 */
    uploadProblem(e) {
        let detail = e.currentTarget.dataset.detail
        let openid = wx.getStorageSync('openid')
        if(openid) {
            wx.navigateTo({
                url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
              })
        } else {
            getOpenidData().then(res=> {
                wx.navigateTo({
                  url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
                })
            })
        }
    },
    // /* 跳转至筛选页 */
    // goSelectLocation(e) {
    //     const path = '/pages/all/index'
    //     wx.redirectTo({
    //       url: `/pages/login/login?path=${path}`,
    //     })
    // },
    /* 跳转至详情页 */
    showDetail(e) {
        let data = e.currentTarget.dataset.item
        wx.navigateTo({
          url: '/package_A/pages/riverDetail/index?data='+ JSON.stringify(data),
        })
    }
})