import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
module.exports={ 
  //是否登录
  isLogin:(data)=>{
    var token = wx.getStorageSync('token')
    if(token){
      return true
    }
    
    wx.showModal({
      title: '提示',
      content: '您未登录，请先登录',
      complete: (res) => {
        if (res.cancel) {
          
        }
    
        if (res.confirm) {
          wx.navigateTo({
            url: '/pages/login/login',
          })
        }
      }
    })
    return false
  },
  //提示
  notify:(obj)=>{
    Notify(obj)
  },
  /**
   * 节流
   * @param {Function} func 
   * @param {Number} delay 
   * @returns 
   */
  throttle:(func, delay = 2000)=> {
    let flag = true
    return () => {
      if (!flag) return;
      flag = false;
      setTimeout(() => {
        func()
        flag = true
      }, delay)
    }
  }
 }
