浏览代码

Merge branch 'master' of http://git.iamberry.com/liujiankang/static

wangxiaoming 7 年之前
父节点
当前提交
70a9a24bef
共有 1 个文件被更改,包括 55 次插入1 次删除
  1. 55 1
      aiberle/pro-details.html

+ 55 - 1
aiberle/pro-details.html

@@ -8,8 +8,21 @@
 		<meta name="apple-mobile-web-app-status-bar-style" content="black">
 		<title>产品详情</title>
 		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
+		<link rel="stylesheet" type="text/css" href="css/icons-extra.css" />
 		<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
 		<link rel="stylesheet" type="text/css" href="css/main.css" />
+		<style>
+			.return{position: fixed;
+    right: 10px;
+    bottom: 140px;
+    background: rgba(0,0,0,.1);
+    padding: 12px;
+    border-radius: 50%;
+    height: 50px;
+    width: 50px;
+    text-align: center;
+    opacity: .9;color: #333;display: none;}
+		</style>
 	</head>
 
 	<body>
@@ -88,6 +101,9 @@
 			<span class="iconfont icon-gouwuche"></span>
 			<span class="mui-badge my-badge-danger">0</span>
 		</div>
+		<div class="return">
+        	<span onClick="gotoTop(0.1,10);return false;" class="mui-icon-extra mui-icon-extra-top"></span>
+        </div>
 		<!-- 加载ing -->
 		<div class="loading covers">
 			<div class="loading-bj"></div>
@@ -423,7 +439,7 @@
 						}
 					});
 			}
-			//分享			
+			//分享		
 			function fenxiang(){
 				var src = location.href;
 					src = "//s.iamberry.com/aiberle/wechat/pro-details.html?productId="+productId;
@@ -441,6 +457,44 @@
 						};
 				getConfig();
 			}
+//返回顶部方法			
+function gotoTop(acceleration, stime) {
+	acceleration = acceleration || 0.1;
+	stime = stime || 10;
+	var x1 = 0,
+		y1 = 0,
+		x2 = 0,
+		y2 = 0,
+		x3 = 0,
+		y3 = 0;
+	if(document.documentElement) {
+		x1 = document.documentElement.scrollLeft || 0;
+		y1 = document.documentElement.scrollTop || 0
+	}
+	if(document.body) {
+		x2 = document.body.scrollLeft || 0;
+		y2 = document.body.scrollTop || 0
+	}
+	var x3 = window.scrollX || 0;
+	var y3 = window.scrollY || 0;
+	var x = Math.max(x1, Math.max(x2, x3));
+	var y = Math.max(y1, Math.max(y2, y3));
+	var speeding = 1 + acceleration;
+	window.scrollTo(Math.floor(x / speeding), Math.floor(y / speeding));
+	if(x > 0 || y > 0) {
+		var run = "gotoTop(" + acceleration + ", " + stime + ")";
+		window.setTimeout(run, stime)
+	}
+};
+//绑定滚动条事件
+$(window).on("scroll", function() {
+	//向下滚动距离大于180像素显示返回顶部,否则隐藏
+	if($(window).scrollTop() > 180) {
+		$(".return").show();
+	} else {
+		$(".return").hide();
+	}
+});
 		</script>
 	</body>