boost.js 1.64 KB
// components/tips/boost.js
const cacheKey='A2L-INDEX'
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },
  lifetimes: {
    attached: function() {
      this.show()
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    disp:false,
    animation:'',
    background:[{
      url:'http://nosqn.colorcun.com/boots/1.png',
      txt:'1.戳选地图上的商家,开始预订',
    },{
      url:'http://nosqn.colorcun.com/boots/3.png',
      txt:'2.搜索商家或位置,开始预订',
    }],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    show(){
      wx.getStorage({
        key:cacheKey,
        fail:()=>{
          this.setData({
            disp:true,
          })
          setTimeout(()=>{
            this.setData({
              animation:'discountShow',
            })
          },300)
          this.triggerEvent('event',{act:'show',txt:'新用户'})
          //wx.setStorage({key:cacheKey, data:new Date().toISOString()})
        },
        success:()=>{
          this.triggerEvent('event',{act:'hide',txt:'老用户'})
        },
      })
    },
    hide(){
      this.setData({
        animation:'discountHide',
      })
      this.triggerEvent('event',{act:'hide',txt:'新用户'})
      setTimeout(()=>{
        this.setData({
          disp:false,
        })
      },300)
    },
    hasGoto:false,
    bindtransition(e){
      console.log(e)
      if('change'==e.type){
        this.hasGoto=false
      }
      if('animationfinish'==e.type){
        if(this.hasGoto && (e.detail.current+1)==2){
          this.hide()
          return;
        }else{
          this.hasGoto=true
        }
      }
    },
  }
})