wkyy 2 years ago
parent
commit
5cac4b098f

+ 18 - 0
apis/parents/course.js

@@ -1,6 +1,24 @@
 import requestStudent from '@/apis/utils/request.js';
 import Qs from 'qs';
 
+export function onlineTicketPrinter(data) {
+	var url='/mobile/student/onlineTicketPrinter';
+	return requestStudent({
+		method: 'post',
+		data: data,
+		url: url
+	})
+}
+
+export function getBuyInvoiceInfo(data) {
+	var url='/mobile/student/getBuyInvoiceInfo';
+	return requestStudent({
+		method: 'post',
+		data: data,
+		url: url
+	})
+}
+
 export function loadMyBuyLog(data) {
 	var url='/mobile/student/loadMyBuyLog';
 	return requestStudent({

+ 3 - 2
config/.env.dev.js

@@ -1,5 +1,6 @@
 const UNI_APP = {  
-	ProjectName :"51充电联盟",
+	ProjectName :"51充电联盟",
+	// BASE_URL: 'http://47.98.231.198:9090/qsng-server/',
 	BASE_URL: 'http://192.168.77.162:8086/education-training-server/',
 	//BASE_URL: 'https://charging.xiaoxinda.com/charging-station-test/',
 	//BASE_URL: 'http://192.168.77.162:8080/charging-station/' ,
@@ -18,7 +19,7 @@ const UNI_APP = {
 	//		openId:"oK9Wr5xRUoP9EygZqBec0xkJMVTs",
 	//openId:"oK9Wr55J1J1eL6BqI2tW749NTxNU",//zq
 	//小鹏管家appid
-	//VUE_APP_WXAPPID:"wx7e70eb62a8459869",
+	// VUE_APP_WXAPPID:"wx7e70eb62a8459869",
 	VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
 	VUE_APP_ALIAPPID:"2021003131641247",
 }  

+ 2 - 1
config/.env.prod.js

@@ -7,7 +7,8 @@ const UNI_APP = {
 	SIMPLE_RUN:false,
 	openId:"oHjCawigqi8SEAwutwkQ-VEgdp3k",//测试用openId
 	//小鹏管家appid
-	VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
+	VUE_APP_WXAPPID:"wx7e70eb62a8459869",
+	// VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
 	VUE_APP_ALIAPPID:"2021003131641247",
 }  
 

+ 2 - 1
config/.env.test.js

@@ -12,7 +12,8 @@ const UNI_APP = {
 	//openId:"oHjCawigqi8SEAwutwkQ-VEgdp3k",//测试用openId
 	//openId:"oHjCawmHqG44pqUW54iBlenaHYB8",D
 	//小鹏管家appid
-	VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
+	VUE_APP_WXAPPID:"wx7e70eb62a8459869",
+	// VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
 	VUE_APP_ALIAPPID:"2021003131641247",
 	//zkx的测试openId
 	// openId:"oHjCawsJ5blME36lHaSpSVfEhleU",

+ 6 - 1
pages/parents/course/paymentDetail.vue

@@ -199,7 +199,7 @@
 		</view>
 		<!-- 底部 -->
 		<view class="check-bill">
-			<button>查看票据</button>
+			<button @click="toViewBill">查看票据</button>
 		</view>
 	</view>
 </template>
@@ -225,6 +225,11 @@
 			}
 		},
 		methods: {
+			toViewBill() {
+				uni.navigateTo({
+					url: '/pages/parents/course/viewBill'
+				})
+			},
 			getLoadMyBuyLog() {
 				uni.showLoading({
 					title: "加载中",

+ 49 - 3
pages/parents/course/printBill.vue

@@ -19,7 +19,9 @@
 			</view> -->
 			<!-- 打印中弹框-->
 			<view class="loading">
-				<img src="../../../assets/img/loading.png" alt="">
+				<view class="loading-img">
+					<img src="../../../assets/img/loading.png" alt="">
+				</view>
 				<view class="text">打印中</view>
 			</view>
 			<!-- 打印信息 -->
@@ -70,19 +72,63 @@
 </template>
 
 <script>
+	import * as courseApi from '@/apis/parents/course.js'
+	
 	export default {
 		data() {
 			return {
-				
+				timeOut: false,
+				id: '',
+				printerId: '',
+				printingInfo: {}
 			}
 		},
+		onLoad(op) {
+			if (op.id) {
+				this.id = op.id;
+				this.timeOut = true;
+			}
+		},
+		onUnload() {
+			this.timeOut = false;
+		},
 		methods: {
-			
+			getOnlineTicketPrinter() {
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				courseApi.onlineTicketPrinter({
+					id: this.id,
+					printerId: this.printerId
+				}).then((res) => {
+					uni.hideLoading();
+					this.printingInfo = res.data;
+					if (this.timeOut) {
+						setTimeout(() => {
+							this.getOnlineTicketPrinter();
+						}, 2000)
+					}
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			}
 		}
 	}
 </script>
 
 <style scoped lang="scss">
+	.loading-img{
+		animation: rotation 2s linear infinite;
+	}
+	@keyframes rotation{
+		from {transform: rotate(0deg)}
+		to {transform: rotate(360deg)}
+	}
+	
 	page{
 		background-color: #fff;
 	}

+ 107 - 45
pages/parents/course/viewBill.vue

@@ -1,53 +1,111 @@
 <template>
 	<view>
 		<u-navbar title="查看票据"></u-navbar>
-		<view class="bill" v-for="item in 2">
-            <view class="img">
-            	<img src="../../../assets/img/bill.png" alt="">
-				
-            </view>			
+		<view class="bill">
+			<view class="img">
+				<img :src="billInfo.invoiceUrl" alt="">
+			</view>
 			<view class="options">
 				<view class="key">
-					票据1
+					{{billInfo.invoiceTitle}}
 				</view>
 				<view class="btn">
-					<button class="download">下载票据</button>
-					<button class="print">打印票据</button>
+					<button class="download" @click="downloadBill">下载票据</button>
+					<button class="print" @click="toPrintBill">打印票据</button>
 				</view>
 			</view>
 		</view>
-		
+
 	</view>
 </template>
 
 <script>
+	import * as courseApi from '@/apis/parents/course.js'
+
 	export default {
 		data() {
 			return {
-				
+				buyId: '',
+				billInfo: {}
+			}
+		},
+		onLoad(op) {
+			if (op.id) {
+				this.buyId = op.id;
 			}
 		},
 		methods: {
-			
+			downloadBill() {
+				const downloadTask = uni.downloadFile({
+					url: this.billInfo.invoiceUrl, //仅为示例,并非真实的资源
+					success: (res) => {
+						if (res.statusCode === 200) {
+							console.log('下载成功');
+						}
+						let that = this;
+						uni.saveFile({
+							tempFilePath: res.tempFilePath,
+							success: function(red) {
+								uni.openDocument({
+									filePath: red.savedFilePath,
+									success: (sus) => {
+										console.log('成功打开')
+									}
+								})
+								console.log(red)
+							}
+						});
+					}
+				})
+				downloadTask.onProgressUpdate((res) => {
+					console.log('下载进度' + res.progress);
+					console.log('已经下载的数据长度' + res.totalBytesWritten);
+					console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
+				})
+			},
+			getBillInfo() {
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				courseApi.getBuyInvoiceInfo({
+					buyId: this.buyId
+				}).then((res) => {
+					uni.hideLoading();
+					this.billInfo = res.data;
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			},
+			toPrintBill() {
+				uni.navigateTo({
+					url: '/pages/parents/course/printBill?id=' + this.billInfo.buyId
+				})
+			}
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
-	.bill{
+	.bill {
 		margin: 24rpx 32rpx;
 		border-radius: 4px;
 		box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.15);
-		.img{
+
+		.img {
 			width: 100%;
 			height: 398rpx;
-			
-		img{
-			width: 100%;
-			height: 100%;
-		}
+
+			img {
+				width: 100%;
+				height: 100%;
+			}
 		}
-		.options{
+
+		.options {
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
@@ -55,35 +113,39 @@
 			background-color: #000000;
 			opacity: 0.4;
 			padding: 24rpx;
-			.key{
+
+			.key {
 				color: rgba(255, 255, 255, 1);
 				font-size: 16px;
-               
+
+			}
+
+			.btn {
+				display: flex;
+
+				uni-button {
+					width: 160rpx;
+					height: 64rpx;
+					line-height: 64rpx;
+					text-align: center;
+					border-radius: 4px;
+					font-size: 28rpx;
+					padding: 0;
+				}
+
+				.download {
+					background-color: rgba(255, 255, 255, 1);
+					color: #333333;
+				}
+
+				.print {
+					background-color: #0DBAC7;
+					color: rgba(255, 255, 255, 1);
+					margin-left: 20rpx;
+				}
+
 			}
-			.btn{
-						display: flex;
-						uni-button{
-							width: 160rpx;
-							height: 64rpx;
-							line-height: 64rpx;
-							text-align: center;
-							border-radius: 4px;
-							font-size: 28rpx;
-							padding: 0;
-						}
-						.download{
-							background-color: rgba(255, 255, 255, 1);
-							color:#333333;
-						}
-						.print{
-							background-color:#0DBAC7;
-							color: rgba(255, 255, 255, 1);
-							margin-left: 20rpx;
-						}
-						
-					}
 		}
-		
-	}
 
+	}
 </style>