Procházet zdrojové kódy

在线缴费-微信支付(未完成)

chenyue před 6 roky
rodič
revize
31e2ac8c03

+ 4 - 0
html/payment/css/payment.css

@ -18,6 +18,10 @@
	padding-left: 35px;
	padding-right: 35px;	
}
.plr30{
	padding-left: 30px;
	padding-right: 30px;	
}
.p30{
	padding: 30px;
}

+ 10 - 5
html/payment/html/payment.html

@ -13,6 +13,7 @@
		<link rel="shortcut icon" href="../../../favicon.ico">
		<link rel="stylesheet" type="text/css" href="../../../css/cross.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/cross.ui.css" />
		<link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
		<link rel="stylesheet" href="../css/payment.css" />		
	</head>
@ -20,9 +21,9 @@
		<div id="app" v-cloak>
			<div class="bgc-fff c-f14 plr15 mt10">
				<div class="c-border-b  ptb10">
					<span class="c-333333">DC1326898&nbsp;(张峰)&nbsp;</span>
					<span class="c-4dcd70">默认</span>
					<span class="c-999" style="float: right;">余额:<span class="c-ff9526">¥&nbsp;3.06元</span></span>						
					<span class="c-333333">{{cardNo}}&nbsp;({{data.name}})&nbsp;</span>
					<span v-if="data.isDefault==1" class="c-4dcd70">默认</span>
					<span class="c-999" style="float: right;">余额:<span class="c-ff9526">¥&nbsp;{{surplusMoney}}元</span></span>						
				</div>	
				<div class="c-999 mt7">
					<img src="../images/feiyong_icon.png" width="17" style="margin-right: 10px;"/><span class="c-f14" style="position: relative;top: -3px;">预交金额</span>
@ -30,18 +31,22 @@
				<div class="mt10 pb10">
					<span class="c-333 c-f25" style="position: absolute;line-height: 30px;">¥</span>					
					<span style="position: absolute;right: 15px;margin-top: 5px;"><img src="../images/shanchu_shuru_icon.png" width="20" height="20"/></span>
					<input type="number" class="c-ser-input plr30" style="color: #333333;font-size: 25px;width: initial;"/>
					<input type="number" v-model="payMoney" class="c-ser-input plr30" style="color: #333333;font-size: 25px;width: initial;" @input="checkNumber(payMoney)"/>
				</div>
				<div class="c-ff5e6c pt10 pb15">
					提示:公众号推送充值结果,可查询缴费记录
				</div>
			</div>
			<div class="p30">
				<button type="button" class="c-btn-4dcd70 c-btn-arc c-btn-full  c-btn-big" style="height: 45px;">微信支付</button>
				<button type="button" class="c-btn-4dcd70 c-btn-arc c-btn-full  c-btn-big" style="height: 45px;"  @click="toPayment()">微信支付</button>
			</div>	
		</div>
		<script src="../../../js/post.js"></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
		<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
		<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
		<script src="../../../widget/artDialog/6.0.5/js/dialog-plus.js"></script>
		<script src="../js/payment.js"></script>
	</body>

+ 39 - 25
html/payment/js/bindingCard.js

