weex splash页面

本文介绍了一个使用Vue实现的Splash页面案例,通过动画模块控制页面中Logo及圆形图案的旋转与缩放,最终触发页面跳转至登录页。文章详细展示了Vue组件的结构、样式与交互逻辑。

1.Splash.vue

<!-- splash页面 -->
<template>
  <div class="wrap" @focus="rotate" @load="rotate">
    <!-- logo图标 -->
    <div class="logo_wrap">
      <image class="img_logo" :src="splash_logo" @click="rotate" />
    </div>
    <!-- 旋转动画 -->
    <div id="animation" style="transform-origin:center center" ref="anim">
      <image class="img_circle" @focus="rotate" :src="splash_circle" @click="rotate" />
    </div>
  </div>
</template>

<style scoped>
  .wrap{
    align-items: center;
    justify-content: center;
    background-color: #000;
  }
  /*logo图标*/
  .logo_wrap {
    width: 300px;
    height:300px;
  }
  .img_logo {
    width: 300px;
    height:300px;
  }
  /*旋转图标*/
  .img_circle {
    width: 400px;
    height:400px;
    align-items: center;
    justify-content: center;
  }
</style>

<script>
  // 动画模块
  const animation = weex.requireModule('animation');
  // 弹窗
  const modal = weex.requireModule('modal');

  export default {
    data() {
      return {
        splash_circle:'//duqian291902259.github.io/dusan/oair/splash_circle.png',
        splash_logo:'//gw.alicdn.com/tps/i2/TB1DpsmMpXXXXabaXXX20ySQVXX-512-512.png_400x400.jpg',
        current_rotate: 0,
        current_scale: 1
      }
    },
    mounted() {
       this.rotate();
    },
    methods: {
      goSite() {
        // 页面跳转
        this.$router.push({path:'/login'});
      },
      // 动画
      anim(styles, timingFunction, duration, callback) {
        var anim = this.$refs.anim;
        // 动画效果
        animation.transition(anim, {
          styles: styles,
          duration: duration, //ms
          timingFunction: timingFunction,
          needLayout:false,
          delay: 0 //ms
        }, callback);
      },
      // 旋转
      rotate() {
        var self = this;
        self.current_rotate += 30;
        self.anim({
          transform: 'rotate(' + self.current_rotate + 'deg)'
        }, 'ease-in-out', 100, function() {
          if (self.current_rotate === 360) {
            self.current_rotate = 0;
            // 页面跳转
            self.goSite();
          }else if (self.current_rotate === 180){
            self.scale();
          }else{
            self.rotate();
          }
        });
      },
      // 缩放
      scale() {
        var self = this;
        self.current_scale = 0.3;
        self.anim({
          transform: 'scale(' + self.current_scale + ')'
        }, 'linear', 500, function() {
            self.current_scale =1;
            // 调用旋转
            self.rotate();
        });
      }
    }
  };
</script>

2.效果图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值