1.隐藏微信网页右上角按钮
< script type= "text/javascript" > document. addEventListener ( 'WeixinJSBridgeReady' , function onBridgeReady ( ) { WeixinJSBridge . call ( 'hideOptionMenu' ) ;
} ) ; document. addEventListener ( 'WeixinJSBridgeReady' , function onBridgeReady ( ) { WeixinJSBridge . call ( 'showOptionMenu' ) ;
} ) ;
< / script>
2.在微信网页中获取用户的网络状态
WeixinJSBridge. invoke ( 'getNetworkType' , { } , function ( e ) { alert ( e. err_msg) ;
} ) ;
3.在微信网页中支付
function onBridgeReady ( orderId, response ) { WeixinJSBridge. invoke ( "getBrandWCPayRequest" , { appId : response. appId, timeStamp : response. timeStamp, nonceStr : response. nonceStr, package : response. packageVal, signType : response. signType, paySign : response. paySign } , function ( res ) { if ( res. err_msg == "get_brand_wcpay_request:ok" ) { $api. pay_order ( orderId) . then ( res => { if ( res. code == 1 ) { state. assistOne = false ; state. assistTwo = false ; $Toast ( { duration : 3000 , message : "支付成功!" } ) ; emit ( "get_brand_wcpay" ) ; } } ) ; } if ( res. err_msg == "get_brand_wcpay_request:cancel" ) { } if ( res. err_msg == "get_brand_wcpay_request:fail" ) { } if ( res. err_msg == "调用支付JSAPI缺少参数:total_fee" ) { } } ) ; } if ( typeof WeixinJSBridge == "undefined" ) { if ( document. addEventListener) { document. addEventListener ( "WeixinJSBridgeReady" , onBridgeReady, false ) ; } else if ( document. attachEvent) { document. attachEvent ( "WeixinJSBridgeReady" , onBridgeReady) ; document. attachEvent ( "onWeixinJSBridgeReady" , onBridgeReady) ; } } else { onBridgeReady ( ) ; }