zoukankan      html  css  js  c++  java
  • 小程序微信在线支付

    timeStamp string   时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间
    nonceStr string   随机字符串,长度为32个字符以下
    package string   统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=***
    signType string MD5 签名算法,应与后台下单时的值一致
    paySign string   签名,具体见微信支付文档
    success function   接口调用成功的回调函数
    fail function   接口调用失败的回调函数
    complete function   接口调用结束的回调函数(调用成功、失败都会执行)


    //钱包充值 - 钱包充值(在线支付) rechargePurse() { const that = this; var postData = { recharge_no: that.data.recharge_no } let header = getApp().header; let datainfo = requestSign.requestSign(postData); header.sign = datainfo; wx.request({ url: api.get_rechargePurse, data: postData, header: header, method: 'POST', dataType: 'json', responseType: 'text', success: ( res ) => { console.log(res, '钱包充值 - 钱包充值(在线支付)') if (res.data.code >= 0) { wx.requestPayment({ timeStamp: res.data.data.timeStamp, nonceStr: res.data.data.nonceStr, package: res.data.data.package, signType: res.data.data.signType, paySign: res.data.data.paySign, success(res) { console.log(res, 'res'); if (res.errMsg == "requestPayment:ok") { // 调用支付成功 wx.showToast({ title: '调用支付成功', icon: 'none', }) wx.navigateBack({ delta: 1, // 回退前 delta(默认为1) 页面 }) } else if (res.errMsg == 'requestPayment:cancel') { // 用户取消支付的操作 wx.showToast({ title: '请支付', icon: 'none', duration: 2000, }) } }, fail(res) { wx.showToast({ title: '支付失败,请稍后再试', icon: 'none', duration: 2000, }) } }) } else { wx.showToast({ title: res.data.message, icon: 'none' }) that.setData({ disabled: '' }) } }, fail: (res) => {}, }) }
  • 相关阅读:
    43. VUE 脚手架 2 版本 新建项目过程
    42 VUE 脚手架 安装 和 基本使用(创建项目)【命令】
    JDBC 原始缺点分析 和 解决
    39-8 WEBPACK —— 搭建本地服务器
    39-7 WEBPACK — js压缩的Plugin
    14. SpringBoot 更换指定的 日志框架
    39-6 打包html的plugin
    39-5 插件 — 添加版权的Plugin
    【HDU 1027】Ignatius and the Princess II
    【洛谷 1896】互不侵犯_new
  • 原文地址:https://www.cnblogs.com/xiaoxiaoxun/p/14445992.html
Copyright © 2011-2022 走看看