Ver código fonte

微信支付首页

zaijin 3 anos atrás
pai
commit
20d5350a62

+ 2 - 2
common/config.js

@@ -1,9 +1,9 @@
 const config = {
 	wxAppid:'wxbe90cc7c5233dd84',// wxAppid 
 	// baseUrl:'http://wx.hw.hongweisoft.com/parking/client',//64
-	baseUrl:'http://wx.hw.hongweisoft.com/parking/client',//殷登顺
+	// baseUrl:'http://wx.hw.hongweisoft.com/parking/client',//殷登顺
 	// 正式接口访问地址
-	// baseUrl:'http://parking.pdzhtc.com/client',
+	baseUrl:'http://parking.pdzhtc.com/client',
 	
 	
 	//登录链接

+ 2 - 2
common/http.interceptor.js

@@ -53,8 +53,8 @@ const install = (Vue, vm) => {
 			let storage = window.sessionStorage; 
 			storage.setItem('backUrl',location.href);
 			alert('还未登录,即将跳转登录');		
-			//setTimeout(()=>{location.href = 'http://h5.pdzhtc.com/#/pages/center/phoneLogin/phoneLogin';});//正式
-			setTimeout(()=>{location.href = 'http://wx.hw.hongweisoft.com/wxpaydemoh5/#/pages/center/phoneLogin/phoneLogin';});//64
+			setTimeout(()=>{location.href = 'http://h5.pdzhtc.com/#/pages/center/phoneLogin/phoneLogin';});//正式
+			// setTimeout(()=>{location.href = 'http://wx.hw.hongweisoft.com/wxpaydemoh5/#/pages/center/phoneLogin/phoneLogin';});//64
 			// setTimeout(()=>{location.href = 'http://172.16.90.127:8080/#/pages/center/phoneLogin/phoneLogin';});//本地
 			
 		}else return res;

+ 1 - 2
pages/center/phoneLogin/phoneLogin.vue

@@ -136,11 +136,10 @@ export default {
 					if(switchTabList.includes(res.data)){}
 					console.log('backUrl',backUrl);
 					const local = window.location.href 
-					alert(backUrl)
 					if (backUrl) {
 						location.href = backUrl;
 					} else {
-						location.href = 'http://wx.hw.hongweisoft.com/wxpaydemoh5'
+						location.href = 'http://h5.pdzhtc.com/'
 					}
 					// location.href = backUrl;
 					// this.$refs.uToast.show({

+ 26 - 1
pages/favourableActivity/favourableActivity.scss

@@ -25,7 +25,7 @@
 					text-align: center;
 				}
 				&:nth-child(2) {
-					margin-top: 290rpx;
+					margin-top: 400rpx;
 					color: #1A517E;
 					font-weight: 400;
 					font-size: 26rpx;
@@ -40,6 +40,18 @@
 					line-height: 52rpx;
 					padding: 0 39rpx;
 				}
+				button {
+					width: calc(100% - 56rpx);
+					height: 96rpx;
+					line-height: 96rpx;
+					background-color: #008CFF;
+					color: #fff;
+					margin-top: 60rpx;
+					border-radius: 10rpx;
+					font-size: 28rpx;
+					font-weight: 500;
+					border: none;
+				}
 			}
 		}
 	}
@@ -84,6 +96,19 @@
 					line-height: 52rpx;
 					padding: 0 39rpx;
 				}
+				button {
+					width: calc(100% - 56rpx);
+					height: 96rpx;
+					line-height: 96rpx;
+					background-color: #FFBABA;
+					background: linear-gradient(#FFA9A9,#FF8C8C);
+					color: #fff;
+					margin-top: 60rpx;
+					border-radius: 10rpx;
+					font-size: 28rpx;
+					font-weight: 500;
+					border: none;
+				}
 			}
 		}
 	}

+ 17 - 4
pages/favourableActivity/favourableActivity.vue