@ -1,12 +1,9 @@
var loading = dialog({
	contentType: 'load',
	skin: 'bk-popup'
});
var checktype=false;
(function() {
	new Vue({
		el: "#app",
		data: {
			code:JSON.parse(localStorage.getItem("wlyyAgent")).uid,
		data: {			
			code:"",
			cardNo:"",
			initdata:{
				name:"",
@ -18,35 +15,52 @@ var loading = dialog({
		mounted: function() {
			var vm = this
			checkUserAgent();
			vm.code=JSON.parse(localStorage.getItem("wlyyAgent")).uid
			vm.data=vm.initdata
		},
		methods: {
			//校验就诊卡
			getData:function(){
				var vm=this
				sendPost("patient/card/validByCard", {cardNo:vm.cardNo}, "json", "get",function(){
				 	loading.close();
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
			        vm.setInit()
			       }, function(res){
			   		loading.close();
			        if(res.status == 200){ 
			        	if(res.data.code==0){			        		
			        		vm.data=res.data
			        		vm.btnshow=true
			        	}else{
			        		 dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.data.message}).show();
			        		 vm.setInit()
			        	}			        	
			        }else{
			            dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
			        	vm.setInit()
			        }
			    })
				if(vm.cardNo){					
					var loading = dialog({
						contentType: 'load',
						skin: 'bk-popup',
						content:'校验中...'
					});
					loading.show();
					sendPost("patient/card/validByCard", {cardNo:vm.cardNo}, "json", "get",function(){
					 	loading.close();
				    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
				        vm.setInit()
				       }, function(res){
				   		loading.close();
				        if(res.status == 200){ 
				        	if(res.data.code==0){			        		
				        		vm.data=res.data
				        		vm.btnshow=true
				        	}else{
				        		 dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.data.message}).show();
				        		 vm.setInit()
				        	}			        	
				        }else{
				            dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
				        	vm.setInit()
				        }
				    })
				}else{
					dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请填写就诊卡号'}).show();
				}
			},
			//添加就诊卡
			addCard:function(){
				var vm = this
				var loading = dialog({
					contentType: 'load',
					skin: 'bk-popup',
					content:'绑定中...'
				});
				loading.show();
				sendPost("patient/card/bindCard", {cardNo:vm.cardNo,patient:vm.code}, "json", "post",function(){
				 	loading.close();
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();

+ 3 - 2
html/payment/js/changeCards.js

@ -4,11 +4,12 @@ var checktype=false;
		el: "#app",
		data: {
			dataList:[],
			code:JSON.parse(localStorage.getItem("wlyyAgent")).uid,
			code:"",
		},
		mounted:function(){
			var vm = this
			checkUserAgent();
			vm.code=JSON.parse(localStorage.getItem("wlyyAgent")).uid
			vm.checkType()
		},
		methods: {
@ -55,7 +56,7 @@ var checktype=false;
						clearInterval(timer);
						vm.getData()
					}
				},100);
				},10);
			},
		},
	})

+ 6 - 4
html/payment/js/patientIDCards-pay.js

@ -1,15 +1,15 @@
var Request = GetRequest(); 
var checktype=false;
(function() {
	new Vue({
		el: "#app",
		data: {
			dataList:[],
			cardId:Request.id,
			code:JSON.parse(localStorage.getItem("wlyyAgent")).uid,
			code:"",
			data:{
		        "id": "",
		        "patient": JSON.parse(localStorage.getItem("wlyyAgent")).uid,
		        "patient": "",
		        "hisId": "",
		        "cardNo": "",
		        "name": "",
@ -27,6 +27,7 @@ var Request = GetRequest();
		mounted:function(){
			var vm = this
			checkUserAgent();
			vm.code=JSON.parse(localStorage.getItem("wlyyAgent")).uid
			vm.checkType()
		},
		methods: {
@ -37,6 +38,7 @@ var Request = GetRequest();
					contentType: 'load',
					skin: 'bk-popup'
				});
				loading.show();
				 sendPost("patient/card/getCardInfo", {id:vm.cardId}, "json", "get",function(){
				 	loading.close();
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
@ -103,7 +105,7 @@ var Request = GetRequest();
						clearInterval(timer);
						vm.getData()
					}
				},100);
				},10);
			},
		},
	})

+ 4 - 2
html/payment/js/patientIDCards.js

@ -6,12 +6,13 @@ var checktype=false;
			dataList:[],
			BtnClass:"p-fix-bottom-0",
			length:0,
			code:JSON.parse(localStorage.getItem("wlyyAgent")).uid,
			code:"",
			surplus:5,
		},
		mounted:function(){
			var vm = this
			checkUserAgent();
			vm.code=JSON.parse(localStorage.getItem("wlyyAgent")).uid
			vm.checkType()
		},
		methods: {
@ -22,6 +23,7 @@ var checktype=false;
					contentType: 'load',
					skin: 'bk-popup'
				});
				loading.show();
				 sendPost("patient/card/getCardList", {patient:vm.code}, "json", "get",function(){
				 	loading.close();
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
@ -82,7 +84,7 @@ var checktype=false;
						clearInterval(timer);
						vm.getData()
					}
				},100);
				},10);
			},
		},
	})

+ 187 - 2
html/payment/js/payment.js

