wxml:

<view class='buy' bindtap='showBuyModal'>立即购买</view>

<!-- 点击立即购买 弹出购买遮罩层 -->
<view class="cover_screen" bindtap="hideBuyModal" wx:if="{{showModalStatus}}"></view> <!-- 点击立即购买 弹窗 -->
<view animation="{{animationData}}" class="buy_box" wx:if="{{showModalStatus}}">
<view class='title'>{{detail.detail.title}} <text style='color:red;'>¥{{detail.price}}</text> </view>
<view class='num'>
<text style='padding-right:40rpx;'>购买数量:</text>
<text class='set'>-</text>
<text class='set'>1</text>
<text class='set'>+</text>
</view>
<button type="primary" bindtap="primary" bindtap='hideBuyModal'> 确定 </button>
</view>

wxss:

.cover_screen {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
opacity: 0.2;
overflow: hidden;
z-index: 1000;
color: #fff;
}
.buy_box {
width: 100%;
box-sizing: border-box;
position: fixed;
bottom: 0;
left: 0;
z-index: 2000;
background: #fff;
padding: 20rpx;
overflow: hidden;
}
.buy_box .title {
font-size: 28rpx;
line-height: 40rpx;
color: #333;
padding: 20rpx 0;
}
.buy_box .num {
font-size: 28rpx;
color: #333;
padding: 40rpx 0;
}
.buy_box .num .set {
display: inline-block;
height: 40rpx;
width: 60rpx;
text-align: center;
line-height: 40rpx;
border:1px solid #444;
margin-right:2rpx;
border-radius:8rpx;
}

js

// pages/detail/detail.js
Page({
data: {
showModalStatus: false
}, onLoad: function (options) {
console.log(options.id)
}, plus () {
let num = this.data.buyNum;
num++;
this.setData({
buyNum: num
})
}, delete () {
let num = this.data.buyNum;
if(num > 1) {
num--;
}
this.setData({
buyNum: num
})
}, showBuyModal () {
// 显示遮罩层
var animation = wx.createAnimation({
duration: 200,
/**
* http://cubic-bezier.com/
* linear 动画一直较为均匀
* ease 从匀速到加速在到匀速
* ease-in 缓慢到匀速
* ease-in-out 从缓慢到匀速再到缓慢
*
* http://www.tuicool.com/articles/neqMVr
* step-start 动画一开始就跳到 100% 直到动画持续时间结束 一闪而过
* step-end 保持 0% 的样式直到动画持续时间结束 一闪而过
*/
timingFunction: "ease",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(), // export 方法每次调用后会清掉之前的动画操作。
showModalStatus: true
})
setTimeout(() => {
animation.translateY(0).step()
this.setData({
animationData: animation.export() // export 方法每次调用后会清掉之前的动画操作。
})
console.log(this)
}, 200)
}, hideBuyModal () {
// 隐藏遮罩层
var animation = wx.createAnimation({
duration: 200,
timingFunction: "ease",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export(),
showModalStatus: false
})
console.log(this)
}.bind(this), 200)
},
})