@@ -8,6 +8,9 @@
 				<view>从客户启用贵州银行行卡支付的第四个月开始,使用我行卡支付永久享受八折优惠(单日不限次数)。时间计算同上。三个月最后一天,假如车主跨天的话,拆分账单计算:三个月内一分钱或八折,三个月外时段八折。
 				</view>
 				<view>如果停车场、路边停车位有15分钟内等免费政策的,我行客户自然享受后再按“一分钱停车”、“八折停车”执行。</view>
+				<view>
+					<button type="default" class="btn1">银行卡开户</button>
+				</view>
 			</view>
 		</view>
 		<view class="eighty-percent-of-parking" v-if="id == 2">
@@ -17,6 +20,9 @@
 				<view>从客户启用贵州银行行卡支付的第四个月开始,使用我行卡支付永久享受八折优惠(单日不限次数)。时间计算同上。三个月最后一天,假如车主跨天的话,拆分账单计算:三个月内一分钱或八折,三个月外时段八折。
 				</view>
 				<view>如果停车场、路边停车位有15分钟内等免费政策的,我行客户自然享受后再按“一分钱停车”、“八折停车”执行。</view>
+				<view>
+					<button type="default" class="btn2">银行卡开户</button>
+				</view>
 			</view>
 		</view>
 	</view>