@ -1,15 +1,200 @@
var Request = GetRequest();
var checktype=false;
var loading = dialog({
	contentType: 'load',
	skin: 'bk-popup'
});
(function() {
	new Vue({
		el: "#app",
		data: {
			dataList:[],
			cardId:Request.id,			
			payMoney:"",
			cardNo:"",
			paytype:Request.paytype, //paytype 1为门诊缴费  2为住院缴费
			surplusMoney:"",
			data:{},
			code:"",
		},
		mounted: function() {
			var vm = this
			loading.show();
			checkUserAgent();
			vm.code=JSON.parse(localStorage.getItem("wlyyAgent")).uid
			vm.checkType()
		},
		methods: {
			
			//获取列表数据
			getData:function(){
				 var vm=this
				 sendPost("patient/card/getCardInfo", {id:vm.cardId}, "json", "get",function(){
				 	loading.close();
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
			      }, function(res){
			        if(res.status == 200){ 
				 	    loading.close();
			        	vm.data=res.data 
			        	if(vm.paytype=="1"){
			        		vm.surplusMoney=vm.data.cardMoney
			        		vm.cardNo=vm.data.cardNo
			        	}else{
			        		vm.surplusMoney=vm.data.cardInpMoney
			        		vm.cardNo=vm.data.inpCardNo
			        	}
			        }else{
				 	  loading.close();
			          dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
			        }
			    })
			},
			//去支付
			toPayment:function(){
				var vm=this
				loading.show();
				if(vm.payMoney){					
//					if(judgeWxVersion()){
//						vm.getWeixinSign()
//					}
					vm.wxReady()
				}else{
				 	 loading.close();
					 dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请输入充值金额'}).show();
				}
			},
			//获得微信sdk信息
			getWeixinSign:function() {
				var vm=this
				var params = {};
    			params.pageUrl = window.location.href;
    			sendPost("weixin/getSign", params, "json", "post",function(){
				 	loading.close();
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
			      }, function(res){
			        if(res.status == 200) {	
						var t = res.data.timestamp;
						var noncestr = res.data.noncestr;
						var signature = res.data.signature;
						wx.config({
							//debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
							appId: appId, // 必填,公众号的唯一标识
							timestamp: t, // 必填,生成签名的时间戳
							nonceStr: noncestr, // 必填,生成签名的随机串
							signature: signature, // 必填,签名,见附录1
							jsApiList: [
								'chooseWXPay',
							] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
						});
						wx.ready(function(){					
							vm.wxReady()
						})
					}else{
				 		loading.close();
			            dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
			        }
			    })
			},			
			wxReady:function(){
				var vm=this
				var params = {
					patientName:vm.data.name,
					healthNo:vm.cardNo,
					healthType:vm.paytype,
					payAmount:parseFloat(vm.payMoney).toFixed(2),
					spbillCreateIp:returnCitySN["cip"],
					code:getUrlParam("code"),
				};
				sendPost("/hy/pay/createPayOrder", params, "json", "post",function(){
			    	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
			      }, function(res){
			        if(res.status == 200) {			        	
				 		loading.close();
						var t = res.data.timestamp;
						var noncestr = res.data.noncestr;
						var package ="prepay_id="+res.data.prepayid;
						var paySign = res.data.paySign;							
						wx.chooseWXPay({
						    timestamp: t, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
						    nonceStr: noncestr, // 支付签名随机串,不长于 32 位
						    package: package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
						    signType: 'MD5', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
						    paySign: paySign, // 支付签名
						    success: function (res) {
						        // 支付成功后的回调函数
						        window.location.href='../../payment/html/paymentResult.html';
						    },error:function(res){
						    	window.location.href='../../payment/html/paymentResult.html';
						    }
						});
					}else{		        	
				 		loading.close();
			            dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
			        }
			    })
			},
			//强制设定最多只能输入两位小数
			checkNumber:function(payMoney){
		        this.payMoney= (payMoney.match(/^\d*(\.?\d{0,2})/g)[0]) || null                  
		    },
			//判断是否验证登录通过
			checkType:function(){
				var vm=this
				var timer = setInterval(function(){
					if(checktype){
						clearInterval(timer);
						vm.getData()
					}
				},10);
			},
		},
	})
})()
})()
function queryInit(){
	checktype=true
}
function getUrlParam(name){
    //构造一个含有目标参数的正则表达式对象
    var reg = new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
    //匹配目标参数
    var r = window.location.search.substr(1).match(reg);
    //返回参数值
    if (r!=null) return unescape(r[2]); return null;
} 
//判断微信版本号
function judgeWxVersion(name){
   var ispass=false
	var wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i)
	if(!wechatInfo) {
		loading.close();
		 dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'当前不是微信,不支持微信支付'}).show();
	}				 
	else
	 {  
	 	wx.checkJsApi({
		    jsApiList: ['chooseWXPay'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
		    success: function(res) {
		    	if("errMsg"=="checkJsApi:ok"){					    		
			    	if(res.checkResult.chooseWXPay){
			    		ispass=true
			    	}else{
				 	    loading.close();
			    		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'当前微信低于5.0,不支持微信支付,请升级后支付'}).show();
			    	}
		    	}else{
		    		if ( wechatInfo[1] < "5.0" ) { 
				 	    loading.close();
		    			dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'当前微信低于5.0,不支持微信支付,请升级后支付'}).show(); 
		    		}else{
		    			ispass=true
		    		}
		    	}
		    }
		});				 	
	 }
	 return ispass
}