微信小程序 自定义对话框实例详解


Posted in Javascript onJanuary 20, 2017

微信小程序 自定义对话框实例详解

效果图:

微信小程序 自定义对话框实例详解

index.wxml:

<button type="default" bindtap="clickbtn"> 
 点击 
</button> 
<view class="commodity_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view> 
<view animation="{{animationData}}" class="commodity_attr_box" wx:if="{{showModalStatus}}"> 
<!--对话框标题--> 
<view class="dialog-title"> 
 请输入内容 
</view> 
<!--对话框输入部分--> 
<view class="input-view"> 
 <input type="text" bindblur="input_content" class="input-style"/> 
</view> 
<!--对话框按钮--> 
<view class="line-top">  
</view> 
<view class="btn-view"> 
 <view class="btn-cancel" bindtap="click_cancel">  
     取 消 
 </view> 
 <view class="btn-line"> 
 </view> 
 <view class="btn-cancel" bindtap="click_ok">  
     确 定 
 </view> 
</view> 
</view>

index.js:

var inputinfo = ""; 
var app = getApp() 
Page({ 
 data: { 
  animationData:"", 
  showModalStatus:false 
 }, 
  
 onLoad: function () { 
   
 }, 
 showModal: function () { 
  // 显示遮罩层 
  var animation = wx.createAnimation({ 
   duration: 200, 
   timingFunction: "linear", 
   delay: 0 
  }) 
  this.animation = animation 
  animation.translateY(300).step() 
  this.setData({ 
   animationData: animation.export(), 
   showModalStatus: true 
  }) 
  setTimeout(function () { 
   animation.translateY(0).step() 
   this.setData({ 
    animationData: animation.export() 
   }) 
  }.bind(this), 200) 
 }, 
 clickbtn:function(){ 
  if(this.data.showModalStatus){ 
   this.hideModal(); 
  }else{ 
   this.showModal(); 
  } 
 }, 
 hideModal: function () { 
  // 隐藏遮罩层 
  var animation = wx.createAnimation({ 
   duration: 200, 
   timingFunction: "linear", 
   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 
   }) 
  }.bind(this), 200) 
 }, 
 click_cancel:function(){ 
  console.log("点击取消"); 
   this.hideModal(); 
 }, 
 click_ok:function(){ 
  console.log("点击了确定===,输入的信息为为==",inputinfo); 
   this.hideModal(); 
 }, 
 input_content:function(e){ 
  console.log(e); 
  inputinfo = e.detail.value;  
 } 
 
})

源码下载:http://xiazai.3water.com/201701/yuanma/modalTest(3water.com).rar

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

Javascript 相关文章推荐
javascript对talbe进行动态添加、删除、验证实现代码
Mar 29 Javascript
jquery插件jSignature实现手动签名
May 04 Javascript
JS中call/apply、arguments、undefined/null方法详解
Feb 15 Javascript
ionic实现带字的toggle滑动组件
Aug 27 Javascript
JavaScript实现自动切换图片代码
Oct 11 Javascript
JavaScript构建自己的对象示例
Nov 29 Javascript
jquery图片放大镜效果
Jun 23 jQuery
js判断文件类型大小并给出提示的实现方法
Jan 03 Javascript
Angular6中使用Swiper的方法示例
Jul 09 Javascript
JS实现数组的增删改查操作示例
Aug 29 Javascript
我所理解的JavaScript中的this指向
Sep 04 Javascript
vue使用wavesurfer.js解决音频可视化播放问题
Apr 04 Vue.js
Vue实例简单方法介绍
Jan 20 #Javascript
微信小程序 Toast自定义实例详解
Jan 20 #Javascript
JavaScript判断浏览器及其版本信息
Jan 20 #Javascript
JS中传递参数的几种不同方法比较
Jan 20 #Javascript
JS出现失效的情况总结
Jan 20 #Javascript
JSON 数据详解及实例代码分析
Jan 20 #Javascript
Angular ui.bootstrap.pagination分页
Jan 20 #Javascript
You might like
php继承的一个应用
2011/09/06 PHP
使用PHP生成图片的缩略图的方法
2015/08/18 PHP
PHP实现的mysql主从数据库状态检测功能示例
2017/07/20 PHP
jQuery 使用手册(六)
2009/09/23 Javascript
解决Extjs4中form表单提交后无法进入success函数问题
2013/11/26 Javascript
JS实现把鼠标放到链接上出现滚动文字的方法
2016/04/06 Javascript
Node.js服务器环境下使用Mock.js拦截AJAX请求的教程
2016/05/23 Javascript
Angularjs 设置全局变量的方法总结
2016/10/20 Javascript
JavaScript页面实时显示当前时间实例代码
2016/10/23 Javascript
原生ajax处理json格式数据的实例代码
2016/12/25 Javascript
Bootstrap 手风琴菜单的实现代码
2017/01/20 Javascript
js控制按钮,防止频繁点击响应的实例
2017/02/15 Javascript
nodejs multer实现文件上传与下载
2017/05/10 NodeJs
vue实现组件之间传值功能示例
2018/07/13 Javascript
Vue的watch和computed方法的使用及区别介绍
2018/09/06 Javascript
js设计模式之单例模式原理与用法详解
2019/08/15 Javascript
详解Vue串联过滤器的使用场景
2020/04/30 Javascript
Nodejs环境实现socket通信过程解析
2020/07/03 NodeJs
[01:01:24]DOTA2上海特级锦标赛A组败者赛 EHOME VS CDEC第三局
2016/02/25 DOTA
python 实现堆排序算法代码
2012/06/05 Python
linux环境下安装pyramid和新建项目的步骤
2013/11/27 Python
Python Tkinter基础控件用法
2014/09/03 Python
使用Python程序抓取新浪在国内的所有IP的教程
2015/05/04 Python
Python爬虫实例扒取2345天气预报
2018/03/04 Python
python顺序执行多个py文件的方法
2019/06/29 Python
python标准库OS模块详解
2020/03/10 Python
使用Keras画神经网络准确性图教程
2020/06/15 Python
加拿大在线眼镜零售商:SmartBuyGlasses加拿大
2019/05/25 全球购物
乌克兰电子和家用电器商店:Foxtrot
2019/07/23 全球购物
荷兰美妆护肤品海淘网站:Beautinow(中文)
2020/11/22 全球购物
JSF界面控制层技术
2013/06/17 面试题
新学期校长寄语
2014/01/18 职场文书
经典搞笑版检讨书
2015/02/19 职场文书
2015双创工作总结
2015/07/24 职场文书
个人道歉信大全
2019/04/11 职场文书
2019年特色火锅店的创业计划书模板
2019/08/28 职场文书