小程序如何写个10秒倒计时然后d出提示框

小程序如何写个10秒倒计时然后d出提示框,第1张

1、首先打开小程序开发工具新建一个小程序。

2、接着编写wxml中的倒计时页面样式,如下图所示。

3、然后定义倒计时需要用到的变量,如下图所示,其中结束时间大多数都是从后台获取的。

4、接着编写倒计时函数,如下图所示,这里主要用到了定时器的功能,如下图所示。

5、接下来在需要调用的地方调用倒计时函数即可,一般都是在结束时间获得以后调用。

6、最后就可以看到页面中出现了倒计时效果了,如下图所示。

 <button bindtap="powerDrawer" type="primary" size="mini" style="width: 55%;" data-statu="open">中奖记录</button>  

<!-- 中间名单d窗 -->

<view class="drawer_div">

  <view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view>

    <view animation="{{animationPrize}}" class="drawer_box" wx:if="{{showModalStatus}}">

      <view class="drawer_title">

        中奖记录

        <image src="/img/x@2xpng" bindtap="powerDrawer" data-statu="close"></image>

      </view>

      <view class="drawer_content">

        <view class="top grid">

          <text>

            名称:啦啦啦啦啦啦啦啦

          </text>

          <text>

            时间:2020-02-20

          </text>

        </view>

        <view class="top grid">

          <text>

            名称:啦啦啦啦啦啦啦啦

          </text>

          <text>

            时间:2020-02-20

          </text>

        </view>

    </view>

  </view>

</view>

drawer_screen {

  width: 100%;

  height: 100%;

  position: fixed;

  top: 0;

  left: 0;

  z-index: 1000;

  background: #000;

  opacity: 05;

  overflow: hidden;

}

/content/

drawer_box {

  width: 650rpx;

  overflow: hidden;

  position: fixed;

  top: 50%;

  left: 0;

  z-index: 1001;

  background: #FAFAFA;

  margin: -150px 50rpx 0 50rpx;

  border-radius: 3px;

}

drawer_title{

  padding:30rpx 20rpx;

  font-size: 36rpx;

  text-align: center;

  position: relative;

}

drawer_title image{

  display: inline-block;

  width: 30rpx;

  height: 30rpx;

  position: absolute;

  right: 9px;

  top: 10px;

}

drawer_content {

  height: 210px;

  overflow-y: scroll; /超出父盒子高度可滚动/

  padding: 0 20rpx;

}

top{

  display: flex;

  justify-content: space-between;

  border-bottom: 1px dashed #ccc;

}

top text{

  display: inline-block;

  height: 60rpx;

  line-height: 20rpx;

}

data: {

animationPrize: {},

}

powerDrawer: function (e) {

    // consolelog(e);

    let currentStatu = ecurrentTargetdatasetstatu;

    thisutil(currentStatu);

  },

  util: function (currentStatu) {

    / 动画部分 /

    // 第1步:创建动画实例

    var animation = wxcreateAnimation({

      duration: 200,  //动画时长

      timingFunction: "linear", //线性

      delay: 0  //0则不延迟

    });

    // 第2步:这个动画实例赋给当前的动画实例

    thisanimation = animation;

    // 第3步:执行第一组动画

    animationopacity(0)rotateX(-100)step();

    // 第4步:导出动画对象赋给数据对象储存

    thissetData({

      animationPrize: animationexport()

    })

    // 第5步:设置定时器到指定时候后,执行第二组动画

    setTimeout(function () {

      // 执行第二组动画

      animationopacity(1)rotateX(0)step();

      // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象

      thissetData({

        animationPrize: animation

      })

      //关闭

      if (currentStatu == "close") {

        thissetData({

          showModalStatus: false

        });

      }

    }bind(this), 200)

    // 显示

    if (currentStatu == "open") {

      thissetData({

        showModalStatus: true

      });

    }

  },

网上看新闻,会有小程序跳转到微信里面的原因是:

1、微信程序出错,可以退出微信之后再打开或者,关机重启之后再打开微信。

2、微信运行程序与其他软件有冲突,可以关闭其他软件之后再登录微信。

3、微信版本较低或运行程序已经损坏,可以卸载这个微信再重新下载新的微信安装包进行安装。

以上就是关于小程序如何写个10秒倒计时然后d出提示框全部的内容,包括:小程序如何写个10秒倒计时然后d出提示框、微信小程序 自定义d窗、我用浏览器打开小程序,为什么会d窗微信等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9288473.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-26
下一篇2023-04-26

发表评论

登录后才能评论

评论列表(0条)

    保存