PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > HBuilderX教程 > 正文

    uniapp微信支付

    作者:admin来源:网络浏览:时间:2021-01-19 13:12:29我要评论
    导读:uniapp微信支付
    uniapp微信支付

    1. buy(address,orderid){ 
    2.                 if(!this.a_id){ 
    3.                     this.util.showLoading("请选择地址"); 
    4.                     return 
    5.                 } 
    6.               //微信支付 
    7.                 uni.getProvider({ 
    8.                     service: 'payment'
    9.                     success: res=>{ 
    10.                         if (~res.provider.indexOf('wxpay')) { //先判断用户是否有微信支付环境(是否安装了微信app) 
    11.                             uni.showLoading({title: '正在调起微信支付'}) 
    12.                             let params={ 
    13.                                 o_id:orderid, 
    14.                                 a_id:address, 
    15.                             } 
    16.                             this.http.post("Wxpay/pay",params).then((res)=>{ 
    17.                                 let resobj=res.data.data 
    18.                                 let pages = getCurrentPages(); // 当前页面 
    19.                                 let beforePage = pages[pages.length - 2]; // 前一个页面 
    20.                                 uni.requestPayment({ 
    21.                                     provider: 'wxpay'
    22.                                     appid: resobj.appId, 
    23.                                     package:resobj.package
    24.                                     nonceStr: resobj.nonceStr, 
    25.                                     timeStamp: resobj.timeStamp, 
    26.                                     paySign: resobj.paySign, 
    27.                                     signType:resobj.signType, 
    28.                                     success: res=>{ 
    29.                                         uni.hideLoading(); 
    30.                                         uni.showToast({title: '支付成功',icon:'none'}) 
    31.                                         this.detail(this.type) 
    32.                                         uni.navigateBack({ 
    33.                                             success: function() { 
    34.                                                       beforePage.onLoad(); // 执行前一个页面的onLoad方法 
    35.                                             } 
    36.                                         }) 
    37.                                     }, 
    38.                                     fail:err=>{ 
    39.                                         uni.hideLoading(); 
    40.                                         uni.showToast({title: '支付失败,请稍后再试',icon:'none'}) 
    41.                                     } 
    42.                                 }); 
    43.                             }) 
    44.                                 // uni.hideLoading(); 
    45.                                 // uni.showToast({title: '服务器开小差了呢,请您稍后再试',icon:'none'}) 
    46.   
    47.                         }else
    48.                             uni.showToast({title: '获取微信通道失败,请检查您的微信是否正常启用',icon:'none'}) 
    49.                         } 
    50.                     } 
    51.                 }); 
    52.   
    53.             }, 

     

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-146-6486-1.html
    相关热词搜索: uniapp微信支付