wangguoyu 4 ay önce
ebeveyn
işleme
17730557d5
1 değiştirilmiş dosya ile 177 ekleme ve 164 silme
  1. 177 164
      pages/pay/svip.vue

+ 177 - 164
pages/pay/svip.vue

@@ -136,8 +136,8 @@
 			orderId.value = ''
 		}
 	})
-	
-	function hyfyClick(){
+
+	function hyfyClick() {
 		agreeType.value = 'hyfwxy'
 		agreeContentDialogRef.value.handleShow();
 	}
@@ -340,6 +340,151 @@
 	}
 
 
+	function wxPay() {
+		orderPayWx({
+			id: orderId.value
+		}).then(res2 => {
+			uni.hideLoading();
+			console.log('res2', res2);
+			uni.requestPayment({
+				"provider": "wxpay",
+				"orderInfo": {
+					"appid": res2.data.appid, // 应用ID(AppID)
+					"partnerid": res2.data.partnerId, // 商户号(PartnerID)
+					"prepayid": res2.data.prepayId, // 预支付交易会话ID
+					"package": res2.data.packageVal, // 固定值
+					"noncestr": res2.data.nonceStr, // 随机字符串
+					"timestamp": res2.data.timestamp, // 时间戳(单位:秒)
+					"sign": res2.data.sign // 签名,这里用的 MD5 签名
+				}, //此处为服务器返回的订单信息字符串
+				success: function(res) {
+
+					//var rawdata = JSON.parse(res.rawdata);
+					//	console.log('res',res);	
+					//	console.log('支付成功');
+					//	console.log('rawdata', rawdata);
+					uni.showLoading({
+						title: '会员开通中,请稍后...'
+					});
+					orderCheck({
+						id: orderId.value
+					}).then(res3 => {
+						console.log('res3', res3);
+						if (res3.code == 0 && res3.data) {
+
+							genggaiVip()
+						} else {
+							setTimeout(() => {
+								orderCheck({
+									id: orderId.value
+								}).then(res4 => {
+									if (res4.code ==
+										0 && res4
+										.data) {
+										genggaiVip()
+									} else {
+										toast(
+											"开通失败,请联系管理员!"
+										)
+										uni
+											.hideLoading();
+										return false
+									}
+								}).catch(() => {
+									uni.hideLoading();
+									toast("check接口报错")
+									return false
+								})
+							}, 5000)
+						}
+					}).catch(() => {
+						uni.hideLoading();
+						toast("check接口报错")
+						return false
+					})
+
+				},
+				fail: function(err) {
+					uni.hideLoading();
+					//  toast('支付失败:' + JSON.stringify(err));
+					console.log('支付失败:' + JSON.stringify(err));
+				}
+			});
+		}).catch((error) => {
+			uni.hideLoading();
+			disabled.value = false
+
+			console.log(error);
+		})
+	}
+	function aliApy(){
+		orderPayAli({
+			id: orderId.value
+		}).then(res2 => {
+			console.log('res2', res2);
+			uni.hideLoading();
+			uni.requestPayment({
+				"provider": "alipay",
+				"orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
+				success: function(res) {
+					// var rawdata = JSON.parse(res.rawdata);
+					// console.log('支付成功');
+					// console.log('rawdata', rawdata);
+		
+					uni.showLoading({
+						title: '会员开通中,请稍后...'
+					});
+					orderCheck({
+						id: orderId.value
+					}).then(res3 => {
+						if (res3.code == 0 && res3.data) {
+							genggaiVip()
+						} else {
+							setTimeout(() => {
+								orderCheck({
+									id: orderId.value
+								}).then(res4 => {
+									if (res4.code ==
+										0 && res4
+										.data) {
+										genggaiVip()
+									} else {
+										disabled
+											.value =
+											false
+										toast(
+											"开通失败,请联系管理员!"
+										)
+										uni
+											.hideLoading();
+										return false
+									}
+								}).catch(() => {
+									disabled.value =
+										false
+									uni.hideLoading();
+									toast("check接口报错")
+									return false
+								})
+							}, 5000)
+						}
+					}).catch(() => {
+						disabled.value = false
+						uni.hideLoading();
+						toast("check接口报错")
+						return false
+					})
+				},
+				fail: function(err) {
+					disabled.value = false
+					//  toast('支付失败:' + JSON.stringify(err));
+					console.log('支付失败:' + JSON.stringify(err));
+					uni.hideLoading();
+				}
+			});
+		})
+	}
+
 	const creatOrder = debounce((data) => {
 
 		console.log('123123123123');
@@ -350,175 +495,43 @@
 			mask: true
 		});
 		if (payType.value == 'weixin') {
-			let req = {
-				cardId: cardId.value
-			}
 			console.log('创建订单11');
-			orderAdd(req).then(res => {
-				console.log('res', res);
-				console.log(' res.data.id', res.data.id);
-				orderId.value = res.data.id
-				orderPayWx({
-					id: res.data.id
-				}).then(res2 => {
-					uni.hideLoading();
-					console.log('res2', res2);
-					uni.requestPayment({
-						"provider": "wxpay",
-						"orderInfo": {
-							"appid": res2.data.appid, // 应用ID(AppID)
-							"partnerid": res2.data.partnerId, // 商户号(PartnerID)
-							"prepayid": res2.data.prepayId, // 预支付交易会话ID
-							"package": res2.data.packageVal, // 固定值
-							"noncestr": res2.data.nonceStr, // 随机字符串
-							"timestamp": res2.data.timestamp, // 时间戳(单位:秒)
-							"sign": res2.data.sign // 签名,这里用的 MD5 签名
-						}, //此处为服务器返回的订单信息字符串
-						success: function(res) {
-
-							//var rawdata = JSON.parse(res.rawdata);
-							//	console.log('res',res);	
-							//	console.log('支付成功');
-							//	console.log('rawdata', rawdata);
-							uni.showLoading({
-								title: '会员开通中,请稍后...'
-							});
-							orderCheck({
-								id: orderId.value
-							}).then(res3 => {
-								console.log('res3', res3);
-								if (res3.code == 0 && res3.data) {
-
-									genggaiVip()
-								} else {
-									setTimeout(() => {
-										orderCheck({
-											id: orderId.value
-										}).then(res4 => {
-											if (res4.code ==
-												0 && res4
-												.data) {
-												genggaiVip()
-											} else {
-												toast(
-													"开通失败,请联系管理员!"
-												)
-												uni
-													.hideLoading();
-												return false
-											}
-										}).catch(() => {
-											uni.hideLoading();
-											toast("check接口报错")
-											return false
-										})
-									}, 5000)
-								}
-							}).catch(() => {
-								uni.hideLoading();
-								toast("check接口报错")
-								return false
-							})
-
-						},
-						fail: function(err) {
-							uni.hideLoading();
-							//  toast('支付失败:' + JSON.stringify(err));
-							console.log('支付失败:' + JSON.stringify(err));
-						}
-					});
-				}).catch((error) => {
+			if (orderId.value) {
+				wxPay()
+			} else {
+				let req = {
+					cardId: cardId.value
+				}
+				orderAdd(req).then(res => {
+					console.log('res', res);
+					console.log(' res.data.id', res.data.id);
+					orderId.value = res.data.id
+					wxPay()
+				}).catch((err) => {
 					uni.hideLoading();
 					disabled.value = false
-
-					console.log(error);
+					toast("订单创建失败")
+					return false
 				})
-
-
-			}).catch((err) => {
-				uni.hideLoading();
-				disabled.value = false
-				toast("订单创建失败")
-				return false
-			})
-		} else {
-			let req = {
-				cardId: cardId.value
 			}
-			orderAdd(req).then(res => {
-				console.log('res', res);
-				orderId.value = res.data.id
-				orderPayAli({
-					id: res.data.id
-				}).then(res2 => {
-					console.log('res2', res2);
+		} else {
+			if(orderId.value){
+					aliApy()
+			}else{
+				let req = {
+					cardId: cardId.value
+				}
+				orderAdd(req).then(res => {
+					console.log('res', res);
+					orderId.value = res.data.id
+					aliApy()
+				}).catch((err) => {
+					disabled.value = false
 					uni.hideLoading();
-					uni.requestPayment({
-						"provider": "alipay",
-						"orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
-						success: function(res) {
-							// var rawdata = JSON.parse(res.rawdata);
-							// console.log('支付成功');
-							// console.log('rawdata', rawdata);
-
-							uni.showLoading({
-								title: '会员开通中,请稍后...'
-							});
-							orderCheck({
-								id: orderId.value
-							}).then(res3 => {
-								if (res3.code == 0 && res3.data) {
-									genggaiVip()
-								} else {
-									setTimeout(() => {
-										orderCheck({
-											id: orderId.value
-										}).then(res4 => {
-											if (res4.code ==
-												0 && res4
-												.data) {
-												genggaiVip()
-											} else {
-												disabled
-													.value =
-													false
-												toast(
-													"开通失败,请联系管理员!"
-												)
-												uni
-													.hideLoading();
-												return false
-											}
-										}).catch(() => {
-											disabled.value =
-												false
-											uni.hideLoading();
-											toast("check接口报错")
-											return false
-										})
-									}, 5000)
-								}
-							}).catch(() => {
-								disabled.value = false
-								uni.hideLoading();
-								toast("check接口报错")
-								return false
-							})
-						},
-						fail: function(err) {
-							disabled.value = false
-							//  toast('支付失败:' + JSON.stringify(err));
-							console.log('支付失败:' + JSON.stringify(err));
-							uni.hideLoading();
-						}
-					});
+					toast("订单创建失败")
+					return false
 				})
-			}).catch((err) => {
-				disabled.value = false
-				uni.hideLoading();
-				toast("订单创建失败")
-				return false
-			})
+			}
 		}
 
 	}, 500)