Переглянути джерело

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
首页 下单 登录 修改

1004749546@qq.com 4 роки тому
батько
коміт
01709dc5fb

+ 8 - 0
api/store.js

@@ -31,4 +31,12 @@ export const getWaitPhoto = params => {
     url: `device/image/${params.deviceNo}`,
     method: 'get'
   })
+};
+
+// 查看网点营业状态
+export const getStoreStatus = params => {
+  return axios.request({
+    url: `store/validateStoreAndDevice?storeId=${params.storeId}&deviceId=${params.deviceId}`,
+    method: 'get'
+  })
 };

+ 2 - 3
libs/axios.js

@@ -39,10 +39,10 @@ const request = (opts, hasToken) => {
 				if(ret.status == '200'){
 					resolve(ret)
 				}else{
-					if(ret.status == 401 && loginTimeOut == 'NO'){  //  未登录或登录过期
+					if(ret.status == '401'){  //  未登录或登录过期
 						uni.showToast({
 							icon:'none',
-							title: ret.message,
+							title: '未登录或登录已过期,请重新登录',
 							duration: 5000 
 						})
 						setTimeout(function() {
@@ -50,7 +50,6 @@ const request = (opts, hasToken) => {
 						  const url = `/pages/login/login?lanuch=${currentRoute.lanuch}&path=` + encodeURIComponent(currentRoute.url);
 						  uni.reLaunch({ url });
 						}, 1000);
-						uni.setStorageSync('loginTimeOut', 'YES');
 					}
 					// 503
 					if(ret.status == '503'||ret.status == '900'){

+ 264 - 186
pages/getOrder/getOrder.vue

@@ -20,7 +20,7 @@
 				</view>
 				<view class="item bottom" @click="lookMore">
 					<view class="item-text">
-						<text >超高加装件不能清洗</text>
+						<text>超高加装件不能清洗</text>
 						<view class="right">
 							<text>查看更多</text>
 							<u-icon name="arrow-right" size="28"></u-icon>
@@ -36,7 +36,8 @@
 						请选择服务模式
 					</view>
 					<view class="list">
-						<view :class="['item', serverIndex==index ?'avtive':'']" @click="chooseItem(index)" v-for="(item,index) in itemList" :key="index">
+						<view :class="['item', serverIndex==index ?'avtive':'']" @click="chooseItem(index)" v-for="(item,index) in itemList"
+						 :key="index">
 							<text>{{item.itemName}}</text>
 							<text class="price">¥{{item.currentPrice}}</text>
 						</view>
@@ -53,13 +54,13 @@
 								<u-icon name="arrow-right" color="rgb(255,0,0)" size="32"></u-icon>
 							</view>
 							<view v-else class="right">
-								<text >暂无可用优惠券</text>
+								<text>暂无可用优惠券</text>
 							</view>
 						</view>
 						<view class="item phone">
 							<text>手机号码</text>
 							<view class="right">
-								<text >{{userPhone}}</text>
+								<text>{{userPhone}}</text>
 							</view>
 						</view>
 					</view>
@@ -90,8 +91,17 @@
 
 <script>
 	import uniSteps from '@/components/uni-steps/uni-steps.vue'
-	import {getUserInfo} from '@/api/login.js'
-	import {getStoreItems, saveOrder, signPay} from '@/api/order.js'
+	import {
+		getUserInfo
+	} from '@/api/login.js'
+	import {
+		getStoreItems,
+		saveOrder,
+		signPay
+	} from '@/api/order.js'
+	import {
+		getStoreStatus
+	} from '@/api/store.js'
 	export default {
 		components: {
 			uniSteps
@@ -104,75 +114,80 @@
 				serverIndex: 0, // 选择服务下标
 				itemList: [], // 服务类型
 				isRead: '', // 是否同意协议
-				couponList: [
-						{
-							id: 23432445,
-							name: "满100减50",
-							price: 100,
-							yxTime: "2020-05-16",
-							remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
-							checked: false
-						},
-						{
-							id: 3544355,
-							name: "满100减50",
-							price: 100,
-							yxTime: "2020-05-16",
-							remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
-							checked: false
-						},
-						{
-							id: 234234234,
-							name: "满100减50",
-							price: 100,
-							yxTime: "2020-05-16",
-							remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
-							checked: false
-						},
-						{
-							id: 66264646,
-							name: "满100减50",
-							price: 100,
-							yxTime: "2020-05-16",
-							remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
-							checked: false
-						},
-						{
-							id: 9794694698,
-							name: "满100减50",
-							price: 100,
-							yxTime: "2020-05-16",
-							remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
-							checked: false
-						}
-					], // 用户可用优惠券
+				couponList: [{
+						id: 23432445,
+						name: "满100减50",
+						price: 100,
+						yxTime: "2020-05-16",
+						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
+						checked: false
+					},
+					{
+						id: 3544355,
+						name: "满100减50",
+						price: 100,
+						yxTime: "2020-05-16",
+						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
+						checked: false
+					},
+					{
+						id: 234234234,
+						name: "满100减50",
+						price: 100,
+						yxTime: "2020-05-16",
+						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
+						checked: false
+					},
+					{
+						id: 66264646,
+						name: "满100减50",
+						price: 100,
+						yxTime: "2020-05-16",
+						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
+						checked: false
+					},
+					{
+						id: 9794694698,
+						name: "满100减50",
+						price: 100,
+						yxTime: "2020-05-16",
+						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
+						checked: false
+					}
+				], // 用户可用优惠券
 				checkedCoupon: null, // 用户当前所选优惠券
 				amount: 0, // 所选服务项目总金额
 				couponAmount: 0, // 优惠券优惠金额
 				finalAmount: 0, // 用户最终所需支付金额
 			}
 		},
-		onLoad(option) {
+		onLoad(options) {
 			// 存储当前扫码的设备及网点id
-			if(options.scene){
-				let scene=decodeURIComponent(options.scene);
+			if (options.scene) {
+				let scene = decodeURIComponent(options.scene);
 				//&是我们定义的参数链接方式
-				let storeId=scene.split(",")[0];
-				let bizId=scene.split(',')[1];
+				let storeId = scene.split(",")[0];
+				let bizId = scene.split(',')[1];
 				//其他逻辑处理。。。。。
 				this.$store.state.vuex_orderInfo.bizId = bizId || '9999'
 				this.$store.state.vuex_orderInfo.storeId = storeId || '100000'
-				
+
 				// 判断当前门店是否已运营
-				 
-			 }else{
-				 // 判断是否扫码过
-				 if(this.$store.state.vuex_orderInfo.bizId!=''){
-					 
-				 }else{
-					 // 返回首页
-				 }
-			 }
+				this.getStoreStatus(storeId,bizId)
+			} else {
+				// 判断是否扫码过
+				if (this.$store.state.vuex_orderInfo.bizId != '') {
+
+				} else {
+					// 返回首页
+				}
+			}
+			// 监听点击已阅读事件
+			uni.$once('read', this.read)
+			// 获取用户信息
+			this.getUserPhone()
+			// 获取服务项目
+			this.getServerList()
 		},
 		onUnload() {
 			uni.removeStorageSync('stepIndex')
@@ -183,11 +198,34 @@
 			console.log(this.stepIndex)
 		},
 		methods: {
-			// 获取用户信息
-			getUserPhone () {
-				getUserInfo().then(res =>{
-					console.log(res,'rrrrrrr')
+			// 获取网点营业状态
+			getStoreStatus(storeId, bizId) {
+				uni.showLoading({
+					title: '加载中...',
+					mask: true
+				})
+				getStoreStatus({
+					storeId: storeId,
+					deviceId: bizId
+				}).then(res => {
+					uni.hideLoading()
 					if(res.status == 200) {
+						
+					} else {
+						this.toashMsg(res.message)
+						setTimeout(()=>{
+							uni.reLaunch({
+								url:'/pages/index/index'
+							})
+						},1000)
+					}
+				})
+			},
+			// 获取用户信息
+			getUserPhone() {
+				getUserInfo().then(res => {
+					console.log(res, 'rrrrrrr')
+					if (res.status == 200) {
 						this.userPhone = res.data.mobile
 					} else {
 						uni.showToast({
@@ -198,19 +236,21 @@
 				})
 			},
 			// 查看更多注意事项
-			lookMore () {
+			lookMore() {
 				uni.navigateTo({
 					url: '/pages/careMore/careMore'
 				})
 			},
 			// 获取服务列表
-			getServerList () {
+			getServerList() {
 				this.status = 'loading'
 				let storeId = this.$store.state.vuex_orderInfo.storeId
-				getStoreItems({storeId:storeId}).then(res =>{
+				getStoreItems({
+					storeId: storeId
+				}).then(res => {
 					this.status = 'loadmore'
 					if (res.status == 200) {
-						this.itemList = res.data 
+						this.itemList = res.data
 						this.serverIndex = 0
 						this.getFinalAmount()
 					} else {
@@ -226,76 +266,76 @@
 			},
 			// 下一步
 			nextStep() {
-				this.stepIndex = this.stepIndex===0 ? 1 : 2
+				this.stepIndex = this.stepIndex === 0 ? 1 : 2
 				uni.setStorageSync('stepIndex', this.stepIndex)
 			},
 			// 已阅读
-			read (e) {
+			read(e) {
 				this.isRead = e.msg
 			},
 			// 获取用户可用优惠券
-			getCouponList () {
-				
+			getCouponList() {
+
 			},
 			// 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
-			formatCouponData (){
-			  let arr = []
-			  let _this = this
-			  this.couponList.map(item => {
-			    let data = {}
-			    data.id = item.couponReceivesId
-			    if (item.couponType == 'DISCOUNT') {
-			      console.log(_this.amount, '_this.amount')
-			      data.subAmount = Number((_this.amount * (1 - item.subAmount)).toFixed(2))
-			    } else {
-			      data.subAmount = item.couponType == 'FULLSUB' ? item.subAmount : item.price
-			    }
-			    arr.push(data)
-			  })
-			  console.log(arr, 'arr')
-			  // 比较数据中优惠金额最大的值 并返回该对象
-			  let obj = arr.reduce((p, v) => p.subAmount < v.subAmount ? v : p)
-			  console.log(obj)
-			  let p = this.couponList.find(item => item.couponReceivesId == obj.id)
-			  // 订单金额为0时,默认不使用优惠卷
-			  if (this.amount != 0){
-			   this.checkedCoupon = p
-			   this.couponAmount = obj.subAmount > this.amount ? this.amount : obj.subAmount
-			  } else {
-			    this.checkedCoupon = null
-			    this.couponAmount = 0
-			  }
-			  // 计算合计
-			  this.getFinalAmount()
+			formatCouponData() {
+				let arr = []
+				let _this = this
+				this.couponList.map(item => {
+					let data = {}
+					data.id = item.couponReceivesId
+					if (item.couponType == 'DISCOUNT') {
+						console.log(_this.amount, '_this.amount')
+						data.subAmount = Number((_this.amount * (1 - item.subAmount)).toFixed(2))
+					} else {
+						data.subAmount = item.couponType == 'FULLSUB' ? item.subAmount : item.price
+					}
+					arr.push(data)
+				})
+				console.log(arr, 'arr')
+				// 比较数据中优惠金额最大的值 并返回该对象
+				let obj = arr.reduce((p, v) => p.subAmount < v.subAmount ? v : p)
+				console.log(obj)
+				let p = this.couponList.find(item => item.couponReceivesId == obj.id)
+				// 订单金额为0时,默认不使用优惠卷
+				if (this.amount != 0) {
+					this.checkedCoupon = p
+					this.couponAmount = obj.subAmount > this.amount ? this.amount : obj.subAmount
+				} else {
+					this.checkedCoupon = null
+					this.couponAmount = 0
+				}
+				// 计算合计
+				this.getFinalAmount()
 			},
 			// 计算合计
-			getFinalAmount () {
+			getFinalAmount() {
 				this.amount = this.itemList[this.serverIndex].currentPrice
-			    let ret = this.amount - this.couponAmount 
-			    this.finalAmount = ret.toFixed(2)
+				let ret = this.amount - this.couponAmount
+				this.finalAmount = ret.toFixed(2)
 			},
 			// 选择优惠券
-			intoChooseCoupon () {
+			intoChooseCoupon() {
 				uni.navigateTo({
 					url: `/pages/coupon/chooseCoupon/chooseCoupon?list=${encodeURIComponent(JSON.stringify(this.couponList))}`
 				})
 			},
 			// 打开服务协议
-			intoAgreement () {
+			intoAgreement() {
 				uni.navigateTo({
 					url: '/pages/agreement/agreement'
 				})
 			},
 			// 去付款 保存订单
-			handleSubmit (){
-				if(this.itemList.length==0){
+			handleSubmit() {
+				if (this.itemList.length == 0) {
 					this.toashMsg('请先选择服务')
-					return 
+					return
 				}
-				if (this.isRead !='read') {
+				if (this.isRead != 'read') {
 					this.toashMsg('请先阅读并同意无人洗车《注意事项及服务协议》!')
-					return 
-				} else if (this.itemList.length==0) {
+					return
+				} else if (this.itemList.length == 0) {
 					this.toashMsg('暂无服务项目')
 					return
 				}
@@ -304,17 +344,19 @@
 					mask: true
 				})
 				let item = this.itemList[this.serverIndex]
+				let storeId = this.$store.state.vuex_orderInfo.storeId
+				let deviceId = this.$store.state.vuex_orderInfo.bizId
 				let params = {
 					"itemId": item.itemId, // 服务id
-					"itemCode": item.itemCode, 
-					"storeId": 100000, // 门店id
-					"deviceId": 100000, // 设备id
-					"orderTime": this.$u.timeFormat(Date.now(), 'yyyy-mm-dd hh:MM:ss'), 
+					"itemCode": item.itemCode,
+					"storeId": storeId, // 门店id
+					"deviceId": deviceId, // 设备id
+					"orderTime": this.$u.timeFormat(Date.now(), 'yyyy-mm-dd hh:MM:ss'),
 					"payableAmount": this.amount, // 应付金额 即优惠前金额
 					"paymentAmount": this.finalAmount // 实收金额 即优惠后金额
 				}
-				saveOrder(params).then(res =>{
-					if (res.status==200) {
+				saveOrder(params).then(res => {
+					if (res.status == 200) {
 						let data = res.data
 						// 保存成功后 请求预支付返回吊起微信支付所需参数
 						this.getPayData(data)
@@ -330,36 +372,38 @@
 				})
 			},
 			// 预支付 返回微信支付所需参数
-			getPayData (orderData) {
-				signPay({orderId:orderData.id}).then(res =>{
-					console.log(res,'预支付')
+			getPayData(orderData) {
+				signPay({
+					orderId: orderData.id
+				}).then(res => {
+					console.log(res, '预支付')
 					uni.hideLoading()
 					if (res.status == 200) {
 						let data = res.data
 						// 0元订单直接支付成功,不用吊微信支付
-						if (data.tradeStatus && data.tradeStatus=="PAID") {
+						if (data.tradeStatus && data.tradeStatus == "PAID") {
 							// 付款成功后开始洗车
 							uni.redirectTo({
-								url:`/pages/work/index/index`
+								url: `/pages/work/index/index`
 							})
 						} else {
 							uni.requestPayment({
-							    provider: 'wxpay',
-							    timeStamp: data.timeStamp,
-							    nonceStr: data.nonceStr,
-							    package: data.package,
-							    signType: data.signType,
-							    paySign: data.paySign,
-							    success: function (res) {
-							        console.log('success:' + JSON.stringify(res));
+								provider: 'wxpay',
+								timeStamp: data.timeStamp,
+								nonceStr: data.nonceStr,
+								package: data.package,
+								signType: data.signType,
+								paySign: data.paySign,
+								success: function(res) {
+									console.log('success:' + JSON.stringify(res));
 									// 付款成功后开始洗车
 									uni.redirectTo({
-										url:`/pages/work/index/index`
+										url: `/pages/work/index/index`
 									})
-							    },
-							    fail: function (err) {
-							        console.log('fail:' + JSON.stringify(err));
-							    }
+								},
+								fail: function(err) {
+									console.log('fail:' + JSON.stringify(err));
+								}
 							});
 						}
 					} else {
@@ -367,68 +411,79 @@
 					}
 				})
 			}
-			
+
 		}
 	}
 </script>
 
 <style lang="scss">
-	page{
+	page {
 		height: 100%;
 	}
-	.order-content{
+
+	.order-content {
 		width: 100%;
 		height: 100%;
 		display: flex;
 		flex-direction: column;
-		.step{
+
+		.step {
 			padding: 40rpx 0;
 		}
-		.step-content{
+
+		.step-content {
 			flex: 1;
 			width: 100%;
 			display: flex;
 			flex-direction: column;
-			.step-item{
+
+			.step-item {
 				width: 100%;
 				display: flex;
 				flex-direction: column;
 				align-items: center;
 				flex: 1;
 			}
+
 			// 第一步
-			.step-one{
-				text{
+			.step-one {
+				text {
 					color: #999;
 					margin: 40rpx 0;
 				}
 			}
+
 			// 第二步
-			.step-two{
+			.step-two {
 				background-color: #F8F8F8;
 				justify-content: space-around;
-				.item{
+
+				.item {
 					background-color: #fff;
 					width: 80%;
 					height: 45%;
 					display: flex;
 					flex-direction: column;
 					align-items: center;
-					image{
+
+					image {
 						width: 80%;
 						flex: 1;
 					}
-					
+
 				}
-				.top{
-					text{
+
+				.top {
+					text {
 						color: #df928e;
 						font-size: 24rpx;
 					}
-					.item-text{
+
+					.item-text {
 						padding-top: 20rpx;
 					}
-					.care{
+
+					.care {
 						padding: 10rpx 20rpx;
 						background-color: #ff805b;
 						border-radius: 30rpx;
@@ -437,23 +492,26 @@
 						margin-bottom: 20rpx;
 					}
 				}
-				.bottom{
-					text{
+
+				.bottom {
+					text {
 						font-size: 24rpx;
 						color: #333;
 					}
-					.item-text{
+
+					.item-text {
 						width: 100%;
-						padding:0 20rpx;
+						padding: 0 20rpx;
 						display: flex;
 						justify-content: space-between;
 						padding-top: 20rpx;
 					}
 				}
 			}
+
 			// 第三步 下单
-			.step-three{
-				.choose{
+			.step-three {
+				.choose {
 					width: 100%;
 					height: auto;
 					padding-bottom: 60rpx;
@@ -461,15 +519,18 @@
 					flex-direction: column;
 					align-items: center;
 					border-bottom: 1px solid #eee;
-					.title{
+
+					.title {
 						color: #666;
 					}
-					.list{
+
+					.list {
 						width: 100%;
 						display: flex;
 						justify-content: space-around;
 						padding: 0 20rpx;
-						.item{
+
+						.item {
 							width: 30%;
 							height: 140rpx;
 							display: flex;
@@ -480,69 +541,84 @@
 							border-radius: 15rpx;
 							margin-top: 30rpx;
 							color: #999;
-							.price{
+
+							.price {
 								font-size: 34rpx;
 								margin-top: 10rpx;
 							}
 						}
-						.avtive{
+
+						.avtive {
 							color: #333;
-							border-color: rgb(255,0,0);
-							.price{
-								color: rgb(255,0,0);
+							border-color: rgb(255, 0, 0);
+
+							.price {
+								color: rgb(255, 0, 0);
 							}
 						}
 					}
-					
+
 				}
-				.choose-content{
+
+				.choose-content {
 					flex: 1;
 					width: 100%;
-					.choose-item{
+
+					.choose-item {
 						width: 100%;
-						.item{
+
+						.item {
 							padding: 0 30rpx;
 						}
 					}
-					.item{
+
+					.item {
 						width: 100%;
 						height: 100rpx;
 						display: flex;
 						align-items: center;
 						justify-content: space-between;
 						border-bottom: 1px solid #eee;
-						.coopon{
-							color: rgb(255,0,0);
+
+						.coopon {
+							color: rgb(255, 0, 0);
 						}
 					}
-					.phone{
+
+					.phone {
 						border-bottom: none;
 					}
-					.read{
+
+					.read {
 						width: 100%;
 						border-top: 1px solid #eee;
 						padding-top: 40rpx;
 						display: flex;
 						justify-content: center;
-						text{
+
+						text {
 							color: #999;
 						}
-						text:last-child{
+
+						text:last-child {
 							color: #ff9ba5;
 						}
 					}
 				}
 			}
 		}
-		.step-footer{
+
+		.step-footer {
 			width: 100%;
 			background-color: #fff;
-			.next-button{
+
+			.next-button {
 				margin: 0;
 				border-radius: 0;
 				padding: 10rpx 0;
 			}
-			.pay{
+
+			.pay {
 				width: 100%;
 				height: 100%;
 				padding: 10rpx;
@@ -550,12 +626,14 @@
 				display: flex;
 				align-items: center;
 				justify-content: flex-end;
-				.amount{
-					color: rgb(255,0,0);
+
+				.amount {
+					color: rgb(255, 0, 0);
 					font-size: 36rpx;
 					margin-right: 40rpx;
 				}
-				button{
+
+				button {
 					width: 200rpx;
 				}
 			}

+ 8 - 16
pages/index/index.vue

@@ -253,23 +253,15 @@
 			},
 			// 扫码洗车
 			scanCode () {
-				checkLogin().then(res =>{
-					if (res.status == '200'){
-						uni.navigateTo({
-							url: '/pages/getOrder/getOrder?scene=100000,9999'
-						})
-						// uni.scanCode({
-						//     success: function (res) {
-						//         console.log('条码类型:' + res.scanType);
-						//         console.log('条码内容:' + res.result);
-						//     }
-						// });
-					} else {
-						uni.navigateTo({
-							url: '/pages/login/login'
-						})
-					}
+				uni.navigateTo({
+					url: `/pages/getOrder/getOrder?scene=100027,9898`
 				})
+				// uni.scanCode({
+				//     success: function (res) {
+				//         console.log('条码类型:' + res.scanType);
+				//         console.log('条码内容:' + res.result);
+				//     }
+				// });
 			},
 			// 创建标记点 OPEN :正常营业  CLOSED:暂停营业  TO_BE_OPENED:待开业
 			createMarker(point) {

+ 0 - 1
pages/login/login.vue

@@ -64,7 +64,6 @@
 									console.log(res.data, 'login data')
 									getApp().globalData.token = res.data
 									_this.$u.vuex('vuex_token',res.data)
-									uni.setStorageSync('loginTimeOut', 'NO')
 									if (_this.path === '/pages/index/index' || _this.lanuch) {
 										uni.reLaunch({
 											url: _this.path

+ 1 - 1
pages/order/order.vue

@@ -16,7 +16,7 @@
 							<text>¥{{item.paymentAmount}}</text>
 							<text>{{item.payType}}</text>
 						</view>
-						<view>2020-07-25 16:20:33</view>
+						<view>{{item.orderTime}}</view>
 					</view>
 				</view>
 			</view>

+ 2 - 2
pages/store/storeDetail.vue

@@ -157,8 +157,8 @@
 					title: '加载中...',
 					mask: true
 				})
-				// let deviceNo = this.storeInfo.deviceVOList.length? this.storeInfo.deviceVOList[0].deviceNo :''
-				getWaitPhoto({deviceNo:9898}).then(res=>{
+				let deviceNo = this.storeInfo.deviceVOList && this.storeInfo.deviceVOList.length? this.storeInfo.deviceVOList[0].deviceNo :''
+				getWaitPhoto({deviceNo:deviceNo}).then(res=>{
 					uni.hideLoading()
 					if(res.status==200) {
 						this.waitPhoto = res.data

BIN
static/img/logo.png