微信小程序之 动画 —— 自定义底部弹出层的更多相关文章

  1. 微信小程序商品筛选,侧方弹出动画选择页面

    https://blog.csdn.net/qq_36538012/article/details/85110641

  2. 微信小程序 功能函数picker-view的弹出模态

    <view class="list"> <form bindsubmit="formSubmit"> <view class=&q ...

  3. 微信小程序上传文件时弹出当前系统代理不是安全代理,是否信任

    我的开发环境是.net core 启用了https,而微信的开发者工具不认这个证书. 解决办法1:关闭https 然后在 Startup.cs 中关闭注释掉 app.UseHttpsRedirecti ...

  4. .net mvc 站点自带简易SSL加密传输 Word报告自动生成(例如 导出数据库结构) 微信小程序:动画(Animation) SignalR 设计理念(一) ASP.NET -- WebForm -- ViewState ASP.NET -- 一般处理程序ashx 常用到的一些js方法,记录一下 CryptoJS与C#AES加解密互转

    .net mvc 站点自带简易SSL加密传输   因项目需要,传输数据需要加密,因此有了一些经验,现简易抽出来分享! 请求:前端cryptojs用rsa/aes 或 rsa/des加密,后端.net ...

  5. 微信小程序把玩(三)tabBar底部导航

    原文:微信小程序把玩(三)tabBar底部导航 tabBar相对而言用的还是比较多的,但是用起来并没有难,在app.json中配置下tabBar即可,注意tabBar至少需要两个最多五个Item选项 ...

  6. 微信小程序页面调用自定义组件内的事件

    微信小程序页面调用自定义组件内的事件 page page.json { "usingComponents": { "my-component": ". ...

  7. 微信小程序四(设置底部导航)

    好了 小程序的头部标题 设置好了,我们来说说底部导航栏是如何实现的. 我们先来看个效果图 这里,我们添加了三个导航图标,因为我们有三个页面,微信小程序最多能加5个. 那他们是怎么出现怎么着色的呢?两步 ...

  8. 微信小程序Animation动画的使用

    目录 1,前言 2,属性 3,使用 1,前言 和css3动画不同,小程序中动画是主要是通过js控制的,简单来说就是创建一个动画实例animation.调用实例的方法来定义动画效果.最后通过动画实例的e ...

  9. 微信小程序中的自定义组件

    微信小程序中的组件 前言 之前做小程序开发的时候,对于开发来说比较头疼的莫过于自定义组件了,当时官方对这方面的文档也只是寥寥几句,一笔带过而已,所以写起来真的是非常非常痛苦!! 好在微信小程序的库从 ...

随机推荐

  1. Python之密度聚类

    # -*- coding: utf-8 -*- """ Created on Tue Sep 25 10:48:34 2018 @author: zhen "& ...

  2. 树莓派上启动nfs server

    1. nfs 是什么 (略)http://vbird.dic.ksu.edu.tw/linux_server/linux_redhat9/0330nfs.php 2. 安装 nfs-kernel-se ...

  3. 使用 Azure CLI 创建 Windows 虚拟机

    Azure CLI 用于从命令行或脚本创建和管理 Azure 资源. 本指南详细介绍如何使用 Azure CLI 部署运行 Windows Server 2016 的虚拟机. 部署完成后,我们连接到服 ...

  4. 解决VB6.0中不能加载MSCOMCTL.OCX的错误提示

    VB6.0毕竟是很古老的开发工具了,其对所使用的第三方组件依赖性比较强,例如在打开从其它电脑上拿来的VB6.0的软件(系统)的工程文件(源代码)时,经常会遇到"不能加载MSCOMCTL.OC ...

  5. Linux 下Shell的学习3-service编程

    1. vim /etc/init.d/nginx 2. chmod 755 /etc/init.d/nginx 3. service nginx status #!/bin/bash # nginx ...

  6. 【汇编】SI DI 的用法

    一.汇编语言中,为什么SI和DI不能同时使用汇编 其实你可以想一下,这两个寄存器的意思,SI源变址寄存器,DI目地变址寄存器,既然是变址寄存器,那么他们肯定是在某个地址的基础上进行偏移变化,由此我们就 ...

  7. ansible 碎记录

    https://www.zhukun.net/archives/8167 ansible -i new/hosts new -m authorized_key -a "user=root k ...

  8. GitKraken 团队项目使用教程

    前期准备:刚下载好要配置些东西,这些跟着教程走就好了,现在主要是讲团队项目的使用,创建分支 和Fork项目到个人仓库,请参考这篇博客的前两个点 1.将项目克隆到本地 打开GitKraken 点击Fil ...

  9. [python]如何理解uiautomator里面的 child, child_by_text, sibling,及使用场景

    如何理解uiautomator里面的 child, child_by_text, sibling,我们借助android原生的uiautomatorviewer抓取的控件来进行理解 以如下图进行详细讲 ...

  10. IIS 注册Asp.net 4.0

    32位的Windows:---------------------------------------------------------------------------1. 运行->cmd ...