zhangdan 4 years ago
parent
commit
447e31d14a
2 changed files with 247 additions and 175 deletions
  1. 2 2
      components/uni-popup/uni-popup-dialog.vue
  2. 245 173
      pages/index/index.vue

+ 2 - 2
components/uni-popup/uni-popup-dialog.vue

@@ -89,7 +89,7 @@
 		},
 		data() {
 			return {
-				dialogType: 'error',
+				dialogType: 'info',
 				focus: false,
 				val: ""
 			}
@@ -218,7 +218,7 @@
 	}
 
 	.uni-button-color {
-		color: #0DC55F;
+		color: #1995FF;
 	}
 
 	.uni-dialog-input {

+ 245 - 173
pages/index/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="content">
 		<view class="header" @click="openPrice">
-			<text >今日回收价格</text>
+			<text>今日回收价格</text>
 			<view>
 				<text>查看详情</text>
 				<u-icon name="arrow-right" color="#4F88F7" size="28"></u-icon>
@@ -13,7 +13,7 @@
 			<view class="title">今日统计</view>
 			<view class="header-cont">
 				<view class="cont-item">
-					<text >{{numTotal}}</text>
+					<text>{{numTotal}}</text>
 					<view>完成订单数(个)</view>
 				</view>
 				<view class="cont-item">
@@ -21,7 +21,7 @@
 					<view>回收重量(kg)</view>
 				</view>
 				<view class="cont-item">
-					<text >{{moneyTotal}}</text>
+					<text>{{moneyTotal}}</text>
 					<view>交易金额(元)</view>
 				</view>
 			</view>
@@ -39,55 +39,75 @@
 				<view>待处理订单({{listdata.length}}个)</view>
 			</view>
 			<view class="list-item" v-for="item in listdata" :key="item.id">
-				<u-image class="img-icon" :src="item.icon?item.imageHeader:'/static/def_home_shop.png'" border-radius="16" width="160" height="160"></u-image>
-				<view @click="intoWaitOrderDetail(item)" class="cont-item-right flex_1 flex flex_column justify_between">
+				<u-image class="img-icon" :src="item.icon?item.imageHeader:'/static/def_home_shop.png'"
+					border-radius="16" width="160" height="160"></u-image>
+				<view @click="intoWaitOrderDetail(item)"
+					class="cont-item-right flex_1 flex flex_column justify_between">
 					<view class="flex align_center justify_between">
 						<view class="flex_1 bold ellipsis-one">{{item.contactName}}</view>
 						<view class="do-btn">去处理</view>
 					</view>
-					 <view class="greey-font flex align_center justify_between">
-						 <view class="dizhi">{{item.contactAddress+(item.houseAddress||'')}}</view>
-						 <view v-if="item.distance" @click.stop="openLocation(item)" class="flex align_center">
-							 <u-icon class="icon" name="icon_coordinate1" custom-prefix="custom-icon" size="20" color="#999999"></u-icon>
-							 <text >{{item.distance}}KM</text>
-						 </view>
-					 </view>
-					 <view class="greey-font">{{item.reserveTime}},预估{{item.reserveWeightDictValue}}</view>
-					 <view class="type">
-						 <text v-for="(key,index) in item.reserveTypeList" :key="index" class="mark">
-						 	{{key}}
-						 </text>
-					 </view>
+					<view class="greey-font flex align_center justify_between">
+						<view class="dizhi">{{item.contactAddress+(item.houseAddress||'')}}</view>
+						<view v-if="item.distance" @click.stop="openLocation(item)" class="flex align_center">
+							<u-icon class="icon" name="icon_coordinate1" custom-prefix="custom-icon" size="20"
+								color="#999999"></u-icon>
+							<text>{{item.distance}}KM</text>
+						</view>
+					</view>
+					<view class="greey-font">{{item.reserveTime}},预估{{item.reserveWeightDictValue}}</view>
+					<view class="type">
+						<text v-for="(key,index) in item.reserveTypeList" :key="index" class="mark">
+							{{key}}
+						</text>
+					</view>
 				</view>
 			</view>
-			
+
 			<view class="nodata" v-if="listdata.length==0 && status!='loading'">
-				<u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
+				<u-empty src="/static/def_result.png" :text="noDataText" icon-size="260"></u-empty>
 			</view>
 			<view class="loadmore">
 				<u-loadmore v-if="status=='loading'" :status="status" />
 			</view>
 		</view>
-		
+		<!-- 取消接单弹窗 -->
+		<uni-popup ref="openModal" type="center">
+			<uni-popup-dialog content="您确定要停止接单吗?" @confirm="onOk" title="温馨提示"></uni-popup-dialog>
+		</uni-popup>
 		<!-- 筛选弹框 -->
-		<search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh" @close="openScreen=false"></search-modal>
+		<search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh"
+			@close="openScreen=false"></search-modal>
 	</view>
 </template>
 
 <script>
-	import {waitOrderQuery,reserveTotal,changeWorkState, WorkStatusGet} from '@/api/index.js'
-	import { checkLogin } from '@/api/login.js'
+	import uniPopup from '@/components/uni-popup/uni-popup.vue'
+	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
+	import {
+		waitOrderQuery,
+		reserveTotal,
+		changeWorkState,
+		WorkStatusGet
+	} from '@/api/index.js'
+	import {
+		checkLogin
+	} from '@/api/login.js'
 	import moment from 'moment'
 	import getDate from '@/libs/getDate.js'
 	export default {
+		components: {
+			uniPopup,
+			uniPopupDialog
+		},
 		data() {
 			return {
 				hasLogin: false, // 是否登录
 				listdata: [], // 列表数据
-				noDataText: '暂无数据',  //  列表请求状态提示语
-				status: 'loading',  //  加载中状态
-				titleStatus: false,  //  顶部加载中状态
-				scrollTop: 0,  //  滚动条位置
+				noDataText: '暂无数据', //  列表请求状态提示语
+				status: 'loading', //  加载中状态
+				titleStatus: false, //  顶部加载中状态
+				scrollTop: 0, //  滚动条位置
 				numTotal: 0, // 完成订单个数
 				weightTotal: 0, // 回收重量
 				moneyTotal: 0, // 交易金额
@@ -105,17 +125,15 @@
 			})
 		},
 		onUnload() {
-			
-		},
-		onShareAppMessage(res) {
-		},
-		onShareTimeline(res) {
+
 		},
+		onShareAppMessage(res) {},
+		onShareTimeline(res) {},
 		onShow() {
 			this.status = 'loading'
 			checkLogin().then(res => {
 				this.hasLogin = res.status == 200
-				if(this.hasLogin){
+				if (this.hasLogin) {
 					this.getCurPosition()
 					this.getTotalData()
 					this.getWorkStatus()
@@ -127,118 +145,124 @@
 		},
 		methods: {
 			// 检查更新
-			checkUpdate(){
+			checkUpdate() {
 				if (uni.canIUse('getUpdateManager')) {
-				      const updateManager = uni.getUpdateManager()
-				      updateManager.onCheckForUpdate(function (res) {
-				        console.log('onCheckForUpdate====', res)
-				        // 请求完新版本信息的回调
-				        if (res.hasUpdate) {
-				          console.log('res.hasUpdate====')
-				          updateManager.onUpdateReady(function () {
-				            uni.showModal({
-				              title: '更新提示',
-				              content: '新版本已经准备好,是否重启应用?',
-				              success: function (res) {
-				                console.log('success====', res)
-				                // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
-				                if (res.confirm) {
-				                  // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-				                  updateManager.applyUpdate()
-				                }
-				              }
-				            })
-				          })
-				          updateManager.onUpdateFailed(function () {
-				            // 新的版本下载失败
-				            uni.showModal({
-				              title: '已经有新版本了哟~',
-				              content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
-				            })
-				          })
-				        }
-				      })
-				    }
+					const updateManager = uni.getUpdateManager()
+					updateManager.onCheckForUpdate(function(res) {
+						console.log('onCheckForUpdate====', res)
+						// 请求完新版本信息的回调
+						if (res.hasUpdate) {
+							console.log('res.hasUpdate====')
+							updateManager.onUpdateReady(function() {
+								uni.showModal({
+									title: '更新提示',
+									content: '新版本已经准备好,是否重启应用?',
+									success: function(res) {
+										console.log('success====', res)
+										// res: {errMsg: "showModal: ok", cancel: false, confirm: true}
+										if (res.confirm) {
+											// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+											updateManager.applyUpdate()
+										}
+									}
+								})
+							})
+							updateManager.onUpdateFailed(function() {
+								// 新的版本下载失败
+								uni.showModal({
+									title: '已经有新版本了哟~',
+									content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
+								})
+							})
+						}
+					})
+				}
 			},
 			// 获取骑手状态
 			getWorkStatus() {
-				WorkStatusGet().then(res=>{
-					if(res.status==200){
+				WorkStatusGet().then(res => {
+					if (res.status == 200) {
 						this.workStatus = res.data[0].workStatus
-					} 
+					}
 				})
 			},
 			// 获取当前位置
-			getCurPosition () {
+			getCurPosition() {
 				let _this = this
 				uni.authorize({
-				    scope: 'scope.userLocation',
-				    success:()=> {
+					scope: 'scope.userLocation',
+					success: () => {
 						console.log(1111111111)
-				        uni.getLocation({
-				        	 type: 'wgs84', // 默认wgs84
-				        	 success: function(res) {
-				        	   console.log(res,'------')
-				        	   let lat = res.latitude
-				        	   let lng = res.longitude
-				        	   // 查询订单信息
-				        	   _this.getList(lat,lng)
-				        	 },
-				        	 fail: function(res) {
-				        		 console.log(res)
-				        		 // 查询订单信息
-				        		 _this.getList()
-				        	 }
-				        });
-				    },
+						uni.getLocation({
+							type: 'wgs84', // 默认wgs84
+							success: function(res) {
+								console.log(res, '------')
+								let lat = res.latitude
+								let lng = res.longitude
+								// 查询订单信息
+								_this.getList(lat, lng)
+							},
+							fail: function(res) {
+								console.log(res)
+								// 查询订单信息
+								_this.getList()
+							}
+						});
+					},
 					fail() {
 						uni.getSetting({
-						   success(res) {
-						      console.log(res.authSetting,'gggggggggg')
-							  if(!res.authSetting['scope.userLocation']){
-								  uni.showModal({
-								    title: '提示',
-								    content: '无法展示用户距离,请开启定位功能!',
-								    success: (res)=> {
-								      if (res.confirm) {
-										uni.openSetting({
-										  success(res) {
-										    console.log(res.authSetting,'res.authSetting')
-										  },
-										  fail(err) {
-										  	console.log(err,'eeeeeeeee')
-										  }
-										})
-								      } else if (res.cancel) {
-								        console.log('用户点击取消');
-										_this.getList()
-								      }
-								    }
-								  });
-								 
-							  }
-						   },
-						   fail() {
-						   	_this.getList()
-						   }
+							success(res) {
+								console.log(res.authSetting, 'gggggggggg')
+								if (!res.authSetting['scope.userLocation']) {
+									uni.showModal({
+										title: '提示',
+										content: '无法展示用户距离,请开启定位功能!',
+										success: (res) => {
+											if (res.confirm) {
+												uni.openSetting({
+													success(res) {
+														console.log(res.authSetting,
+															'res.authSetting')
+													},
+													fail(err) {
+														console.log(err, 'eeeeeeeee')
+													}
+												})
+											} else if (res.cancel) {
+												console.log('用户点击取消');
+												_this.getList()
+											}
+										}
+									});
+
+								}
+							},
+							fail() {
+								_this.getList()
+							}
 						})
-						
+
 					}
 				})
-				
+
 			},
 			// 待处理订单信息
-			getList (lat,lng) {
+			getList(lat, lng) {
 				uni.showLoading({
 					title: '加载中...'
 				})
-				waitOrderQuery({handleUserLng:lng,handleUserLat:lat}).then(res => {
+				waitOrderQuery({
+					handleUserLng: lng,
+					handleUserLat: lat
+				}).then(res => {
 					console.log(res)
-					if(res.status == 200){
+					if (res.status == 200) {
 						this.listdata = res.data
-						this.listdata.forEach(item =>{
-							item.distance = item.distanct && item.distanct.distance ? (item.distanct.distance/1000).toFixed(2) : ''
-							item.reserveTime = moment(item.reserveDateBegin).format('YYYY-MM-DD') + item.reserveTimeTypeDictValue
+						this.listdata.forEach(item => {
+							item.distance = item.distanct && item.distanct.distance ? (item.distanct
+								.distance / 1000).toFixed(2) : ''
+							item.reserveTime = moment(item.reserveDateBegin).format('YYYY-MM-DD') + item
+								.reserveTimeTypeDictValue
 							item.reserveTypeList = item.reserveRubbishType.split(',')
 						})
 						this.noDataText = '暂无数据'
@@ -252,10 +276,10 @@
 			// 今日统计
 			getTotalData() {
 				this.titleStatus = true
-				reserveTotal({}).then(res=>{
-					if(res.status == 200 && res.data) {
+				reserveTotal({}).then(res => {
+					if (res.status == 200 && res.data) {
 						this.numTotal = res.data.orderReserveCount || 0
-						this.weightTotal = res.data.totalWeight/1000 || 0
+						this.weightTotal = res.data.totalWeight / 1000 || 0
 						this.moneyTotal = res.data.originalAmount || 0
 					} else {
 						this.numTotal = 0
@@ -266,15 +290,15 @@
 				})
 			},
 			// 打开回收价格页面
-			openPrice(){
+			openPrice() {
 				uni.navigateTo({
 					url: '/pages/recoveryPrice/index'
 				})
 			},
 			// 进入待处理订单详情
-			intoWaitOrderDetail(item){
+			intoWaitOrderDetail(item) {
 				uni.navigateTo({
-					url: '/pages/order/waitOrderDetail?orderNo='+item.orderReserveNo
+					url: '/pages/order/waitOrderDetail?orderNo=' + item.orderReserveNo
 				})
 			},
 			// 导航
@@ -287,39 +311,59 @@
 				});
 			},
 			// 未登录弹窗
-			loginModal(){
+			loginModal() {
 				uni.showModal({
-				  title: '提示',
-				  content: '您尚未登录或登录已过期,请登录后使用',
-				  success: (res)=> {
-				    if (res.confirm) {
-				     uni.navigateTo({
-				         url: '/pages/login/login'
-				     })
-				    } else if (res.cancel) {
-				      console.log('用户点击取消');
-				    }
-				  }
+					title: '提示',
+					content: '您尚未登录或登录已过期,请登录后使用',
+					success: (res) => {
+						if (res.confirm) {
+							uni.navigateTo({
+								url: '/pages/login/login'
+							})
+						} else if (res.cancel) {
+							console.log('用户点击取消');
+						}
+					}
 				});
 			},
 			// 点击开始或停止接单
 			changeWorkStateFun(flag) {
-				changeWorkState({workStatus:flag}).then(res=>{
-					if(res.status == 200) {
+				if (flag == 0) {
+					console.log(flag)
+					this.$refs.openModal.open()
+				} else{
+					changeWorkState({
+						workStatus: flag
+					}).then(res => {
+						if (res.status == 200) {
+							this.getWorkStatus()
+						}
+					})
+				}
+				
+			},
+			onOk(){
+				changeWorkState({
+					workStatus: 0
+				}).then(res => {
+					if (res.status == 200) {
+						this.$refs.openModal.close()
 						this.getWorkStatus()
 					}
 				})
+				
 			}
 		}
 	}
 </script>
 
-<style lang="scss" >
-	page{
+<style lang="scss">
+	page {
 		width: 100%;
 		height: 100%;
 		background-color: #fff;
 	}
+
 	.content {
 		width: 100%;
 		height: 100%;
@@ -328,56 +372,66 @@
 		background-color: #fff;
 		padding: 0 32rpx;
 		color: #191919;
-		.header{
+
+		.header {
 			width: 100%;
 			font-size: 36rpx;
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
 			padding: 16upx 0;
+
 			view:last-of-type {
 				font-size: 32rpx;
 				color: #4F88F7;
-				text{
+
+				text {
 					margin-right: 10rpx;
 				}
 			}
-			
+
 		}
-		.header-total{
+
+		.header-total {
 			width: 100%;
 			background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
 			border-radius: 24rpx;
 			color: #fff;
 			margin: 20rpx 0;
 			height: 224rpx;
+
 			.title {
 				padding: 18rpx 34rpx;
 				font-size: 32rpx;
 			}
 		}
-		.header-cont{
+
+		.header-cont {
 			display: flex;
 			align-items: center;
 			justify-content: space-between;
 			flex: 1;
 			padding: 20rpx 34rpx;
-			.cont-item{
+
+			.cont-item {
 				display: flex;
 				flex-direction: column;
 				align-items: center;
-				text{
+
+				text {
 					line-height: 50upx;
 					font-size: 48upx;
 					font-family: Arial;
-					font-style:italic;
+					font-style: italic;
 				}
-				view{
+
+				view {
 					font-size: 24upx;
 				}
 			}
 		}
-		.btn-view{
+
+		.btn-view {
 			width: 100%;
 			height: 100rpx;
 			border-radius: 24rpx;
@@ -386,29 +440,35 @@
 			font-size: 36rpx;
 			margin: 20rpx 0;
 		}
-		.start-btn{
+
+		.start-btn {
 			border: 1px solid #4F88F7;
 			color: #4F88F7;
 		}
-		.end-btn{
+
+		.end-btn {
 			border: 1px solid #FF2C5C;
 			color: #FF2C5C;
 		}
+
 		// item样式
-		.list{
-			.title{
+		.list {
+			.title {
 				padding: 24rpx;
 				font-size: 36rpx;
 			}
-			.nodata{
+
+			.nodata {
 				padding-top: 100rpx;
 			}
 		}
+
 		.list-item {
 			display: flex;
 			align-items: center;
 			font-size: 28upx;
-			.cont-item-right{
+
+			.cont-item-right {
 				padding: 30upx 0upx;
 				min-height: 220rpx;
 				margin-left: 20upx;
@@ -416,12 +476,14 @@
 				font-size: 34rpx;
 				color: #222222;
 				width: 0;
-				.location-icon{
+
+				.location-icon {
 					width: 20rpx;
 					height: 20rpx;
 					margin: 0 10rpx;
 				}
-				.do-btn{
+
+				.do-btn {
 					width: 120rpx;
 					height: 48rpx;
 					border: 1px solid #4F88F7;
@@ -431,25 +493,30 @@
 					text-align: center;
 					line-height: 48rpx;
 				}
-				.bold{
+
+				.bold {
 					font-weight: 600;
 				}
-				.greey{
+
+				.greey {
 					font-size: 28rpx;
 					color: #424D5E;
 				}
-				.greey-font{
+
+				.greey-font {
 					font-size: 28rpx;
 					color: #666666;
 					line-height: 44rpx;
 				}
-				.dizhi{
+
+				.dizhi {
 					margin-right: 36rpx;
 					flex: 1;
 					line-height: 44rpx;
 					word-break: break-all;
 				}
-				.btn{
+
+				.btn {
 					width: 132rpx;
 					height: 52rpx;
 					background: #FFD100;
@@ -461,13 +528,16 @@
 					font-size: 28rpx;
 				}
 			}
+
 			&:last-child .cont-item-right {
 				border-bottom: none;
 			}
-			.type{
+
+			.type {
 				line-height: 50rpx;
 			}
-			.mark{
+
+			.mark {
 				padding: 6rpx 16rpx;
 				border-radius: 12rpx;
 				font-size: 22rpx;
@@ -476,16 +546,18 @@
 				margin-right: 20rpx;
 				margin-bottom: 10rpx;
 			}
-			.mark-left{
+
+			.mark-left {
 				border: 1px solid #BB8415;
 				color: #BB8415;
 				margin-right: 20rpx;
 			}
-			.mark-right{
+
+			.mark-right {
 				border: 1px solid #FF6824;
 				color: #FF6824;
 			}
-			
+
 		}
 	}
 </style>