MUI中等待框的H5实现
MUI没有内置的那个弹出转圈圈的那个等待框,那个nativeui.showwaiting是只能用于app中的,不能用在H5网页中的,网上找了下,找到个别人已经写好的,自己 测试了下没问题,先记下来
@{
Layout = null;
Niunan.GRWX.Model.Product product = ViewBag.product;
Niunan.GRWX.Model.Userinfo user = ViewBag.user;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>兑换礼品</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link href="/content/css/mui.min.css" rel="stylesheet" />
<link href="/content/css/theone.css" rel="stylesheet" />
<style>
html,
body {
background-color: #efeff4;
}
.title {
padding: 20px 15px 10px;
color: #6d6d72;
font-size: 15px;
background-color: #fff;
}
</style>
<style>
/*----------------mui.showLoading---------------*/
.mui-show-loading {
position: fixed;
padding: 5px;
width: 120px;
min-height: 120px;
top: 45%;
left: 50%;
margin-left: -60px;
background: rgba(0, 0, 0, 0.6);
text-align: center;
border-radius: 5px;
color: #FFFFFF;
visibility: hidden;
margin: 0;
z-index: 2000;
-webkit-transition-duration: .2s;
transition-duration: .2s;
opacity: 0;
-webkit-transform: scale(0.9) translate(-50%, -50%);
transform: scale(0.9) translate(-50%, -50%);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.mui-show-loading.loading-visible {
opacity: 1;
visibility: visible;
-webkit-transform: scale(1) translate(-50%, -50%);
transform: scale(1) translate(-50%, -50%);
}
.mui-show-loading .mui-spinner {
margin-top: 24px;
width: 36px;
height: 36px;
}
.mui-show-loading .text {
line-height: 1.6;
font-family: -apple-system-font,"Helvetica Neue",sans-serif;
font-size: 14px;
margin: 10px 0 0;
color: #fff;
}
.mui-show-loading-mask {
position: fixed;
z-index: 1000;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.mui-show-loading-mask-hidden {
display: none !important;
}
</style>
</head>
<body>
<div class="mui-content user-password user-addcard">
<form class="mui-input-group" style="margin-top: 0;">
<div class="mui-input-row">
<label>礼品名称</label>
<span style="line-height:38px;">@product.proname</span>
</div>
<div class="mui-input-row">
<label>用户名</label>
<span style="line-height:38px;">@user.username</span>
</div>
<div class="mui-input-row">
<label>手机</label>
<input type="text" class="mui-input-clear" id="mobile" name="mobile" value="@user.mobile" />
</div>
<div class="mui-input-row">
<label>收货地址</label>
<input type="text" class="mui-input-clear" id="address" name="address" value="@user.address" />
</div>
<div class="enterbtn-wr">
<button type="button" class="mui-btn mui-btn-danger enterbtn" id="btn1">兑换礼品</button>
@Html.AntiForgeryToken()
<input type="hidden" id="proid" value="@product.id" />
<input type="hidden" id="userid" value="@user.id" />
</div>
</form>
</div>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/mui.min.js"></script>
<script>
//扩展mui.showLoading http://ask.dcloud.net.cn/article/12856?item_id=12464
(function ($, window) {
//显示加载框
$.showLoading = function (message, type) {
if ($.os.plus && type !== 'div') {
$.plusReady(function () {
plus.nativeUI.showWaiting(message);
});
} else {
var html = '';
html += '<i class="mui-spinner mui-spinner-white"></i>';
html += '<p class="text">' + (message || "数据加载中") + '</p>';
//遮罩层
var mask = document.getElementsByClassName("mui-show-loading-mask");
if (mask.length == 0) {
mask = document.createElement('div');
mask.classList.add("mui-show-loading-mask");
document.body.appendChild(mask);
mask.addEventListener("touchmove", function (e) { e.stopPropagation(); e.preventDefault(); });
} else {
mask[0].classList.remove("mui-show-loading-mask-hidden");
}
//加载框
var toast = document.getElementsByClassName("mui-show-loading");
if (toast.length == 0) {
toast = document.createElement('div');
toast.classList.add("mui-show-loading");
toast.classList.add('loading-visible');
document.body.appendChild(toast);
toast.innerHTML = html;
toast.addEventListener("touchmove", function (e) { e.stopPropagation(); e.preventDefault(); });
} else {
toast[0].innerHTML = html;
toast[0].classList.add("loading-visible");
}
}
};
//隐藏加载框
$.hideLoading = function (callback) {
if ($.os.plus) {
$.plusReady(function () {
plus.nativeUI.closeWaiting();
});
}
var mask = document.getElementsByClassName("mui-show-loading-mask");
var toast = document.getElementsByClassName("mui-show-loading");
if (mask.length > 0) {
mask[0].classList.add("mui-show-loading-mask-hidden");
}
if (toast.length > 0) {
toast[0].classList.remove("loading-visible");
callback && callback();
}
}
})(mui, window);
</script>
<script>
document.getElementById('btn1').addEventListener('tap', function () {
var userid = document.getElementById('userid').value;
var proid = document.getElementById('proid').value;
var mobile = document.getElementById('mobile').value;
var zipcode = '';
var address = document.getElementById('address').value;
var __RequestVerificationToken = document.getElementsByName('__RequestVerificationToken')[0].value;
var postdata = { userid: userid, proid: proid, mobile: mobile, zipcode: zipcode, address: address, __RequestVerificationToken: __RequestVerificationToken };
console.log(postdata);
var url = "/order/add";
mui.showLoading("正在提交..", "div");
mui.post(url, postdata, function (data) {
mui.hideLoading(function () { });//隐藏后的回调函数
if (data.code == 0) {
mui.alert(data.msg, function () { location.href = "/userinfo/index" });
} else {
mui.alert(data.msg);
}
}, 'json')
})
</script>
</body>
</html>
MUI中等待框的H5实现的更多相关文章
- Mui中mui.openWindow()方法具体参数信息(内容来自Mui问题专区)
mui.openWindow({ url: 'xxx.html', //String类型,要打开的界面的地址 id: 'id', //String类型,要打开的界面的id styles: { //We ...
- IOS开发UI篇之──自定义加载等待框(MBProgressHUD)
本文转载至 http://blog.csdn.net/xunyn/article/details/8064984 原文地址http://www.189works.com/article-89289 ...
- (转载)Android自定义ProgressDialog进度等待框
Android自定义ProgressDialog进度等待框 作者:无缘公子 字体:[增加 减小] 类型:转载 时间:2016-01-11我要评论 这篇文章主要介绍了Android自定义Progress ...
- Hybrid App中原生页面 VS H5页面
Hybrid App中原生页面 VS H5页面 现有3类主流APP,分别为:Web App.Hybrid App(混合模式移动应用,Hybrid有"混合的"意思). Nativ ...
- mui中的关闭页面的几种方法
一.总结: mui中关闭当前页面的几种方式: 1.swipeBack(暂未测试过) 2.keyEventBind(暂未测试过) 3.给标签的class加.mui-action-back(返回的是前一个 ...
- IOS 加载中提示框
LoadingView.h #import <Foundation/Foundation.h> @class MBProgressHUD; @interface LoadingView : ...
- MVC 如何在一个同步方法(非async)方法中等待async方法
MVC 如何在一个同步方法(非async)方法中等待async方法 问题 首先,在ASP.NET MVC 环境下对async返回的Task执行Wait()会导致线程死锁.例: public Actio ...
- 关于mui 中popover与下拉刷新冲突问题
最近用mui做app混合式开发时,作为一个后端开发,高前端确实有点吃了,期间遇到的问题肯定也不少.这两天app做更新,为了装逼,将更新的提示搞得好看些,用到了mui中的popover,结果把自己整死了 ...
- boostrap中模态框显示在阴影之下
boostrap中模态框显示在阴影之下 出现这种情况的原因我开始也搞了很久,问题出现在哪里呢? 有事问百度,在百度上查了一下资料,他们主要的解决办法:是 修改标签的z-index属性的值, 我试着改了 ...
随机推荐
- 【Java】 剑指offer(63) 股票的最大利润
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 假设把某股票的价格按照时间先后顺序存储在数组中,请问买卖交易该 ...
- C++ 冒泡排序、选择排序、快速排序
#include<stdio.h> #define N 10 void swap(int *p1, int *p2); void BubbleSort(int *a); void Sele ...
- 转载收藏用<meta name="ROBOTS"
SEO优化meta标签 name="robots" content="index,follow,noodp,noydir"解释 (2012-10-11 10:33:08)转载 SEO优化meta标 ...
- 洛谷 [P1024]一元三次方程求解【二分答案】
题目链接:https://www.luogu.org/problemnew/show/P1024 题目描述 有形如:ax3+bx2+cx+d=0 这样的一个一元三次方程.给出该方程中各项的系数(a,b ...
- 基于tensorflow搭建一个神经网络
一,tensorflow的简介 Tensorflow是一个采用数据流图,用于数值计算的 开源软件库.节点在图中表示数字操作,图中的线 则表示在节点间相互联系的多维数据数组,即张量 它灵活的架构让你可以 ...
- SQL Server中查找包含某个文本的存储过程
SELECT name,text from sysobjects o,syscomments s where o.id=s.id and text LIKE '%text%' and o.xtype= ...
- unity3d 给游戏添加音源 Unity3d adds a sound source to the game
unity3d 给游戏添加音源 Unity3d adds a sound source to the game 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:3131345 ...
- Python3练习题系列(04)
题目: 制作一个游戏 知识点: 函数.if_elif_else, while, exit 游戏图谱: 游戏代码: from sys import exit def gold_room(): print ...
- 牛客网NOIP赛前集训营-提高组(第四场)游记
牛客网NOIP赛前集训营-提高组(第四场)游记 动态点分治 题目大意: \(T(t\le10000)\)组询问,求\([l,r]\)中\(k(l,r,k<2^{63})\)的非负整数次幂的数的个 ...
- python 反射的用法
class Foo(): def __init__(self,name): self.name=name def text(self): f=Foo() ''' hasattr(obj,name) 判 ...