heyang 3 years ago
parent
commit
2d3901d06b

+ 28 - 4
microserviceUserH5/static/css/browserDetail.css

@@ -30,9 +30,17 @@ input{
   background: #F5F7FA;
 }
 .download-wrap{
+  padding-top: 2.74rem;
   padding-bottom: 0.3rem;
+  height: calc(99vh - 2.94rem);
+  overflow-y: scroll;
 }
 .header-wrap{
+  width: 100%;
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: 999;
   padding-top: 0.18rem;
   background: #FFFFFF;
   overflow: hidden;
@@ -122,15 +130,19 @@ input{
   margin-top: -0.46rem;
   border-radius: 0.32rem;
   border: 0.02rem solid #EBEBEB;
-  background-color: #666666;
+  /* background-color: #666666; */
 }
 .app-wrap{
   margin-left: 0.2rem;
 }
 .app-title{
+  width: 3.6rem;
   font-size: 0.32rem;
   font-weight: 500;
   color: #333333;
+  white-space:nowrap;
+  overflow:hidden;
+  text-overflow:ellipsis;
 }
 .app-description{
   width: 3.6rem;
@@ -187,12 +199,20 @@ input{
   color: #BBBBBB;
 }
 
+.loading{
+  font-size: 0.26rem;
+  color: #BBBBBB;
+  text-align: center;
+}
+
 #toast-container>.toast-error {
   background-image: none !important;
+  border-radius: 0.2rem;
 }
 
 .toast-error {
   background-color: rgba(0, 0, 0, 0.8);
+  border-radius: 0.2rem;
 }
 
 #toast-container>div {
@@ -200,19 +220,23 @@ input{
   min-width: 80px !important;
   padding: 12px !important;
   box-shadow: none;
+  border-radius: 0.2rem;
 }
 
 .toast-center-center {
-  min-width: 100px;
+  position: fixed;
+  width: 220px;
   top: 50%;
   left: 50%;
   text-align: center;
-  transform: translateX(-50%);
+  transform: translate(-50%, -50%);
+  color: #FFFFFF;
+  border-radius: 0.2rem;
 }
 
 @media (max-width: 480px) and (min-width: 241px) {
   #toast-container>div {
-    min-width: 80px !important;
+    min-width: 88px !important;
     width: auto;
   }
 }

+ 104 - 55
microserviceUserH5/vcloud/browserDetail.html

@@ -19,6 +19,10 @@
         var deviveWidth = document.documentElement.clientWidth;
         document.documentElement.style.fontSize = deviveWidth / 7.5 + 'px';
     </script>
+	<script>
+		toastr.options.positionClass = 'toast-center-center';
+		// toastr.options.timeOut = '1500';
+	</script>
 </head>
 <body>
 	<div class="container">
@@ -33,17 +37,23 @@
 			</div>
 			<div class="tag-wrap"></div>
 		</div>
-		<div class="download-wrap"></div>
+		<div class="download-wrap">
+			<div class="download-content"></div>
+			<div class="loading"></div>
+		</div>
 	</div>
 <script type="text/javascript">
 	let title = decodeURIComponent(GetRequest().plateName);
 	let timer,flag = true;
-	let labelId = '', pageNum = 1, pageSize = 10, index = 0;
+	let labelId = '', pageNum = 1, pageSize = 10, index = 0, recordFlag = true, total = 0, nowlength = 0;
 	$('.title').eq(0).text(title);
 	(function(){
 		init();
 	})();
 	function init(){
+		if(nowlength === 0) {
+			toastr.error('加载中...');
+		}
 		$.ajax({
 			url: `${baseUrl}/api/public/v1/browserLabel/client/query/${GetRequest().plateId}`,
 			type: 'get',
@@ -62,69 +72,95 @@
 			}
 		})
 	};
