zhongtianhaoyuan 2 years ago
parent
commit
6a39f4133e
2 changed files with 219 additions and 60 deletions
  1. 55 11
      pages/mine/often/oftenRoute.vue
  2. 164 49
      pages/riders/index.vue

+ 55 - 11
pages/mine/often/oftenRoute.vue

@@ -1,5 +1,6 @@
 <template>
 	<view class="center">
+		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
 		<view class="route">
 			<view v-for="(item,index) in routeData" class="route_css">
 				<view class="route_site flex">
@@ -22,10 +23,10 @@
 					<view class="btn_css" @click="showChane(item)">{{item.displayFlag == 1?"显示中":"已隐藏"}}</view>
 				</view>
 			</view>
-			<u-loadmore :status="status" :nomore-text="nomoreText" />
+			<!-- <u-loadmore :status="status" :nomore-text="nomoreText" /> -->
 		</view>
+		</mescroll-body>
 		<u-toast ref="uToast"></u-toast>
-		
 		<view class="bottom_add">
 			<view class="add_btn" @click="addRoute(1)">添加常用路线</view>
 			<span class="tips">最多可创建50条</span>
@@ -33,11 +34,12 @@
 		<u-modal :show="tipsShow" :title="tipsText" :closeOnClickOverlay='true' :showCancelButton='true'
 			confirmColor='#2772FB' @confirm="delSubmit" @close="cancelClick" @cancel="cancelClick"></u-modal>
 	</view>
-
 </template>
 
 <script>