@@ -30,10 +36,17 @@
 			}
 		},
 		onLoad(page) {
-			uni.setNavigationBarTitle({
-				title: page.title
-			})
-			this.id = page.id
+			if (page.title) {
+				uni.setNavigationBarTitle({
+					title: page.title
+				})
+				this.id = page.id	
+			} else {
+				uni.setNavigationBarTitle({
+					title: '一分钱停车'
+				})
+				this.id = 1
+			}
 		},
 		onShow() {
 			console.log(this.id == 1)

+ 18 - 18
pages/handleMonthly/handleMonthly.vue

@@ -100,7 +100,7 @@
 				days = days.getDate() //获取当前日期中的月的天数
 				let year2 = year;
 				let month2 = parseInt(month) + parseInt(monthNum)
-				if (month2 >12) {
+				if (month2 > 12) {
 					year2 = parseInt(year2) + parseInt((parseInt(month2) / 12 == 0 ? 1 : parseInt(month2) / 12))
 					month2 = parseInt(month2) % 12;
 				}
@@ -114,7 +114,7 @@
 					month2 = '0' + month2;
 				}
 				const t1 = year + '.' + (month > 9 ? month : '0' + month) + '.' + (day > 9 ? day : '0' + day)
-				const t2 = year2 + '.' + month2 + '.' + day2
+				const t2 = year2 + '.' + month2 + '.' + (day2 > 9 ? day2 : '0' + day2)
 				this.startTime=t1
 				this.endTime=t2
 				this.monthStartTime=year + '-' + (month > 9 ? month : '0' + month) + '-' + (day > 9 ? day : '0' + day) + ' ' + hours + ':' + minutes + ':' +seconds
@@ -184,22 +184,22 @@
 					.then(res => {
 						console.log("createMonth",res)
 						if(res.code === 200){
-							this.monthId = res.data.monthId
-							console.log(this.monthId)
-							this.$u.api.monthPay({
-								monthId:this.monthId
-							}).then(res => {
-								console.log("monthPay",res)
-								if(res.code === 200){
-									this.payUrl=encodeURIComponent(res.data.url);
-									this.$u.route({
-										url: 'pages/handleMonthly/monthPay',
-										params: {
-											payUrl:this.payUrl
-										}
-									});
-								}
-							})
+							// this.monthId = res.data.monthId
+							// console.log(this.monthId)
+							// this.$u.api.monthPay({
+							// 	monthId:this.monthId
+							// }).then(res => {
+							// 	console.log("monthPay",res)
+							// 	if(res.code === 200){
+							// 		this.payUrl=encodeURIComponent(res.data.url);
+							// 		this.$u.route({
+							// 			url: 'pages/handleMonthly/monthPay',
+							// 			params: {
+							// 				payUrl:this.payUrl
+							// 			}
+							// 		});
+							// 	}
+							// })
 						}else{
 							this.$refs.uToast.show({
 								title: res.msg,

+ 25 - 0
pages/index/index.scss

@@ -252,4 +252,29 @@ page{background-color: $my-page-bg-color;}
 			width: 20rpx;
 		}
 	}
+}
+.pay-way {
+	display: flex;
+	justify-content: space-between;
+	width: calc(100% - 34rpx);
+	border-top: solid 1px #979797;
+	margin: 23rpx auto;
+	padding: 38rpx 86rpx;
+	.pay-way-item {
+		text-align: center;
+		font-size: 30rpx;
+		color: #5F5F5F;
+		image {
+			width: 143rpx;
+			height: 143rpx;
+		}
+	}
+}
+.pay-way-close-btn {
+	width: calc(100% - 34rpx);
+	margin: 0 auto 68rpx;
+	border: none;
+	background-color: #3397FA;
+	color: #fff;
+	border-radius: 10rpx;
 }

+ 132 - 28
pages/index/index.vue

@@ -34,7 +34,7 @@
 					</view>
 					<view class="content-nav-item-icon-text">停车缴费</view>
 				</view>
-				<view class="content-nav-item" @click="$refs.uToast.show({title: '建设中'})">
+				<view class="content-nav-item" @click="openPage('pages/favourableActivity/favourableActivity')">
 					<view class="content-nav-item-icon-wrap">
 						<u-image src="../../static/img/index-content-nav-02.png" width="95rpx" height="95rpx" mode="heightFix"></u-image>
 					</view>
@@ -168,6 +168,27 @@
 				知道了
 			</view>
 		</u-popup>
+		<!-- 缴费方式-->
+		<u-modal
+		v-model="payWayPop"
+		:title-style="{color: '#404040'}"
+		title="缴费方式"
+		:show-confirm-button="false"
+		:show-cancel-button="false">
+			<view class="slot-content">
+				<view class="pay-way">
+					<view class="pay-way-item" @click="gyBankPay">
+						<image src="../../static/img/gy-bank-pay-icon.png" mode=""></image>
+						<view>贵州银行</view>
+					</view>
+					<view class="pay-way-item" @click="wechatPay">
+						<image src="../../static/img/wechat-pay-icon.png" mode=""></image>
+						<view>微信支付</view>
+					</view>
+				</view>
+				<button class="pay-way-close-btn" @click="payWayPop = false">关闭</button>
+			</view>
+		</u-modal>
 		<u-toast ref="uToast" />
 	</view>
 </template>
@@ -209,7 +230,11 @@
 				],
 				contractStatus:'',
 				vehicleId:'',
-				recordList:[]
+				recordList:[],
+				// 支付方式
+				payWayPop: false,
+				// 订单号
+				curOrderList: []
 			}
 		},
 		onShow() {
@@ -296,31 +321,34 @@
 				});
 			},
 			goPay(orderId){
-				let orderList=[];
-				orderList.push(orderId);
-				this.$u.api.payGzbank({orderList: orderList}).then(res=>{
-					let payUrl = res.data.url;
-					this.currentPayUrl=encodeURIComponent(res.data.url);
-					// return;
-					this.$u.route({
-						url: 'pages/payLists/pay',
-						params: {
-							currentPayUrl:this.currentPayUrl
-						}
-					});
-				}).catch(err=>{
-					this.$refs.uToast.show({
-						title: err.msg,
-						type: 'error',
-					});
-				});
-				
-				// this.$u.route({
-				// 	url: 'pages/payPage/payPage',
-				// 	params: {
-				// 		orderId: orderId
-				// 	}
+				this.payWayPop = true
+				this.curOrderList = []
+				this.curOrderList.push(orderId)
+				// let orderList=[];
+				// orderList.push(orderId);
+				// this.$u.api.payGzbank({orderList: orderList}).then(res=>{
+				// 	let payUrl = res.data.url;
+				// 	this.currentPayUrl=encodeURIComponent(res.data.url);
+				// 	// return;
+				// 	this.$u.route({
+				// 		url: 'pages/payLists/pay',
+				// 		params: {
+				// 			currentPayUrl:this.currentPayUrl
+				// 		}
+				// 	});
+				// }).catch(err=>{
+				// 	this.$refs.uToast.show({
+				// 		title: err.msg,
+				// 		type: 'error',
+				// 	});
 				// });
+				
+				// // this.$u.route({
+				// // 	url: 'pages/payPage/payPage',
+				// // 	params: {
+				// // 		orderId: orderId
+				// // 	}
+				// // });
 			},			
 			//
 			onRoadInfo(item){
@@ -356,8 +384,84 @@
 						})
 					}
 				})
