var app = getapp();
page({
  data: {
    userinfo: {},
    src: '',
    coverimg:{
      hidden: false,
      top: 0, //上面图片的top值
      bottom: 0, //下面图片的bottom值
      locked: false //首页展开触摸锁定
    },
    openpage: app.globaldata.openpage==1?true:false
  },
  resetcoverimg: function() {
    this.setdata({
      coverimg:{
        hidden: false,
        top: '0',
        bottom: '0'
      }
    })
  },
  bindopentap: function () {
    var that = this;
    if(!that.data.coverimg.locked){
      that.setdata({coverimg:{locked: true}});
      var dis = 0;
      var timer = setinterval(function(){
          dis -= 1;
          that.setdata({
            coverimg:{
              top: dis+'%',
              bottom: dis+'%'
            }
          })
        },10);
        settimeout(function(){
          clearinterval(timer);
          //展开首页图
          that.setdata({
            coverimg:{
              hidden: true,
              locked: false
            }
          })
          //未展示开屏页直接跳转
          if(that.data.openpage){
            that.gotoopenpage();
          }else{
            that.gotolistpage();
          }
        },500);
    }
  },
  gotolistpage: function() {
    wx.navigateto({
      url: '../list/list'
    })
  },
  gotoopenpage: function() {
    wx.navigateto({
      url: '../open/open'
    })
  },
  //分享
  onshareappmessage: function() {
      app.updateuserinfo({'type':0});
      return {
          title: '优惠猎手pro',
          desc: '优惠猎手pro',
          path: 'pages/index/index'
      }
  },
  onshow: function() {
      this.resetcoverimg();
  }
})
以上就是微信小程序学习用demo:简易图片动画红包代码的详细内容。
   
 
   