Browse Source

扫码打卡

zhengkaixin 4 years ago
parent
commit
2d65fae13a
8 changed files with 123 additions and 7 deletions
  1. 9 0
      apis/user.js
  2. 11 4
      bobo-router/index.js
  3. 3 1
      components/Common.vue
  4. 10 0
      pages.json
  5. 7 1
      pages/index/login.js
  6. 76 0
      pages/index/scan.vue
  7. BIN
      static/img/scanok.png
  8. 7 1
      utils/request.js

+ 9 - 0
apis/user.js

@@ -2,6 +2,15 @@ import request from '@/utils/request'
 import Qs from 'qs';
 import Qs from 'qs';
 
 
 
 
+export function driverAttendance(data) {
+	return request({
+		url: '/mobile/merchantApi/driverAttendance',
+		data: Qs.stringify(data),
+		method: 'post',
+	})
+}
+
+
 export function findByOpenId(data) {
 export function findByOpenId(data) {
 	return request({
 	return request({
 		url: '/mobile/merchantApi/findByOpenId',
 		url: '/mobile/merchantApi/findByOpenId',

+ 11 - 4
bobo-router/index.js

@@ -72,10 +72,13 @@ router.beforeEach(function(to, from, next) {
 		routerBeforeEach(to, from, next);
 		routerBeforeEach(to, from, next);
 	} else {
 	} else {
 		
 		
-		if (!carhelp.getOpenId()) {
-			if (isWeiXin()) {
-				getOpenId();
-			}
+		if (!carhelp.getOpenId()) {
+			getOpenId();
+			// if (isWeiXin()) {
+				
+			// }else{
+			// alert("请使用微信登录")
+			// }
 		} else {
 		} else {
 			
 			
 			routerBeforeEach(to, from, next);
 			routerBeforeEach(to, from, next);
@@ -112,6 +115,10 @@ function getOpenId() {
 					var token = response2.data ? response2.data.token : '';
 					var token = response2.data ? response2.data.token : '';
 					carhelp.setToken(token);
 					carhelp.setToken(token);
 					carhelp.setPersonInfo(response2.data.token)	
 					carhelp.setPersonInfo(response2.data.token)	
+					
+					uni.switchTab({
+						url: '/pages/index/index'
+					});
 				}
 				}
 					
 					
 			}).catch(error => {					
 			}).catch(error => {					

+ 3 - 1
components/Common.vue

@@ -51,9 +51,11 @@
 			
 			
 			
 			
 			islogin(){
 			islogin(){
+				
 				if(this.login){
 				if(this.login){
+					
 					if (!this.carhelp.getPersonInfo()) {
 					if (!this.carhelp.getPersonInfo()) {
-						var route_path = window.location.href.split("#")[1];
+						//var route_path = window.location.href.split("#")[1];
 						
 						
 						uni.reLaunch({
 						uni.reLaunch({
 							url: '/pages/car/login'
 							url: '/pages/car/login'

+ 10 - 0
pages.json

@@ -107,6 +107,16 @@
             }
             }
             
             
         }
         }
+       
+        ,{//扫码打卡
+            "path" : "pages/index/scan",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
     ],
 	 
 	 
 	"globalStyle": {
 	"globalStyle": {

+ 7 - 1
pages/index/login.js

@@ -14,6 +14,7 @@ import {
 				isSendMsgIng: false,
 				isSendMsgIng: false,
 				sendMsgSecond: 60,
 				sendMsgSecond: 60,
 				back:false,
 				back:false,
+				message:'',
 			}
 			}
 		},
 		},
 		methods: {
 		methods: {
@@ -154,12 +155,17 @@ import {
 			}
 			}
 			console.log(ob)
 			console.log(ob)
 			this.subFormCode.openId = this.carhelp.getOpenId();
 			this.subFormCode.openId = this.carhelp.getOpenId();
-			
+			if(temp.message){
+				this.message=temp.message;
+			}
 		
 		
 			console.log(this.carhelp.getPrefix())
 			console.log(this.carhelp.getPrefix())
 			
 			
 				
 				
 		},onReady(){
 		},onReady(){
+			if(this.message){
+				this.$refs.common.showLoading(false,this.message) 
+			}
 			if(this.carhelp.getOpenId()){
 			if(this.carhelp.getOpenId()){
 				this.findByOpenId();
 				this.findByOpenId();
 			}
 			}

+ 76 - 0
pages/index/scan.vue

@@ -0,0 +1,76 @@
+<template>
+	<view  class="cxd-login">
+		<car-common   ref="common"  ></car-common>
+		<u-navbar   title="扫码打卡" :is-back="false" >
+				<view class="slot-wrap"></view>	
+		</u-navbar>
+		<view class="text-center" style="    padding: 1rem 0 1.5rem;" >
+			<image v-if="result=='2'" src="/static/img/scanok.png"
+			
+			style="
+			    width: 202px;
+			    height: 172px;
+			"
+			
+			></image>
+			<u-cell-group v-if="result=='2'" :border="false" >
+					<u-cell-item :border-bottom="false" :title-style="{fontSize:'14px'}"  :value-style="{textAlign:'left',color:'#000',paddingLeft:'10px',fontSize:'14px'}"  title="打卡人 : " :arrow="false" :value="obj.driverName"></u-cell-item>
+					<u-cell-item :border-bottom="false" :title-style="{fontSize:'14px'}" :value-style="{textAlign:'left',color:'#000',paddingLeft:'10px',fontSize:'14px'}"  title="车牌号 : " :arrow="false"  :value="obj.licensePlateNumber" ></u-cell-item>
+					<u-cell-item :border-bottom="false" :title-style="{fontSize:'14px'}" :value-style="{textAlign:'left',color:'#000',paddingLeft:'10px',fontSize:'11px'}"  title="打卡点 : "  :arrow="false" :value="obj.place" ></u-cell-item>
+					
+			</u-cell-group>
+			
+			<h1 v-if="result=='3'">打卡失败</h1>
+			
+		</view>
+	</view>
+</template>
+
+<script>
+	import * as API_user from '@/apis/user'
+	
+	export default {
+		data() {
+			return {
+				id:'',
+				obj:{},
+				result:"1",
+			}
+		},
+		methods: {
+			getDriverAttendance(){
+				API_user.driverAttendance({
+					carNum:this.id
+				}).then(response => {
+					 if(response.result){
+						 this.obj=response.data;
+						 this.$refs.common.showLoading(false,"打卡成功");
+						 this.result="2";
+					 }else{
+						 this.result="3";
+						 this.$refs.common.showLoading(false,response.message);
+						 
+					 }	
+				}).catch(error => {					
+					this.$refs.common.showLoading(false,error);	
+				})
+			}
+		},
+		onLoad(temp) {
+			 
+			this.id=temp.carNum;
+			
+			
+				
+		},onReady(){
+			this.$refs.common.showLoading()
+			if(this.carhelp.getOpenId()){
+				this.getDriverAttendance();
+			}	
+		}
+	}
+</script>
+
+<style>
+
+</style>

BIN
static/img/scanok.png


+ 7 - 1
utils/request.js

@@ -29,10 +29,16 @@ const request = (options) => {
 			let [error, res] = response;
 			let [error, res] = response;
 			
 			
 			if (!process.car.SIMPLE_RUN) {
 			if (!process.car.SIMPLE_RUN) {
+				
 				if (res.data.code == 415&&res.data.message=='请先注册信息') {
 				if (res.data.code == 415&&res.data.message=='请先注册信息') {
+					var message=""
+					if(options.url=="/mobile/merchantApi/driverAttendance"){
+						message="请登录后再进行扫码打卡"
+					}
+					
 					carhelp.signOut()
 					carhelp.signOut()
 					uni.redirectTo({
 					uni.redirectTo({
-						url: '/pages/index/login'
+						url: '/pages/index/login?message='+message
 					})
 					})
 					return;
 					return;
 				}
 				}