123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- 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.showModal();
- checkUserAgent();
- vm.code=JSON.parse(localStorage.getItem("wlyyAgent")).uid
- vm.checkType()
- $(".c-ser-input").focus()
- },
- 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.data.cardMoney:0
- vm.cardNo=vm.data.cardNo
- }else{
- vm.surplusMoney=vm.data.cardInpMoney?vm.data.cardInpMoney:0
- vm.cardNo=vm.data.inpCardNo
- }
- }else{
- loading.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
- }
- })
- },
- //去支付
- toPayment:function(){
- var vm=this
- loading.showModal();
- if(vm.payMoney){
- if(judgeWxVersion()){
- vm.getWeixinSign()
- }
- }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 timestamp = 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: timestamp, // 必填,生成签名的时间戳
- nonceStr: noncestr, // 必填,生成签名的随机串
- signature: signature, // 必填,签名,见附录1
- jsApiList: [
- 'chooseWXPay',
- 'checkJsApi'
- ] // 必填,需要使用的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 = {
- patient:vm.data.patient,
- healthNo:vm.cardNo,
- healthType:vm.paytype,
- payAmount:parseFloat(vm.payMoney).toFixed(2),
- spbillCreateIp:returnCitySN["cip"],
- code:getUrlParam("code"),
- openid:JSON.parse(localStorage.getItem("wlyyAgent")).openid
- };
- sendPost("third/hy/pay/createPayOrder", params, "json", "post",function(){
- loading.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
- }, function(res){
- if(res.status == 200) {
- loading.close();
- var data = res.data;
- wx.chooseWXPay({
- appId:data.appId,
- timestamp: data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
- nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
- package: data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
- signType: data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
- paySign: data.sign, // 支付签名
- success: function (res) {
- // 支付成功后的回调函数
- window.location.href='../../payment/html/paymentResult.html?seqNo='+data.seqNo;
- },
- cencel:function(res){
- // 支付取消回调函数
- //alert("支付过程中用户取消");
- },
- fail: function(res){
- // 支付失败回调函数
- var errorparams={seqNo:data.seqNo,wxErrorMsg:res.errMsg}
- sendPost("third/hy/pay/setPayLogWxFail", errorparams, "json", "post",function(){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
- }, function(res){
- window.location.href='../../payment/html/paymentResult.html?seqNo='+data.seqNo;
- })
- }
- });
- }else{
- loading.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- }
- })
- },
- //强制设定最多只能输入两位小数
- checkNumber:function(payMoney){
- var myreg=/^[0][0-9]{1}$/;
- if(myreg.test(payMoney)){
- payMoney="0"
- }
- 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
- {
- if ( wechatInfo[1] < "5.0" ) {
- loading.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'当前微信低于5.0,不支持微信支付,请升级后支付'}).show();
- }else{
- ispass=true
- }
- }
- return ispass
- }
|