瀏覽代碼

支付修改

lianghanqiang 4 年之前
父節點
當前提交
a2fd12cd76
共有 6 個文件被更改,包括 220 次插入100 次删除
  1. 5 0
      package-lock.json
  2. 1 0
      package.json
  3. 103 53
      pages/checkstand/index.vue
  4. 1 1
      pages/checkstand/order-res.vue
  5. 98 35
      pages/checkstand/pay-qrcode.vue
  6. 12 11
      pages/mine/mine.vue

+ 5 - 0
package-lock.json

@@ -22,6 +22,11 @@
         "@dcloudio/types": "^2.0.16"
       }
     },
+    "tki-qrcode": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/tki-qrcode/-/tki-qrcode-0.1.6.tgz",
+      "integrity": "sha512-EnnlS8psowC7PsW3MDYcxvJYkuklX3WAZ/BYanR4TdBHTu74GfjTBX8Y16REP+AeDENiVtBPh4jtTRL2P736hQ=="
+    },
     "totp-generator": {
       "version": "0.0.9",
       "resolved": "https://registry.npmjs.org/totp-generator/-/totp-generator-0.0.9.tgz",

+ 1 - 0
package.json

@@ -11,6 +11,7 @@
   "license": "ISC",
   "dependencies": {
     "luch-request": "^3.0.6",
+    "tki-qrcode": "^0.1.6",
     "totp-generator": "0.0.9",
     "uview-ui": "^1.8.4"
   }

+ 103 - 53
pages/checkstand/index.vue

@@ -1,11 +1,31 @@
 <template>
 	<view class="check-panel flex-direction">
-		<image :src="logo" class="buyer-logo"></image>
-		<view class="title center">{{buyer}}</view>
-		<u-input  class="amount"  :custom-style="inputStyle"  focus  placeholder="0" input-align="center "  v-model="orderAmount" :type="digit" :clearable="false" />
-		<button @click="$jump('/pages/checkstand/order-res')">去支付</button>
-		<view class="bottom-line center">联兑通提供技术支持</view>
-	</view>
+			<image :src="logo" class="buyer-logo"></image>
+			<view class="title center">{{buyer}}</view>
+			<view class="input-content">
+				<view class="tips">交易金额</view>
+				<view class="input-bar center" @tap="show=true">
+					<view class="icon center">¥</view>
+					<view class="input center">
+						<view>{{orderAmount}}</view>
+						<view class="cusor"></view>
+					</view>
+				</view>
+				<view style="height: 50rpx;"></view>
+				<u-button class="button" type="warning" @click="$jump('/pages/checkstand/order-res')">付款</u-button>
+			</view>
+			
+			<view  class="bottom-line center"> -- 联兑通提供技术支持 --</view>
+			<u-keyboard 
+				ref="uKeyboard" 
+				:show-tips="false"
+				:safe-area-inset-bottom="true" 
+				:mask="false"
+				v-model="show" 
+				@change="handleInput" 
+				@backspace="handleDelete"
+			></u-keyboard>
+		</view>
 </template>
 
 <script>
@@ -14,63 +34,93 @@
 		},
 		data() {
 			return {
-				logo: "/static/bank/CMBCHINA.png",
+				show: true,
+				logo: "/static/bank/ABC.png",
 				buyer: "中国招商银行",
-				orderAmount: 0,
-				inputStyle: {
-					'margin-top': '100rpx',
-					'font-size': '80rpx',
-					'height': '120rpx',
-					'font-weight': '500',
-					'color': '#000000'
-				}
+				orderAmount: '',
 			}
 		},
 		methods: {
-			
+			handleInput(num){
+							if(this.orderAmount.length>12) {
+								return
+							}
+							this.orderAmount =this.orderAmount + num
+						},
+						handleDelete(){
+							if(this.$isEmpty(this.orderAmount)){
+								return
+							}
+							this.orderAmount = this.orderAmount.substr(0,this.orderAmount.length-1)
+						},
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
 	.check-panel{
-		background-color: #FFFFFF;
-		border-radius: 25rpx;
-		width: 90%;
-		min-height: 900rpx;
-		margin: 20rpx  5%;
-		
-		.buyer-logo{
-			width: 100rpx;
-			height: 100rpx;
-			margin-top: 70rpx;
-			margin-left: calc(50% - 50rpx);
-		}
-		.title{
-			height: 70rpx;
-			letter-spacing: 3rpx;
-			color: #5D5D5D;
-		}
-		.amount::before{
-			position: relative;
-			left: 100rpx;
-			color: #bec2c2;
-			letter-spacing: 2rpx;
-			content: '金额 (¥)';
+			.buyer-logo{
+				width: 100rpx;
+				height: 100rpx;
+				margin-top: 50rpx;
+				margin-left: calc(50% - 50rpx);
+			}
+			.title{
+				height: 70rpx;
+				letter-spacing: 3rpx;
+				color: #5D5D5D;
+			}
+			.input-content{
+				padding: 50rpx;
+				position: absolute;
+				top: 280rpx;
+				bottom: 0;
+				left: 0;
+				right: 0;
+				background-color: #FFFFFF;
+				width: 100%;
+				border-radius: 25rpx 25rpx 0 0;
+				.tips{
+					height: 100rpx;
+					font-size: 30rpx;
+					display: flex;
+					justify-content: left;
+					align-items: center;
+				}
+				.input-bar{
+					height: 150rpx;
+					border-bottom: 1rpx solid #DDDDDD;
+					.icon{
+						width: 15%;
+						font-size: 70rpx;
+						font-weight: 900;
+						height: 100%;
+					}
+					.input{
+						width: 85%;
+						height: 100%;
+						overflow: hidden;
+						font-size: 70rpx;
+					}
+					.cusor{
+						width: 2rpx;
+						height: 80%;
+						background-color: #FD711B;
+						animation: blink 1500ms infinite ease-in-out;
+					}
+				}
+			}
 		}
-		button{
-			width: 90%;
-			margin-top: 100rpx;
-			color: white;
-			background-color: #E1961A;
-			letter-spacing: 5rpx;
+		.bottom-line{
+			position: absolute;
+			bottom: 50rpx;
+			left: 0;
+			width: 100%;
+			color: #dddddd;
 		}
-	}
-	.bottom-line{
-		position: absolute;
-		bottom: 50rpx;
-		left: 0;
-		width: 100%;
-		color: #dddddd;
-	}
+		  @keyframes blink {
+		    from{
+				opacity: 0;
+			}
+		  }
 </style>

+ 1 - 1
pages/checkstand/order-res.vue

@@ -87,7 +87,7 @@
 			position: absolute;
 			width: 40%;
 			left: 30%;
-			bottom: 15%;
+			bottom: 25%;
 			color: #E1961A;
 			border-color:   #E1961A ;
 			letter-spacing: 20rpx;

+ 98 - 35
pages/checkstand/pay-qrcode.vue

@@ -1,60 +1,117 @@
 <template>
 	<view class="code-container">
-		<view class="title center">向商家付款</view>
-		<!-- <image class="bar-code" :src="barCode"></image> -->
+		<view class="title center">{{isPayment? "向商家付款":"扫一扫,向我付款"}}</view>
 		<view  class="main-content">
-			<view class="bar-code center">
-				<tki-barcode
-			    ref="barcode"
-				:val="barContent"
-				onval=true
-				:opations="barOption"
-			  /></view>
-			<view class="qr-code center">
-				<ayQrcode ref="qrcode" :modal="true" :url="url" :height="150" :width="150" />
+			<view v-if="isPayment">
+				<!-- 占位 -->
+				<view style="height: 50rpx;"></view>
+				<!-- 条形码 -->
+				<view  class="bar-code center">
+					<tki-barcode
+				    ref="barcode"
+					:val="content"
+					onval=true
+					:opations="barOption"
+				  /></view>
+				  <!-- 付款码 -->
+				<view class="qr-code center">
+					 <tki-qrcode
+						cid="2"
+					    ref="qrcode"
+					    :val="content"
+						size="300"
+					    :onval="true"
+					    :loadMake="true"
+					    :usingComponents="true"
+					    />
+				</view>
+			</view>
+			<!-- 收款码 -->
+			<view v-else class="charge-code center">
+				 <tki-qrcode
+					cid="1"
+				    ref="qrcode-charge"
+				    :val="id"
+					:icon="avatar"
+					size="420"
+				    :onval="true"
+				    :loadMake="true"
+				    :usingComponents="true"
+				    />
 			</view>
 		</view>
 		<view class="footer center">
-			<view @click="isPayment=!isPayment"  class="cu-btn round cuIcon-qrcode text-orange" style="font-size: 50rpx;height: 100rpx;">
+			<view @click="isPayment=!isPayment"  class="cu-btn round cuIcon-qrcode" style="font-size: 50rpx;height: 100rpx;" :style="{color: isPayment? 'orange':'green' }">
 				<view class="text-black text-xl margin-left-30">{{ isPayment? " 切换收款码":"切换付款码"}}</view>
 			</view>
 		</view>
-	
+		
 	</view>
 </template>
 
 <script>
-	import ayQrcode from "@/components/ay-qrcode/ay-qrcode.vue"
+	import tkiQrcode from "tki-qrcode"
 	import tkiBarcode from "@/components/tki-barcode/tki-barcode.vue"
-
+	import  totp   from "@/utils/totp.js"
+	// import global from "@/utils/global.js"
+	// const  { transformKey } = global;
 	export default {
-		components: { ayQrcode ,tkiBarcode},
-		mounted(option){
-			//生成动态密码
-
-		this.$refs.qrcode.crtQrCode()
-		const totp = require("totp-generator");
-		totp("JBSWY3DPEHPK3PXP");
-		},
-		watch:{
-			
-		},
+		components: { tkiBarcode,tkiQrcode},
 		computed:{
+			content(){
+				let  transformStr = (this.id*95256)*2
+				return transformStr+this.secret
+			}
 		},
 		data() {
 			return {
-				id: '',
+				id: "",
+				avatar: "",
+				secret: '000000',
 				isPayment: true,
-				barContent: '321968494981965849',
-				url: 'https://pixabay.com/images/search/?order=ec', 
+				timer: '',
 				barOption: {
 					width: 4,
-					fontColor: "#caad20"
+					height: 130,
+					displayValue:  false
 				}
 			}
 		},
 		methods: {
-			
+			refreshCode(){
+				this.timer = setInterval(()=>{
+					this.secret =  totp.getSecret(this.id);
+				},1000)
+			},
+			async initAvatat(url){
+				return new Promise((reslove,reject)=>{
+					uni.downloadFile({
+							url,
+							success: (res)=> {
+								reslove(res);
+							},
+							fail: (err) => {
+								reject(err)
+							}
+					})
+				})
+				
+			}
+		},
+		async created(option) {
+			//获取用户头像
+			let avatar = "https://gxsz-bucket-01.obs.cn-south-1.myhuaweicloud.com/7123b4d61ba04f1ea2fb0335e36b9477.jpg";
+
+			this. avatar =(await  this.initAvatat(avatar)).tempFilePath;
+		},
+		mounted(option){
+			//获取用户ID
+			this.id = "13126058204"
+			//生成动态密码
+			this.refreshCode();
+		},
+		beforeDestroy() {
+			clearInterval(this.timer);
 		}
 	}
 </script>
@@ -91,16 +148,22 @@
 		}
 		.main-content{
 			width: 100%;
-			height: 550rpx;
+			height: 600rpx;
+			scroll-margin-top: 600rpx;
+			// overflow: hidden;
 			.bar-code{
-				width: 90%;
 				margin-left: 5%;
+				width: 90%;
 				height: 150rpx;
-				margin-top: 50rpx;
 			}
 			.qr-code{
 				width: 100%;
-				height: 400rpx;
+				height: 450rpx;
+			}
+			.charge-code{
+				width: 100%;
+				height: 600rpx;
+				transition: transform 1s ease-in-out;
 			}
 		}
 	}

+ 12 - 11
pages/mine/mine.vue

@@ -221,17 +221,18 @@
 			
 			scanCode(){
 				const _this = this;
-				this.jump('/pages/checkstand/index')
-				// uni.scanCode({
-				//     success: function (res) {
-				// 		_this.jump('/pages/checkstand/index')
-				//     },
-				// 	fail: (res) => {
-				// 		if(res.errMsg!='scanCode:fail cancel'){
-				// 			this.scanNotify = {scan: true,scanMessage: res.errMsg};
-				// 		}
-				// 	}
-				// });
+				// this.jump('/pages/checkstand/index')
+				uni.scanCode({
+				    success: function (res) {
+						console.log(res,1236456);
+						_this.jump('/pages/checkstand/index')
+				    },
+					fail: (res) => {
+						if(res.errMsg!='scanCode:fail cancel'){
+							this.scanNotify = {scan: true,scanMessage: res.errMsg};
+						}
+					}
+				});
 			},
 			jump(url,type){
 				if (type==1) {