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. LeetCode题解之 Longest Common Prefix

    1.题目描述 2.问题分析 直接使用循环解决问题 3.代码 string longestCommonPrefix(vector<string>& strs) { string re ...

  2. 解决Elasticsearch问题的一些心得体会

    在开始前先来介绍下背景:我的日志采集系统采用ELK(logstash(收集).elasticsearch(存储+搜索).kibana(展示)三个软件的简称)开源架构,在elasticsearch搭建了 ...

  3. Coursera-AndrewNg(吴恩达)机器学习笔记——第四周编程作业(多分类与神经网络)

    多分类问题——识别手写体数字0-9 一.逻辑回归解决多分类问题 1.图片像素为20*20,X的属性数目为400,输出层神经元个数为10,分别代表1-10(把0映射为10). 通过以下代码先形式化展示数 ...

  4. 在eclipse中方便的比较各个语言 资源文件—jinto的安装

    一.下载与安装jinto Eclipse插件的插件,用来解决资源文件的国际化问题 用jinto编辑器打开properties文件后,就可以方便的建立出各国和各种语言的资源文件,同时可以方便的对比书写各 ...

  5. pip安装python模块遇到一直出现retrying的问题

    最近安装python模块,遇到这样的一个问题如图所示: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status= ...

  6. 9.算法之顺序、二分、hash查找

    一.查找/搜索 - 我们现在把注意力转向计算中经常出现的一些问题,即搜索或查找的问题.搜索是在元素集合中查找特定元素的算法过程.搜索通常对于元素是否存在返回 True 或 False.有时它可能返回元 ...

  7. 8.4Solr API使用(Result Grouping分组查询)

    转载请出自出处:http://eksliang.iteye.com/blog/2169458 一.概述 分组统计查询不同于分组统计(Facet),facet只是简单统计记录数,并不能为每组数据返回实际 ...

  8. CentOs7 编译安装PHP7.1.5

    1 创建php用户和用户组,并在github下载php7源码 #######新建php用户和php组 [root@typecodes ~]# groupadd -r www && us ...

  9. windows下mysql和linux下mysql主从配置

    1. linux下mysql安装版本5.6   windows下mysql版本5.7  不要问我为什么版本不一致  就是想这么搞 2. linux为主服务器   windows为从服务器 3.找到li ...

  10. Vue入门1

    欢迎转载,转载请注明出处. 前言 学习本系列Vue知识,需要结合本系列的一些demo.你可以查看我的 Github 或者直接下载 ZIP包 . 建议学习本系列之前已经会一个其他的前端框架,了解计算属性 ...