// pages/user/region/region.js
import * as UTIL from '../../../utils/util.js';
import * as EVN_CONFIG from '../../../env/env.js';
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isIPX: app.globalData.isIPX,
    activeNames: ['1'],
    nowDress:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    
  },
  onChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },
  back:function(){
    wx.navigateBack({
      delta: 1
    })
  },
  getLocation(){
    // var location =   UTIL.getLocationFromWX();
    console.log(app.globalData.setInfo.latitude);
  },
  goChangeUrl(e){
    // https://192.168.0.112:8080/api e.currentTarget.dataset.url
    const url = e.currentTarget.dataset.url; //e.currentTarget.dataset.url;
    const name = e.currentTarget.dataset.name;
    const parentname = e.currentTarget.dataset.parentname;
    wx.setStorageSync('dressCode', url);//'http://116.255.223.226:8082/nsgk_test'
    wx.setStorageSync('dressName', parentname+'-'+name);
    getApp().globalData.APIURL = url
    wx.reLaunch({
      url: '../login/login',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var that = this ;
    let url = 'https://www.nongshen.net/static/wechat/area.json';
    wx.request({
      url: url, //接口地址
      data:{
        date:new Date().getTime()
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success (res) {
        console.log(res);
        that.setData({
          list : res.data,
          nowDress: wx.getStorageSync('dressName')
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})