李书文 2 years ago
parent
commit
55c71f020a
1 changed files with 36 additions and 54 deletions
  1. 36 54
      pages/index/index.vue

+ 36 - 54
pages/index/index.vue

@@ -13,36 +13,36 @@
 			</view>
 		</view>
 		<view class="list">
-			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item.id,'1')">
+			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item.id, '1')">
 				<view class="title">
-					<text class="tv">{{item.items.__yZMMXcXNnmKq5pTTfPH.value}}</text>
+					<text class="tv">{{ item.items.__yZMMXcXNnmKq5pTTfPH.value }}</text>
 					<text class="icon">&#xe631;</text>
 					<view class="clear"></view>
 				</view>
 				<view class="con">
 					<view class="it">
 						<view class="label">委托单编号:</view>
-						<view class="name">{{item.items.__BFdnHQXCEaXwAC4nryK.value}}</view>
+						<view class="name">{{ item.items.__BFdnHQXCEaXwAC4nryK.value }}</view>
 					</view>
 					<view class="it">
 						<view class="label">申请单位:</view>
-						<view class="name">{{item.items.__VP07fdxAVMa7bSHb8ZU.value}}</view>
+						<view class="name">{{ item.items.__VP07fdxAVMa7bSHb8ZU.value }}</view>
 					</view>
 					<view class="it">
 						<view class="label">试验部门:</view>
-						<view class="name">{{item.items.__DVAKyCmSOS9bvFpome2.value}}</view>
+						<view class="name">{{ item.items.__DVAKyCmSOS9bvFpome2.value }}</view>
 					</view>
 					<view class="it">
 						<view class="label">当前审批人:</view>
-						<view class="name">{{item.items.__hInQ1R0YkMQNrgTq3q0.value}}</view>
+						<view class="name">{{ item.items.__hInQ1R0YkMQNrgTq3q0.value }}</view>
 					</view>
-					<view class="tag" v-if="item.items.__oUywWKvn4BhpnBmxqYT.value !=''">{{item.items.__oUywWKvn4BhpnBmxqYT.value}}</view>
+					<view class="tag" v-if="item.items.__oUywWKvn4BhpnBmxqYT.value != ''">{{ item.items.__oUywWKvn4BhpnBmxqYT.value }}</view>
 				</view>
 			</view>
 			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
 			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
 		</view>
-		<view class="footer"><button class="btn" style="width: 30%;border-radius: 25px;" @click="detail('0',2)">新建</button></view>
+		<view class="footer"><button class="btn" style="width: 30%;border-radius: 25px;" @click="detail('0', 2)">新建</button></view>
 	</view>
 </template>
 
@@ -50,17 +50,15 @@
 export default {
 	data() {
 		return {
-			param: {appId:"__gAPYBW4YxB3UePM3lqO",containTitle:"申请单",opentarget:"detail",viewId:"__km3aURKW95BHxp12XVt" },
+			param: { appId: '__gAPYBW4YxB3UePM3lqO', containTitle: '申请单', opentarget: 'detail', viewId: '__km3aURKW95BHxp12XVt', _currpage: 1 },
 			list: [],
 			show: false,
-			loadMore: true,
-			pageNum:1
+			loadMore: true
 		};
 	},
 	onLoad(e) {
 		//this.getaccessToken();
 		this.getData();
-		
 	},
 	methods: {
 		getaccessToken() {
@@ -69,45 +67,42 @@ export default {
 				data: this.param,
 				loading: 'false',
 				success: res => {
-				//console.log("gfgh==="+JSON.stringify(res));
-				if(res.data.errcode==0){
-								
-				uni.removeStorageSync('user');
-				uni.setStorageSync('user', res.data.data);
-				this.getData();
-				console.log("res.data.resultCode==="+res.data.errcode);
-				}
+					console.log('gfgh===1111' + JSON.stringify(res));
+					if (res.data.errcode == 0) {
+						uni.removeStorageSync('user');
+						uni.setStorageSync('user', res.data.data);
+						this.getData();
+						console.log('res.data.resultCode===' + res.data.errcode);
+					}
 				}
 			});
-		},	getData() {
-			
+		},
+		getData() {
 			this.http.request({
-				url: this.http.urls.wt_list+'&_currpage='+this.pageNum,
+				url: this.http.urls.wt_list,
 				data: this.param,
-				method:'POST',
+				method: 'POST',
 				loading: 'false',
 				success: res => {
-				console.log("this.list==="+JSON.stringify(res));
-					this.loadMore = res.data.data.page > this.pageNum-1? true : false;
+					let totalPage = res.data.data.row_count < 10 ? 1 : res.data.data.row_count / 10;
+					this.loadMore = totalPage > this.param._currpage ? true : false;
 					res.data.data.data.forEach(item => {
 						this.list.push(item);
 					});
-					//console.log("this.list==="+JSON.stringify(this.list));
 				}
 			});
 		},
 		//刷新数据
 		refresh() {
 			this.loadMore = true;
-			this.pageNum = 1;
+			this.param._currpage = 1;
 			this.list = [];
 			this.getData();
-			
 		},
 		//跳转到详情
-		detail(id,ste) {
+		detail(id, ste) {
 			uni.navigateTo({
-				url: '/pages/index/detail?id=' + id+"&ste="+ ste
+				url: '/pages/index/detail?id=' + id + '&ste=' + ste
 			});
 		},
 		//跳转到详情
@@ -119,7 +114,6 @@ export default {
 	},
 	//下拉刷新
 	onPullDownRefresh() {
-		console.log("222===");
 		setTimeout(() => {
 			this.refresh();
 			uni.stopPullDownRefresh();
@@ -127,11 +121,8 @@ export default {
 	},
 	//上拉加载
 	onReachBottom() {
-	
 		if (this.loadMore) {
-			
-			this.pageNum++;
-			
+			this.param._currpage++;
 			this.getData();
 		}
 	},
@@ -146,24 +137,10 @@ export default {
 page {
 	background-color: #f2f3f5;
 }
-.search {
-	background-color: white;
-	padding: 5px 15px;
-	.input {
-		margin-bottom: 10px;
-	}
-	.f {
-		padding: 5px;
-		background-color: white;
-	}
-	.c {
-		background-color: #f44336;
-	}
-}
 .list {
-	padding: 0px 15px;
+	padding: 10px 15px 80px 15px;
 	.item {
-		margin-top: 10px;
+		margin-bottom: 10px;
 		background-color: white;
 		border-radius: 5px;
 		overflow: hidden;
@@ -176,6 +153,9 @@ page {
 				float: left;
 				width: 90%;
 			}
+			.icon {
+				float: right;
+			}
 		}
 		.con {
 			position: relative;
@@ -186,18 +166,20 @@ page {
 					float: left;
 					color: #969696;
 				}
+				.name {
+					color: $font-c;
+				}
 			}
 			.tag {
 				position: absolute;
 				top: 10%;
 				right: 0px;
 				padding: 3px 10px;
-				background-color: red;
+				background-color: #e64340;
 				color: white;
 				border-radius: 15px 0px 0px 15px;
 			}
 		}
 	}
 }
-
 </style>