+	function getType() {
+		return new Promise((resolve, reject) => {
+			$.ajax({
+				url: `http://192.168.211.215:9000/getType`,
+				type: 'get',
+				contentType:"application/json",
+				dataType: 'json',
+				cache: false,
+				success: function (res) {
+					if(res.code === 200){
+						let cardType = res.data.devType;
+						let phoneObj = {
+							'RK_3399': 'SVIP'
+						}
+						phoneType = phoneObj[cardType];
+						resolve(phoneType);
+					}
+				}
+			})
+		})
+	}
 	function rankingGet(){
-		// $.ajax({
-		// 	url: `http://192.168.211.215:9000/getType`,
-		// 	type: 'get',
-		// 	contentType:"application/json",
-		// 	dataType: 'json',
-		// 	cache: false,
-		// 	success: function (res) {
-		// 		console.log(res)
-		// 	}
-		// })
-		// return
-		$.ajax({
-			url: `${baseUrl}/api/public/v1/ranking/client/get`,
-			type: 'post',
-			data: JSON.stringify({
-				labelId: labelId,
-				phoneType: 'SVIP',
-				pageNum: pageNum,
-				pageSize: pageSize
-			}),
-			contentType:"application/json",
-			dataType: 'json',
-			cache: false,
-			success: function (res) {
-				if(res.status === 0){
-					let list = res.data.records;
-					let node = '';
-					for(let i=0; i < list.length; i++){
-						node += `<div class="download-item">
-									<div class="main-wrap">
-										<img class="app-icon" src=${fileCenterApi}/document/newFile/download/0/3dn9b4585511476691c6?fileKey=${list[i].iconKey} />
-										<div class="app-wrap">
-											<div class="app-title">${list[i].appName}</div>
-											<div class="app-description">${list[i].introduction}</div>
+		getType().then((phoneType) => {
+			$.ajax({
+				url: `${baseUrl}/api/public/v1/ranking/client/get`,
+				type: 'post',
+				data: JSON.stringify({
+					labelId: +labelId,
+					phoneType: phoneType,
+					pageNum: pageNum,
+					pageSize: pageSize
+				}),
+				contentType:"application/json",
+				dataType: 'json',
+				cache: false,
+				success: function (res) {
+					if(res.status === 0){
+						let list = res.data.records;
+						nowlength += list.length;
+						total = res.data.total;
+						recordFlag = true;
+						let node = '';
+						for(let i=0; i < list.length; i++){
+							node += `<div class="download-item">
+										<div class="main-wrap">
+											<img class="app-icon" src=${fileCenterApi}/document/newFile/download/0/3dn9b4585511476691c6?fileKey=${list[i].iconKey} />
+											<div class="app-wrap">
+												<div class="app-title">${list[i].appName}</div>
+												<div class="app-description">${list[i].introduction}</div>
+											</div>
 										</div>
-									</div>
-									<div class="btn-wrap" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">
-										<div class="progress" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}"></div>
-										<text class="text" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">下载</text>
-									</div>
-								</div>`
-					}
-					if(list.length === 0){
-						node = `<div class="none-wrap">
-									<img class="none-img" src="../static/img/browser/none.png" />
-									<div class="none-text">没有更多内容哦~</div>
-								</div>`
+										<div class="btn-wrap" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">
+											<div class="progress" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}"></div>
+											<text class="text" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">下载</text>
+										</div>
+									</div>`
+						}
+						if(nowlength !== total){
+							$('.loading').eq(0).text('正在努力加载中...');
+						} else {
+							$('.loading').eq(0).text('已加载全部内容');
+						}
+						if(list.length === 0){
+							node = `<div class="none-wrap">
+										<img class="none-img" src="../static/img/browser/none.png" />
+										<div class="none-text">没有更多内容哦~</div>
+									</div>`
+						}
+						$('.download-content').eq(0).append(node);
+					}else{
+						stopManyClick(() => {
+							toastr.error(res.msg);
+						})
 					}
-					$('.download-wrap').eq(0).append(node);
-				}else{
-					stopManyClick(() => {
-						toastr.error(res.msg);
-					})
 				}
-			}
+			})
 		})
 	};
+	//点击切换
 	$('.tag-wrap')[0].addEventListener('click',(e)=>{
 		labelId = e.target.dataset.id;
 		let className = e.target.className;
 		if(className.includes('tag-item')){
-			$('.download-wrap').eq(0).text('');
+			pageNum = 1;
+			nowlength = 0;
+			total = 0;
+			toastr.error('加载中...');
+			$('.loading').eq(0).text('');
+			$('.download-content').eq(0).text('');
 			$('.tag-item')[index].className = 'tag-item';
 			index = e.target.dataset.index;
 			$('.tag-item')[index].className = 'tag-item active';
@@ -197,6 +233,19 @@
 	$('.left-arrow')[0].addEventListener('click',()=>{
 		location.href = './browser.html'
 	},false);
+	//数据下拉加载
+	$('.download-wrap')[0].addEventListener('scroll',function () {
+		let scrollTop = $('.download-wrap')[0].scrollTop;
+		let clientHeight = $('.download-wrap')[0].clientHeight;
+		let scrollHeight = $('.download-wrap')[0].scrollHeight;
+		if(scrollTop + clientHeight + 10 > scrollHeight){
+			if(recordFlag && nowlength < total && total > 0){
+				recordFlag = false;
+				pageNum++;
+				rankingGet();
+			}
+		}
+	});
 	//防止提示一秒内重复显示
 	function stopManyClick(fn) {
 		if (flag) {