Преглед изворни кода

修改存在的支付问题和统一api

zaijin пре 3 година
родитељ
комит
b28378f61e

+ 12 - 1
common/config.js

@@ -1,5 +1,6 @@
 const config = {
 const config = {
-	wxAppid:'wxbe90cc7c5233dd84',// wxAppid 
+	// wxAppid:'wxbe90cc7c5233dd84',// 测试wxAppid 
+	wxAppid: 'wx45c3cf2b632f5fd5', // 正式公众号
 	// baseUrl:'http://wx.hw.hongweisoft.com/parking/client',//64
 	// 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',//殷登顺
 	// 正式接口访问地址
 	// 正式接口访问地址
@@ -10,6 +11,16 @@ const config = {
 	// loginUrl:'http://wx.hw.hongweisoft.com/parking/client/wechat/h5/authorize?returnUrl=http://wx.hw.hongweisoft.com/wxpaydemoh5',
 	// loginUrl:'http://wx.hw.hongweisoft.com/parking/client/wechat/h5/authorize?returnUrl=http://wx.hw.hongweisoft.com/wxpaydemoh5',
 	//七牛云
 	//七牛云
 	// imgUrl:"http://qny.gzsdtfp.com/",
 	// imgUrl:"http://qny.gzsdtfp.com/",
+	
+	// 登录重定向首页地址
+	jumpHomeUrl: 'http://h5.pdzhtc.com/', // 正式服务器地址
+	// jumpHomeUrl: 'http://wx.hw.hongweisoft.com/wxpaydemoh5/', // 64服务器地址
+	// jumpHomeUrl: 'http://172.16.90.127:8080/', // 本地地址
+	// 重定位登录页
+	jumpLoginUrl: 'http://h5.pdzhtc.com/#/pages/center/phoneLogin/phoneLogin', // 正式环境地址
+	// jumpLoginUrl: 'http://wx.hw.hongweisoft.com/wxpaydemoh5/#/pages/center/phoneLogin/phoneLogin', // 64环境地址
+	// jumpLoginUrl: 'http://172.16.90.127:8080/#/pages/center/phoneLogin/phoneLogin', // 本地环境地址
+	
 }
 }
 export {
 export {
 	config
 	config

+ 3 - 5
common/http.interceptor.js

@@ -30,13 +30,13 @@ const install = (Vue, vm) => {
 		// 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的,所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值
 		// 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的,所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值
 		// const token = uni.getStorageSync('token');
 		// const token = uni.getStorageSync('token');
 		// config.header.token = token;
 		// config.header.token = token;
-		
+		// url加时间戳
+		config.url = config.url + '?t=' + Date.now()
 		// 此url参数为this.$u.get(url)中的url值
 		// 此url参数为this.$u.get(url)中的url值
 		let noTokenList = ['/wechat/h5/user','/client/auth/verifyCode'];
 		let noTokenList = ['/wechat/h5/user','/client/auth/verifyCode'];
 		if(noTokenList.includes(config.url)) config.header.noToken = true;
 		if(noTokenList.includes(config.url)) config.header.noToken = true;
 		// console.log('noTokenList.includes(config.url)',noTokenList.includes(config.url));
 		// console.log('noTokenList.includes(config.url)',noTokenList.includes(config.url));
 		// console.log('config.url',config.url);
 		// console.log('config.url',config.url);
-		
 		return config; 
 		return config; 
 	}
 	}
 	// 响应拦截,判断状态码是否通过
 	// 响应拦截,判断状态码是否通过
@@ -53,9 +53,7 @@ const install = (Vue, vm) => {
 			let storage = window.sessionStorage; 
 			let storage = window.sessionStorage; 
 			storage.setItem('backUrl',location.href);
 			storage.setItem('backUrl',location.href);
 			alert('还未登录,即将跳转登录');		
 			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://172.16.90.127:8080/#/pages/center/phoneLogin/phoneLogin';});//本地
+			setTimeout(()=>{location.href = config.jumpLoginUrl});//本地
 			
 			
 		}else return res;
 		}else return res;
 	}
 	}

+ 13 - 1
pages.json

@@ -21,7 +21,8 @@
 		{
 		{
 			"path": "pages/center/phoneLogin/phoneLogin",
 			"path": "pages/center/phoneLogin/phoneLogin",
 			"style": {
 			"style": {
-				"navigationBarTitleText": "手机号登录"
+				"navigationBarTitleText": "手机号登录",
+				"navigationStyle":"custom"
 			}
 			}
 		},
 		},
 		{
 		{
@@ -180,6 +181,17 @@
             }
             }
             
             
         }
         }
