1. this.payType==0就是微信支付  支付宝支付代码就不贴了

paysubmit(){if(this.payType==0){//便于维护 单独写// #ifdef H5 if(this.is_weixn()){this.inWxWebPay(); //  this.wxMpPay();}else{this.wxWebPay();}// #endif// #ifdef APP-PLUSthis.wxAppPay();// #endif// #ifdef MP-WEIXINthis.wxMpPay();// #endif}else{this.zfbPay();}
},
/*** @Description: H5微信支付* @author: ZXL* @createTime: 2022-6-10 8:51:18* @Copyright by 蓝创科技有限公司*/async wxWebPay(){uni.showLoading({title:'请稍等...'})let _this=this;let payInfo = {token: _this.token,duesWaterId: _this.duesWaterId,money: _this.shouldPay,type: 3,count: 1,}let res = await _this.request.post("/dues/setOrderWx", payInfo)uni.hideLoading()if(res.code==1){// #ifdef APP-PLUSplus.runtime.openURL(res.map2.mweb_url);// #endif// #ifdef H5window.location.href=res.map2.mweb_url// #endif}},
/*** @Description: 微信小程序支付* @author: ZXL* @createTime: 2022-6-10 11:05:26* @Copyright by 蓝创科技有限公司
*/
async wxMpPay(){uni.showLoading({title:'请稍等...'})let _this=this;let payInfo = {token: _this.token,duesWaterId: _this.duesWaterId,money: _this.shouldPay,type: 4,count: 1,}let res = await _this.request.post("/dues/setOrderWx", payInfo)uni.hideLoading()if(res.code==1){let payInfoDetail = res.mapuni.requestPayment({provider: 'wxpay',timeStamp: res.map2.xcxtimeStamp,nonceStr: res.map2.xcxnonceStr,package: res.map2.xcxpackage,signType: res.map2.signType,paySign: res.map2.xcxpaySign,success: function (res) {_this.$set(_this.dfPayList[_this.payIndex],'payFlag',1)_this.$set(_this.dfPayList[_this.payIndex],'isNormal','已缴费')uni.showToast({title:'支付成功',icon:'success'})},fail: function (err) {uni.showToast({title:'支付失败',icon:'error'})}});}else{uni.showToast({title:res.mag,icon:'none'})}
},
/*** @Description: APP微信支付* @author: ZXL* @createTime: 2022-4-16 1:56:56 * @Copyright by 蓝创科技有限公司
*/
async wxAppPay(){uni.showLoading({title:'请稍等...'})let _this=this;let payInfo = {token: _this.token,duesWaterId: _this.duesWaterId,money: _this.shouldPay,type: 2,count: 1,}let res = await _this.request.post("/dues/setOrderWx", payInfo)uni.hideLoading()if(res.code==1){ let payInfoDetail = res.maplet payorderInfo =  { appid: payInfoDetail.appid,noncestr: payInfoDetail.noncestr,package: 'Sign=WXPay',partnerid: '1534302791',prepayid: payInfoDetail.prepayid,timestamp: payInfoDetail.timestamp,sign: payInfoDetail.sign,}uni.requestPayment({provider: "wxpay",orderInfo: JSON.stringify( payorderInfo ),async success( pays ) {_this.$set(_this.dfPayList[_this.payIndex],'payFlag',1)_this.$set(_this.dfPayList[_this.payIndex],'isNormal','已缴费')uni.showToast({title:'支付成功',icon:'success'})},fail( error ) {uni.showToast({title:'支付失败',icon:'error'})}})}else{uni.showToast({title:res.mag,icon:'none'})}
},

下面是微信内置浏览器支付

安装npm install jweixin-module --save

##判断是否是微信内置浏览器
is_weixin(){var ua = navigator.userAgent.toLowerCase();if(ua.match(/MicroMessenger/i)=='micromessenger') {return true;} else {return false;}
},
onLoad() {this.code=this.getUrlCode().codeif(this.is_weixin()&&this.getUrlCode().code){ //判断是否是微信内置浏览器和code是否为空  然后取openidthis.getopenId(this.getUrlCode().code);}if (this.is_weixin()&&!this.wxAuthopenId&&!this.getUrlCode().code) {window.location.href ='https://open.weixin.qq.com/connect/oauth2/authorize?appid=”你自己appid“&redirect_uri='+this.reqUrl+'/h5&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect';}
},
getUrlCode() { // 截取url中的code方法var url = location.searchthis.winUrl = urlvar theRequest = new Object()if (url.indexOf("?") != -1) {var str = url.substr(1)var strs = str.split("&")for(var i = 0; i < strs.length; i ++) {theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1])}}return theRequest
},
async getopenId(codes){let res = await this.request.post("/pro/Wx/WxInformation",{code:codes})if(res.code==1){this.res=JSON.stringify(res)uni.setStorageSync('wxAuthopenId', res.openId);this.setWxAuthopenId(uni.getStorageSync('wxAuthopenId'))}
},

然后就是

var jweixin = require('jweixin-module');async gopay(){let datas={duesWaterId:1,money:0.01, token:this.token,count:1,type:4,openId:this.wxAuthopenId}let res = await this.request.post("/pro/dues/setOrderWx",datas)this.resmsg=JSON.stringify(res)if(res.code==1){this.paysign(res)} },paysign(res){ jweixin.config({debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。appId: res.mapConfig.appId, // 必填,公众号的唯一标识timestamp: res.mapConfig.timestamp, // 必填,生成签名的时间戳nonceStr: res.mapConfig.noncestr, // 必填,生成签名的随机串signature: res.mapConfig.signature, // 必填,签名jsApiList: ['chooseWXPay'], });jweixin.ready(function() {jweixin.checkJsApi({jsApiList: ['chooseWXPay'], // 需要检测的JS接⼝列表,所有JS接⼝列表见附录2,success: function(res) {},fail:function(res) {}});jweixin.chooseWXPay({appId: res.map2.xcxappId,timestamp: res.map2.xcxtimeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符nonceStr: res.map2.xcxnonceStr, // 支付签名随机串,不长于 32package: res.map2.xcxpackage, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)signType: res.map2.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'paySign: res.map2.xcxpaySign, // 支付签名success: function(res) {uni.showToast({title: "付款成功!",duration: 1000})},cancel: function(res) {uni.showToast({title: "付款失败!",duration: 1000})},fail: function(res) {uni.showToast({title: "付款失败!",duration: 1000})}});})},

uni-app微信支付相关推荐

  1. java+uniapp对接app微信支付

    java+uniapp对接app微信支付 1.准备工作 注册app APP接入微信支付,需要先将商户APP在微信开放平台进行注册,登记APP开发参数以生成APPID.具体操作步骤如下: 一.登录微信开 ...

  2. IOS --app微信支付

    2019独角兽企业重金招聘Python工程师标准>>> 微信支付分为好几种,这里记录的是app微信支付流程. 适用场景 用户使用xxAPP时,需要通过微信支付完成某项报名.此时xxA ...

  3. APP微信支付报错《商户号该产品权限未开通,请前往商户平台产品中心检查后重试》

    App微信支付调官方的统一下单接口返回错误信息 {return_msg=商户号该产品权限未开通,请前往商户平台>产品中心检查后重试, return_code=FAIL} 微信开放平台,微信认证申 ...

  4. php android 微信支付,Android_Android实现微信支付功能,开发Android APP微信支付功能, - phpStudy...

    Android实现微信支付功能 开发Android APP微信支付功能,需要完成三个步骤:第一步生成预支付订单.第二步生成微信支付参数.第三步调起微信APP支付.除了需要审核通过的APP应用外,还需要 ...

  5. Android支付宝错误码62009,hb混合开发app 微信支付提示支付宝62009未知错误

    问题描述 hb混合开发app 微信支付提示支付宝62009未知错误 问题出现的环境背景及自己尝试过哪些方法 真机模拟测试 相关代码 获取通道 mounted(){ plus.payment.getCh ...

  6. app微信支付后端接口编写

    刚做完app微信支付,我这块主要负责的是后端,现在我将我怎么开发的以及踩过的坑给大家写出来 微信支付主要有3步, 第一步:是生成一个预付订单 第二步:第二次签名的信息传到app端 第三步:最后接受到微 ...

  7. 微信h5支付 php sdk_微信支付V3版,H5,APP微信支付PHP服务端使用方式

    使用步骤: 1.导入下载好的微信V3版本SDK public function __construct() { parent::__construct(); //引入微信支付 Vendor('Wxpa ...

  8. app微信支付-java服务端接口 支付/查询/退款

    app微信支付-java服务端接口 支付-查询-退款 个人看微信的文档,看了很多前辈的写法,终于调通了,在这里做一下记录. 首先来定义各种处理类(微信支付不需要特殊jar包,很多处理需要自己封装,当然 ...

  9. 微信回调 java_详解APP微信支付(java后台_统一下单和回调)

    1.微信配置信息 global.properties 2.方法wxpay用于生成预支付订单信息 方法notifyWeiXinPay用于微信支付成功后的回调, 注意: 在手机端使用微信支付成功后,微信服 ...

  10. uniapp支付之APP微信支付unicloud版(附源码)

    1 先上效果图 为啥要用 unicloud ? 不用搭建自己的服务器,不用买域名,不用备案域名,不用支持https.只需要一个简单的云函数,就可以轻松的实现微信支付功能 问:服务端语言是什么,有框架限 ...

最新文章

  1. html两个性别按钮并排,css实现男女切换按钮
  2. 人民日报:人工智能,务实发展是正道
  3. java课程 数独 文库_数独java
  4. mysql进度查看_MySQL长查询进度监控
  5. android广告sdk破例,ADT bundle和Android SDK是什么?(能否说的通俗一些,谢谢)
  6. 双一流大学毕业的我,应该何去何从?
  7. vscode怎样导入数据_【Python开发】用VSCode+Jupyter notebook 编写 Python
  8. Android安卓进程保活(二)
  9. 组织架构递归_映射架构和递归管理数据–第1部分
  10. python 面向对象_Python 和 Java 基础对比 08 —— 面向对象
  11. 如何使用ExpressBurn Plus mac版刻录数据CD
  12. Python 爬虫的工具列表大全
  13. StringIndexOutOfBoundsException
  14. 掌握一门计算机语言需要多长时间,学习一门语言需要多长时间?科学告诉你
  15. win10系统:虚拟桌面的创建、切换、删除快捷键
  16. C语言程序设计精髓(MOOC第12周 )题
  17. 荒野行动pc版服务器无响应,荒野行动PC版闪退怎么办 电脑版闪退解决方法
  18. 阿里云-云开发平台入门篇——静态网站的全生命周期实战
  19. CGB2108day17
  20. ESD静电二极管|静电保护器件

热门文章

  1. 张宏系列又双叒叕售罄了
  2. BZOJ 3926: [Zjoi2015]诸神眷顾的幻想乡
  3. 湖人VS火箭 continue....
  4. 无电子设备的课堂也可拥有完美反馈—Plickers+OneNote教学模式探索
  5. BitShares 2.0 多节点私链部署
  6. 分享10款小白也能做起来的平衡车设计资料
  7. 量化交易准备资料-短线策略
  8. 【vue设计与实现】快速Diff算法 1
  9. aac转化为mp3格式的三种详细步骤
  10. Maven将有依赖其它jar包的项目打包成jar包(路径依赖),一步到位。