Преглед изворни кода

打印测试,设置其他功能

aleyds пре 3 година
родитељ
комит
2ef1a698b9
4 измењених фајлова са 58 додато и 4 уклоњено
  1. 5 2
      common/apiurl.js
  2. 7 1
      common/http.api.js
  3. 11 1
      pages/index/index.vue
  4. 35 0
      pages/setting/setting.vue

+ 5 - 2
common/apiurl.js

@@ -1,6 +1,8 @@
 const apiurl = {
 	//登录
 	loginUrl:'/payee/auth/login',
+	//退出登录
+	loginOut: '/payee/auth/loginOut',
 	//首页信息
 	getIndexUrl:'/payee/index',
 	//路段车位列表
@@ -33,8 +35,9 @@ const apiurl = {
 	qiniuUploadUrl:'/file/qiniu/upload',
 	
 	//设备注册
-	deviceReg: '/device/pda/accept'
-
+	deviceReg: '/device/pda/accept',
+	
+	printIn: '/payee/orderinfo/parkIn/print/',
 }
 
 export {

+ 7 - 1
common/http.api.js

@@ -7,6 +7,8 @@ const install = (Vue, vm) => {
 	// 登录
 	let login = (params = {}) => vm.$u.post(apiurl.loginUrl, params);
 	
+	let loginOut = (params = {}) => vm.$u.post(apiurl.loginOut, params);
+	
 	let getRoadspace = (params = {}) => vm.$u.get(apiurl.getRoadspaceUrl, params);
 	
 	let entrance = (params = {}) => vm.$u.put(apiurl.entranceUrl, params);
@@ -33,9 +35,12 @@ const install = (Vue, vm) => {
 	
 	let qiniuUpload = (params = {}) => vm.$u.post(apiurl.qiniuUploadUrl, params);
 	
+	let printIn = (params = {}) => vm.$u.get(apiurl.printIn + params.orderId);
+	
 	// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
 	vm.$u.api = {
 		login,
+		loginOut,
 		getRoadspace,
 		entrance,
 		getOut,
@@ -48,7 +53,8 @@ const install = (Vue, vm) => {
 		punchIn,
 		parkInConfirm,
 		parkInInfo,
-		qiniuUpload
+		qiniuUpload,
+		printIn
 	};
 }
 

+ 11 - 1
pages/index/index.vue

@@ -61,7 +61,7 @@
 					<u-image width="120rpx" height="120rpx" src="/static/img/index-feature-07.png"></u-image>
 					<view class="feature-item-text">密码修改</view>
 				</view> -->
-				<view class="feature-item" @click="$refs.uToast.show({title: '建设中'})">
+				<view class="feature-item" @click="onPrint()">
 					<u-image width="120rpx" height="120rpx" src="/static/img/index-feature-10.png"></u-image>
 					<view class="feature-item-text">车主查询</view>
 				</view>	
@@ -89,6 +89,7 @@
 	var ALog = uni.requireNativePlugin("AndroidLog")
 	var location = uni.requireNativePlugin("Location")
 	var speak = uni.requireNativePlugin("SpeechPlug")
+	var device = uni.requireNativePlugin("DeviceInfo")
 	export default {
 		data() {
 			return {
@@ -132,6 +133,15 @@
 			speaks(msg){
 				speak.speakAction(msg)
 			},
+			onPrint(){
+				this.$u.api.printIn({orderId:'550110630002380800'})
+				.then(res=>{
+					device.print(res.data);
+				}).catch(err=>{
+					
+				});
+				
+			},
 			getLocation(){
 				ALog.info({msg:'请求定位'})
 				uni.getLocation({

+ 35 - 0
pages/setting/setting.vue

@@ -14,6 +14,12 @@
 				<u-cell-item title="修改密码" @click="openPage('pages/modifypwd/modifypwd')">
 					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
 				</u-cell-item>
+				<u-cell-item title="打印走纸" @click="onPrintFeed()">
+					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
+				</u-cell-item>
+				<u-cell-item title="退出登录" @click="onLoginOut()">
+					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
+				</u-cell-item>
 			</u-cell-group>
 		</view>
 		
@@ -21,6 +27,7 @@
 </template>
 
 <script>
+	var device = uni.requireNativePlugin("DeviceInfo")
 	export default{
 		data(){
 			return{
@@ -46,6 +53,34 @@
 					url: path
 				});
 			},
+			onPrintFeed(){
+				device.printFeed(10);
+			},
+			onLoginOut(){
+				uni.showModal({
+				  title: '温馨提示',  
+				  content: '是否确认退出?',  
+				  success: (res) => { 
+					   if (res.confirm) {
+							  this.$u.api.loginOut({})
+							  .then(res=>{
+									uni.showToast({
+										title: '退出成功',
+										duration: 2000
+									});
+							  	uni.redirectTo({
+							  		url:'../login/login'
+							  	});
+							  }).catch(err=>{
+							  });
+						  } else if (res.cancel) {
+							  
+						  }
+					  
+				  }  
+				})  
+				
+			}
 			
 		}
 	}