+        ,{
+            "path" : "pages/parkingLock/parkingLock",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "车位锁",
+                "enablePullDownRefresh": false,
+				"navigationBarBackgroundColor": "#008CFF",
+				"navigationBarTextStyle": "white"
+            }
+            
+        }
     ],
     ],
 	"globalStyle": {
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTextStyle": "black",

+ 34 - 3
pages/center/index.vue

@@ -2,7 +2,7 @@
 	<view>
 	<view>
 		<u-navbar title-color="#fff" :custom-back="customBack" :border-bottom="false" back-icon-color="#CCE8FF" :background="{background: '#008CFF' }" title="我的"></u-navbar>
 		<u-navbar title-color="#fff" :custom-back="customBack" :border-bottom="false" back-icon-color="#CCE8FF" :background="{background: '#008CFF' }" title="我的"></u-navbar>
 		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
 		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
-			<view class="u-m-r-24" @click="login($store.state.vuex_hasLogin)">
+			<view class="u-m-r-24" @click="logoutPop = true">
 				<u-avatar :src="userInfo.headImgUrl || userInfo.avatar||pic" size="140"></u-avatar>
 				<u-avatar :src="userInfo.headImgUrl || userInfo.avatar||pic" size="140"></u-avatar>
 			</view>
 			</view>
 			<view class="u-flex-1" @click="login($store.state.vuex_hasLogin)">
 			<view class="u-flex-1" @click="login($store.state.vuex_hasLogin)">
@@ -80,7 +80,23 @@
 				<u-cell-item icon="phone" title="手机号登录" @click="openPage('/pages/center/phoneLogin/phoneLogin')"></u-cell-item>
 				<u-cell-item icon="phone" title="手机号登录" @click="openPage('/pages/center/phoneLogin/phoneLogin')"></u-cell-item>
 			</u-cell-group>
 			</u-cell-group>
 		</view> -->
 		</view> -->
-		
+		<!-- 登出提示-->
+		<u-modal
+		v-model="logoutPop"
+		:title-style="{color: '#404040'}"
+		title="登出提示"
+		:show-confirm-button="true"
+		confirm-text="确认"
+		:confirm-style="{backgroundColor: '#3397FA', color: '#fff'}"
+		:show-cancel-button="true"
+		cancel-text="取消"
+		@cancel="logoutPop = false"
+		:cancel-style="{backgroundColor: '#EBF1FF', color: '#3397FA'}"
+		@confirm="loginOut">
+			<view class="slot-content">
+				<view class="pay-tips">你确认退出登录吗?</view>
+			</view>
+		</u-modal>
 		<u-toast ref="uToast" />
 		<u-toast ref="uToast" />
 	</view>
 	</view>
 </template>
 </template>
@@ -94,7 +110,7 @@
 				userInfo:[],
 				userInfo:[],
 				code:null,
 				code:null,
 				phoneNo:'114',
 				phoneNo:'114',
-				
+				logoutPop: false
 			}
 			}
 		},
 		},
 		onLoad() {
 		onLoad() {
@@ -143,6 +159,20 @@
 				    phoneNumber: phone
 				    phoneNumber: phone
 				});
 				});
 			},
 			},
+			loginOut() {
+				this.$store.state.vuex_hasLogin = false
+				this.$store.state.vuex_token = ''
+				this.$store.state.vuex_user = null
+				this.userInfo = []
+				this.code = ''
+				localStorage.clear()
+				setTimeout(() => {
+					this.logoutPop = false
+					this.$u.route({
+						url: 'pages/center/phoneLogin/phoneLogin'
+					});
+				}, 500)
+			}
 			// 贵州银行支付
 			// 贵州银行支付
 			// guizhouPay(){
 			// guizhouPay(){
 			// 	let tradeNo = new Date().getTime();
 			// 	let tradeNo = new Date().getTime();
@@ -186,4 +216,5 @@ page{background-color: $my-page-bg-color;}
 .u-cell-box /deep/ .u-cell__left-icon-wrap,
 .u-cell-box /deep/ .u-cell__left-icon-wrap,
 .u-cell-box /deep/ .custom-icon
 .u-cell-box /deep/ .custom-icon
 {color: $my-main-color;margin-right: 10rpx;}
 {color: $my-main-color;margin-right: 10rpx;}
+.pay-tips {text-align: center;margin: 30rpx 0;}
 </style>
 </style>

+ 50 - 15
pages/center/phoneLogin/phoneLogin.vue

@@ -24,6 +24,8 @@
 </template>
 </template>
 
 
 <script>
 <script>
+import getUrlParams from "./../../../utils/getUrlParams.js";
+import { config } from '@/common/config.js';
 export default {
 export default {
 	data() {
 	data() {
 		return {
 		return {
@@ -33,7 +35,7 @@ export default {
 			messageDisable: false,
 			messageDisable: false,
 			codelength: 4,
 			codelength: 4,
 			show: false,
 			show: false,
-			second:10,
+			second:60,
 			toastMsg:'',
 			toastMsg:'',
 			toastUrl:'',
 			toastUrl:'',
 			toastType:'',
 			toastType:'',
@@ -85,7 +87,7 @@ export default {
 								// this.messageError = true;
 								// this.messageError = true;
 							}
 							}
 							clearInterval(interval);
 							clearInterval(interval);
-							that.second=10;
+							that.second=60;
 						}
 						}
 					}, 1000);
 					}, 1000);
 					console.log('getcode res',res);
 					console.log('getcode res',res);
