|
@ -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
|
|
|
}
|