wkyy 2 years ago
parent
commit
d231e4517a
3 changed files with 132 additions and 74 deletions
  1. 20 23
      package.json
  2. 2 2
      pages/mine/mine.vue
  3. 110 49
      pages/mine/paymentCode.vue

+ 20 - 23
package.json

@@ -1,27 +1,26 @@
 {
-
 	"dependencies": {
 		"compression-webpack-plugin": "^8.0.1",
 		"echarts": "^5.3.2",
 		"hls.js": "^0.14.11",
+		"qrcodejs2": "0.0.2",
 		"uview-ui": "^1.8.4",
 		"vconsole": "^3.4.0",
+		"vue-cli": "^2.9.6",
 		"vue-cropper": "^0.5.6",
-		"weixin-js-sdk": "^1.6.0",
-		"vue-cli": "^2.9.6",
-		"vue-cropper": "^0.5.6",
-		"vuex": "^3.6.2"
-	},
-	"devDependencies": {
-	 "@vue/cli-plugin-babel": "^4.0.0",
-	 "@vue/cli-plugin-eslint": "^4.0.0",
-	 "@vue/cli-service": "^4.0.0",
-	 "babel-eslint": "^10.0.3",
-	 "eslint": "^5.16.0",
-	 "eslint-plugin-vue": "^5.0.0",
-	 "node-sass": "^5.0.0",
-	 "sass-loader": "^11.0.1",
-	 "vue-template-compiler": "^2.6.10"
+		"vuex": "^3.6.2",
+		"weixin-js-sdk": "^1.6.0"
+	},
+	"devDependencies": {
+		"@vue/cli-plugin-babel": "^4.0.0",
+		"@vue/cli-plugin-eslint": "^4.0.0",
+		"@vue/cli-service": "^4.0.0",
+		"babel-eslint": "^10.0.3",
+		"eslint": "^5.16.0",
+		"eslint-plugin-vue": "^5.0.0",
+		"node-sass": "^5.0.0",
+		"sass-loader": "^11.0.1",
+		"vue-template-compiler": "^2.6.10"
 	},
 	"uni-app": {
 		"scripts": {
@@ -33,7 +32,7 @@
 					"NODE_NAME": "test"
 				},
 				"define": {
-					"CUSTOM-CONST": true,
+					"CUSTOM-CONST": true,
 					"NODE_NAME_T": "test"
 				}
 			},
@@ -42,15 +41,13 @@
 				"BROWSER": "Chrome",
 				"env": {
 					"UNI_PLATFORM": "h5",
-					"NODE_NAME": "production"
-					
+					"NODE_NAME": "production"
 				},
 				"define": {
-					"CUSTOM-CONST": true,
-					"NODE_NAME_T": "production"
-					
+					"CUSTOM-CONST": true,
+					"NODE_NAME_T": "production"
 				}
 			}
 		}
 	}
-}
+}

+ 2 - 2
pages/mine/mine.vue

@@ -81,7 +81,7 @@
 				<view class="balance">
 					饭卡余额(元)
 				</view>
-				<view class="check">
+				<view class="check" @click="gotoUrl('pages/mine/myMealCard')">
 					<text><img src="../../assets/img/riLine-eye-line@1x.png" alt=""></text>查看消费记录
 				</view>
 			</view>
@@ -95,7 +95,7 @@
 						<text>下次清零 2023月6月1日 0点</text>
 					</view>
 				</view>
-				<view class="payment-code">
+				<view class="payment-code" @click="gotoUrl('pages/mine/paymentCode')">
 					<view class="code">
 						<img src="../../assets/img/iconPark-pay-code-one@1x.png" alt="">
 					</view>

+ 110 - 49
pages/mine/paymentCode.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<u-navbar title="付款码">	
+		<u-navbar title="付款码">
 		</u-navbar>
 		<view class="content">
 			<!-- 饭卡信息 -->
@@ -24,14 +24,13 @@
 			</view>
 			<!-- 二维码 -->
 			<view class="qr-code ">
-				<view class="img">
+				<div class="img" ref="qrCodeDiv"></div>
+				<!-- <view class="img">
 					<img src="../../assets/img/qrCode.png" alt="">
 					<view class="qr-logo">
 						<img src="../../assets/img/qrLogo.png" alt="">
 					</view>
-					
-					
-				</view>
+				</view> -->
 				<view class="hint">
 					将二维码对准摄像头,即可付款就餐
 				</view>
@@ -44,7 +43,7 @@
 			     </view>
 			</view> -->
 			<!-- 我的消费记录 -->
-			<view class="consumption-record">
+			<view class="consumption-record" @click="gotoUrl('pages/mine/myMealCard')">
 				<view class="icon">
 					<img src="../../assets/img/riLine-file-list-3-line@1x.png" alt="">
 				</view>
@@ -56,74 +55,122 @@
 				</view>
 			</view>
 		</view>
-		
+
 	</view>
 </template>
 
 <script>
