瀏覽代碼

支付宝修正

wgl 4 年之前
父節點
當前提交
1fefff2813

+ 5 - 2
src/projects/parking/components/CommonCar.vue

@@ -11,6 +11,7 @@
 	import {
 		getUrlParam,
 		getWeixinRedirectURI,
+		getAlipayRedirectURI
 	} from '$project/utils'
 	import {
 		mapGetters,
@@ -73,7 +74,7 @@
 				} else {
 					console.log(code);
 
-					if (!this.openId) {
+					if (!this.wx_openId) {
 						const step1 = API_WeiXin.getDataByCode(code).then(response => {
 							//console.log(response)
 							this.set_wx_openid(response.openid);
@@ -106,16 +107,18 @@
 			getUserId() {
 				const code = getUrlParam('code');
 				if (!code) {
+					//alert(getAlipayRedirectURI(process.env.VUE_APP_ALIAPPID, document.URL))
 					window.location.href = getAlipayRedirectURI(process.env.VUE_APP_ALIAPPID, document.URL);
 				} else {
 					console.log(code);
 
-					if (!this.openId) {
+					if (!this.ali_openid) {
 						const step1 = API_Ali.getDataByCode(code).then(response => {
 							//console.log(response)
 							this.set_ali_openid(response.openid);
 
 							//回调
+							//alert(JSON.stringify(response))
 							this.asynCallBack();
 
 							return Promise.resolve(response.openid);

+ 12 - 25
src/projects/parking/views/Car/Pay.vue

@@ -52,10 +52,12 @@
 		mapGetters,
 		mapMutations
 	} from 'vuex'
-	import QRCode from 'qrcodejs2'
 	import {
 		wxPayJs
 	} from '$project/utils/wxpay'
+	import {
+		aliPayJs
+	} from '$project/utils/alipay'
 	export default {
 		name: 'CarPay',
 		components: {
@@ -118,30 +120,14 @@
 					openId: this.ali_openid
 				}).then(url => {
 					this.isLoading = false;
-					let qrcode = new QRCode('qrcode', {
-						width: 200,
-						height: 200,
-						text: url,
-						correctLevel: QRCode.CorrectLevel.M,
-					})
-					var canvas = document.getElementsByTagName('canvas')[0];
-					this.qrCodeImg = convertCanvasToImage(canvas);
-
-					var btnArray = ['关闭', "支付成功?"];
-					var _this = this
-					mui.confirm('<img src="' + this.qrCodeImg + '" >',
-
-						'请使用支付宝扫码', btnArray,
-						function(e) {
-							if (e.index == 1) {
-								_this.$router.push({
-									name: 'CarPayResult',
-								})
-							}
-
-						})
-
-
+					let opthions = {
+						tradeNo: response.tradeOrder.tradeNo,
+						succUrl: window.location.href.split("#")[0] + "/#/car/payResult",
+						cancelUrl: window.location.href.split("#")[0] + "/#/car/search?companyId=" + this
+							.parking_company_id,
+					}
+					console.log(opthions);
+					aliPayJs(opthions);
 				}).catch(error => {
 					this.isLoading = false;
 					mui.toast(error);
@@ -159,6 +145,7 @@
 			...mapGetters({
 				wx_openId: 'wx_openid',
 				ali_openid: 'ali_openid',
+				parking_company_id: 'parking_company_id'
 			})
 		}
 	}

+ 3 - 1
src/projects/parking/views/Car/Search.vue

@@ -155,7 +155,9 @@
 			})
 		},
 		mounted() {
-			this.getInfo();
+			if(this.parking_company_id){
+				this.getInfo();
+			}
 		},
 		destroyed() {