├── rev ├── css │ └── rev-manifest.json └── js │ └── rev-manifest.json ├── dist ├── index.js ├── js │ └── index.js ├── images │ ├── preview.jpg │ ├── preview.png │ ├── login-head.jpg │ └── login-icon.png ├── css │ └── index.css ├── h5-base.min.css ├── h5-base.css ├── h5-base.min.js └── h5-base.js ├── src ├── js │ └── index.js ├── images │ ├── preview.jpg │ ├── preview.png │ ├── login-head.jpg │ └── login-icon.png └── css │ └── index.less ├── package.json ├── index.html ├── gulpfile.js ├── README.md └── libs ├── h5-common.less ├── h5-common.js └── zepto.min.js /rev/css/rev-manifest.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rev/js/rev-manifest.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | MT.p2m(640); 3 | }); 4 | -------------------------------------------------------------------------------- /dist/js/index.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | //初始化调用 3 | MT.p2m(640); 4 | }); 5 | -------------------------------------------------------------------------------- /src/js/index.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | //初始化调用 3 | MT.p2m(640); 4 | }); 5 | -------------------------------------------------------------------------------- /dist/images/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/dist/images/preview.jpg -------------------------------------------------------------------------------- /dist/images/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/dist/images/preview.png -------------------------------------------------------------------------------- /src/images/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/src/images/preview.jpg -------------------------------------------------------------------------------- /src/images/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/src/images/preview.png -------------------------------------------------------------------------------- /src/images/login-head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/src/images/login-head.jpg -------------------------------------------------------------------------------- /src/images/login-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/src/images/login-icon.png -------------------------------------------------------------------------------- /dist/images/login-head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/dist/images/login-head.jpg -------------------------------------------------------------------------------- /dist/images/login-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geneking/h5-base/HEAD/dist/images/login-icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | 2 | 3 | { 4 | "name": "h5-common", 5 | "version": "1.0.0", 6 | "description": "", 7 | "main": "gulpfile.js", 8 | "dependencies": { 9 | "gulp-rename": "^1.2.2", 10 | "lazypipe": "^1.0.1", 11 | "q": "^1.4.1" 12 | }, 13 | "devDependencies": {}, 14 | "scripts": { 15 | "start": "gulp -watch", 16 | "test": "echo \"Error: no test specified\" && exit 1" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/geneking/h5-common.git" 21 | }, 22 | "author": "", 23 | "license": "ISC", 24 | "bugs": { 25 | "url": "https://github.com/geneking/h5-common/issues" 26 | }, 27 | "homepage": "https://github.com/geneking/h5-common#readme" 28 | } 29 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 登录 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 | 23 | 24 |
25 |
26 | 27 |
登录
28 | 29 | 33 |
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/css/index.less: -------------------------------------------------------------------------------- 1 | body{background-color: #f6f6f6;} 2 | .main{ 3 | width: 6.4rem; 4 | margin: 0 auto; 5 | } 6 | .login-head{ 7 | width: 6.4rem; 8 | height: 4.2rem; 9 | margin-bottom: .3rem; 10 | background: url(../images/login-head.jpg) no-repeat; 11 | background-size: 100%; 12 | } 13 | 14 | form{ 15 | width: 4.6rem; 16 | margin: 0 auto; 17 | } 18 | .input-wrap{ 19 | margin: .2rem 0; 20 | border-bottom: .02rem solid #d9d9d9; 21 | i{ 22 | display: inline-block; 23 | height: .85rem; 24 | width: .6rem; 25 | background: url(../images/login-icon.png) no-repeat; 26 | background-size: .65rem; 27 | background-position: 0 .2rem; 28 | } 29 | .pass{background-position: 0 -0.7rem;} 30 | input{ 31 | float: right; 32 | height: .85rem; 33 | width: 3.7rem; 34 | padding-left: .3rem; 35 | border: none; 36 | font-size: .32rem; 37 | background-color: #f6f6f6; 38 | outline: none; 39 | } 40 | } 41 | 42 | .login{ 43 | width: 4.6rem; 44 | height: .8rem; 45 | margin: .8rem auto; 46 | line-height: .8rem; 47 | text-align: center; 48 | color: #fff; 49 | font-size: .28rem; 50 | background-color: #1ab2e8; 51 | border-radius: .05rem; 52 | } 53 | 54 | .footer{ 55 | width: 4.6rem; 56 | margin: 1.5rem auto .5rem auto; 57 | a{ 58 | float: left; 59 | display: inline-block; 60 | width: 2.3rem; 61 | color: #a2a2a2; 62 | text-decoration: none; 63 | } 64 | .register{text-align: right;} 65 | } 66 | -------------------------------------------------------------------------------- /dist/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #f6f6f6; 3 | } 4 | .main { 5 | width: 6.4rem; 6 | margin: 0 auto; 7 | } 8 | .login-head { 9 | width: 6.4rem; 10 | height: 4.2rem; 11 | margin-bottom: .3rem; 12 | background: url(../images/login-head.jpg) no-repeat; 13 | background-size: 100%; 14 | } 15 | form { 16 | width: 4.6rem; 17 | margin: 0 auto; 18 | } 19 | .input-wrap { 20 | margin: .2rem 0; 21 | border-bottom: .02rem solid #d9d9d9; 22 | } 23 | .input-wrap i { 24 | display: inline-block; 25 | height: .85rem; 26 | width: .6rem; 27 | background: url(../images/login-icon.png) no-repeat; 28 | background-size: .65rem; 29 | background-position: 0 .2rem; 30 | } 31 | .input-wrap .pass { 32 | background-position: 0 -0.7rem; 33 | } 34 | .input-wrap input { 35 | float: right; 36 | height: .85rem; 37 | width: 3.7rem; 38 | padding-left: .3rem; 39 | border: none; 40 | font-size: .32rem; 41 | background-color: #f6f6f6; 42 | outline: none; 43 | } 44 | .login { 45 | width: 4.6rem; 46 | height: .8rem; 47 | margin: .8rem auto; 48 | line-height: .8rem; 49 | text-align: center; 50 | color: #fff; 51 | font-size: .28rem; 52 | background-color: #1ab2e8; 53 | border-radius: .05rem; 54 | } 55 | .footer { 56 | width: 4.6rem; 57 | margin: 1.5rem auto .5rem auto; 58 | } 59 | .footer a { 60 | float: left; 61 | display: inline-block; 62 | width: 2.3rem; 63 | color: #a2a2a2; 64 | text-decoration: none; 65 | } 66 | .footer .register { 67 | text-align: right; 68 | } 69 | -------------------------------------------------------------------------------- /dist/h5-base.min.css: -------------------------------------------------------------------------------- 1 | .mt-confirm-dialog,.mt-toast{position:fixed;-webkit-transform:translate3d(-50%,-50%,0);text-align:center}*{margin:0;padding:0;word-wrap:break-word}li,ul{list-style:none;overflow:hidden}input{-webkit-appearance:none}.clearfix::after{content:" ";display:block;clear:both}body{-webkit-touch-callout:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;-webkit-font-smoothing:antialiased;font-size:.25rem;opacity:0;font-family:'microsoft yahei,STXihei,Arial'}.mt-mask{display:none;position:fixed;top:0;left:0;bottom:0;right:0;background:rgba(0,0,0,.6);z-index:9999}.mt-confirm-dialog,.mt-mask span,.mt-toast{top:50%;font-size:.3rem}.mt-animate-arrow{position:fixed;display:block;left:50%;bottom:.4rem;-webkit-transform:translate3d(-50%,-50%,0);-webkit-animation:updown 1.5s ease infinite normal both}.mt-toast{background:rgba(0,0,0,.8);padding:.4rem .5rem;border-radius:.12rem;z-index:10001;left:50%;color:#fff;width:3.4rem}.mt-confirm-dialog{left:50%;width:5.32rem;color:#000;border-radius:.2rem;background:#DEE4EA;overflow:hidden;z-index:10000}.mt-confirm-dialog .text{width:100%;height:1.4rem;line-height:1.4rem;border-bottom:.01rem solid #98AFC0}.mt-confirm-dialog span{float:left;display:inline-block;width:2.65rem;height:1rem;line-height:1rem;color:#087EFF;background:#DEE4EA}.mt-confirm-dialog .mt-confirm-btn{border-right:.01rem solid #98AFC0}.mt-confirm-dialog .mt-touch-btn{background:#98AFC0}.mt-zindex{z-index:10001}.mt-mask span{position:absolute;left:50%;-webkit-transform:translate(-50%,-50%);color:#fff}@media all and (orientation:landscape){.mt-mask{display:block}}@media all and (orientation:portrait){.mt-mask{display:none}} -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | concat = require('gulp-concat'), 3 | less = require('gulp-less'), 4 | minifycss = require('gulp-minify-css'), 5 | uglify = require('gulp-uglify'), 6 | csslint = require('gulp-csslint'), 7 | jshint = require('gulp-jshint'), 8 | rename = require('gulp-rename'), 9 | //q = require('q'), 10 | //rev = require('gulp-rev'), 11 | //revcollector = require('gulp-rev-collector'), 12 | lazypipe = require('lazypipe'); 13 | 14 | var compilecss = lazypipe() 15 | .pipe(less) 16 | .pipe(csslint) 17 | .pipe(csslint.reporter); 18 | 19 | gulp.task('css', function() { 20 | //var deferred = q.defer(); 21 | gulp.src(['src/css/*']) 22 | .pipe(compilecss()) 23 | .pipe(gulp.dest('dist/css')); 24 | /*.pipe(rev()) 25 | .pipe(gulp.dest('dist')) 26 | .pipe(rev.manifest()) 27 | .pipe(gulp.dest('./rev/css'))*/ 28 | 29 | gulp.src(['libs/h5-common.less']) 30 | .pipe(compilecss()) 31 | .pipe(rename('h5-base.css')) 32 | .pipe(gulp.dest('dist')) 33 | .pipe(minifycss()) 34 | .pipe(rename('h5-base.min.css')) 35 | .pipe(gulp.dest('dist')); 36 | //return deferred.promise; 37 | }); 38 | 39 | gulp.task('js', function() { 40 | gulp.src(['libs/zepto.min.js', 'libs/h5-common.js']) 41 | //.pipe(jshint()) 42 | //.pipe(jshint.reporter()) 43 | .pipe(concat('h5-base.js')) 44 | .pipe(gulp.dest('dist')) 45 | .pipe(uglify()) 46 | .pipe(rename('h5-base.min.js')) 47 | .pipe(gulp.dest('dist')); 48 | /*.pipe(rev()) 49 | .pipe(gulp.dest('dist')) 50 | .pipe(rev.manifest()) 51 | .pipe(gulp.dest('./rev/js'))*/ 52 | 53 | gulp.src(['src/js/*']) 54 | .pipe(jshint()) 55 | .pipe(jshint.reporter()) 56 | .pipe(gulp.dest('dist/js')); 57 | }); 58 | 59 | gulp.task('images', function() { 60 | gulp.src(['src/images/*']) 61 | .pipe(gulp.dest('dist/images')); 62 | //return deferred.promise; 63 | }); 64 | 65 | gulp.task('default', ['css','js', 'images'], function(){ 66 | gulp.watch(['src/css/*.less','libs/*.less'],['css']); 67 | gulp.watch(['src/js/*.js','libs/*.js'],['js']); 68 | gulp.watch(['src/images/*'],['images']); 69 | }); 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # h5-base 2 | 3 |     前段时间总结完善了一个H5的基础函数库,包括常用的工具函数,及一些小组件,最终用gulp将zepto和common库打包成h5-base.js和h5-base.css大家有兴趣的可以在git上补充,以后的想法是做成像jquery-ui一样可定制生成base库,需要zepto打包zepto,依赖jquery打包jquery等。 4 | 5 | ## 一、函数列表 6 | 7 | * p2m px=>rem的适配 8 | * getUrlparam 获取url参数 9 | * getDataUrl 获取图片base64编码 10 | * judgePlat 判断平台类型 11 | * isAndroid 判断是否为安卓设备 12 | * isIOS 判断是否为IOS设备 13 | * setCookie 设置cookie 14 | * getCookie 获取cookie 15 | * delCookie 删除cookie 16 | * getPhoneCode 获取手机验证码 17 | * delayGo 延迟处理/跳转 18 | * cutContent 字符串截取 19 | * toast toast 弹层 20 | * listenNet 监听网络状态连接 21 | * orientation 旋转屏幕后刷新页面 22 | * confirm confirm弹层 23 | * animArrow 向下滑动指示箭头 24 | * downloadApp banner下载 25 | * rotateTip 横竖屏切换提示 26 | * shareWx 分享到微信配置 27 | 28 | ## 二、屏幕适配 29 | ### 1.屏幕的适配主要在对应页面初始化时调用p2m完成 30 | ```javascript 31 | /** 32 | * viewport缩放,px转rem 33 | * @function p2m 34 | * @param {designW:设计稿尺寸,一般为640px/750px} 35 | **/ 36 | MT.p2m = function(designW){ 37 | var resizeNum = 0, 38 | timer = null, 39 | winW = window.innerWidth; 40 | var resize = function() { 41 | var clientW = document.body.clientWidth; 42 | clearTimeout(timer); 43 | if (clientW > 414) { 44 | winW = 414; 45 | MT.TOUCH_START = "click"; 46 | MT.TOUCH_END = "click"; 47 | } 48 | document.getElementsByTagName("html")[0].style.fontSize = (winW/designW)*100 + "px"; 49 | if (winW > clientW && resizeNum <= 10) { 50 | timer = setTimeout(function() { 51 | resize(++resizeNum); 52 | }, 100); 53 | } else { 54 | document.getElementsByTagName("body")[0].style.opacity = 1; 55 | } 56 | } 57 | resize(); 58 | window.onresize = resize; 59 | }; 60 | ``` 61 | 62 | ### 2.适配过程 63 | * 从p2m方法可以看出,有个动态参数designW,一般来说设计稿尺寸为640px或750px,这个按照具体情况传对应的参数; 64 | * 以1rem=100px做适配,我们知道iphone6+的逻辑分辨率为414*736,其他移动设备也大不相同,所以无法做到与设计稿的对应,所以要做一个比率的缩放,即 (winW/designW)x100,rem是以根节点为基准,所以只处理html节点; 65 | * 因为移动端viewport的宽度平常大于设备宽度,所以以这个为判定条件之一,为什么要计算10次呢,是因为一次在低配手机上可能会适配失败; 66 | * 对于pc端的兼容,当设备尺寸大于414时,文档默认414宽度,touch事件变更成click事件; 67 | 68 | ## 三、调用方法 69 | 70 | ### 1.meta设置 71 | 一般H5页面我们禁止缩放 72 | 73 | ```html 74 | 75 | 76 | 77 | 78 | ``` 79 | 80 | ### 2.body的默认opacity 81 | 默认为0(可查看h5-base.ccss),适配完成后设为1,避免适配过程中的闪屏现象; 82 | 83 | ### 3.初始化调用适配方法 84 | * 在页面初始化时,需调用MT.p2m方法完成屏幕适配; 85 | * 如需调用其他方法,也用“MT.方法名”去调用; 86 | * 由于对PC端做了事件兼容,所以调用"touchstart"或"touchend"时应该用"MT.TOUCH_START"和"MT.TOUCH_END" 87 | * 写CSS全用rem做单位,以1rem:100px的基准去写 88 | 89 | ### 4.注意 90 | * 所用方法都赋值在window域下的MT对象上,所以禁止window域下操作MT或者声明MT; 91 | * 禁止操作html字体大小; 92 | 93 | ## 四、DEMO 94 | 下载后,请预览index.html 95 | ![demo](./src/images/preview.png) 96 | -------------------------------------------------------------------------------- /dist/h5-base.css: -------------------------------------------------------------------------------- 1 | /************************************ 2 | * @author: weigang.jin@renren-inc.com 3 | * @vsersion 1.0 4 | * ---------- 基础样式 ---------------- 5 | ************************************/ 6 | * { 7 | margin: 0; 8 | padding: 0; 9 | word-wrap: break-word; 10 | } 11 | ul, 12 | li { 13 | list-style: none; 14 | overflow: hidden; 15 | } 16 | input { 17 | -webkit-appearance: none; 18 | } 19 | .clearfix { 20 | *zoom: 1; 21 | } 22 | .clearfix::after { 23 | content: " "; 24 | display: block; 25 | clear: both; 26 | } 27 | body { 28 | -webkit-touch-callout: none; 29 | -webkit-user-select: none; 30 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 31 | -webkit-font-smoothing: antialiased; 32 | font-size: 0.25rem; 33 | opacity: 0; 34 | font-family: 'microsoft yahei,STXihei,Arial'; 35 | } 36 | .mt-mask { 37 | display: none; 38 | position: fixed; 39 | top: 0; 40 | left: 0; 41 | bottom: 0; 42 | right: 0; 43 | background: rgba(0, 0, 0, 0.6); 44 | z-index: 9999; 45 | } 46 | /********** animArrow start *******/ 47 | .mt-animate-arrow { 48 | position: fixed; 49 | display: block; 50 | left: 50%; 51 | bottom: .4rem; 52 | -webkit-transform: translate3d(-50%, -50%, 0); 53 | -webkit-animation: updown 1.5s ease infinite normal both; 54 | } 55 | /********** animArrow end ********/ 56 | /********** toatst start *********/ 57 | .mt-toast { 58 | position: fixed; 59 | width: auto; 60 | background: rgba(0, 0, 0, 0.8); 61 | padding: 0.4rem 0.5rem; 62 | border-radius: 0.12rem; 63 | z-index: 10001; 64 | top: 50%; 65 | left: 50%; 66 | -webkit-transform: translate3d(-50%, -50%, 0); 67 | font-size: 0.3rem; 68 | color: #fff; 69 | text-align: center; 70 | width: 3.4rem; 71 | } 72 | /********** toatst end **********/ 73 | /***** confirm-dialog start *****/ 74 | .mt-confirm-dialog { 75 | position: fixed; 76 | top: 50%; 77 | left: 50%; 78 | -webkit-transform: translate3d(-50%, -50%, 0); 79 | width: 5.32rem; 80 | font-size: .3rem; 81 | color: #000; 82 | border-radius: .2rem; 83 | background: #DEE4EA; 84 | text-align: center; 85 | overflow: hidden; 86 | z-index: 10000; 87 | } 88 | .mt-confirm-dialog .text { 89 | width: 100%; 90 | height: 1.4rem; 91 | line-height: 1.4rem; 92 | border-bottom: 0.01rem solid #98AFC0; 93 | } 94 | .mt-confirm-dialog span { 95 | float: left; 96 | display: inline-block; 97 | width: 2.65rem; 98 | height: 1rem; 99 | line-height: 1rem; 100 | color: #087EFF; 101 | background: #DEE4EA; 102 | } 103 | .mt-confirm-dialog .mt-confirm-btn { 104 | border-right: 0.01rem solid #98AFC0; 105 | } 106 | .mt-confirm-dialog .mt-touch-btn { 107 | background: #98AFC0; 108 | } 109 | /***** confirm-dialog end ******/ 110 | /****** rotateTip start *******/ 111 | .mt-zindex { 112 | z-index: 10001; 113 | } 114 | .mt-mask span { 115 | position: absolute; 116 | top: 50%; 117 | left: 50%; 118 | -webkit-transform: translate(-50%, -50%); 119 | font-size: 0.3rem; 120 | color: #fff; 121 | } 122 | @media all and (orientation: landscape) { 123 | .mt-mask { 124 | display: block; 125 | } 126 | } 127 | @media all and (orientation: portrait) { 128 | .mt-mask { 129 | display: none; 130 | } 131 | } 132 | /****** rotateTip end *******/ 133 | -------------------------------------------------------------------------------- /libs/h5-common.less: -------------------------------------------------------------------------------- 1 | /************************************ 2 | * @author: weigang.jin@renren-inc.com 3 | * @vsersion 1.0 4 | * ---------- 基础样式 ---------------- 5 | ************************************/ 6 | 7 | *{ 8 | margin:0; 9 | padding:0; 10 | word-wrap:break-word; 11 | } 12 | ul,li{ 13 | list-style: none; 14 | overflow: hidden; 15 | } 16 | input{ -webkit-appearance: none;} 17 | .clearfix { 18 | *zoom: 1; 19 | } 20 | .clearfix::after { 21 | content: " "; 22 | display: block; 23 | clear: both; 24 | } 25 | body{ 26 | -webkit-user-select: none; 27 | -webkit-touch-callout: none; 28 | -webkit-user-select: none; 29 | -webkit-tap-highlight-color:rgba(0,0,0,0); 30 | -webkit-font-smoothing: antialiased; 31 | font-size: 0.25rem; 32 | opacity: 0; 33 | font-family: 'microsoft yahei,STXihei,Arial'; 34 | } 35 | .mt-mask{ 36 | display: none; 37 | position: fixed; 38 | top:0; 39 | left: 0; 40 | bottom: 0; 41 | right: 0; 42 | background: rgba(0,0,0,.6); 43 | z-index: 9999; 44 | } 45 | 46 | /********** animArrow start *******/ 47 | .mt-animate-arrow{ 48 | position: fixed; 49 | display: block; 50 | left: 50%; 51 | bottom: .4rem; 52 | -webkit-transform: translate3d(-50%,-50%,0); 53 | -webkit-animation: updown 1.5s ease infinite normal both; 54 | } 55 | /********** animArrow end ********/ 56 | 57 | /********** toatst start *********/ 58 | .mt-toast{ 59 | position: fixed; 60 | width: auto; 61 | background: rgba(0,0,0,.8); 62 | padding:0.4rem 0.5rem; 63 | border-radius: 0.12rem; 64 | z-index: 10001; 65 | top:50%; 66 | left: 50%; 67 | -webkit-transform:translate3d(-50%,-50%,0); 68 | font-size: 0.3rem; 69 | color: #fff; 70 | text-align: center; 71 | width: 3.4rem; 72 | } 73 | /********** toatst end **********/ 74 | 75 | /***** confirm-dialog start *****/ 76 | .mt-confirm-dialog{ 77 | position: fixed;; 78 | top: 50%; 79 | left: 50%; 80 | -webkit-transform:translate3d(-50%,-50%,0); 81 | width: 5.32rem; 82 | font-size: .3rem; 83 | color: #000; 84 | border-radius: .2rem; 85 | background: #DEE4EA; 86 | text-align: center; 87 | overflow: hidden; 88 | z-index: 10000; 89 | .text{ 90 | width: 100%; 91 | height: 1.4rem; 92 | line-height: 1.4rem; 93 | border-bottom: 0.01rem solid #98AFC0; 94 | } 95 | span{ 96 | float: left; 97 | display: inline-block; 98 | width: 2.65rem; 99 | height: 1rem; 100 | line-height: 1rem; 101 | color: #087EFF; 102 | background: #DEE4EA; 103 | } 104 | .mt-confirm-btn{border-right: 0.01rem solid #98AFC0;} 105 | .mt-touch-btn{background: #98AFC0;} 106 | } 107 | /***** confirm-dialog end ******/ 108 | 109 | /****** rotateTip start *******/ 110 | .mt-zindex{z-index:10001;} 111 | .mt-mask span{ 112 | position: absolute; 113 | top:50%; 114 | left: 50%; 115 | -webkit-transform:translate(-50%,-50%); 116 | font-size: 0.3rem; 117 | color: #fff; 118 | } 119 | @media all and (orientation : landscape) { 120 | .mt-mask{display:block;} 121 | } 122 | @media all and (orientation : portrait) { 123 | .mt-mask{display:none;} 124 | } 125 | /****** rotateTip end *******/ 126 | -------------------------------------------------------------------------------- /libs/h5-common.js: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * @author: jinweigang 3 | * @vsersion 1.0 4 | 5 | * ---------------函数 列表--------------—— 6 | * @p2m px=>rem的适配 7 | * @getUrlparam 获取url参数 8 | * @getDataUrl 获取图片base64编码 9 | * @judgePlat 判断平台类型 10 | * @isAndroid 判断是否为安卓设备 11 | * @isIOS 判断是否为IOS设备 12 | * @setCookie 设置cookie 13 | * @getCookie 获取cookie 14 | * @delCookie 删除cookie 15 | * @getPhoneCode 获取手机验证码 16 | * @delayGo 延迟处理/跳转 17 | * @cutContent 字符串截取 18 | * @toast toast弹层 19 | * @listenNet 监听网络状态连接 20 | * @orientation 旋转屏幕后刷新页面 21 | * @confirm confirm弹层 22 | * @animArrow 向下滑动指示箭头 23 | * @downloadApp banner下载 24 | * @rotateTip 横竖屏切换提示 25 | * @shareWx 分享到微信配置 26 | *****************************************/ 27 | 28 | ;(function(window, $, undefined){ 29 | window.MT = { 30 | TOUCH_START: "touchstart", 31 | TOUCH_END: "touchend" 32 | }; 33 | 34 | /** 35 | * viewport缩放,px转rem 36 | * @function p2m 37 | * @param {designW:设计稿尺寸,一般为640px/750px} 38 | **/ 39 | MT.p2m = function(designW){ 40 | var resizeNum = 0, 41 | timer = null, 42 | winW = window.innerWidth; 43 | var resize = function() { 44 | var clientW = document.body.clientWidth; 45 | clearTimeout(timer); 46 | if (clientW > 414) { 47 | winW = 414; 48 | MT.TOUCH_START = "click"; 49 | MT.TOUCH_END = "click"; 50 | } 51 | document.getElementsByTagName("html")[0].style.fontSize = (winW/designW)*100 + "px"; 52 | if (winW > clientW && resizeNum <= 10) { 53 | timer = setTimeout(function() { 54 | resize(++resizeNum); 55 | }, 100); 56 | } else { 57 | document.getElementsByTagName("body")[0].style.opacity = 1; 58 | } 59 | } 60 | resize(); 61 | window.onresize = resize; 62 | }; 63 | 64 | /** 65 | * 获取url参数 66 | * @function getUrlParam 67 | * @param {url: 需要解析的url} 68 | **/ 69 | MT.getUrlParam = function(url) { 70 | var data = decodeURIComponent(url || location.href).split("?")[1].split("&"); 71 | var param = {}; 72 | 73 | for(var i =0; i 1) { 98 | imageWidth = (maxWidth > imageWidth) ? imageWidth : maxWidth; 99 | imageHeight = Math.round(imageWidth / ratio); 100 | if (imageHeight > maxHeight) { 101 | imageHeight = maxHeight; 102 | imageWidth = Math.round(imageHeight * ratio); 103 | } 104 | } else { 105 | imageHeight = (maxHeight > imageHeight) ? imageHeight : maxHeight; 106 | imageWidth = Math.round(imageHeight * ratio); 107 | if (imageWidth > maxWidth) { 108 | imageWidth = maxWidth; 109 | imageHeight = Math.round(imageWidth / ratio); 110 | } 111 | } 112 | canvas.width = imageWidth; 113 | canvas.height = imageHeight; 114 | canvas.getContext('2d').drawImage(this, 0, 0); 115 | callback(canvas.toDataURL('image/jpeg').substring(23)); 116 | }; 117 | image.src = e.target.result; 118 | }; 119 | 120 | }; 121 | 122 | /** 123 | * 根据UA判断平台类型 124 | * @function judgePlat 125 | **/ 126 | MT.judgePlat = function(){ 127 | var browser = "other", 128 | ua = navigator.userAgent.toLowerCase(); 129 | 130 | if(/MicroMessenger/i.test(ua)) browser="weixin"; 131 | if(/weibo/i.test(ua)) browser="weibo"; 132 | return browser; 133 | }; 134 | 135 | /** 136 | * 判断是否为安卓设备 137 | * @function isAndroid 138 | **/ 139 | MT.isAndroid = function(){ 140 | /* HTC Flyer平板的UA字符串中不包含Android关键词 */ 141 | return /Android|HTC/i.test(navigator.userAgent.toLowerCase()); 142 | }; 143 | 144 | /** 145 | * 判断是否为ios设备 146 | * @function isIOS 147 | **/ 148 | MT.isIOS = function(){ 149 | return /iPod|iPad|iPhone/i.test(navigator.userAgent.toLowerCase()); 150 | }; 151 | 152 | /** 153 | * 设置cookie 154 | * @function setCookie 155 | * @param {key:cookie名称,value:cookie值,days:过期时间} 156 | **/ 157 | MT.setCookie = function(key, value, days){ 158 | var expire = new Date(), 159 | expireTime = expire.getTime() + days*24*60*60*1000; 160 | document.cookie = key + "=" + escape(value) + ";expires=" + new Date(expireTime); 161 | }; 162 | 163 | /** 164 | * 获取cookie 165 | * @function getCookie 166 | * @param {key:cookie名称} 167 | **/ 168 | MT.getCookie = function(key){ 169 | var reg = new RegExp("(^| )"+name+"=([^;]*)(;|$)"), 170 | arr = document.cookie.match(reg); 171 | if(arr !== null) return unescape(arr[2]); 172 | return false; 173 | }; 174 | 175 | /** 176 | * 删除cookie 177 | * @function delCookie 178 | * @param {key:cookie名称} 179 | **/ 180 | MT.delCookie = function(key){ 181 | MT.setCookie(key,"",-1); 182 | }; 183 | 184 | /** 185 | * 启动一个定时器 186 | * @function getPhoneCode 187 | * @param {_option:参数集合} 188 | **/ 189 | MT.getPhoneCode = function(_option) { 190 | var option = $.extend({ 191 | sendBtn: null, //发送按钮 192 | time: 60, //倒计时时间 193 | disabled: 'disabled', //按钮禁止点击class 194 | sendCode: function() {}//发送验证码函数 195 | }, _option); 196 | var timer = null, 197 | count = option.time; 198 | 199 | option.sendBtn.on(MT.TOUCH_START, function() { 200 | if (option.sendBtn.data("lock") == "true") return; 201 | if (typeof option.sendCode == 'function') { 202 | option.sendCode(); //发送验证码 203 | } else { 204 | MT.toast('错误:' + option.sendCode + '应为函数'); 205 | return false; 206 | } 207 | option.sendBtn.addClass(option.disabled).data("lock", true); 208 | option.sendBtn.text("重新发送(60)"); 209 | timer = setInterval(function() { 210 | if (--count > 0) { 211 | option.sendBtn.text("重新发送(" + count + ")"); 212 | } else { 213 | option.sendBtn.removeClass(option.disabled).text("重新发送").data( 214 | "lock", 215 | false); 216 | clearInterval(timer); 217 | count = option.time; 218 | } 219 | }, 1000); 220 | }); 221 | }; 222 | 223 | 224 | /** 225 | * 延迟处理/跳转 226 | * @function delayGo 227 | * @param {callback:跳转地址/回调函数, time:延迟时间ms} 228 | */ 229 | MT.delayGo = function(callback, time){ 230 | var timer = setTimeout(function(){ 231 | if (typeof callback == 'string') { 232 | location.href = callback; 233 | } else if(typeof callback == 'function') { 234 | callback(); 235 | } 236 | clearTimeout(timer); 237 | }, time || 1500); 238 | }; 239 | 240 | /** 241 | * 延迟处理/跳转 242 | * @function cutContent 243 | * @param {str:截取字符串, len:截取长度, tag: 标记} 244 | */ 245 | MT.cutContent = function(str, len, tag){ 246 | //只是计算字符长度,不区分中英文 247 | var newStr = ''; 248 | if (str.length > len) { 249 | newStr = str.substr(0,len); 250 | } 251 | return newStr + (tag || '...'); 252 | }; 253 | 254 | /** 255 | * 黑色浮层弹窗 256 | * @function toast 257 | * @param {text:弹出文案,time:弹窗持续时间 callback:回调函数} 258 | */ 259 | MT.toast = function(text, time, callback){ 260 | $(".mt-toast").remove(); 261 | $("body").append("

"+text+"

"); 262 | var timer = setTimeout(function(){ 263 | $(".mt-toast").remove(); 264 | if(callback) callback(); 265 | clearTimeout(timer); 266 | },time || 2000); 267 | }; 268 | 269 | /** 270 | * 网络断开toast提示 271 | * @function offLine 272 | */ 273 | MT.listenNet = function(){ 274 | window.addEventListener("offline",function(){ 275 | MT.toast("网络连接失败,请重试",1000000); 276 | },false); 277 | window.addEventListener("online",function(){ 278 | $(".mt-toast").remove(); 279 | },false); 280 | }; 281 | 282 | /** 283 | * 屏幕旋转后刷新页面 284 | * @function orientation 285 | */ 286 | MT.orientation = function(){ 287 | window.addEventListener('orientationchange',function(){ 288 | location.reload(); 289 | }); 290 | }; 291 | 292 | /** 293 | * 黑色浮层弹窗 294 | * @function confirmDialog 295 | * @param {option:参数配置} 296 | */ 297 | MT.confirm = function(_option){ 298 | var option = $.extend({ 299 | text: "提示", 300 | okBtnText: "确定", 301 | cancelBtnText: "取消", 302 | okCallback: function(){ 303 | }, 304 | cancelCallback: function(){ 305 | }, 306 | close:function(){ 307 | $(".mt-confirm-dialog").remove(); 308 | $(".mt-mask").remove(); 309 | } 310 | },_option || {}); 311 | 312 | var html = ['
', 313 | '

',option.text,'

', 314 | '

',option.okBtnText,'', 315 | '',option.cancelBtnText,'

', 316 | '
', 317 | '
'].join(""); 318 | $("body").append(html); 319 | $(".mt-mask").show(); 320 | var confirmBtn = $('.mt-confirm-btn'), 321 | canceBtn = $(".mt-cancel-btn"); 322 | 323 | confirmBtn.on(MT.TOUCH_START,function(){ 324 | confirmBtn.addClass("touch-btn"); 325 | }) 326 | .on(MT.TOUCH_END,function(){ 327 | confirmBtn.removeClass("touch-btn"); 328 | option.okCallback(); 329 | option.close(); 330 | }); 331 | 332 | canceBtn.on(MT.TOUCH_START,function(){ 333 | canceBtn.addClass("mt-touch-btn"); 334 | }) 335 | .on(MT.TOUCH_END,function(){ 336 | canceBtn.removeClass("mt-touch-btn"); 337 | option.cancelCallback(); 338 | option.close(); 339 | }); 340 | }; 341 | 342 | /** 343 | * 向下指示箭头 344 | * @function animArrow 345 | * @param {imgUrl: 箭头图片地址} 346 | **/ 347 | MT.animArrow = function(imgUrl){ 348 | var img = imgUrl ? imgUrl : "", 349 | html = ['
'].join(); 350 | $("body").append(html); 351 | }; 352 | 353 | /** 354 | * 底部下载app banner 355 | * @function downloadApp 356 | * @param{option对象} 357 | **/ 358 | MT.downloadApp = function(_option){ 359 | var option = $.extend({ 360 | position: "static", 361 | height: "1rem", 362 | wxUrl:"", 363 | androidUrl:"", 364 | iosUrl:"", 365 | imgUrl:"" 366 | },_option || {}); 367 | var html = "", 368 | plat = MT.judgePlat(); 369 | 370 | if(plat == "weixin"){ 371 | option.downloadUrl = wxUrl; 372 | } else if(plat == "ios"){ 373 | option.downloadUrl = iosUrl; 374 | } else if(plat == "android"){ 375 | option.downloadUrl = androidUrl; 376 | } 377 | html = ['
'].join(""); 379 | $("body").append(html); 380 | }; 381 | 382 | /** 383 | * 横竖屏提示 384 | * @function rotateTip 385 | * @param{} 386 | **/ 387 | MT.rotateTip = function(){ 388 | var timer = setTimeout(function(){ 389 | $("body").append('
请切换至竖屏显示
'); 390 | clearTimeout(timer); 391 | },0); 392 | }; 393 | 394 | /** 395 | * 分享到微信 396 | * @function shareWx 397 | * @param{data对象} 398 | **/ 399 | MT.shareWx = function(data,authUrl){ 400 | var callback = function (data) { 401 | wx.config({ 402 | debug: false, 403 | appId: data.appId, 404 | timestamp: data.timestamp, 405 | nonceStr: data.nonceStr, 406 | signature: data.signature, 407 | jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo', 408 | 'chooseImage','previewImage','uploadImage','downloadImage'] 409 | }); 410 | 411 | wx.ready(function () { 412 | var shareData = { 413 | title: data.title, 414 | desc: data.desc, 415 | link: location.href, // 分享链接 416 | imgUrl: data.imgUrl, 417 | success: function () { 418 | // 用户确认分享后执行的回调函数 419 | } 420 | }; 421 | wx.onMenuShareAppMessage(shareData); 422 | wx.onMenuShareQQ(shareData); 423 | wx.onMenuShareWeibo(shareData); 424 | wx.onMenuShareTimeline(shareData); 425 | 426 | console.log('weixin support set success.'); 427 | }); 428 | wx.error(function (res) { 429 | //alert(res.errMsg); 430 | }); 431 | }; 432 | $.ajax({ 433 | url: authUrl, 434 | dataType: "json", 435 | data: location.href.split("#")[0], 436 | success: function (res) { 437 | callback(res); 438 | }, 439 | error: function (xhr, type) { 440 | console.log('xhr:' + xhr + "type:" + type); 441 | MT.toast("认证接口错误"); 442 | } 443 | }); 444 | }; 445 | 446 | })(window, Zepto); 447 | -------------------------------------------------------------------------------- /libs/zepto.min.js: -------------------------------------------------------------------------------- 1 | /* Zepto v1.0rc1 - polyfill zepto event detect fx ajax form touch - zeptojs.com/license */ 2 | (function(a){String.prototype.trim===a&&(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),Array.prototype.reduce===a&&(Array.prototype.reduce=function(b){if(this===void 0||this===null)throw new TypeError;var c=Object(this),d=c.length>>>0,e=0,f;if(typeof b!="function")throw new TypeError;if(d==0&&arguments.length==1)throw new TypeError;if(arguments.length>=2)f=arguments[1];else do{if(e in c){f=c[e++];break}if(++e>=d)throw new TypeError}while(!0);while(e0?[].concat.apply([],a):a}function H(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function I(a){return a in i?i[a]:i[a]=new RegExp("(^|\\s)"+a+"(\\s|$)")}function J(a,b){return typeof b=="number"&&!k[H(a)]?b+"px":b}function K(a){var b,c;return h[a]||(b=g.createElement(a),g.body.appendChild(b),c=j(b,"").getPropertyValue("display"),b.parentNode.removeChild(b),c=="none"&&(c="block"),h[a]=c),h[a]}function L(b,d){return d===a?c(b):c(b).filter(d)}function M(a,b,c,d){return A(b)?b.call(a,c,d):b}function N(a,b,d){var e=a%2?b:b.parentNode;e?e.insertBefore(d,a?a==1?e.firstChild:a==2?b:null:b.nextSibling):c(d).remove()}function O(a,b){b(a);for(var c in a.childNodes)O(a.childNodes[c],b)}var a,b,c,d,e=[],f=e.slice,g=window.document,h={},i={},j=g.defaultView.getComputedStyle,k={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},l=/^\s*<(\w+|!)[^>]*>/,m=[1,3,8,9,11],n=["after","prepend","before","append"],o=g.createElement("table"),p=g.createElement("tr"),q={tr:g.createElement("tbody"),tbody:o,thead:o,tfoot:o,td:p,th:p,"*":g.createElement("div")},r=/complete|loaded|interactive/,s=/^\.([\w-]+)$/,t=/^#([\w-]+)$/,u=/^[\w-]+$/,v={}.toString,w={},x,y,z=g.createElement("div");return w.matches=function(a,b){if(!a||a.nodeType!==1)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var d,e=a.parentNode,f=!e;return f&&(e=z).appendChild(a),d=~w.qsa(e,b).indexOf(a),f&&z.removeChild(a),d},x=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},y=function(a){return a.filter(function(b,c){return a.indexOf(b)==c})},w.fragment=function(b,d){d===a&&(d=l.test(b)&&RegExp.$1),d in q||(d="*");var e=q[d];return e.innerHTML=""+b,c.each(f.call(e.childNodes),function(){e.removeChild(this)})},w.Z=function(a,b){return a=a||[],a.__proto__=arguments.callee.prototype,a.selector=b||"",a},w.isZ=function(a){return a instanceof w.Z},w.init=function(b,d){if(!b)return w.Z();if(A(b))return c(g).ready(b);if(w.isZ(b))return b;var e;if(D(b))e=F(b);else if(C(b))e=[c.extend({},b)],b=null;else if(m.indexOf(b.nodeType)>=0||b===window)e=[b],b=null;else if(l.test(b))e=w.fragment(b.trim(),RegExp.$1),b=null;else{if(d!==a)return c(d).find(b);e=w.qsa(g,b)}return w.Z(e,b)},c=function(a,b){return w.init(a,b)},c.extend=function(c){return f.call(arguments,1).forEach(function(d){for(b in d)d[b]!==a&&(c[b]=d[b])}),c},w.qsa=function(a,b){var c;return a===g&&t.test(b)?(c=a.getElementById(RegExp.$1))?[c]:e:a.nodeType!==1&&a.nodeType!==9?e:f.call(s.test(b)?a.getElementsByClassName(RegExp.$1):u.test(b)?a.getElementsByTagName(b):a.querySelectorAll(b))},c.isFunction=A,c.isObject=B,c.isArray=D,c.isPlainObject=C,c.inArray=function(a,b,c){return e.indexOf.call(b,a,c)},c.trim=function(a){return a.trim()},c.uuid=0,c.map=function(a,b){var c,d=[],e,f;if(E(a))for(e=0;e0&&w.matches(this[0],a)},not:function(b){var d=[];if(A(b)&&b.call!==a)this.each(function(a){b.call(this,a)||d.push(this)});else{var e=typeof b=="string"?this.filter(b):E(b)&&A(b.item)?f.call(b):c(b);this.forEach(function(a){e.indexOf(a)<0&&d.push(a)})}return c(d)},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!B(a)?a:c(a)},last:function(){var a=this[this.length-1];return a&&!B(a)?a:c(a)},find:function(a){var b;return this.length==1?b=w.qsa(this[0],a):b=this.map(function(){return w.qsa(this,a)}),c(b)},closest:function(a,b){var d=this[0];while(d&&!w.matches(d,a))d=d!==b&&d!==g&&d.parentNode;return c(d)},parents:function(a){var b=[],d=this;while(d.length>0)d=c.map(d,function(a){if((a=a.parentNode)&&a!==g&&b.indexOf(a)<0)return b.push(a),a});return L(b,a)},parent:function(a){return L(y(this.pluck("parentNode")),a)},children:function(a){return L(this.map(function(){return f.call(this.children)}),a)},siblings:function(a){return L(this.map(function(a,b){return f.call(b.parentNode.children).filter(function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return this.map(function(){return this[a]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=null),j(this,"").getPropertyValue("display")=="none"&&(this.style.display=K(this.nodeName))})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){return this.each(function(){c(this).wrapAll(c(a)[0].cloneNode(!1))})},wrapAll:function(a){return this[0]&&(c(this[0]).before(a=c(a)),a.append(this)),this},unwrap:function(){return this.parent().each(function(){c(this).replaceWith(c(this).children())}),this},clone:function(){return c(this.map(function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(b){return(b===a?this.css("display")=="none":b)?this.show():this.hide()},prev:function(){return c(this.pluck("previousElementSibling"))},next:function(){return c(this.pluck("nextElementSibling"))},html:function(b){return b===a?this.length>0?this[0].innerHTML:null:this.each(function(a){var d=this.innerHTML;c(this).empty().append(M(this,b,a,d))})},text:function(b){return b===a?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=b})},attr:function(c,d){var e;return typeof c=="string"&&d===a?this.length==0||this[0].nodeType!==1?a:c=="value"&&this[0].nodeName=="INPUT"?this.val():!(e=this[0].getAttribute(c))&&c in this[0]?this[0][c]:e:this.each(function(a){if(this.nodeType!==1)return;if(B(c))for(b in c)this.setAttribute(b,c[b]);else this.setAttribute(c,M(this,d,a,this.getAttribute(c)))})},removeAttr:function(a){return this.each(function(){this.nodeType===1&&this.removeAttribute(a)})},prop:function(b,c){return c===a?this[0]?this[0][b]:a:this.each(function(a){this[b]=M(this,c,a,this[b])})},data:function(b,c){var d=this.attr("data-"+H(b),c);return d!==null?d:a},val:function(b){return b===a?this.length>0?this[0].value:a:this.each(function(a){this.value=M(this,b,a,this.value)})},offset:function(){if(this.length==0)return null;var a=this[0].getBoundingClientRect();return{left:a.left+window.pageXOffset,top:a.top+window.pageYOffset,width:a.width,height:a.height}},css:function(c,d){if(d===a&&typeof c=="string")return this.length==0?a:this[0].style[x(c)]||j(this[0],"").getPropertyValue(c);var e="";for(b in c)typeof c[b]=="string"&&c[b]==""?this.each(function(){this.style.removeProperty(H(b))}):e+=H(b)+":"+J(b,c[b])+";";return typeof c=="string"&&(d==""?this.each(function(){this.style.removeProperty(H(c))}):e=H(c)+":"+J(c,d)),this.each(function(){this.style.cssText+=";"+e})},index:function(a){return a?this.indexOf(c(a)[0]):this.parent().children().indexOf(this[0])},hasClass:function(a){return this.length<1?!1:I(a).test(this[0].className)},addClass:function(a){return this.each(function(b){d=[];var e=this.className,f=M(this,a,b,e);f.split(/\s+/g).forEach(function(a){c(this).hasClass(a)||d.push(a)},this),d.length&&(this.className+=(e?" ":"")+d.join(" "))})},removeClass:function(b){return this.each(function(c){if(b===a)return this.className="";d=this.className,M(this,b,c,d).split(/\s+/g).forEach(function(a){d=d.replace(I(a)," ")}),this.className=d.trim()})},toggleClass:function(b,d){return this.each(function(e){var f=M(this,b,e,this.className);(d===a?!c(this).hasClass(f):d)?c(this).addClass(f):c(this).removeClass(f)})}},["width","height"].forEach(function(b){c.fn[b]=function(d){var e,f=b.replace(/./,function(a){return a[0].toUpperCase()});return d===a?this[0]==window?window["inner"+f]:this[0]==g?g.documentElement["offset"+f]:(e=this.offset())&&e[b]:this.each(function(a){var e=c(this);e.css(b,M(this,d,a,e[b]()))})}}),n.forEach(function(a,b){c.fn[a]=function(){var a=c.map(arguments,function(a){return B(a)?a:w.fragment(a)});if(a.length<1)return this;var d=this.length,e=d>1,f=b<2;return this.each(function(c,g){for(var h=0;h0&&this.bind(o,n),setTimeout(function(){m.css(i),e<=0&&setTimeout(function(){m.each(function(){n.call(this)})},0)},0),this},i=null}(Zepto),function($){function triggerAndReturn(a,b,c){var d=$.Event(b);return $(a).trigger(d,c),!d.defaultPrevented}function triggerGlobal(a,b,c,d){if(a.global)return triggerAndReturn(b||document,c,d)}function ajaxStart(a){a.global&&$.active++===0&&triggerGlobal(a,null,"ajaxStart")}function ajaxStop(a){a.global&&!--$.active&&triggerGlobal(a,null,"ajaxStop")}function ajaxBeforeSend(a,b){var c=b.context;if(b.beforeSend.call(c,a,b)===!1||triggerGlobal(b,c,"ajaxBeforeSend",[a,b])===!1)return!1;triggerGlobal(b,c,"ajaxSend",[a,b])}function ajaxSuccess(a,b,c){var d=c.context,e="success";c.success.call(d,a,e,b),triggerGlobal(c,d,"ajaxSuccess",[b,c,a]),ajaxComplete(e,b,c)}function ajaxError(a,b,c,d){var e=d.context;d.error.call(e,c,b,a),triggerGlobal(d,e,"ajaxError",[c,d,a]),ajaxComplete(b,c,d)}function ajaxComplete(a,b,c){var d=c.context;c.complete.call(d,b,a),triggerGlobal(c,d,"ajaxComplete",[b,c]),ajaxStop(c)}function empty(){}function mimeToDataType(a){return a&&(a==htmlType?"html":a==jsonType?"json":scriptTypeRE.test(a)?"script":xmlTypeRE.test(a)&&"xml")||"text"}function appendQuery(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function serializeData(a){isObject(a.data)&&(a.data=$.param(a.data)),a.data&&(!a.type||a.type.toUpperCase()=="GET")&&(a.url=appendQuery(a.url,a.data))}function serialize(a,b,c,d){var e=$.isArray(b);$.each(b,function(b,f){d&&(b=c?d:d+"["+(e?"":b)+"]"),!d&&e?a.add(f.name,f.value):(c?$.isArray(f):isObject(f))?serialize(a,f,c,b):a.add(b,f)})}var jsonpID=0,isObject=$.isObject,document=window.document,key,name,rscript=/)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(a){var b="jsonp"+ ++jsonpID,c=document.createElement("script"),d=function(){$(c).remove(),b in window&&(window[b]=empty),ajaxComplete("abort",e,a)},e={abort:d},f;return a.error&&(c.onerror=function(){e.abort(),a.error()}),window[b]=function(d){clearTimeout(f),$(c).remove(),delete window[b],ajaxSuccess(d,e,a)},serializeData(a),c.src=a.url.replace(/=\?/,"="+b),$("head").append(c),a.timeout>0&&(f=setTimeout(function(){e.abort(),ajaxComplete("timeout",e,a)},a.timeout)),e},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0},$.ajax=function(options){var settings=$.extend({},options||{});for(key in $.ajaxSettings)settings[key]===undefined&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host);var dataType=settings.dataType,hasPlaceholder=/=\?/.test(settings.url);if(dataType=="jsonp"||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,"callback=?")),$.ajaxJSONP(settings);settings.url||(settings.url=window.location.toString()),serializeData(settings);var mime=settings.accepts[dataType],baseHeaders={},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=$.ajaxSettings.xhr(),abortTimeout;settings.crossDomain||(baseHeaders["X-Requested-With"]="XMLHttpRequest"),mime&&(baseHeaders.Accept=mime,mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime));if(settings.contentType||settings.data&&settings.type.toUpperCase()!="GET")baseHeaders["Content-Type"]=settings.contentType||"application/x-www-form-urlencoded";settings.headers=$.extend(baseHeaders,settings.headers||{}),xhr.onreadystatechange=function(){if(xhr.readyState==4){clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&xhr.status<300||xhr.status==304||xhr.status==0&&protocol=="file:"){dataType=dataType||mimeToDataType(xhr.getResponseHeader("content-type")),result=xhr.responseText;try{dataType=="script"?(1,eval)(result):dataType=="xml"?result=xhr.responseXML:dataType=="json"&&(result=blankRE.test(result)?null:JSON.parse(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings):ajaxSuccess(result,xhr,settings)}else ajaxError(null,"error",xhr,settings)}};var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async);for(name in settings.headers)xhr.setRequestHeader(name,settings.headers[name]);return ajaxBeforeSend(xhr,settings)===!1?(xhr.abort(),!1):(settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr)},$.get=function(a,b){return $.ajax({url:a,success:b})},$.post=function(a,b,c,d){return $.isFunction(b)&&(d=d||c,c=b,b=null),$.ajax({type:"POST",url:a,data:b,success:c,dataType:d})},$.getJSON=function(a,b){return $.ajax({url:a,success:b,dataType:"json"})},$.fn.load=function(a,b){if(!this.length)return this;var c=this,d=a.split(/\s/),e;return d.length>1&&(a=d[0],e=d[1]),$.get(a,function(a){c.html(e?$(document.createElement("div")).html(a.replace(rscript,"")).find(e).html():a),b&&b.call(c)}),this};var escape=encodeURIComponent;$.param=function(a,b){var c=[];return c.add=function(a,b){this.push(escape(a)+"="+escape(b))},serialize(c,a,b),c.join("&").replace("%20","+")}}(Zepto),function(a){a.fn.serializeArray=function(){var b=[],c;return a(Array.prototype.slice.call(this.get(0).elements)).each(function(){c=a(this);var d=c.attr("type");this.nodeName.toLowerCase()!="fieldset"&&!this.disabled&&d!="submit"&&d!="reset"&&d!="button"&&(d!="radio"&&d!="checkbox"||this.checked)&&b.push({name:c.attr("name"),value:c.val()})}),b},a.fn.serialize=function(){var a=[];return this.serializeArray().forEach(function(b){a.push(encodeURIComponent(b.name)+"="+encodeURIComponent(b.value))}),a.join("&")},a.fn.submit=function(b){if(b)this.bind("submit",b);else if(this.length){var c=a.Event("submit");this.eq(0).trigger(c),c.defaultPrevented||this.get(0).submit()}return this}}(Zepto),function(a){function d(a){return"tagName"in a?a:a.parentNode}function e(a,b,c,d){var e=Math.abs(a-b),f=Math.abs(c-d);return e>=f?a-b>0?"Left":"Right":c-d>0?"Up":"Down"}function h(){g=null,b.last&&(b.el.trigger("longTap"),b={})}function i(){g&&clearTimeout(g),g=null}var b={},c,f=750,g;a(document).ready(function(){var j,k;a(document.body).bind("touchstart",function(e){j=Date.now(),k=j-(b.last||j),b.el=a(d(e.touches[0].target)),c&&clearTimeout(c),b.x1=e.touches[0].pageX,b.y1=e.touches[0].pageY,k>0&&k<=250&&(b.isDoubleTap=!0),b.last=j,g=setTimeout(h,f)}).bind("touchmove",function(a){i(),b.x2=a.touches[0].pageX,b.y2=a.touches[0].pageY}).bind("touchend",function(a){i(),b.isDoubleTap?(b.el.trigger("doubleTap"),b={}):b.x2&&Math.abs(b.x1-b.x2)>30||b.y2&&Math.abs(b.y1-b.y2)>30?(b.el.trigger("swipe")&&b.el.trigger("swipe"+e(b.x1,b.x2,b.y1,b.y2)),b={}):"last"in b&&(b.el.trigger("tap"),c=setTimeout(function(){c=null,b.el.trigger("singleTap"),b={}},250))}).bind("touchcancel",function(){c&&clearTimeout(c),g&&clearTimeout(g),g=c=null,b={}})}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(b){a.fn[b]=function(a){return this.bind(b,a)}})}(Zepto); -------------------------------------------------------------------------------- /dist/h5-base.min.js: -------------------------------------------------------------------------------- 1 | !function(t){String.prototype.trim===t&&(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),Array.prototype.reduce===t&&(Array.prototype.reduce=function(n){if(void 0===this||null===this)throw new TypeError;var e,i=Object(this),r=i.length>>>0,o=0;if("function"!=typeof n)throw new TypeError;if(0==r&&1==arguments.length)throw new TypeError;if(arguments.length>=2)e=arguments[1];else for(;;){if(o in i){e=i[o++];break}if(++o>=r)throw new TypeError}for(;r>o;)o in i&&(e=n.call(t,e,i[o],o,i)),o++;return e})}();var Zepto=function(){function t(t){return"[object Function]"==B.call(t)}function n(t){return t instanceof Object}function e(n){var e,i;if("[object Object]"!==B.call(n))return!1;if(i=t(n.constructor)&&n.constructor.prototype,!i||!hasOwnProperty.call(i,"isPrototypeOf"))return!1;for(e in n);return e===m||hasOwnProperty.call(n,e)}function i(t){return t instanceof Array}function r(t){return"number"==typeof t.length}function o(t){return t.filter(function(t){return t!==m&&null!==t})}function a(t){return t.length>0?[].concat.apply([],t):t}function s(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function u(t){return t in M?M[t]:M[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function c(t,n){return"number"!=typeof n||j[s(t)]?n:n+"px"}function l(t){var n,e;return C[t]||(n=E.createElement(t),E.body.appendChild(n),e=S(n,"").getPropertyValue("display"),n.parentNode.removeChild(n),"none"==e&&(e="block"),C[t]=e),C[t]}function f(t,n){return n===m?g(t):g(t).filter(n)}function h(n,e,i,r){return t(e)?e.call(n,i,r):e}function d(t,n,e){var i=t%2?n:n.parentNode;i?i.insertBefore(e,t?1==t?i.firstChild:2==t?n:null:n.nextSibling):g(e).remove()}function p(t,n){n(t);for(var e in t.childNodes)p(t.childNodes[e],n)}var m,v,g,y,w,T,x=[],b=x.slice,E=window.document,C={},M={},S=E.defaultView.getComputedStyle,j={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},k=/^\s*<(\w+|!)[^>]*>/,O=[1,3,8,9,11],A=["after","prepend","before","append"],N=E.createElement("table"),U=E.createElement("tr"),P={tr:E.createElement("tbody"),tbody:N,thead:N,tfoot:N,td:U,th:U,"*":E.createElement("div")},R=/complete|loaded|interactive/,L=/^\.([\w-]+)$/,_=/^#([\w-]+)$/,D=/^[\w-]+$/,B={}.toString,Z={},H=E.createElement("div");return Z.matches=function(t,n){if(!t||1!==t.nodeType)return!1;var e=t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(e)return e.call(t,n);var i,r=t.parentNode,o=!r;return o&&(r=H).appendChild(t),i=~Z.qsa(r,n).indexOf(t),o&&H.removeChild(t),i},w=function(t){return t.replace(/-+(.)?/g,function(t,n){return n?n.toUpperCase():""})},T=function(t){return t.filter(function(n,e){return t.indexOf(n)==e})},Z.fragment=function(t,n){n===m&&(n=k.test(t)&&RegExp.$1),n in P||(n="*");var e=P[n];return e.innerHTML=""+t,g.each(b.call(e.childNodes),function(){e.removeChild(this)})},Z.Z=function(t,n){return t=t||[],t.__proto__=arguments.callee.prototype,t.selector=n||"",t},Z.isZ=function(t){return t instanceof Z.Z},Z.init=function(n,r){if(!n)return Z.Z();if(t(n))return g(E).ready(n);if(Z.isZ(n))return n;var a;if(i(n))a=o(n);else if(e(n))a=[g.extend({},n)],n=null;else if(O.indexOf(n.nodeType)>=0||n===window)a=[n],n=null;else if(k.test(n))a=Z.fragment(n.trim(),RegExp.$1),n=null;else{if(r!==m)return g(r).find(n);a=Z.qsa(E,n)}return Z.Z(a,n)},g=function(t,n){return Z.init(t,n)},g.extend=function(t){return b.call(arguments,1).forEach(function(n){for(v in n)n[v]!==m&&(t[v]=n[v])}),t},Z.qsa=function(t,n){var e;return t===E&&_.test(n)?(e=t.getElementById(RegExp.$1))?[e]:x:1!==t.nodeType&&9!==t.nodeType?x:b.call(L.test(n)?t.getElementsByClassName(RegExp.$1):D.test(n)?t.getElementsByTagName(n):t.querySelectorAll(n))},g.isFunction=t,g.isObject=n,g.isArray=i,g.isPlainObject=e,g.inArray=function(t,n,e){return x.indexOf.call(n,t,e)},g.trim=function(t){return t.trim()},g.uuid=0,g.map=function(t,n){var e,i,o,s=[];if(r(t))for(i=0;i0&&Z.matches(this[0],t)},not:function(n){var e=[];if(t(n)&&n.call!==m)this.each(function(t){n.call(this,t)||e.push(this)});else{var i="string"==typeof n?this.filter(n):r(n)&&t(n.item)?b.call(n):g(n);this.forEach(function(t){i.indexOf(t)<0&&e.push(t)})}return g(e)},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!n(t)?t:g(t)},last:function(){var t=this[this.length-1];return t&&!n(t)?t:g(t)},find:function(t){var n;return n=1==this.length?Z.qsa(this[0],t):this.map(function(){return Z.qsa(this,t)}),g(n)},closest:function(t,n){for(var e=this[0];e&&!Z.matches(e,t);)e=e!==n&&e!==E&&e.parentNode;return g(e)},parents:function(t){for(var n=[],e=this;e.length>0;)e=g.map(e,function(t){return(t=t.parentNode)&&t!==E&&n.indexOf(t)<0?(n.push(t),t):void 0});return f(n,t)},parent:function(t){return f(T(this.pluck("parentNode")),t)},children:function(t){return f(this.map(function(){return b.call(this.children)}),t)},siblings:function(t){return f(this.map(function(t,n){return b.call(n.parentNode.children).filter(function(t){return t!==n})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return this.map(function(){return this[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=null),"none"==S(this,"").getPropertyValue("display")&&(this.style.display=l(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){return this.each(function(){g(this).wrapAll(g(t)[0].cloneNode(!1))})},wrapAll:function(t){return this[0]&&(g(this[0]).before(t=g(t)),t.append(this)),this},unwrap:function(){return this.parent().each(function(){g(this).replaceWith(g(this).children())}),this},clone:function(){return g(this.map(function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(t){return(t===m?"none"==this.css("display"):t)?this.show():this.hide()},prev:function(){return g(this.pluck("previousElementSibling"))},next:function(){return g(this.pluck("nextElementSibling"))},html:function(t){return t===m?this.length>0?this[0].innerHTML:null:this.each(function(n){var e=this.innerHTML;g(this).empty().append(h(this,t,n,e))})},text:function(t){return t===m?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=t})},attr:function(t,e){var i;return"string"==typeof t&&e===m?0==this.length||1!==this[0].nodeType?m:"value"==t&&"INPUT"==this[0].nodeName?this.val():!(i=this[0].getAttribute(t))&&t in this[0]?this[0][t]:i:this.each(function(i){if(1===this.nodeType)if(n(t))for(v in t)this.setAttribute(v,t[v]);else this.setAttribute(t,h(this,e,i,this.getAttribute(t)))})},removeAttr:function(t){return this.each(function(){1===this.nodeType&&this.removeAttribute(t)})},prop:function(t,n){return n===m?this[0]?this[0][t]:m:this.each(function(e){this[t]=h(this,n,e,this[t])})},data:function(t,n){var e=this.attr("data-"+s(t),n);return null!==e?e:m},val:function(t){return t===m?this.length>0?this[0].value:m:this.each(function(n){this.value=h(this,t,n,this.value)})},offset:function(){if(0==this.length)return null;var t=this[0].getBoundingClientRect();return{left:t.left+window.pageXOffset,top:t.top+window.pageYOffset,width:t.width,height:t.height}},css:function(t,n){if(n===m&&"string"==typeof t)return 0==this.length?m:this[0].style[w(t)]||S(this[0],"").getPropertyValue(t);var e="";for(v in t)"string"==typeof t[v]&&""==t[v]?this.each(function(){this.style.removeProperty(s(v))}):e+=s(v)+":"+c(v,t[v])+";";return"string"==typeof t&&(""==n?this.each(function(){this.style.removeProperty(s(t))}):e=s(t)+":"+c(t,n)),this.each(function(){this.style.cssText+=";"+e})},index:function(t){return t?this.indexOf(g(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return this.length<1?!1:u(t).test(this[0].className)},addClass:function(t){return this.each(function(n){y=[];var e=this.className,i=h(this,t,n,e);i.split(/\s+/g).forEach(function(t){g(this).hasClass(t)||y.push(t)},this),y.length&&(this.className+=(e?" ":"")+y.join(" "))})},removeClass:function(t){return this.each(function(n){return t===m?this.className="":(y=this.className,h(this,t,n,y).split(/\s+/g).forEach(function(t){y=y.replace(u(t)," ")}),this.className=y.trim(),void 0)})},toggleClass:function(t,n){return this.each(function(e){var i=h(this,t,e,this.className);(n===m?!g(this).hasClass(i):n)?g(this).addClass(i):g(this).removeClass(i)})}},["width","height"].forEach(function(t){g.fn[t]=function(n){var e,i=t.replace(/./,function(t){return t[0].toUpperCase()});return n===m?this[0]==window?window["inner"+i]:this[0]==E?E.documentElement["offset"+i]:(e=this.offset())&&e[t]:this.each(function(e){var i=g(this);i.css(t,h(this,n,e,i[t]()))})}}),A.forEach(function(t,e){g.fn[t]=function(){var t=g.map(arguments,function(t){return n(t)?t:Z.fragment(t)});if(t.length<1)return this;var i=this.length,r=i>1,o=2>e;return this.each(function(n,a){for(var s=0;sn&&(u=u.cloneNode(!0)),d(e,a,u)}})},g.fn[e%2?t+"To":"insert"+(e?"Before":"After")]=function(n){return g(n)[t](this),this}}),Z.Z.prototype=g.fn,Z.camelize=w,Z.uniq=T,g.zepto=Z,g}();window.Zepto=Zepto,"$"in window||(window.$=Zepto),function(t){function n(t){return t._zid||(t._zid=f++)}function e(t,e,o,a){if(e=i(e),e.ns)var s=r(e.ns);return(l[n(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||s.test(t.ns))&&(!o||n(t.fn)===n(o))&&(!a||t.sel==a)})}function i(t){var n=(""+t).split(".");return{e:n[0],ns:n.slice(1).sort().join(" ")}}function r(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function o(n,e,i){t.isObject(n)?t.each(n,i):n.split(/\s/).forEach(function(t){i(t,e)})}function a(e,r,a,s,u,c){c=!!c;var f=n(e),h=l[f]||(l[f]=[]);o(r,a,function(n,r){var o=u&&u(r,n),a=o||r,l=function(t){var n=a.apply(e,[t].concat(t.data));return n===!1&&t.preventDefault(),n},f=t.extend(i(n),{fn:r,proxy:l,sel:s,del:o,i:h.length});h.push(f),e.addEventListener(f.e,l,c)})}function s(t,i,r,a){var s=n(t);o(i||"",r,function(n,i){e(t,n,i,a).forEach(function(n){delete l[s][n.i],t.removeEventListener(n.e,n.proxy,!1)})})}function u(n){var e=t.extend({originalEvent:n},n);return t.each(m,function(t,i){e[t]=function(){return this[i]=d,n[t].apply(n,arguments)},e[i]=p}),e}function c(t){if(!("defaultPrevented"in t)){t.defaultPrevented=!1;var n=t.preventDefault;t.preventDefault=function(){this.defaultPrevented=!0,n.call(this)}}}var l=(t.zepto.qsa,{}),f=1,h={};h.click=h.mousedown=h.mouseup=h.mousemove="MouseEvents",t.event={add:a,remove:s},t.proxy=function(e,i){if(t.isFunction(e)){var r=function(){return e.apply(i,arguments)};return r._zid=n(e),r}if("string"==typeof i)return t.proxy(e[i],e);throw new TypeError("expected function")},t.fn.bind=function(t,n){return this.each(function(){a(this,t,n)})},t.fn.unbind=function(t,n){return this.each(function(){s(this,t,n)})},t.fn.one=function(t,n){return this.each(function(e,i){a(this,t,n,null,function(t,n){return function(){var e=t.apply(i,arguments);return s(i,n,t),e}})})};var d=function(){return!0},p=function(){return!1},m={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(n,e,i){var r=!1;return"blur"!=e&&"focus"!=e||(t.iswebkit?e="blur"==e?"focusout":"focus"==e?"focusin":e:r=!0),this.each(function(o,s){a(s,e,i,n,function(e){return function(i){var r,o=t(i.target).closest(n,s).get(0);return o?(r=t.extend(u(i),{currentTarget:o,liveFired:s}),e.apply(o,[r].concat([].slice.call(arguments,1)))):void 0}},r)})},t.fn.undelegate=function(t,n,e){return this.each(function(){s(this,n,e,t)})},t.fn.live=function(n,e){return t(document.body).delegate(this.selector,n,e),this},t.fn.die=function(n,e){return t(document.body).undelegate(this.selector,n,e),this},t.fn.on=function(n,e,i){return void 0==e||t.isFunction(e)?this.bind(n,e):this.delegate(e,n,i)},t.fn.off=function(n,e,i){return void 0==e||t.isFunction(e)?this.unbind(n,e):this.undelegate(e,n,i)},t.fn.trigger=function(n,e){return"string"==typeof n&&(n=t.Event(n)),c(n),n.data=e,this.each(function(){"dispatchEvent"in this&&this.dispatchEvent(n)})},t.fn.triggerHandler=function(n,i){var r,o;return this.each(function(a,s){r=u("string"==typeof n?t.Event(n):n),r.data=i,r.target=s,t.each(e(s,n.type||n),function(t,n){return o=n.proxy(r),r.isImmediatePropagationStopped()?!1:void 0})}),o},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout change select keydown keypress keyup error".split(" ").forEach(function(n){t.fn[n]=function(t){return this.bind(n,t)}}),["focus","blur"].forEach(function(n){t.fn[n]=function(t){if(t)this.bind(n,t);else if(this.length)try{this.get(0)[n]()}catch(e){}return this}}),t.Event=function(t,n){var e=document.createEvent(h[t]||"Events"),i=!0;if(n)for(var r in n)"bubbles"==r?i=!!n[r]:e[r]=n[r];return e.initEvent(t,i,!0,null,null,null,null,null,null,null,null,null,null,null,null),e}}(Zepto),function(t){function n(t){var n=this.os={},e=this.browser={},i=t.match(/WebKit\/([\d.]+)/),r=t.match(/(Android)\s+([\d.]+)/),o=t.match(/(iPad).*OS\s([\d_]+)/),a=!o&&t.match(/(iPhone\sOS)\s([\d_]+)/),s=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),u=s&&t.match(/TouchPad/),c=t.match(/Kindle\/([\d.]+)/),l=t.match(/Silk\/([\d._]+)/),f=t.match(/(BlackBerry).*Version\/([\d.]+)/);(e.webkit=!!i)&&(e.version=i[1]),r&&(n.android=!0,n.version=r[2]),a&&(n.ios=n.iphone=!0,n.version=a[2].replace(/_/g,".")),o&&(n.ios=n.ipad=!0,n.version=o[2].replace(/_/g,".")),s&&(n.webos=!0,n.version=s[2]),u&&(n.touchpad=!0),f&&(n.blackberry=!0,n.version=f[2]),c&&(n.kindle=!0,n.version=c[1]),l&&(e.silk=!0,e.version=l[1]),!l&&n.android&&t.match(/Kindle Fire/)&&(e.silk=!0)}n.call(t,navigator.userAgent),t.__detect=n}(Zepto),function(t,n){function e(t){return t.toLowerCase()}function i(t){return r?r+t:e(t)}var r,o="",a={Webkit:"webkit",Moz:"",O:"o",ms:"MS"},s=window.document,u=s.createElement("div"),c=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,l={};t.each(a,function(t,i){return u.style[t+"TransitionProperty"]!==n?(o="-"+e(t)+"-",r=i,!1):void 0}),l[o+"transition-property"]=l[o+"transition-duration"]=l[o+"transition-timing-function"]=l[o+"animation-name"]=l[o+"animation-duration"]="",t.fx={off:r===n&&u.style.transitionProperty===n,cssPrefix:o,transitionEnd:i("TransitionEnd"),animationEnd:i("AnimationEnd")},t.fn.animate=function(n,e,i,r){return t.isObject(e)&&(i=e.easing,r=e.complete,e=e.duration),e&&(e/=1e3),this.anim(n,e,i,r)},t.fn.anim=function(e,i,r,a){var s,u,f,h={},d=this,p=t.fx.transitionEnd;if(i===n&&(i=.4),t.fx.off&&(i=0),"string"==typeof e)h[o+"animation-name"]=e,h[o+"animation-duration"]=i+"s",p=t.fx.animationEnd;else{for(u in e)c.test(u)?(s||(s=[]),s.push(u+"("+e[u]+")")):h[u]=e[u];s&&(h[o+"transform"]=s.join(" ")),!t.fx.off&&"object"==typeof e&&(h[o+"transition-property"]=Object.keys(e).join(", "),h[o+"transition-duration"]=i+"s",h[o+"transition-timing-function"]=r||"linear")}return f=function(n){if("undefined"!=typeof n){if(n.target!==n.currentTarget)return;t(n.target).unbind(p,arguments.callee)}t(this).css(l),a&&a.call(this)},i>0&&this.bind(p,f),setTimeout(function(){d.css(h),0>=i&&setTimeout(function(){d.each(function(){f.call(this)})},0)},0),this},u=null}(Zepto),function(t){function n(n,e,i){var r=t.Event(e);return t(n).trigger(r,i),!r.defaultPrevented}function e(t,e,i,r){return t.global?n(e||y,i,r):void 0}function i(n){n.global&&0===t.active++&&e(n,null,"ajaxStart")}function r(n){n.global&&!--t.active&&e(n,null,"ajaxStop")}function o(t,n){var i=n.context;return n.beforeSend.call(i,t,n)===!1||e(n,i,"ajaxBeforeSend",[t,n])===!1?!1:void e(n,i,"ajaxSend",[t,n])}function a(t,n,i){var r=i.context,o="success";i.success.call(r,t,o,n),e(i,r,"ajaxSuccess",[n,i,t]),u(o,n,i)}function s(t,n,i,r){var o=r.context;r.error.call(o,i,n,t),e(r,o,"ajaxError",[i,r,t]),u(n,i,r)}function u(t,n,i){var o=i.context;i.complete.call(o,n,t),e(i,o,"ajaxComplete",[n,i]),r(i)}function c(){}function l(t){return t&&(t==E?"html":t==b?"json":T.test(t)?"script":x.test(t)&&"xml")||"text"}function f(t,n){return(t+"&"+n).replace(/[&?]{1,2}/,"?")}function h(n){g(n.data)&&(n.data=t.param(n.data)),n.data&&(!n.type||"GET"==n.type.toUpperCase())&&(n.url=f(n.url,n.data))}function d(n,e,i,r){var o=t.isArray(e);t.each(e,function(e,a){r&&(e=i?r:r+"["+(o?"":e)+"]"),!r&&o?n.add(a.name,a.value):(i?t.isArray(a):g(a))?d(n,a,i,e):n.add(e,a)})}var p,m,v=0,g=t.isObject,y=window.document,w=/)<[^<]*)*<\/script>/gi,T=/^(?:text|application)\/javascript/i,x=/^(?:text|application)\/xml/i,b="application/json",E="text/html",C=/^\s*$/;t.active=0,t.ajaxJSONP=function(n){var e,i="jsonp"+ ++v,r=y.createElement("script"),o=function(){t(r).remove(),i in window&&(window[i]=c),u("abort",s,n)},s={abort:o};return n.error&&(r.onerror=function(){s.abort(),n.error()}),window[i]=function(o){clearTimeout(e),t(r).remove(),delete window[i],a(o,s,n)},h(n),r.src=n.url.replace(/=\?/,"="+i),t("head").append(r),n.timeout>0&&(e=setTimeout(function(){s.abort(),u("timeout",s,n)},n.timeout)),s},t.ajaxSettings={type:"GET",beforeSend:c,success:c,error:c,complete:c,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript",json:b,xml:"application/xml, text/xml",html:E,text:"text/plain"},crossDomain:!1,timeout:0},t.ajax=function(n){var e=t.extend({},n||{});for(p in t.ajaxSettings)void 0===e[p]&&(e[p]=t.ajaxSettings[p]);i(e),e.crossDomain||(e.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(e.url)&&RegExp.$2!=window.location.host);var r=e.dataType,u=/=\?/.test(e.url);if("jsonp"==r||u)return u||(e.url=f(e.url,"callback=?")),t.ajaxJSONP(e);e.url||(e.url=window.location.toString()),h(e);var d,v=e.accepts[r],g={},y=/^([\w-]+:)\/\//.test(e.url)?RegExp.$1:window.location.protocol,w=t.ajaxSettings.xhr();e.crossDomain||(g["X-Requested-With"]="XMLHttpRequest"),v&&(g.Accept=v,v.indexOf(",")>-1&&(v=v.split(",",2)[0]),w.overrideMimeType&&w.overrideMimeType(v)),(e.contentType||e.data&&"GET"!=e.type.toUpperCase())&&(g["Content-Type"]=e.contentType||"application/x-www-form-urlencoded"),e.headers=t.extend(g,e.headers||{}),w.onreadystatechange=function(){if(4==w.readyState){clearTimeout(d);var t,n=!1;if(w.status>=200&&w.status<300||304==w.status||0==w.status&&"file:"==y){r=r||l(w.getResponseHeader("content-type")),t=w.responseText;try{"script"==r?(0,eval)(t):"xml"==r?t=w.responseXML:"json"==r&&(t=C.test(t)?null:JSON.parse(t))}catch(i){n=i}n?s(n,"parsererror",w,e):a(t,w,e)}else s(null,"error",w,e)}};var T="async"in e?e.async:!0;w.open(e.type,e.url,T);for(m in e.headers)w.setRequestHeader(m,e.headers[m]);return o(w,e)===!1?(w.abort(),!1):(e.timeout>0&&(d=setTimeout(function(){w.onreadystatechange=c,w.abort(),s(null,"timeout",w,e)},e.timeout)),w.send(e.data?e.data:null),w)},t.get=function(n,e){return t.ajax({url:n,success:e})},t.post=function(n,e,i,r){return t.isFunction(e)&&(r=r||i,i=e,e=null),t.ajax({type:"POST",url:n,data:e,success:i,dataType:r})},t.getJSON=function(n,e){return t.ajax({url:n,success:e,dataType:"json"})},t.fn.load=function(n,e){if(!this.length)return this;var i,r=this,o=n.split(/\s/);return o.length>1&&(n=o[0],i=o[1]),t.get(n,function(n){r.html(i?t(y.createElement("div")).html(n.replace(w,"")).find(i).html():n),e&&e.call(r)}),this};var M=encodeURIComponent;t.param=function(t,n){var e=[];return e.add=function(t,n){this.push(M(t)+"="+M(n))},d(e,t,n),e.join("&").replace("%20","+")}}(Zepto),function(t){t.fn.serializeArray=function(){var n,e=[];return t(Array.prototype.slice.call(this.get(0).elements)).each(function(){n=t(this);var i=n.attr("type");"fieldset"!=this.nodeName.toLowerCase()&&!this.disabled&&"submit"!=i&&"reset"!=i&&"button"!=i&&("radio"!=i&&"checkbox"!=i||this.checked)&&e.push({name:n.attr("name"),value:n.val()})}),e},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(n){t.push(encodeURIComponent(n.name)+"="+encodeURIComponent(n.value))}),t.join("&")},t.fn.submit=function(n){if(n)this.bind("submit",n);else if(this.length){var e=t.Event("submit");this.eq(0).trigger(e),e.defaultPrevented||this.get(0).submit()}return this}}(Zepto),function(t){function n(t){return"tagName"in t?t:t.parentNode}function e(t,n,e,i){var r=Math.abs(t-n),o=Math.abs(e-i);return r>=o?t-n>0?"Left":"Right":e-i>0?"Up":"Down"}function i(){a=null,s.last&&(s.el.trigger("longTap"),s={})}function r(){a&&clearTimeout(a),a=null}var o,a,s={},u=750;t(document).ready(function(){var c,l;t(document.body).bind("touchstart",function(e){c=Date.now(),l=c-(s.last||c),s.el=t(n(e.touches[0].target)),o&&clearTimeout(o),s.x1=e.touches[0].pageX,s.y1=e.touches[0].pageY,l>0&&250>=l&&(s.isDoubleTap=!0),s.last=c,a=setTimeout(i,u)}).bind("touchmove",function(t){r(),s.x2=t.touches[0].pageX,s.y2=t.touches[0].pageY}).bind("touchend",function(t){r(),s.isDoubleTap?(s.el.trigger("doubleTap"),s={}):s.x2&&Math.abs(s.x1-s.x2)>30||s.y2&&Math.abs(s.y1-s.y2)>30?(s.el.trigger("swipe")&&s.el.trigger("swipe"+e(s.x1,s.x2,s.y1,s.y2)),s={}):"last"in s&&(s.el.trigger("tap"),o=setTimeout(function(){o=null,s.el.trigger("singleTap"),s={}},250))}).bind("touchcancel",function(){o&&clearTimeout(o),a&&clearTimeout(a),a=o=null,s={}})}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(n){t.fn[n]=function(t){return this.bind(n,t)}})}(Zepto),function(t,n,e){t.MT={TOUCH_START:"touchstart",TOUCH_END:"touchend"},MT.p2m=function(n){var e=0,i=null,r=t.innerWidth,o=function(){var t=document.body.clientWidth;clearTimeout(i),t>414&&(r=414,MT.TOUCH_START="click",MT.TOUCH_END="click"),document.getElementsByTagName("html")[0].style.fontSize=r/n*100+"px",r>t&&10>=e?i=setTimeout(function(){o(++e)},100):document.getElementsByTagName("body")[0].style.opacity=1};o(),t.onresize=o},MT.getUrlParam=function(t){for(var n=decodeURIComponent(t||location.href).split("?")[1].split("&"),e={},i=0;i1?(e=r>e?e:r,i=Math.round(e/a),i>o&&(i=o,e=Math.round(i*a))):(i=o>i?i:o,e=Math.round(i*a),e>r&&(e=r,i=Math.round(e/a))),t.width=e,t.height=i,t.getContext("2d").drawImage(this,0,0),n(t.toDataURL("image/jpeg").substring(23))},e.src=t.target.result}},MT.judgePlat=function(){var t="other",n=navigator.userAgent.toLowerCase();return/MicroMessenger/i.test(n)&&(t="weixin"),/weibo/i.test(n)&&(t="weibo"),t},MT.isAndroid=function(){return/Android|HTC/i.test(navigator.userAgent.toLowerCase())},MT.isIOS=function(){return/iPod|iPad|iPhone/i.test(navigator.userAgent.toLowerCase())},MT.setCookie=function(t,n,e){var i=new Date,r=i.getTime()+24*e*60*60*1e3;document.cookie=t+"="+escape(n)+";expires="+new Date(r)},MT.getCookie=function(t){var n=new RegExp("(^| )"+name+"=([^;]*)(;|$)"),e=document.cookie.match(n);return null!==e?unescape(e[2]):!1},MT.delCookie=function(t){MT.setCookie(t,"",-1)},MT.getPhoneCode=function(t){var e=n.extend({sendBtn:null,time:60,disabled:"disabled",sendCode:function(){}},t),i=null,r=e.time;e.sendBtn.on(MT.TOUCH_START,function(){if("true"!=e.sendBtn.data("lock")){if("function"!=typeof e.sendCode)return MT.toast("错误:"+e.sendCode+"应为函数"),!1;e.sendCode(),e.sendBtn.addClass(e.disabled).data("lock",!0),e.sendBtn.text("重新发送(60)"),i=setInterval(function(){--r>0?e.sendBtn.text("重新发送("+r+")"):(e.sendBtn.removeClass(e.disabled).text("重新发送").data("lock",!1),clearInterval(i),r=e.time)},1e3)}})},MT.delayGo=function(t,n){var e=setTimeout(function(){"string"==typeof t?location.href=t:"function"==typeof t&&t(),clearTimeout(e)},n||1500)},MT.cutContent=function(t,n,e){var i="";return t.length>n&&(i=t.substr(0,n)),i+(e||"...")},MT.toast=function(t,e,i){n(".mt-toast").remove(),n("body").append("

"+t+"

");var r=setTimeout(function(){n(".mt-toast").remove(),i&&i(),clearTimeout(r)},e||2e3)},MT.listenNet=function(){t.addEventListener("offline",function(){MT.toast("网络连接失败,请重试",1e6)},!1),t.addEventListener("online",function(){n(".mt-toast").remove()},!1)},MT.orientation=function(){t.addEventListener("orientationchange",function(){location.reload()})},MT.confirm=function(t){var e=n.extend({text:"提示",okBtnText:"确定",cancelBtnText:"取消",okCallback:function(){},cancelCallback:function(){},close:function(){n(".mt-confirm-dialog").remove(),n(".mt-mask").remove()}},t||{}),i=['
','

',e.text,"

",'

',e.okBtnText,"",'',e.cancelBtnText,"

","
",'
'].join("");n("body").append(i),n(".mt-mask").show();var r=n(".mt-confirm-btn"),o=n(".mt-cancel-btn");r.on(MT.TOUCH_START,function(){r.addClass("touch-btn")}).on(MT.TOUCH_END,function(){r.removeClass("touch-btn"),e.okCallback(),e.close()}),o.on(MT.TOUCH_START,function(){o.addClass("mt-touch-btn")}).on(MT.TOUCH_END,function(){o.removeClass("mt-touch-btn"),e.cancelCallback(),e.close()})},MT.animArrow=function(t){var e=t?t:"",i=['
'].join();n("body").append(i)},MT.downloadApp=function(t){var e=n.extend({position:"static",height:"1rem",wxUrl:"",androidUrl:"",iosUrl:"",imgUrl:""},t||{}),i="",r=MT.judgePlat();"weixin"==r?e.downloadUrl=wxUrl:"ios"==r?e.downloadUrl=iosUrl:"android"==r&&(e.downloadUrl=androidUrl),i=['
'].join(""),n("body").append(i)},MT.rotateTip=function(){var t=setTimeout(function(){n("body").append('
请切换至竖屏显示
'),clearTimeout(t)},0)},MT.shareWx=function(t,e){var i=function(t){wx.config({debug:!1,appId:t.appId,timestamp:t.timestamp,nonceStr:t.nonceStr,signature:t.signature,jsApiList:["onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareWeibo","chooseImage","previewImage","uploadImage","downloadImage"]}),wx.ready(function(){var n={title:t.title,desc:t.desc,link:location.href,imgUrl:t.imgUrl,success:function(){}};wx.onMenuShareAppMessage(n),wx.onMenuShareQQ(n),wx.onMenuShareWeibo(n),wx.onMenuShareTimeline(n),console.log("weixin support set success.")}),wx.error(function(t){})};n.ajax({url:e,dataType:"json",data:location.href.split("#")[0],success:function(t){i(t)},error:function(t,n){console.log("xhr:"+t+"type:"+n),MT.toast("认证接口错误")}})}}(window,Zepto); -------------------------------------------------------------------------------- /dist/h5-base.js: -------------------------------------------------------------------------------- 1 | /* Zepto v1.0rc1 - polyfill zepto event detect fx ajax form touch - zeptojs.com/license */ 2 | (function(a){String.prototype.trim===a&&(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),Array.prototype.reduce===a&&(Array.prototype.reduce=function(b){if(this===void 0||this===null)throw new TypeError;var c=Object(this),d=c.length>>>0,e=0,f;if(typeof b!="function")throw new TypeError;if(d==0&&arguments.length==1)throw new TypeError;if(arguments.length>=2)f=arguments[1];else do{if(e in c){f=c[e++];break}if(++e>=d)throw new TypeError}while(!0);while(e0?[].concat.apply([],a):a}function H(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function I(a){return a in i?i[a]:i[a]=new RegExp("(^|\\s)"+a+"(\\s|$)")}function J(a,b){return typeof b=="number"&&!k[H(a)]?b+"px":b}function K(a){var b,c;return h[a]||(b=g.createElement(a),g.body.appendChild(b),c=j(b,"").getPropertyValue("display"),b.parentNode.removeChild(b),c=="none"&&(c="block"),h[a]=c),h[a]}function L(b,d){return d===a?c(b):c(b).filter(d)}function M(a,b,c,d){return A(b)?b.call(a,c,d):b}function N(a,b,d){var e=a%2?b:b.parentNode;e?e.insertBefore(d,a?a==1?e.firstChild:a==2?b:null:b.nextSibling):c(d).remove()}function O(a,b){b(a);for(var c in a.childNodes)O(a.childNodes[c],b)}var a,b,c,d,e=[],f=e.slice,g=window.document,h={},i={},j=g.defaultView.getComputedStyle,k={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},l=/^\s*<(\w+|!)[^>]*>/,m=[1,3,8,9,11],n=["after","prepend","before","append"],o=g.createElement("table"),p=g.createElement("tr"),q={tr:g.createElement("tbody"),tbody:o,thead:o,tfoot:o,td:p,th:p,"*":g.createElement("div")},r=/complete|loaded|interactive/,s=/^\.([\w-]+)$/,t=/^#([\w-]+)$/,u=/^[\w-]+$/,v={}.toString,w={},x,y,z=g.createElement("div");return w.matches=function(a,b){if(!a||a.nodeType!==1)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var d,e=a.parentNode,f=!e;return f&&(e=z).appendChild(a),d=~w.qsa(e,b).indexOf(a),f&&z.removeChild(a),d},x=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},y=function(a){return a.filter(function(b,c){return a.indexOf(b)==c})},w.fragment=function(b,d){d===a&&(d=l.test(b)&&RegExp.$1),d in q||(d="*");var e=q[d];return e.innerHTML=""+b,c.each(f.call(e.childNodes),function(){e.removeChild(this)})},w.Z=function(a,b){return a=a||[],a.__proto__=arguments.callee.prototype,a.selector=b||"",a},w.isZ=function(a){return a instanceof w.Z},w.init=function(b,d){if(!b)return w.Z();if(A(b))return c(g).ready(b);if(w.isZ(b))return b;var e;if(D(b))e=F(b);else if(C(b))e=[c.extend({},b)],b=null;else if(m.indexOf(b.nodeType)>=0||b===window)e=[b],b=null;else if(l.test(b))e=w.fragment(b.trim(),RegExp.$1),b=null;else{if(d!==a)return c(d).find(b);e=w.qsa(g,b)}return w.Z(e,b)},c=function(a,b){return w.init(a,b)},c.extend=function(c){return f.call(arguments,1).forEach(function(d){for(b in d)d[b]!==a&&(c[b]=d[b])}),c},w.qsa=function(a,b){var c;return a===g&&t.test(b)?(c=a.getElementById(RegExp.$1))?[c]:e:a.nodeType!==1&&a.nodeType!==9?e:f.call(s.test(b)?a.getElementsByClassName(RegExp.$1):u.test(b)?a.getElementsByTagName(b):a.querySelectorAll(b))},c.isFunction=A,c.isObject=B,c.isArray=D,c.isPlainObject=C,c.inArray=function(a,b,c){return e.indexOf.call(b,a,c)},c.trim=function(a){return a.trim()},c.uuid=0,c.map=function(a,b){var c,d=[],e,f;if(E(a))for(e=0;e0&&w.matches(this[0],a)},not:function(b){var d=[];if(A(b)&&b.call!==a)this.each(function(a){b.call(this,a)||d.push(this)});else{var e=typeof b=="string"?this.filter(b):E(b)&&A(b.item)?f.call(b):c(b);this.forEach(function(a){e.indexOf(a)<0&&d.push(a)})}return c(d)},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!B(a)?a:c(a)},last:function(){var a=this[this.length-1];return a&&!B(a)?a:c(a)},find:function(a){var b;return this.length==1?b=w.qsa(this[0],a):b=this.map(function(){return w.qsa(this,a)}),c(b)},closest:function(a,b){var d=this[0];while(d&&!w.matches(d,a))d=d!==b&&d!==g&&d.parentNode;return c(d)},parents:function(a){var b=[],d=this;while(d.length>0)d=c.map(d,function(a){if((a=a.parentNode)&&a!==g&&b.indexOf(a)<0)return b.push(a),a});return L(b,a)},parent:function(a){return L(y(this.pluck("parentNode")),a)},children:function(a){return L(this.map(function(){return f.call(this.children)}),a)},siblings:function(a){return L(this.map(function(a,b){return f.call(b.parentNode.children).filter(function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return this.map(function(){return this[a]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=null),j(this,"").getPropertyValue("display")=="none"&&(this.style.display=K(this.nodeName))})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){return this.each(function(){c(this).wrapAll(c(a)[0].cloneNode(!1))})},wrapAll:function(a){return this[0]&&(c(this[0]).before(a=c(a)),a.append(this)),this},unwrap:function(){return this.parent().each(function(){c(this).replaceWith(c(this).children())}),this},clone:function(){return c(this.map(function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(b){return(b===a?this.css("display")=="none":b)?this.show():this.hide()},prev:function(){return c(this.pluck("previousElementSibling"))},next:function(){return c(this.pluck("nextElementSibling"))},html:function(b){return b===a?this.length>0?this[0].innerHTML:null:this.each(function(a){var d=this.innerHTML;c(this).empty().append(M(this,b,a,d))})},text:function(b){return b===a?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=b})},attr:function(c,d){var e;return typeof c=="string"&&d===a?this.length==0||this[0].nodeType!==1?a:c=="value"&&this[0].nodeName=="INPUT"?this.val():!(e=this[0].getAttribute(c))&&c in this[0]?this[0][c]:e:this.each(function(a){if(this.nodeType!==1)return;if(B(c))for(b in c)this.setAttribute(b,c[b]);else this.setAttribute(c,M(this,d,a,this.getAttribute(c)))})},removeAttr:function(a){return this.each(function(){this.nodeType===1&&this.removeAttribute(a)})},prop:function(b,c){return c===a?this[0]?this[0][b]:a:this.each(function(a){this[b]=M(this,c,a,this[b])})},data:function(b,c){var d=this.attr("data-"+H(b),c);return d!==null?d:a},val:function(b){return b===a?this.length>0?this[0].value:a:this.each(function(a){this.value=M(this,b,a,this.value)})},offset:function(){if(this.length==0)return null;var a=this[0].getBoundingClientRect();return{left:a.left+window.pageXOffset,top:a.top+window.pageYOffset,width:a.width,height:a.height}},css:function(c,d){if(d===a&&typeof c=="string")return this.length==0?a:this[0].style[x(c)]||j(this[0],"").getPropertyValue(c);var e="";for(b in c)typeof c[b]=="string"&&c[b]==""?this.each(function(){this.style.removeProperty(H(b))}):e+=H(b)+":"+J(b,c[b])+";";return typeof c=="string"&&(d==""?this.each(function(){this.style.removeProperty(H(c))}):e=H(c)+":"+J(c,d)),this.each(function(){this.style.cssText+=";"+e})},index:function(a){return a?this.indexOf(c(a)[0]):this.parent().children().indexOf(this[0])},hasClass:function(a){return this.length<1?!1:I(a).test(this[0].className)},addClass:function(a){return this.each(function(b){d=[];var e=this.className,f=M(this,a,b,e);f.split(/\s+/g).forEach(function(a){c(this).hasClass(a)||d.push(a)},this),d.length&&(this.className+=(e?" ":"")+d.join(" "))})},removeClass:function(b){return this.each(function(c){if(b===a)return this.className="";d=this.className,M(this,b,c,d).split(/\s+/g).forEach(function(a){d=d.replace(I(a)," ")}),this.className=d.trim()})},toggleClass:function(b,d){return this.each(function(e){var f=M(this,b,e,this.className);(d===a?!c(this).hasClass(f):d)?c(this).addClass(f):c(this).removeClass(f)})}},["width","height"].forEach(function(b){c.fn[b]=function(d){var e,f=b.replace(/./,function(a){return a[0].toUpperCase()});return d===a?this[0]==window?window["inner"+f]:this[0]==g?g.documentElement["offset"+f]:(e=this.offset())&&e[b]:this.each(function(a){var e=c(this);e.css(b,M(this,d,a,e[b]()))})}}),n.forEach(function(a,b){c.fn[a]=function(){var a=c.map(arguments,function(a){return B(a)?a:w.fragment(a)});if(a.length<1)return this;var d=this.length,e=d>1,f=b<2;return this.each(function(c,g){for(var h=0;h0&&this.bind(o,n),setTimeout(function(){m.css(i),e<=0&&setTimeout(function(){m.each(function(){n.call(this)})},0)},0),this},i=null}(Zepto),function($){function triggerAndReturn(a,b,c){var d=$.Event(b);return $(a).trigger(d,c),!d.defaultPrevented}function triggerGlobal(a,b,c,d){if(a.global)return triggerAndReturn(b||document,c,d)}function ajaxStart(a){a.global&&$.active++===0&&triggerGlobal(a,null,"ajaxStart")}function ajaxStop(a){a.global&&!--$.active&&triggerGlobal(a,null,"ajaxStop")}function ajaxBeforeSend(a,b){var c=b.context;if(b.beforeSend.call(c,a,b)===!1||triggerGlobal(b,c,"ajaxBeforeSend",[a,b])===!1)return!1;triggerGlobal(b,c,"ajaxSend",[a,b])}function ajaxSuccess(a,b,c){var d=c.context,e="success";c.success.call(d,a,e,b),triggerGlobal(c,d,"ajaxSuccess",[b,c,a]),ajaxComplete(e,b,c)}function ajaxError(a,b,c,d){var e=d.context;d.error.call(e,c,b,a),triggerGlobal(d,e,"ajaxError",[c,d,a]),ajaxComplete(b,c,d)}function ajaxComplete(a,b,c){var d=c.context;c.complete.call(d,b,a),triggerGlobal(c,d,"ajaxComplete",[b,c]),ajaxStop(c)}function empty(){}function mimeToDataType(a){return a&&(a==htmlType?"html":a==jsonType?"json":scriptTypeRE.test(a)?"script":xmlTypeRE.test(a)&&"xml")||"text"}function appendQuery(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function serializeData(a){isObject(a.data)&&(a.data=$.param(a.data)),a.data&&(!a.type||a.type.toUpperCase()=="GET")&&(a.url=appendQuery(a.url,a.data))}function serialize(a,b,c,d){var e=$.isArray(b);$.each(b,function(b,f){d&&(b=c?d:d+"["+(e?"":b)+"]"),!d&&e?a.add(f.name,f.value):(c?$.isArray(f):isObject(f))?serialize(a,f,c,b):a.add(b,f)})}var jsonpID=0,isObject=$.isObject,document=window.document,key,name,rscript=/)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(a){var b="jsonp"+ ++jsonpID,c=document.createElement("script"),d=function(){$(c).remove(),b in window&&(window[b]=empty),ajaxComplete("abort",e,a)},e={abort:d},f;return a.error&&(c.onerror=function(){e.abort(),a.error()}),window[b]=function(d){clearTimeout(f),$(c).remove(),delete window[b],ajaxSuccess(d,e,a)},serializeData(a),c.src=a.url.replace(/=\?/,"="+b),$("head").append(c),a.timeout>0&&(f=setTimeout(function(){e.abort(),ajaxComplete("timeout",e,a)},a.timeout)),e},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0},$.ajax=function(options){var settings=$.extend({},options||{});for(key in $.ajaxSettings)settings[key]===undefined&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host);var dataType=settings.dataType,hasPlaceholder=/=\?/.test(settings.url);if(dataType=="jsonp"||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,"callback=?")),$.ajaxJSONP(settings);settings.url||(settings.url=window.location.toString()),serializeData(settings);var mime=settings.accepts[dataType],baseHeaders={},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=$.ajaxSettings.xhr(),abortTimeout;settings.crossDomain||(baseHeaders["X-Requested-With"]="XMLHttpRequest"),mime&&(baseHeaders.Accept=mime,mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime));if(settings.contentType||settings.data&&settings.type.toUpperCase()!="GET")baseHeaders["Content-Type"]=settings.contentType||"application/x-www-form-urlencoded";settings.headers=$.extend(baseHeaders,settings.headers||{}),xhr.onreadystatechange=function(){if(xhr.readyState==4){clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&xhr.status<300||xhr.status==304||xhr.status==0&&protocol=="file:"){dataType=dataType||mimeToDataType(xhr.getResponseHeader("content-type")),result=xhr.responseText;try{dataType=="script"?(1,eval)(result):dataType=="xml"?result=xhr.responseXML:dataType=="json"&&(result=blankRE.test(result)?null:JSON.parse(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings):ajaxSuccess(result,xhr,settings)}else ajaxError(null,"error",xhr,settings)}};var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async);for(name in settings.headers)xhr.setRequestHeader(name,settings.headers[name]);return ajaxBeforeSend(xhr,settings)===!1?(xhr.abort(),!1):(settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr)},$.get=function(a,b){return $.ajax({url:a,success:b})},$.post=function(a,b,c,d){return $.isFunction(b)&&(d=d||c,c=b,b=null),$.ajax({type:"POST",url:a,data:b,success:c,dataType:d})},$.getJSON=function(a,b){return $.ajax({url:a,success:b,dataType:"json"})},$.fn.load=function(a,b){if(!this.length)return this;var c=this,d=a.split(/\s/),e;return d.length>1&&(a=d[0],e=d[1]),$.get(a,function(a){c.html(e?$(document.createElement("div")).html(a.replace(rscript,"")).find(e).html():a),b&&b.call(c)}),this};var escape=encodeURIComponent;$.param=function(a,b){var c=[];return c.add=function(a,b){this.push(escape(a)+"="+escape(b))},serialize(c,a,b),c.join("&").replace("%20","+")}}(Zepto),function(a){a.fn.serializeArray=function(){var b=[],c;return a(Array.prototype.slice.call(this.get(0).elements)).each(function(){c=a(this);var d=c.attr("type");this.nodeName.toLowerCase()!="fieldset"&&!this.disabled&&d!="submit"&&d!="reset"&&d!="button"&&(d!="radio"&&d!="checkbox"||this.checked)&&b.push({name:c.attr("name"),value:c.val()})}),b},a.fn.serialize=function(){var a=[];return this.serializeArray().forEach(function(b){a.push(encodeURIComponent(b.name)+"="+encodeURIComponent(b.value))}),a.join("&")},a.fn.submit=function(b){if(b)this.bind("submit",b);else if(this.length){var c=a.Event("submit");this.eq(0).trigger(c),c.defaultPrevented||this.get(0).submit()}return this}}(Zepto),function(a){function d(a){return"tagName"in a?a:a.parentNode}function e(a,b,c,d){var e=Math.abs(a-b),f=Math.abs(c-d);return e>=f?a-b>0?"Left":"Right":c-d>0?"Up":"Down"}function h(){g=null,b.last&&(b.el.trigger("longTap"),b={})}function i(){g&&clearTimeout(g),g=null}var b={},c,f=750,g;a(document).ready(function(){var j,k;a(document.body).bind("touchstart",function(e){j=Date.now(),k=j-(b.last||j),b.el=a(d(e.touches[0].target)),c&&clearTimeout(c),b.x1=e.touches[0].pageX,b.y1=e.touches[0].pageY,k>0&&k<=250&&(b.isDoubleTap=!0),b.last=j,g=setTimeout(h,f)}).bind("touchmove",function(a){i(),b.x2=a.touches[0].pageX,b.y2=a.touches[0].pageY}).bind("touchend",function(a){i(),b.isDoubleTap?(b.el.trigger("doubleTap"),b={}):b.x2&&Math.abs(b.x1-b.x2)>30||b.y2&&Math.abs(b.y1-b.y2)>30?(b.el.trigger("swipe")&&b.el.trigger("swipe"+e(b.x1,b.x2,b.y1,b.y2)),b={}):"last"in b&&(b.el.trigger("tap"),c=setTimeout(function(){c=null,b.el.trigger("singleTap"),b={}},250))}).bind("touchcancel",function(){c&&clearTimeout(c),g&&clearTimeout(g),g=c=null,b={}})}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(b){a.fn[b]=function(a){return this.bind(b,a)}})}(Zepto); 3 | /**************************************** 4 | * @author: jinweigang 5 | * @vsersion 1.0 6 | 7 | * ---------------函数 列表--------------—— 8 | * @p2m px=>rem的适配 9 | * @getUrlparam 获取url参数 10 | * @getDataUrl 获取图片base64编码 11 | * @judgePlat 判断平台类型 12 | * @isAndroid 判断是否为安卓设备 13 | * @isIOS 判断是否为IOS设备 14 | * @setCookie 设置cookie 15 | * @getCookie 获取cookie 16 | * @delCookie 删除cookie 17 | * @getPhoneCode 获取手机验证码 18 | * @delayGo 延迟处理/跳转 19 | * @cutContent 字符串截取 20 | * @toast toast弹层 21 | * @listenNet 监听网络状态连接 22 | * @orientation 旋转屏幕后刷新页面 23 | * @confirm confirm弹层 24 | * @animArrow 向下滑动指示箭头 25 | * @downloadApp banner下载 26 | * @rotateTip 横竖屏切换提示 27 | * @shareWx 分享到微信配置 28 | *****************************************/ 29 | 30 | ;(function(window, $, undefined){ 31 | window.MT = { 32 | TOUCH_START: "touchstart", 33 | TOUCH_END: "touchend" 34 | }; 35 | 36 | /** 37 | * viewport缩放,px转rem 38 | * @function p2m 39 | * @param {designW:设计稿尺寸,一般为640px/750px} 40 | **/ 41 | MT.p2m = function(designW){ 42 | var resizeNum = 0, 43 | timer = null, 44 | winW = window.innerWidth; 45 | var resize = function() { 46 | var clientW = document.body.clientWidth; 47 | clearTimeout(timer); 48 | if (clientW > 414) { 49 | winW = 414; 50 | MT.TOUCH_START = "click"; 51 | MT.TOUCH_END = "click"; 52 | } 53 | document.getElementsByTagName("html")[0].style.fontSize = (winW/designW)*100 + "px"; 54 | if (winW > clientW && resizeNum <= 10) { 55 | timer = setTimeout(function() { 56 | resize(++resizeNum); 57 | }, 100); 58 | } else { 59 | document.getElementsByTagName("body")[0].style.opacity = 1; 60 | } 61 | } 62 | resize(); 63 | window.onresize = resize; 64 | }; 65 | 66 | /** 67 | * 获取url参数 68 | * @function getUrlParam 69 | * @param {url: 需要解析的url} 70 | **/ 71 | MT.getUrlParam = function(url) { 72 | var data = decodeURIComponent(url || location.href).split("?")[1].split("&"); 73 | var param = {}; 74 | 75 | for(var i =0; i 1) { 100 | imageWidth = (maxWidth > imageWidth) ? imageWidth : maxWidth; 101 | imageHeight = Math.round(imageWidth / ratio); 102 | if (imageHeight > maxHeight) { 103 | imageHeight = maxHeight; 104 | imageWidth = Math.round(imageHeight * ratio); 105 | } 106 | } else { 107 | imageHeight = (maxHeight > imageHeight) ? imageHeight : maxHeight; 108 | imageWidth = Math.round(imageHeight * ratio); 109 | if (imageWidth > maxWidth) { 110 | imageWidth = maxWidth; 111 | imageHeight = Math.round(imageWidth / ratio); 112 | } 113 | } 114 | canvas.width = imageWidth; 115 | canvas.height = imageHeight; 116 | canvas.getContext('2d').drawImage(this, 0, 0); 117 | callback(canvas.toDataURL('image/jpeg').substring(23)); 118 | }; 119 | image.src = e.target.result; 120 | }; 121 | 122 | }; 123 | 124 | /** 125 | * 根据UA判断平台类型 126 | * @function judgePlat 127 | **/ 128 | MT.judgePlat = function(){ 129 | var browser = "other", 130 | ua = navigator.userAgent.toLowerCase(); 131 | 132 | if(/MicroMessenger/i.test(ua)) browser="weixin"; 133 | if(/weibo/i.test(ua)) browser="weibo"; 134 | return browser; 135 | }; 136 | 137 | /** 138 | * 判断是否为安卓设备 139 | * @function isAndroid 140 | **/ 141 | MT.isAndroid = function(){ 142 | /* HTC Flyer平板的UA字符串中不包含Android关键词 */ 143 | return /Android|HTC/i.test(navigator.userAgent.toLowerCase()); 144 | }; 145 | 146 | /** 147 | * 判断是否为ios设备 148 | * @function isIOS 149 | **/ 150 | MT.isIOS = function(){ 151 | return /iPod|iPad|iPhone/i.test(navigator.userAgent.toLowerCase()); 152 | }; 153 | 154 | /** 155 | * 设置cookie 156 | * @function setCookie 157 | * @param {key:cookie名称,value:cookie值,days:过期时间} 158 | **/ 159 | MT.setCookie = function(key, value, days){ 160 | var expire = new Date(), 161 | expireTime = expire.getTime() + days*24*60*60*1000; 162 | document.cookie = key + "=" + escape(value) + ";expires=" + new Date(expireTime); 163 | }; 164 | 165 | /** 166 | * 获取cookie 167 | * @function getCookie 168 | * @param {key:cookie名称} 169 | **/ 170 | MT.getCookie = function(key){ 171 | var reg = new RegExp("(^| )"+name+"=([^;]*)(;|$)"), 172 | arr = document.cookie.match(reg); 173 | if(arr !== null) return unescape(arr[2]); 174 | return false; 175 | }; 176 | 177 | /** 178 | * 删除cookie 179 | * @function delCookie 180 | * @param {key:cookie名称} 181 | **/ 182 | MT.delCookie = function(key){ 183 | MT.setCookie(key,"",-1); 184 | }; 185 | 186 | /** 187 | * 启动一个定时器 188 | * @function getPhoneCode 189 | * @param {_option:参数集合} 190 | **/ 191 | MT.getPhoneCode = function(_option) { 192 | var option = $.extend({ 193 | sendBtn: null, //发送按钮 194 | time: 60, //倒计时时间 195 | disabled: 'disabled', //按钮禁止点击class 196 | sendCode: function() {}//发送验证码函数 197 | }, _option); 198 | var timer = null, 199 | count = option.time; 200 | 201 | option.sendBtn.on(MT.TOUCH_START, function() { 202 | if (option.sendBtn.data("lock") == "true") return; 203 | if (typeof option.sendCode == 'function') { 204 | option.sendCode(); //发送验证码 205 | } else { 206 | MT.toast('错误:' + option.sendCode + '应为函数'); 207 | return false; 208 | } 209 | option.sendBtn.addClass(option.disabled).data("lock", true); 210 | option.sendBtn.text("重新发送(60)"); 211 | timer = setInterval(function() { 212 | if (--count > 0) { 213 | option.sendBtn.text("重新发送(" + count + ")"); 214 | } else { 215 | option.sendBtn.removeClass(option.disabled).text("重新发送").data( 216 | "lock", 217 | false); 218 | clearInterval(timer); 219 | count = option.time; 220 | } 221 | }, 1000); 222 | }); 223 | }; 224 | 225 | 226 | /** 227 | * 延迟处理/跳转 228 | * @function delayGo 229 | * @param {callback:跳转地址/回调函数, time:延迟时间ms} 230 | */ 231 | MT.delayGo = function(callback, time){ 232 | var timer = setTimeout(function(){ 233 | if (typeof callback == 'string') { 234 | location.href = callback; 235 | } else if(typeof callback == 'function') { 236 | callback(); 237 | } 238 | clearTimeout(timer); 239 | }, time || 1500); 240 | }; 241 | 242 | /** 243 | * 延迟处理/跳转 244 | * @function cutContent 245 | * @param {str:截取字符串, len:截取长度, tag: 标记} 246 | */ 247 | MT.cutContent = function(str, len, tag){ 248 | //只是计算字符长度,不区分中英文 249 | var newStr = ''; 250 | if (str.length > len) { 251 | newStr = str.substr(0,len); 252 | } 253 | return newStr + (tag || '...'); 254 | }; 255 | 256 | /** 257 | * 黑色浮层弹窗 258 | * @function toast 259 | * @param {text:弹出文案,time:弹窗持续时间 callback:回调函数} 260 | */ 261 | MT.toast = function(text, time, callback){ 262 | $(".mt-toast").remove(); 263 | $("body").append("

"+text+"

"); 264 | var timer = setTimeout(function(){ 265 | $(".mt-toast").remove(); 266 | if(callback) callback(); 267 | clearTimeout(timer); 268 | },time || 2000); 269 | }; 270 | 271 | /** 272 | * 网络断开toast提示 273 | * @function offLine 274 | */ 275 | MT.listenNet = function(){ 276 | window.addEventListener("offline",function(){ 277 | MT.toast("网络连接失败,请重试",1000000); 278 | },false); 279 | window.addEventListener("online",function(){ 280 | $(".mt-toast").remove(); 281 | },false); 282 | }; 283 | 284 | /** 285 | * 屏幕旋转后刷新页面 286 | * @function orientation 287 | */ 288 | MT.orientation = function(){ 289 | window.addEventListener('orientationchange',function(){ 290 | location.reload(); 291 | }); 292 | }; 293 | 294 | /** 295 | * 黑色浮层弹窗 296 | * @function confirmDialog 297 | * @param {option:参数配置} 298 | */ 299 | MT.confirm = function(_option){ 300 | var option = $.extend({ 301 | text: "提示", 302 | okBtnText: "确定", 303 | cancelBtnText: "取消", 304 | okCallback: function(){ 305 | }, 306 | cancelCallback: function(){ 307 | }, 308 | close:function(){ 309 | $(".mt-confirm-dialog").remove(); 310 | $(".mt-mask").remove(); 311 | } 312 | },_option || {}); 313 | 314 | var html = ['
', 315 | '

',option.text,'

', 316 | '

',option.okBtnText,'', 317 | '',option.cancelBtnText,'

', 318 | '
', 319 | '
'].join(""); 320 | $("body").append(html); 321 | $(".mt-mask").show(); 322 | var confirmBtn = $('.mt-confirm-btn'), 323 | canceBtn = $(".mt-cancel-btn"); 324 | 325 | confirmBtn.on(MT.TOUCH_START,function(){ 326 | confirmBtn.addClass("touch-btn"); 327 | }) 328 | .on(MT.TOUCH_END,function(){ 329 | confirmBtn.removeClass("touch-btn"); 330 | option.okCallback(); 331 | option.close(); 332 | }); 333 | 334 | canceBtn.on(MT.TOUCH_START,function(){ 335 | canceBtn.addClass("mt-touch-btn"); 336 | }) 337 | .on(MT.TOUCH_END,function(){ 338 | canceBtn.removeClass("mt-touch-btn"); 339 | option.cancelCallback(); 340 | option.close(); 341 | }); 342 | }; 343 | 344 | /** 345 | * 向下指示箭头 346 | * @function animArrow 347 | * @param {imgUrl: 箭头图片地址} 348 | **/ 349 | MT.animArrow = function(imgUrl){ 350 | var img = imgUrl ? imgUrl : "", 351 | html = ['
'].join(); 352 | $("body").append(html); 353 | }; 354 | 355 | /** 356 | * 底部下载app banner 357 | * @function downloadApp 358 | * @param{option对象} 359 | **/ 360 | MT.downloadApp = function(_option){ 361 | var option = $.extend({ 362 | position: "static", 363 | height: "1rem", 364 | wxUrl:"", 365 | androidUrl:"", 366 | iosUrl:"", 367 | imgUrl:"" 368 | },_option || {}); 369 | var html = "", 370 | plat = MT.judgePlat(); 371 | 372 | if(plat == "weixin"){ 373 | option.downloadUrl = wxUrl; 374 | } else if(plat == "ios"){ 375 | option.downloadUrl = iosUrl; 376 | } else if(plat == "android"){ 377 | option.downloadUrl = androidUrl; 378 | } 379 | html = ['
'].join(""); 381 | $("body").append(html); 382 | }; 383 | 384 | /** 385 | * 横竖屏提示 386 | * @function rotateTip 387 | * @param{} 388 | **/ 389 | MT.rotateTip = function(){ 390 | var timer = setTimeout(function(){ 391 | $("body").append('
请切换至竖屏显示
'); 392 | clearTimeout(timer); 393 | },0); 394 | }; 395 | 396 | /** 397 | * 分享到微信 398 | * @function shareWx 399 | * @param{data对象} 400 | **/ 401 | MT.shareWx = function(data,authUrl){ 402 | var callback = function (data) { 403 | wx.config({ 404 | debug: false, 405 | appId: data.appId, 406 | timestamp: data.timestamp, 407 | nonceStr: data.nonceStr, 408 | signature: data.signature, 409 | jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo', 410 | 'chooseImage','previewImage','uploadImage','downloadImage'] 411 | }); 412 | 413 | wx.ready(function () { 414 | var shareData = { 415 | title: data.title, 416 | desc: data.desc, 417 | link: location.href, // 分享链接 418 | imgUrl: data.imgUrl, 419 | success: function () { 420 | // 用户确认分享后执行的回调函数 421 | } 422 | }; 423 | wx.onMenuShareAppMessage(shareData); 424 | wx.onMenuShareQQ(shareData); 425 | wx.onMenuShareWeibo(shareData); 426 | wx.onMenuShareTimeline(shareData); 427 | 428 | console.log('weixin support set success.'); 429 | }); 430 | wx.error(function (res) { 431 | //alert(res.errMsg); 432 | }); 433 | }; 434 | $.ajax({ 435 | url: authUrl, 436 | dataType: "json", 437 | data: location.href.split("#")[0], 438 | success: function (res) { 439 | callback(res); 440 | }, 441 | error: function (xhr, type) { 442 | console.log('xhr:' + xhr + "type:" + type); 443 | MT.toast("认证接口错误"); 444 | } 445 | }); 446 | }; 447 | 448 | })(window, Zepto); 449 | --------------------------------------------------------------------------------