+	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
 	export default {
+		mixins: [MescrollMixin], // 使用mixin
 		data() {
 			return {
 				routeData: [],
@@ -46,16 +48,63 @@
 				tipsShow: false,
 				tipsText: "",
 				delId: "",
+				mescroll:{}
 			}
 		},
 		onShow() {},
-		onLoad() {
-			this.getList()
-		},
+		onLoad() {},
 		onNavigationBarButtonTap(e) {
 			this.addRoute(1)
 		},
 		methods: {
+			mescrollInit(mescroll) {
+				this.mescroll = mescroll;
+			},
+			downCallback() {
+				// 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
+				// 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )     
+				this.mescroll.resetUpScroll()
+			},
+			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
+			upCallback(page) {
+				console.log(page)
+				// 此处可以继续请求其他接口
+				// if (page.num == 1) {
+				// 	this.routeData = []
+				// 	// 请求其他接口...
+				// }
+				// 如果希望先请求其他接口,再触发upCallback,可参考以下写法
+				// if(!this.isInitxx){
+				// 	apiGetxx().then(res=>{
+				// 		this.isInitxx = true
+				// 		this.mescroll.resetUpScroll() // 重新触发upCallback
+				// 	}).catch(()=>{
+				// 		this.mescroll.endErr()
+				// 	})
+				// 	return // 此处return,先获取xx
+				// }
+			
+				//联网加载数据
+				this.status = 'loading';
+				this.$request.baseRequest('get', '/commonRoute/select', {
+						commonId: uni.getStorageSync("firstAuthentication").commonId,
+						pageSize: page.size,
+						currentPage: page.num
+					}).then(res => {
+						if (res.code == 200) {
+							if (page.num == 1) {
+								this.routeData = []
+							}
+							this.routeData = this.routeData.concat(res.data.records); //追加新数据
+							this.$forceUpdate()
+							this.mescroll.endBySize(res.data.records.length, res.data.total);
+							console.log(this.routeData)
+						}
+					})
+					.catch(res => {
+						uni.$u.toast(res.message);
+					});
+			},
 			delSubmit() {
 				this.$request.baseRequest('post', '/commonRoute/api/delete', {
 						id: this.delId
@@ -163,15 +212,11 @@
 				height: 120rpx;
 
 				.site_text {
-					// width: 180rpx;
 					max-width: 200rpx;
 					overflow: hidden;
-					// height: 60rpx;
 					text-overflow: ellipsis;
 					white-space: nowrap;
 					font-size: 32rpx;
-					// font-weight: 500;
-					// margin: 0 20rpx;
 				}
 			}
 
@@ -179,7 +224,6 @@
 				width: 60rpx;
 				height: 20rpx;
 				margin: 0 23rpx;
-
 			}
 
 			.dot {

+ 164 - 49
pages/riders/index.vue

@@ -12,7 +12,7 @@
 					height="35px" @click="myPage"></u--image>
 			</view>
 		</view>
-		<view class="driver" v-show="indexbtn == 1">
+		<view class="driver" v-if="indexbtn == 1">
 			<view class="flex screen">
 				<view @click="selectAddress(1)" class="screen_item">
 					<view class="screen_sign sign1">装</view>
@@ -28,47 +28,50 @@
 				<itmister-address-picker-other ref="addressEltwo" :wholeCountry="true"
 					@confirmChange="confirmChangeTwo"></itmister-address-picker-other>
 			</view>
-			<view class="route" >
-				<view v-for="(item,index) in routeData">
-					<view class="flex route_item">
-						<view style="width: 20%;">
-							<u-avatar :src="item.driverPortrait" size="60"></u-avatar>
-						</view>
-						<view style="width: 80%;">
-							<view class="flex">
-								<view class="driver_name">
-									{{item.driverNickname}}
-								</view>
-								<view class="driver_invite">
-									<view class="route_invite" style="margin-left: 30px;" @click="invitation(item)">
-										<image src="../../static/images/riders/yaoqing.png" mode=""
-											style="width: 26rpx;height: 26rpx;margin-rigth:10rpx;"></image>邀请
+			<view class="route">
+				<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
+					<view v-for="(item,index) in routeData">
+						<view class="flex route_item">
+							<view style="width: 20%;">
+								<u-avatar :src="item.driverPortrait" size="60"></u-avatar>
+							</view>
+							<view style="width: 80%;">
+								<view class="flex">
+									<view class="driver_name">
+										{{item.driverNickname}}
 									</view>
+									<view class="driver_invite">
+										<view class="route_invite" style="margin-left: 30px;" @click="invitation(item)">
+											<image src="../../static/images/riders/yaoqing.png" mode=""
+												style="width: 26rpx;height: 26rpx;margin-rigth:10rpx;"></image>邀请
+										</view>
+									</view>
+									<u-picker :show="fleetShow" :columns="columns" @cancel="fleetClose"
+										@confirm="invitationCheng">
+									</u-picker>
+								</view>
+								<view class="address" v-for="(items,index) in item.startAdress">
+									<span class="spots spot1"></span>
+									{{item.startAdress[index]}}
+									<!-- {{item.sendCity ? item.sendCity: item.sendProvince }}{{item.sendArea}} -->
+									<image class="jt-icon" src="@/static/images/goodSource/jt.png" mode='widthFix'>
+									</image>
+									<span class="spots spot2"></span>
+									{{item.endAdress[index]}}
+									<!-- {{item.unloadCity ? item.unloadCity: item.unloadProvince }}{{item.unloadArea}} -->
 								</view>
-								<u-picker :show="fleetShow" :columns="columns" @cancel="fleetClose"
-									@confirm="invitationCheng">
-								</u-picker>
-							</view>
-							<view class="address" v-for="(items,index) in item.startAdress">
-								<span class="spots spot1"></span>
-								{{item.startAdress[index]}}
-								<!-- {{item.sendCity ? item.sendCity: item.sendProvince }}{{item.sendArea}} -->
-								<image class="jt-icon" src="@/static/images/goodSource/jt.png" mode='widthFix'></image>
-								<span class="spots spot2"></span>
-								{{item.endAdress[index]}}
-								<!-- {{item.unloadCity ? item.unloadCity: item.unloadProvince }}{{item.unloadArea}} -->
 							</view>
 						</view>
 					</view>
-				</view>
-				<u-loadmore :status="status"  :nomore-text="nomoreText" />
+					<!-- <u-loadmore :status="status" :nomore-text="nomoreText" /> -->
+				</mescroll-body>
 			</view>
-			
+
 			<!-- <view v-if="routeData.length == 0" style="background: #FFFFFF;text-align: center;padding-top: 20rpx;">
 				暂无数据
 			</view> -->
 		</view>
-		<view class="riders" v-show="indexbtn == 2">
+		<view class="riders" v-if="indexbtn == 2">
 			<view class="flex riders_top">
 				<view @click="selectChange" class="riders_city">{{city ? city : province}}</view>
 				<itmister-address-picker ref="addressElthree" :showCheck="false" @confirmChange="confirmChangethree">
@@ -77,6 +80,7 @@
 					maxlength="15"></u-search>
 			</view>
 			<view class="fleet">
+				<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
 				<view v-for="(item,index) in formData" class="flex">
 					<view class="fleet_item">
 						<view class="flex">
@@ -114,7 +118,8 @@
 						</view>
 					</view>
 				</view>
-				<u-loadmore :status="status"  :nomore-text="nomoreText"  />
+				<!-- <u-loadmore :status="status" :nomore-text="nomoreText" /> -->
+					</mescroll-body>
 			</view>
 
 			<!-- <view v-if="formData.length == 0" style="background: #FFFFFF;text-align: center;">
@@ -129,9 +134,11 @@
 </template>
 
 <script>
+	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
 	import itmisterAddressPicker from '@/components/itmister-address-picker/itmister-address-picker.nvue'
 	import itmisterAddressPickerOther from '@/components/itmister-address-picker/itmister-address-picker-other.nvue'
 	export default {
+		mixins: [MescrollMixin], // 使用mixin
 		components: {
 			itmisterAddressPicker,
 			itmisterAddressPickerOther
@@ -175,7 +182,8 @@
 					paddingTop: "0",
 				},
 				status: 'loadmore',
-				 nomoreText: '实在没有了'
+				nomoreText: '实在没有了',
+				mescroll:{}
 			}
 		},
 		created() {},
@@ -203,12 +211,119 @@
 			}
 			this.commonId = uni.getStorageSync("firstAuthentication").commonId
 			this.checking()
-			this.getList()
+			// this.getList()
 		},
 		onLoad() {},
 		methods: {
-			lookfleet(item){
-				uni.$u.route("/pages/riders/fleetSee?fleetId="+item.id)
+			mescrollInit(mescroll) {
+				this.mescroll = mescroll;
+			},
+			downCallback() {
+				// 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
+				// 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )     
+				this.mescroll.resetUpScroll()
+			},
+			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
+			upCallback(page) {
+				console.log(page)
+				// 此处可以继续请求其他接口
+				if (page.num == 1) {
+					this.routeData = []
+					this.formData = []
+					// 请求其他接口...
+				}
+				// 如果希望先请求其他接口,再触发upCallback,可参考以下写法
+				// if(!this.isInitxx){
+				// 	apiGetxx().then(res=>{
+				// 		this.isInitxx = true
+				// 		this.mescroll.resetUpScroll() // 重新触发upCallback
+				// 	}).catch(()=>{
+				// 		this.mescroll.endErr()
+				// 	})
+				// 	return // 此处return,先获取xx
+				// }
+
+				//联网加载数据
+				this.status = 'loading';
+				if (this.indexbtn == 1) {
+					// if(this.sendInfo.sendProvince == "北京"||this.sendInfo.sendProvince == "重庆"||this.sendInfo.sendProvince == "天津"||this.sendInfo.sendProvince == "上海"){
+					// 	this.sendInfo.sendCity = this.sendInfo.sendProvince
+					// 	this.sendInfo.sendProvince = ""
+					// }
+					if (this.unloadInfo.unloadProvince == "全国") {
+						this.unloadInfo.unloadProvince = ""
+					}
+					this.$request.baseRequest('get', '/commonRoute/driverList', {
+							pageSize: page.size,
+							currentPage: page.num,
+							sendProvince: this.sendInfo.sendProvince,
+							sendCity: this.sendInfo.sendCity,
+							sendArea: this.sendInfo.sendArea,
+							unloadProvince: this.unloadInfo.unloadProvince,
+							unloadCity: this.unloadInfo.unloadCity,
+							unloadArea: this.unloadInfo.unloadArea
+						}).then(res => {
+							if (res.code == 200) {
+								if (page.num == 1) {
+									this.routeData = []
+									this.formData = []
+								}
+								this.routeData = this.routeData.concat(res.data.records); //追加新数据
+								
+								for (let i = 0; i < this.routeData.length; i++) {
+									if (this.routeData[i].startAdress) {
+										this.routeData[i].startAdress = this.routeData[i].startAdress.split(",")
+									}
+									if (this.routeData[i].endAdress) {
+										this.routeData[i].endAdress = this.routeData[i].endAdress.split(",")
+									}
+								}
+								this.$forceUpdate()
+								this.mescroll.endBySize(res.data.records.length, res.data.total);
+							}
+						})
+						.catch(res => {
+							uni.$u.toast(res.message);
+						});
+				} else {
+					let that = this
+					this.$request.baseRequest('get', '/fleetInfo/selectFleetInfo', {
+							commonId: this.commonId,
+							province: this.province, //省
+							city: this.city, //市
+							searchKeyWord: this.searchKeyWord,
+							pageSize: page.size,
+							currentPage: page.num,
+						}).then(res => {
+							if (page.num == 1) {
+								this.routeData = []
+								this.formData = []
+							}
+							this.formData = this.formData.concat(res.data.records); //追加新数据
+						
+							for (let i = 0; i < that.formData.length; i++) {
+								that.formData[i].textShow = false
+								if (that.formData[i].fleetUrl) {
+									that.formData[i].img = []
+									let imgList = that.formData[i].fleetUrl.split(",")
+									for (let j = 0; j < imgList.length; j++) {
+										that.formData[i].img.push({
+											url: imgList[j]
+										})
+									}
+								}
+							}
+							this.$forceUpdate()
+							this.mescroll.endBySize(res.data.records.length, res.data.total);
+
+						})
+						.catch(res => {
+							uni.$u.toast(res.message);
+						});
+				}
+			},
+			lookfleet(item) {
+				uni.$u.route("/pages/riders/fleetSee?fleetId=" + item.id)
 			},
 			checking() {
 				this.statusVal = uni.getStorageSync("firstAuthentication").authenticationStatus
@@ -357,7 +472,7 @@
 				this.unloadInfo.unloadProvince = address.province ? address.province : ''
 				this.unloadInfo.unloadCity = address.city ? address.city : ''
 				this.unloadInfo.unloadArea = address.area ? address.area : ''
-			
+
 				if (address.city == '全省') {
 					this.title2 = address.province
 					this.unloadInfo.unloadCity = ""
@@ -366,11 +481,11 @@
 					this.title2 = address.province + address.city
 					this.unloadInfo.unloadArea = ""
 				} else {
-					if(address.province == '全国'){
+					if (address.province == '全国') {
 						this.title2 = address.province
-					}else{
+					} else {
 						this.title2 = address.province + address.city + address.area;
-						}
+					}
 				}
 				uni.setStorageSync("unloadInfo", this.unloadInfo)
 				this.getList()
@@ -434,8 +549,8 @@
 					// 	this.sendInfo.sendCity = this.sendInfo.sendProvince
 					// 	this.sendInfo.sendProvince = ""
 					// }
-					if(this.unloadInfo.unloadProvince =="全国"){
-						this.unloadInfo.unloadProvince= ""
+					if (this.unloadInfo.unloadProvince == "全国") {
+						this.unloadInfo.unloadProvince = ""
 					}
 					this.$request.baseRequest('get', '/commonRoute/driverList', {
 							pageSize: 10,
@@ -443,7 +558,7 @@
 							sendProvince: this.sendInfo.sendProvince,
 							sendCity: this.sendInfo.sendCity,
 							sendArea: this.sendInfo.sendArea,
-							unloadProvince: this.unloadInfo.unloadProvince ,
+							unloadProvince: this.unloadInfo.unloadProvince,
 							unloadCity: this.unloadInfo.unloadCity,
 							unloadArea: this.unloadInfo.unloadArea
 						}).then(res => {
@@ -457,12 +572,12 @@
 										this.routeData[i].endAdress = this.routeData[i].endAdress.split(",")
 									}
 								}
-								if(res.data.total == 0){
+								if (res.data.total == 0) {
 									this.status = 'nomore'
-								}else{
+								} else {
 									this.status = 'loadmore'
 								}
-								
+
 							}
 						})
 						.catch(res => {
@@ -491,9 +606,9 @@
 									}
 								}
 							}
-							if(res.data.total == 0){
+							if (res.data.total == 0) {
 								this.status = 'nomore'
-							}else{
+							} else {
 								this.status = 'loadmore'
 							}
 						})