-			}
-
+			},
+			gyBankPay() {
+				this.$u.api.payGzbank({orderList: this.curOrderList}).then(res=>{
+					let payUrl = res.data.url;
+					this.currentPayUrl=encodeURIComponent(res.data.url);
+					this.$u.route({
+						url: 'pages/payLists/pay',
+						params: {
+							currentPayUrl: this.currentPayUrl
+						}
+					});
+				}).catch(err=>{
+					this.$refs.uToast.show({
+						title: err.msg,
+						type: 'error',
+					});
+				});
+			},
+			// 微信支付
+			wechatPay() {
+				const openId = this.$store.state.vuex_wxinfo.openId
+				if (openId) {
+					this.getWXPay(this.curOrderList)
+				} else {
+					this.getCode()
+				}
+			},
+			async getWXPay(list){
+				let params = {
+					orderList: list,
+					openid: this.$store.state.vuex_wxinfo.openId
+				};
+				await this.$wxApi.config();
+				this.$pay.wechatPay(params).then(res =>{
+					if(res.code == 0){
+						// 成功
+						this.$u.route({
+							url:'/',
+						});
+					}else if(res.code == 1){
+						// 取消
+						// uni.redirectTo({
+						// 	url: '/pages/userCenter/myOrder/myOrder'
+						// })
+					}else if(res.code == 2){
+						this.$refs.uToast.show({
+							title: '支付失败,请检查!',
+							type: 'error',
+							// url: '/pages/user/index'
+						});
+					}
+				});
+			},
+			getCode () {
+				var local = window.location.href // 获取页面url
+				let locationLocaturl = window.location.search;
+				this.code = getUrlParams(locationLocaturl,"code"); // 截取code
+				if (this.code == null || this.code === '') { // 如果没有code,则去请求
+					window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
+				} else {
+					this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
+				}
+			},
+			handleGetWXInfo (code) { // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
+				let _this = this
+				this.$u.api.getWXInfo(code).then((res) => {
+					if (res.code === 200 ) {
+						this.$u.vuex('vuex_wxinfo', res.data);
+						// 继续支付
+						this.getWXPay(this.currentItem)
+					}
+				}).catch((err) => {
+					this.$refs.uToast.show({
+						title: err.msg,
+						type: 'error',
+					});
+				})
+			},
 		}
 	}
 </script>

+ 1 - 1
pages/parkingInformation/parkingInformation.scss

@@ -101,7 +101,7 @@
 		.parking-information-content-price {
 			text-align: center;
 			margin: 37rpx 0 81rpx 0;
-			font-size: 20rpx;
+			font-size: 24rpx;
 			color: #A4A4A4;
 			font-weight: 400;
 			text {

+ 0 - 3
pages/payLists/payLists.vue

@@ -323,9 +323,6 @@
 						// 成功
 						this.$u.route({
 							url:'pages/payLists/payLists',
-							// params: {
-							// 	keyword: this.keyword
-							// }
 						});
 					}else if(res.code == 1){
 						// 取消

+ 2 - 2
pay.js

@@ -24,7 +24,7 @@ export default {
 					//#endif
 					this.payError(res);
 				}).catch(err =>{
-					alert(err.msg);
+					// alert(err.msg);
 					console.log('pay err',err);
 				})
 		});
@@ -42,7 +42,7 @@ export default {
 					//#endif
 					this.payError(res);
 				}).catch(err =>{
-					alert(err.msg);
+					// alert(err.msg);
 					console.log('pay err',err);
 				})
 		});