+	import QRCode from 'qrcodejs2'
+
 	export default {
 		data() {
 			return {
 				
 			}
 		},
+		onReady() {
+			this.getQrcode();
+		},
 		methods: {
-			
+			getQrcode() {
+				this.$nextTick(() => {
+					let div = document.createElement('div');// 创建一个div,用来生成二维码
+					// 生成二维码
+					let qrcode = new QRCode(div, {
+						text: '123456789', // 你的扫码内容,填网址
+						width: 200, // 二维码宽度 
+						height: 200, // 二维码高度
+						colorDark: "#333333", //二维码颜色
+						colorLight: "#ffffff", //二维码背景色
+						correctLevel: QRCode.CorrectLevel.H, //从上至下生成码密度越来越高 L - M - Q - H
+						// 容错率越高,越复杂
+					})
+					let logo = new Image();
+					logo.crossOrigin = 'Anonymous';
+					logo.src = require("@/assets/img/qrLogo.png") // 填入你本地log图片
+					// 生成log图
+					logo.onload = () => {
+						let container = this.$refs['qrCodeDiv']; 
+						// 获取页面上的div,可以使用document.querySelector()等等方法,不类推了
+						if (container.innerHTML != "") {
+							// 获取页面div , 有则清空已存在的
+							container.innerHTML = ""
+						}
+						let qrImg = qrcode._el.getElementsByTagName('img')[0]; // 获取二维码
+						let canvas = qrcode._el.getElementsByTagName('canvas')[0]; // 获取canvas
+				
+						let ctx = canvas.getContext("2d");
+						ctx.drawImage(logo, 200 * 0.5 - 22, 200 * 0.5 - 22, 56, 56); // 写入log
+						qrImg.src = canvas.toDataURL();
+						container.appendChild(qrcode._el);
+					}
+				})
+			}
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
-	page{
+	page {
 		background-color: #2A8EFB;
 	}
-	/deep/.u-navbar{
+
+	/deep/.u-navbar {
 		background-color: #2A8EFB !important;
-		
+
 	}
-	/deep/.u-title{
+
+	/deep/.u-title {
 		color: #fff !important;
 		font-weight: bold !important;
 	}
-	/deep/.uicon-nav-back{
+
+	/deep/.uicon-nav-back {
 		color: #fff !important
 	}
+
 	/deep/.u-border-bottom:after {
-       border-bottom-width: 0px;
-}
+		border-bottom-width: 0px;
+	}
 
-    .content{
+	.content {
 		border-radius: 24rpx;
 		background-color: rgba(255, 255, 255, 1);
-		margin:48rpx 32rpx;
+		margin: 48rpx 32rpx;
+
 		// 饭卡信息
-		.head{
+		.head {
 			padding: 32rpx 0;
 			margin: 0 32rpx;
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
 			border-bottom: 1px solid rgba(232, 232, 232, 1);
-			.person{
+
+			.person {
 				display: flex;
 				align-items: center;
-				.photo{
+
+				.photo {
 					width: 48rpx;
 					height: 48rpx;
 					border-radius: 100rpx;
 					overflow: hidden;
-					img{
+
+					img {
 						width: 100%;
 						height: 100%;
 					}
 				}
-				.name{
+
+				.name {
 					color: rgba(51, 51, 51, 1);
 					font-size: 36rpx;
 					margin-left: 16rpx;
 				}
 			}
-			.balance{
+
+			.balance {
 				display: flex;
 				align-items: center;
 				color: rgba(16, 16, 16, 1);
@@ -131,68 +178,81 @@
 				font-weight: bold;
 			}
 		}
+
 		// 二维码
-		.qr-code{
+		.qr-code {
 			padding: 80rpx 0;
-			
-			.img{
+
+			.img {
 				width: 400rpx;
 				height: 400rpx;
 				position: relative;
 				margin: 0 144rpx;
-				img{
+
+				img {
 					width: 100%;
 					height: 100%;
 				}
 			}
-			.qr-logo{
+
+			.qr-logo {
 				width: 112rpx;
 				height: 112rpx;
-				position:absolute;
-				top: 0;left:0;right:0;bottom:0;
+				position: absolute;
+				top: 0;
+				left: 0;
+				right: 0;
+				bottom: 0;
 				margin: auto;
-				
-				img{
+
+				img {
 					width: 100%;
 					height: 100%;
 				}
 			}
+
 			// 付款中
-			
+
 		}
-		.hint{
+
+		.hint {
 			margin-top: 16rpx;
 			color: rgba(51, 51, 51, 1);
 			text-align: center;
 		}
+
 		//我的消费记录
-		.consumption-record{
+		.consumption-record {
 			display: flex;
 			align-items: center;
 			padding: 32rpx 0;
 			margin: 0 32rpx;
 			border-top: 1px solid rgba(232, 232, 232, 1);
-			.icon{
+
+			.icon {
 				width: 40rpx;
 				height: 40rpx;
-				
-				img{
+
+				img {
 					width: 100%;
 					height: 100%;
 				}
 			}
-			.text{
+
+			.text {
 				color: rgba(51, 51, 51, 1);
 				font-size: 32rpx;
 				margin-left: 8rpx;
 			}
-			.right{
+
+			.right {
 				margin-left: auto;
 			}
 		}
 	}
+
 	// 付款中
-	.paying{
+	.paying {
 		width: 160rpx;
 		height: 160rpx;
 		border-radius: 8px;
@@ -200,20 +260,21 @@
 		color: #fff;
 		padding: 22rpx 0;
 		text-align: center;
-		position:absolute;
+		position: absolute;
 		top: 440rpx;
-		left:0;
-		right:0;
-		
+		left: 0;
+		right: 0;
+
 		margin: auto;
-		
-		img{
+
+		img {
 			width: 72rpx;
 			height: 72rpx;
 		}
 	}
+
 	// 透明
-	.opacity{
+	.opacity {
 		opacity: 0.3;
 	}
-</style>
+</style>