Explorar el Código

支付功能完善

vaecebyZ hace 1 año
padre
commit
54020baf3f
Se han modificado 2 ficheros con 64 adiciones y 0 borrados
  1. 6 0
      pages.json
  2. 58 0
      pay/ortherPay.vue

+ 6 - 0
pages.json

@@ -415,6 +415,12 @@
 					"style": {
 						"navigationBarTitleText": "优惠券"
 					}
+				},
+				{
+					"path": "ortherPay",
+					"style": {
+						"navigationBarTitleText": "支付"
+					}
 				}
 		
 			]

+ 58 - 0
pay/ortherPay.vue

@@ -0,0 +1,58 @@
+<template>
+	<view>
+
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				payData: "",
+			}
+		},
+		onLoad(option) {
+
+			uni.showLoading({
+				title: '支付中'
+			})
+
+			let that = {};
+			that.payData = JSON.parse(option.miniPayquest)
+			if (that.payData == null) return uni.hideLoading()
+			
+			uni.requestPayment({
+				"provider": "wxpay",
+				"orderInfo": that.payData,
+				"appid": "wx3be1d6d84d46cdf7", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
+				"paySign": that.payData.paySign,
+				"nonceStr": that.payData.nonceStr, // 随机字符串
+				"package": that.payData.package, // 固定值
+				// "prepayid":  that.payData.package, // 统一下单订单号 
+				"timeStamp": that.payData.timeStamp, // 时间戳(单位:秒)
+				"signType": that.payData.signType, //签名算法
+				success(msg) {
+					console.log('msg', msg, res);
+					
+					uni.showToast({
+						title: '支付成功!',
+						icon: 'fail'
+					})
+					
+					uni.hideLoading()
+				},
+				fail(e) {
+					console.log('err', e);
+					uni.hideLoading()
+					uni.showToast({
+						title: '取消支付',
+						icon: 'fail'
+					})
+				}
+			})
+		}
+	}
+</script>
+
+<style>
+</style>