[视图层使用方法]
视图层:html页面使用方法
~~~
<!DOCTYPE html>
<html class="no-js " lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>微信安全支付</title>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
//调用微信JS api 支付
function jsApiCall()
{
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
<?php echo $jsApiParameters; ?>,
function(res){
//WeixinJSBridge.log(res.err_msg);
//alert(res.err_code + '<=>' + res.err_desc + '<=>' + res.err_msg);
if (res.err_msg == 'get_brand_wcpay_request:ok') {
var order_id = "<?php echo $order_id;?>";
window.location.href = '/order/wx_call_back?order_id=' + order_id;//同步回调地址,即支付完之后,点击页面完成按钮跳转的页面
} else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
}
}
);
}
function callpay()
{
if (typeof WeixinJSBridge == "undefined"){
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', jsApiCall);
document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
}
}else{
jsApiCall();
}
}
</script>
</head>
<body style="padding-bottom: 46px;">
<div class="padding">
<a href="javascript:;" class="weui_btn weui_btn_primary" onclick="callpay()">微信安全支付</a>
</div>
</body>
</html>
~~~