在微信浏览器里面打开H5网页中执行JS调起支付,

详细信息请参照微信JSAPI支付文档说明:

https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6

注意:WeixinJSBridge内置对象在其他浏览器中无效。

自己写的代码如下:

提示信息,可以换成mitui的提示框

 methods: {goPay() {Indicator.open();console.log(2322222222222222222);console.log(this.orderId);console.log(this.getCookie("WeiId"));console.log(this.id);if ((this.orderId != "undefined") && (this.orderId != "null") && (this.orderId != "")) {var ua = navigator.userAgent.toLowerCase();var isWeixin = ua.indexOf('micromessenger') != -1;if (isWeixin) {console.log("在微信浏览器");//用于支付成功和失败页的参数,5个,localStorage.dingdan_id = this.id;  //订单编号localStorage.orderId = this.orderId; //订单idif (document.cookie.indexOf("WeiId=") != -1) {this.openid = this.getCookie("WeiId");console.log(this.openid);if(!this.openid){this.$router.push({path:'/riverDetail'})}this.axios.post("/tiket/wx/jpi/unifiedOrder?orderNum="+localStorage.dingdan_id + "&openid=" + this.openid + "&tradeType=JSAPI").then(res => {Indicator.close();console.log(res);if (res.data.result == 1) {//调起微信公众号支付WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.value,function (res) {if (res.err_msg == "get_brand_wcpay_request:ok") {// alert("支付成功");function chaxun(){Indicator.open();var xhr = new XMLHttpRequest();//alert("id"+localStorage.id);xhr.open('POST', "/ticet/wx/getesult?orderNum="+localStorage.dingdan_id, true);xhr.onload = function () {Indicator.close();//alert("后台测试是否支付成功");console.log("请求成功");var zhifu = JSON.parse(xhr.responseText);//alert(JSON.stringify(zhifu));if (zhifu.result == 1) {//alert("后台测试支付成功-----");window.location.href = "http://trel.enn.cn/encta-tiet/#/river_payMent_success";} else {//alert("后台测试支付失败-----");window.location.href = "http://trel.enn.cn/encta-tiet/#/river_payMent_error?id="+localStorage.orderId+"&lnum="+localStorage.dingdan_id;}}xhr.send(null);}window.setTimeout(chaxun,2000);}if (res.err_msg == "get_brand_wcpay_request:cancel") {//alert("支付过程中用户取消");window.location.href = "http://trel.enn.cn/encta-tiet/#/river_payMent_error?id="+localStorage.orderId+"&lnum="+localStorage.dingdan_id;}});} else if (res.data.result == 2) {alert("后台无此订单信息");} else if (res.data.result == 3) {alert("订单不处于待支付状态");} else if (res.data.result == 4) {alert("后台报错");}}).catch(() => { });} else {Indicator.close();location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxcdbacc55093a60d0&redirect_uri=http%3A%2F%2Fral.enn.cn%2Feata-ti2FriverDetail&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";}} else {Indicator.close();console.log("不在微信浏览器");alert("请在微信浏览器中支付!")}}},getCookie(c_name) {var that = this;if (document.cookie.length > 0) {//检查这个cookie是否存在,不存在就为 -1var c_start = document.cookie.indexOf(c_name + "=")if (c_start != -1) {//获取cookie值的开始位置c_start = c_start + c_name.length + 1;//通过";"号是否存在来判断结束位置var c_end = document.cookie.indexOf(";", c_start);if (c_end == -1) {c_end = document.cookie.length;}//通过substring()得到了值return unescape(document.cookie.substring(c_start, c_end))}}return null}}

vue 微信公众号的H5支付相关推荐

  1. 微信公众号接入H5支付

    一.概述 1.H5支付是指商户在微信客户端外的移动端网页展示商品或服务,用户在前述页面确认使用微信支付时,商户发起本服务呼起微信客户端进行支付.主要用于触屏版的手机浏览器请求微信支付的场景.可以方便的 ...

  2. vue 微信公众号开发

    vue 微信公众号开发 开题 上个月初入职了一家新公司.来了新公司很忙.本来计划是在上个月底写一篇博客的,写一下关于新公司的事情. 几度思考之后还是没写.也许做程序员接手别人的项目,都会说别人的项目多 ...

  3. 微信公众号:支付宝支付

    微信公众号:支付宝支付 微信公众号:支付宝支付 由于支付宝月微信是两个对立的企业,支付宝想介入微信的充值,微信发现就将其规避,在支付宝与微信博弈的过程中,双方一直是处于你争我赶的地步. 微信公众号接入 ...

  4. (Node+Vue+微信公众号开发)企业级产品全栈开发速成周末班

    (Node+Vue+微信公众号开发)企业级产品全栈开发速成周末班 从零到壹全栈部落 产品:个人独立博客,21点见 Vue + Node + MongoDB支持服务端渲染的博客系统(5天) 开发环境技术 ...

  5. 关于微信公众号调起支付

    vue微信公众号项目中调起微信支付并发起支付的流程 首先在public文件夹下的index.html引入微信JS-SDK <script src="http://res.wx.qq.c ...

  6. vue微信公众号授权开发流程

    vue微信公众号授权开发流程 项目采用的是vue2.0开发的,还未更新到vue3.0.项目描述:只有通过微信授权登录,不需要绑定手机号. 1.注册公众号,这个不多说了 2.配置公众号 在[公众号设置] ...

  7. 微信公众号网页 H5 video 标签自动播放

    目录 微信公众号网页 H5 video 标签自动播放 问题描述 解决方案 微信公众号网页 H5 video 标签自动播放 环境:微信公众号网页 需求:H5 video 标签自动播放视频 video 标 ...

  8. 【UNI-APP】开发微信公众号(H5)JSSDK调式

    UNI-APP 开发微信公众号(H5)JSSDK调试 安装 - NPM安装方式 复制代码npm install jweixin-module --save - 下载使用方式 下载地址:https:// ...

  9. UNI-APP 开发微信公众号(H5)JSSDK的使用、微信扫一扫

    UNI-APP 开发微信公众号(H5)JSSDK的使用.微信扫一扫 自己做了一个h5端调起微信扫一扫的功能,上网一找,没有说得很详细的,依样画葫芦,结果出了很多问题.下面给大家讲一下做的方法,用这个方 ...

最新文章

  1. 微软宣布 Win10 设备数突破8亿,距离10亿还远吗?
  2. CentOS重新加载网卡报错 Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/23
  3. vue.js 默认选中select_vue.js 解决v-model让select默认选中不生效的问题
  4. html 显示代码块,使用Pre在文章中显示代码块 - 文章教程
  5. 详解三种主流分布式事务方案的优劣
  6. docker 发布应用时添加 git revision
  7. click事件在什么时候出发_剖析setTimeout和click点击事件的触发顺序
  8. android uber启动动画,仿 Uber 视频背景登录界面以及登录动画
  9. ASP.NET 控制页和内容页中的事件
  10. J2EE学习辅助工具资料列表及下载3(初学积累中)
  11. LeetCode刷题(36)--Text Justification
  12. Redis 中两种持久化机制详解
  13. 谷歌大脑组合模型霸榜 SuperGLUE
  14. 一起学Hive——总结复制Hive表结构和数据的方法
  15. Debug调试工具使用
  16. 网络服务器管理系统设置实训总结,网络系统管理与维护实训报告.doc
  17. OSI网络七层协议与TCPIP协议
  18. 滴滴程序员年薪80万却被亲戚鄙视:钱多有啥用,我儿子二本大学教师
  19. 在中国搞定粉丝秘笈:如何创造粉丝经济
  20. gazebo可以另存为world

热门文章

  1. 意外之喜-VIM插件之VOoM
  2. 设计模式:工厂方式模式、抽象工厂模式
  3. 《灌篮高手手游》的设计分析
  4. 据说是ORACLE10G的报价,加集群部分,各位确认一下
  5. Bert+BiLSTM+CRF实体抽取
  6. Apache DolphinScheduler——开源大数据调度器神器
  7. Nginx reload和restart区别
  8. [转帖]Photoshop把美女照片转成清爽的矢量图
  9. node连接kafka2.0
  10. VOC Dataset