@@ -123,24 +125,13 @@ export default {
 				userId:this.userId,
 				userId:this.userId,
 				code:value
 				code:value
 			};
 			};
-			console.log('params',params);
 			this.$u.api.phoneLoginAuth(params)
 			this.$u.api.phoneLoginAuth(params)
 			.then(res =>{
 			.then(res =>{
 				if(res.code=='200'){
 				if(res.code=='200'){
 					// console.log('finish res',res);
 					// console.log('finish res',res);
 					this.$u.vuex('vuex_user', res.data);
 					this.$u.vuex('vuex_user', res.data);
 					this.$u.vuex('vuex_hasLogin', true);
 					this.$u.vuex('vuex_hasLogin', true);
-					let storage = window.sessionStorage;  
-					let backUrl = storage.getItem('backUrl');
-					let switchTabList = ['/pages/use/use'];
-					if(switchTabList.includes(res.data)){}
-					console.log('backUrl',backUrl);
-					const local = window.location.href 
-					if (backUrl) {
-						location.href = backUrl;
-					} else {
-						location.href = 'http://h5.pdzhtc.com/'
-					}
+					this.wechatLogin()
 					// location.href = backUrl;
 					// location.href = backUrl;
 					// this.$refs.uToast.show({
 					// this.$refs.uToast.show({
 					// 	title: '操作成功',
 					// 	title: '操作成功',
@@ -173,7 +164,51 @@ export default {
 				this.toastMsg = err.msg;
 				this.toastMsg = err.msg;
 				this.showToast();
 				this.showToast();
 			});
 			});
-		}
+		},
+		// 微信登录
+		wechatLogin() {
+			const openId = this.$store.state.vuex_wxinfo.openId
+			if (openId) {
+				this.jumpIndex()
+			} else {
+				this.getCode()
+			}
+		},
+		// 微信已登录则跳转到首页
+		jumpIndex() {
+			let storage = window.sessionStorage;
+			let backUrl = storage.getItem('backUrl');
+			if (backUrl) {
+				location.href = backUrl;
+			} else {
+				location.href = config.jumpHomeUrl
+			}
+		},
+		// 获取code
+		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传给后台获取用户信息
+			}
+		},
+		// 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
+		handleGetWXInfo (code) {
+			this.$u.api.getWXInfo(code).then((res) => {
+				if (res.code === 200 ) {
+					this.$u.vuex('vuex_wxinfo', res.data);
+					this.jumpIndex()
+				}
+			}).catch((err) => {
+				this.$refs.uToast.show({
+					title: err.msg,
+					type: 'error',
+				});
+			})
+		},
 	}
 	}
 };
 };
 </script>
 </script>

+ 21 - 16
pages/handleMonthly/handleMonthly.vue

@@ -184,22 +184,27 @@
 					.then(res => {
 					.then(res => {
 						console.log("createMonth",res)
 						console.log("createMonth",res)
 						if(res.code === 200){
 						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,
+										type: 'error',
+									});
+								}
+							})
 						}else{
 						}else{
 							this.$refs.uToast.show({
 							this.$refs.uToast.show({
 								title: res.msg,
 								title: res.msg,

+ 8 - 0
pages/index/index.scss

@@ -277,4 +277,12 @@ page{background-color: $my-page-bg-color;}
 	background-color: #3397FA;
 	background-color: #3397FA;
 	color: #fff;
 	color: #fff;
 	border-radius: 10rpx;
 	border-radius: 10rpx;
+}
+.empty-data-box {
+	background-color: #fff;
+	height: 462rpx;
+	width: calc(100% - 80rpx);
+	margin: 0 auto;
+	border-radius: 16rpx;
+	margin-top: 20rpx;
 }
 }

+ 3 - 1
pages/index/index.vue

@@ -55,7 +55,9 @@
 			</view>
 			</view>
 		</u-card>
 		</u-card>
 		
 		
-		<u-empty text="暂无停车信息" mode="list" class="u-m-t-80" v-if="!orderList||orderList.length<1"></u-empty>
+		<view class="empty-data-box" v-if="!orderList||orderList.length<1">
+			<u-empty text="暂无停车信息" mode="list"></u-empty>
+		</view>
 		<template v-for="(item, index) in orderList">
 		<template v-for="(item, index) in orderList">
 			<u-card :show-foot="false" border-radius="16" margin="20rpx 40rpx" padding="30">
 			<u-card :show-foot="false" border-radius="16" margin="20rpx 40rpx" padding="30">
 				<view class="pending-order-head" slot="head">
 				<view class="pending-order-head" slot="head">

+ 3 - 1
pages/myCars/myCars.vue

@@ -67,7 +67,9 @@
 		},
 		},
 		onLoad(){
 		onLoad(){
 			this.handlegetMycars();
 			this.handlegetMycars();
-			
+		},
+		onShow() {
+			this.handlegetMycars();
 		},
 		},
 		methods:{
 		methods:{
 			customBack(){
 			customBack(){