uni-app APP支付 uni.requestPayment APP微信支付

滑令
2023-12-01

JS部分代码

zhifu(){
//APP支付
// #ifdef APP-PLUS
	uni.showLoading({title: '加载中',})
	uni.request({
	  url: getApp().globalData.https + '/wap.php/Order/pay_course_order',//支付订单接口链接
	  data: {
		oid:data.oid,//订单号
	  },
	  method: 'POST',
	  header: getApp().globalData.header,
	  dataType: 'json',  
	  success: function (res) {
		var data = res.data;
		if(data.status == 1){
			uni.requestPayment({
				provider: 'wxpay',//微信支付
				orderInfo: {
					"appid": data.data.appid,
					"noncestr": data.data.noncestr,
					"package": "Sign=WXPay",
					"partnerid": data.data.partnerid,
					"prepayid": data.data.prepayid,
					"timestamp": data.data.timestamp,
					"sign": data.data.sign
				},
				success: function (res) {
					setTimeout(function () {uni.hideLoading();}, 100);
					uni.showLoading({
					  title: '跳转中',
					})
					setTimeout(() => {
					 	uni.redirectTo({
					 	    url: '/pages/user/order_list'
					 	});
					}, 1000);
				},
				fail: function (err) {
					uni.redirectTo({
					    url: '/pages/user/order_list?'
					});
				},
			})
		}
		if(data.status == 0){
			uni.showToast({
				title: data.msg,
				icon: "none"
			});
			return false;
		}
	  }
	})
	// #endif
}

八七站长
http://www.19870125.xyz/

 类似资料: