Jelajahi Sumber

停车收费相关功能

wgl 4 tahun lalu
induk
melakukan
eceeb94267

+ 32 - 0
src/projects/parking/apis/merchant.js

@@ -0,0 +1,32 @@
+import request from '@/utils/request'
+import Qs from 'qs';
+
+//查询获取商户token等信息
+export function findByOpenIdAndMerchant(openId, merchantId) {
+	return request({
+		url: '/mobile/parkingInfoApi/findByOpenIdAndMerchant',
+		data: Qs.stringify({
+			openId: openId,
+			merchantId: merchantId
+		}),
+		method: 'post',
+	})
+}
+
+//查询停车详情
+export function queryParkDetail(params) {
+	return request({
+		url: '/mobile/parkingInfoApi/queryParkDetail',
+		data: Qs.stringify(params),
+		method: 'post',
+	})
+}
+
+//赠送优惠券
+export function giveDiscountTicket(params) {
+	return request({
+		url: '/mobile/parkingInfoApi/giveDiscountTicket',
+		data: Qs.stringify(params),
+		method: 'post',
+	})
+}

+ 0 - 3
src/projects/parking/apis/parking.js

@@ -1,3 +0,0 @@
-import request from '@/utils/request'
-import Qs from 'qs';
-

+ 156 - 0
src/projects/parking/components/CommonMerchant.vue

@@ -0,0 +1,156 @@
+<template>
+	<div>
+		<loading :visible="isLoading" :doLoading="doLoading"></loading>
+	</div>
+</template>
+
+<script>
+	import * as API_WeiXin from '$project/apis/weixin'
+	import * as API_Merchant from '@/apis/merchant'
+	import Loading from '$project/components/Loading.vue'
+	import {
+		getUrlParam,
+		getWeixinRedirectURI,
+		isWeiXin
+	} from '$project/utils'
+	import {
+		mapGetters,
+		mapMutations
+	} from 'vuex'
+	import * as types from '$project/store/mutation-types'
+	export default {
+		name: 'CommonMerchant',
+		components: {
+			Loading,
+		},
+		props: {
+			//是否获取openid
+			checkOpenId: {
+				require: false,
+				default: true,
+			},
+			doLoading: {
+				require: false,
+				default: false,
+			},
+		},
+		data() {
+			return {
+				isLoading: false,
+			}
+		},
+		created() {
+			//公共组件的执行方法放在created中执行,父组件的create放在motuned中执行
+			if (isWeiXin()) {
+				if (this.checkOpenId) {
+					if (!this.openId) {
+						this.getOpenid();
+					} else {
+						this.getDataByOpenId();
+					}
+				}
+			} else {
+				if (this.checkOpenId) {
+					/* mui.alert('请使用微信浏览打开!', '提示', function() {
+						//info.innerText = '你刚关闭了警告框';
+					}); */
+				}
+			}
+		},
+		methods: {
+			//获取openid
+			getOpenid() {
+				const code = getUrlParam('code');
+				if (!code) {
+					window.location.href = getWeixinRedirectURI(process.env.VUE_APP_WXAPPID, document.URL);
+				} else {
+					console.log(code);
+
+					if (!this.openId) {
+						const step1 = API_WeiXin.getDataByCode(code).then(response => {
+							//console.log(response)
+							this.set_openid(response.openid);
+
+							//角色判定调用不同的信息获取详情
+							this.getDataByOpenId();
+
+							return Promise.resolve(response.openid);
+						}).catch(error => {
+							//console.log(error);
+							return Promise.reject(error);
+						});
+						step1.then(() => {
+							let redirect = this.$route.query.redirect;
+							if (redirect) {
+								this.$router.push({
+									path: decodeURIComponent(redirect)
+								});
+							} else {
+								window.location.href = document.URL.replace(/\?code=(.*?)&state=STATE/g, '');
+							}
+						});
+					} else {
+						//如果存在openid,把链接中code字符去除
+						window.location.href = document.URL.replace(/\?code=(.*?)&state=STATE/g, '');
+					}
+				}
+			},
+			//角色判定调用不同的信息获取详情
+			getDataByOpenId() {
+				this.getUserInfoByOpenId();
+			},
+			//获取用户详情
+			getUserInfoByOpenId() {
+				this.isLoading = true;
+
+				var type = type || '';
+				API_Merchant.findByOpenIdAndMerchant(this.openId, this.parking_merchant_id).then(response => {
+
+					this.isLoading = false;
+
+					console.log(response)
+
+					var token = response ? response.token : '';
+					this.set_token(token);
+
+					this.set_parking_merchant_data(response);
+
+
+					this.asynCallBack();
+
+				}).catch(error => {
+					mui.toast(error);
+				})
+			},
+
+
+
+			//异步回调父组件的方法
+			asynCallBack() {
+				this.$emit('asynCallBack');
+			},
+			...mapMutations({
+				set_openid: types.SET_WEIXIN_OPENID,
+				set_token: types.SET_TOKEN,
+				set_parking_merchant_data: types.SET_PARKING_MERCHANT_DATA
+			})
+		},
+		mounted() {
+			//如果是开发环境则直接读取findbyopenid信息
+			if (process.env.VUE_APP_NODE_NAME == 'devlopment') {
+				this.getDataByOpenId();
+			}
+		},
+		computed: {
+			...mapGetters({
+				openId: 'wx_openid',
+				token: 'token',
+				parking_merchant_id: 'parking_merchant_id',
+				parking_merchant_data: 'parking_merchant_data'
+			})
+		}
+	}
+</script>
+
+<style>
+</style>

+ 17 - 5
src/projects/parking/views/Merchant/Check/Result.vue

@@ -1,7 +1,7 @@
 <template>
 	<div>
-		<common ref="common" @asynCallBack="asynCallBack"></common>
-		<top-header :pageTitle="pageTitle"></top-header>
+		<common-merchant ref="common" @asynCallBack="asynCallBack"></common-merchant>
+		<top-header routeName="MerchantCheckSearch" :pageTitle="pageTitle"></top-header>
 
 		<div class="mui-content">
 			<div class="vongi-car-over">
@@ -10,7 +10,9 @@
 			</div>
 		</div>
 		<div class="fyy-footer padd30">
-			<div class="bindfyy-btn"><button type="submit" class="mui-btn mui-btn-primary ">返 回</button></div>
+			<div class="bindfyy-btn">
+				<button type="button" @click="goToBack" class="mui-btn mui-btn-primary ">返 回</button>
+			</div>
 		</div>
 
 		<loading :visible="isLoading"></loading>
@@ -18,7 +20,7 @@
 </template>
 
 <script>
-	import Common from '$project/components/Common.vue'
+	import CommonMerchant from '@/components/CommonMerchant.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
 	import {
@@ -28,7 +30,7 @@
 	export default {
 		name: 'MerchantCheckResult',
 		components: {
-			Common,
+			CommonMerchant,
 			Loading,
 			TopHeader,
 		},
@@ -41,6 +43,15 @@
 		},
 		created() {},
 		methods: {
+			//返回
+			goToBack() {
+				this.$router.push({
+					name: 'MerchantCheckSearch',
+					query: {
+						merchantId: this.parking_merchant_id
+					}
+				})
+			},
 			asynCallBack() {
 
 			},
@@ -52,6 +63,7 @@
 		computed: {
 			...mapGetters({
 				openId: 'wx_openid',
+				parking_merchant_id: 'parking_merchant_id'
 			})
 		}
 	}

+ 67 - 10
src/projects/parking/views/Merchant/Check/Search.vue

@@ -1,17 +1,17 @@
 <template>
 	<div>
-		<common ref="common" @asynCallBack="asynCallBack"></common>
+		<common-merchant ref="common" @asynCallBack="asynCallBack"></common-merchant>
 		<top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink"></top-header>
 
 		<div class="mui-content vongi-car-index">
 			<div class="vongi-car-banner">
-				<h5 class="mui-ellipsis">协议商户:金盆洗脚城(金盆岭店)</h5>
+				<h5 class="mui-ellipsis">协议商户:{{parking_merchant_data.name}}</h5>
 				<div class="flew">
-					<input type="text" onfocus="show(this,'tn')" placeholder="请输入车牌号查询">
-					<button class="mui-btn mui-btn-blue">查询</button>
+					<input type="text" v-model="searchForm.carNumber" placeholder="请输入车牌号查询">
+					<button class="mui-btn mui-btn-blue" @click="submit">查询</button>
 				</div>
 			</div>
-			<div class="vongi-car-not">
+			<div v-show="kongResult" class="vongi-car-not">
 				<img src="~$project/assets/img/car_not.png">
 				<div class="mui-text-center">没有找到停车信息!</div>
 			</div>
@@ -22,17 +22,19 @@
 </template>
 
 <script>
-	import Common from '$project/components/Common.vue'
+	import * as API_Merchant from '@/apis/merchant'
+	import CommonMerchant from '@/components/CommonMerchant.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
 	import {
 		mapGetters,
 		mapMutations
 	} from 'vuex'
+	import * as types from '$project/store/mutation-types'
 	export default {
 		name: 'MerchantCheckSearch',
 		components: {
-			Common,
+			CommonMerchant,
 			Loading,
 			TopHeader,
 		},
@@ -48,15 +50,68 @@
 					style: 'font-size:15px;',
 					title: '历史记录'
 				},
+
+				searchForm: {
+					carNumber: '鄂D'
+				},
+
+				kongResult: false,
+			}
+		},
+		created() {
+			if (this.$route.query.merchantId) {
+				//入口页必须带merchantId
+				this.set_parking_merchat_id(this.$route.query.merchantId);
+			} else {
+				if (!this.parking_merchant_id) {
+					mui.alert('参数错误');
+				}
 			}
 		},
-		created() {},
 		methods: {
 			asynCallBack() {
 
 			},
-			//完成
-			doRightLink() {}
+			//检测
+			checkForm() {
+				if (!this.searchForm.carNumber) {
+					mui.toast('请输入车牌号码');
+					return false;
+				} else {
+					return true;
+				}
+			},
+			//查询
+			submit() {
+				if (this.checkForm()) {
+					this.isLoading = true;
+					API_Merchant.queryParkDetail(this.searchForm).then(response => {
+
+						this.isLoading = false;
+
+						this.$router.push({
+							name: 'MerchantCheckSearchResult',
+							params: {
+								detail: response
+							}
+						})
+
+					}).catch(error => {
+						this.isLoading = false;
+						mui.toast(error);
+						this.kongResult = true;
+					})
+				}
+			},
+			//历史记录
+			doRightLink() {
+				this.$router.push({
+					name: 'MerchantHistoryList'
+				})
+			},
+			...mapMutations({
+				set_parking_merchat_id: types.SET_PARKING_MERCHANT_ID,
+			})
 		},
 		mounted() {},
 		destroyed() {
@@ -65,6 +120,8 @@
 		computed: {
 			...mapGetters({
 				openId: 'wx_openid',
+				parking_merchant_id: 'parking_merchant_id',
+				parking_merchant_data: 'parking_merchant_data'
 			})
 		}
 	}

+ 62 - 15
src/projects/parking/views/Merchant/Check/SearchResult.vue

@@ -1,6 +1,6 @@
 <template>
 	<div>
-		<common ref="common" @asynCallBack="asynCallBack"></common>
+		<common-merchant ref="common" @asynCallBack="asynCallBack"></common-merchant>
 		<top-header :pageTitle="pageTitle"></top-header>
 
 		<div class="mui-content vongi-car-dj">
@@ -9,35 +9,37 @@
 					<img class="mui-media-object" src="~$project/assets/img/antFill-car.png">
 					<div class="mui-media-body ">
 						车牌号码
-						<p class='mui-h2'>鄂D 88888</p>
+						<p class='mui-h2' v-text="detail.carNumber"></p>
 					</div>
 				</div>
 				<div>
-					<button class="mui-btn mui-btn-outlined">修改</button>
+					<button class="mui-btn mui-btn-outlined" @click="goToSearch">修改</button>
 				</div>
 			</div>
 			<div class="vongi-car-over">
 				<h1>- 停车中 -</h1>
 				<div class="vongi-car-over-line"></div>
-				<h4>协议商户:金盆洗脚城</h4>
-				<h4>停车位置:金盆岭停车场</h4>
-				<h4>入场时间:07-12 13:51</h4>
-				<h4>已停时长:14分钟</h4>
+				<h4>协议商户:{{detail.merchantName}}</h4>
+				<h4>停车位置:{{detail.parkingName}}</h4>
+				<h4>入场时间:{{detail.inParkingTime}}</h4>
+				<h4>已停时长:{{detail.parkingTime}}</h4>
 			</div>
 			<div class="vongi-car-juan flew-items">
 				<div class="car-juan">
-					<h2>¥<span class="mui-h1">5</span></h2>
+					<h2>¥<span class="mui-h1" v-text="detail.discountMoney"></span></h2>
 					<h6>抵用券</h6>
 				</div>
 				<div class="car-juan-text">
-					<h4 class="mui-ellipsis">[停车]5元停车抵用券</h4>
-					<p class="colorf8b155">仅限 2021.3.4 当日有效</p>
+					<h4 class="mui-ellipsis">[停车]{{detail.discountMoney}}元停车抵用券</h4>
+					<p class="colorf8b155">仅限 {{today}} 当日有效</p>
 					<p>本抵用券无法叠加使用</p>
 				</div>
 			</div>
 		</div>
 		<div class="fyy-footer">
-			<div class="bindfyy-btn"><button type="submit" class="mui-btn mui-btn-primary ">确认赠送</button></div>
+			<div class="bindfyy-btn">
+				<button type="button" @click="sure" class="mui-btn mui-btn-primary ">确认赠送</button>
+			</div>
 		</div>
 
 		<loading :visible="isLoading"></loading>
@@ -45,17 +47,22 @@
 </template>
 
 <script>
-	import Common from '$project/components/Common.vue'
+	import * as API_Merchant from '@/apis/merchant'
+	import CommonMerchant from '@/components/CommonMerchant.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
 	import {
 		mapGetters,
 		mapMutations
 	} from 'vuex'
+	import {
+		currentTimeStamp,
+		parseUnixTime
+	} from '$project/utils'
 	export default {
 		name: 'MerchantCheckSearchResult',
 		components: {
-			Common,
+			CommonMerchant,
 			Loading,
 			TopHeader,
 		},
@@ -64,13 +71,53 @@
 				isLoading: false,
 
 				pageTitle: '车牌登记',
+
+				detail: {},
+
+				sureForm: {
+					carNumber: '',
+					id: '',
+				},
+				today: '',
 			}
 		},
-		created() {},
+		created() {
+			this.detail = this.$route.params.detail;
+			this.sureForm.carNumber = this.detail.carNumber;
+			this.sureForm.id = this.detail.id;
+
+			this.today = parseUnixTime(currentTimeStamp(), '{y}.{m}.{d}');
+		},
 		methods: {
-			asynCallBack() {
+			//确认赠送
+			sure() {
+				var _this = this;
+				var btnArray = ['否', '是'];
+				mui.confirm('是否确认赠送?', '提示', btnArray, function(e) {
+					if (e.index == 1) {
+						_this.sendTicket();
+					}
+				})
+			},
+			sendTicket() {
+				this.isLoading = true;
+				API_Merchant.giveDiscountTicket(this.sureForm).then(response => {
 
+					this.isLoading = false;
+
+					this.$router.push({
+						name: 'MerchantCheckResult'
+					})
+				}).catch(error => {
+					this.isLoading = false;
+					mui.toast(error);
+				})
+			},
+			//返回修改
+			goToSearch() {
+				this.$router.go(-1);
 			},
+			asynCallBack() {},
 		},
 		mounted() {},
 		destroyed() {

+ 3 - 3
src/projects/parking/views/Merchant/History/Info.vue

@@ -1,6 +1,6 @@
 <template>
 	<div>
-		<common ref="common" @asynCallBack="asynCallBack"></common>
+		<common-merchant ref="common" @asynCallBack="asynCallBack"></common-merchant>
 		<top-header :pageTitle="pageTitle"></top-header>
 
 		<div class="mui-content">
@@ -58,7 +58,7 @@
 </template>
 
 <script>
-	import Common from '$project/components/Common.vue'
+	import CommonMerchant from '@/components/CommonMerchant.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
 	import {
@@ -68,7 +68,7 @@
 	export default {
 		name: 'MerchantHistoryInfo',
 		components: {
-			Common,
+			CommonMerchant,
 			Loading,
 			TopHeader,
 		},

+ 3 - 3
src/projects/parking/views/Merchant/History/List.vue

@@ -1,6 +1,6 @@
 <template>
 	<div>
-		<common ref="common" @asynCallBack="asynCallBack"></common>
+		<common-merchant ref="common" @asynCallBack="asynCallBack"></common-merchant>
 		<top-header :pageTitle="pageTitle"></top-header>
 
 		<div class="mui-content vongi-kqtj-center vongi-dktz-c">
@@ -42,7 +42,7 @@
 </template>
 
 <script>
-	import Common from '$project/components/Common.vue'
+	import CommonMerchant from '@/components/CommonMerchant.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
 	import {
@@ -52,7 +52,7 @@
 	export default {
 		name: 'MerchantHistoryList',
 		components: {
-			Common,
+			CommonMerchant,
 			Loading,
 			TopHeader,
 		},

+ 5 - 1
src/store/getters.js

@@ -40,4 +40,8 @@ export const activity_form_data = state => state.activity_form_data
 
 export const keep_alive_components = state => state.keep_alive_components
 
-export const api_type = state => state.api_type
+export const api_type = state => state.api_type
+
+export const parking_merchant_id = state => state.parking_merchant_id
+
+export const parking_merchant_data = state => state.parking_merchant_data

+ 2 - 0
src/store/mutation-types.js

@@ -20,5 +20,7 @@ export const SET_INVITATION_CODE = 'SET_INVITATION_CODE'
 export const SET_DEFAULT_EXAMINE_PERSON = 'SET_DEFAULT_EXAMINE_PERSON'
 export const SET_ACTIVITY_FORM_DATA = 'SET_ACTIVITY_FORM_DATA'
 export const SET_API_TYPE = 'SET_API_TYPE'
+export const SET_PARKING_MERCHANT_ID = 'SET_PARKING_MERCHANT_ID'
+export const SET_PARKING_MERCHANT_DATA = 'SET_PARKING_MERCHANT_DATA'
 
 export const SET_KEEP_ALIVE_COMPONENTS = 'SET_KEEP_ALIVE_COMPONENTS'

+ 13 - 1
src/store/mutations.js

@@ -18,7 +18,9 @@ import {
 	setInvitationCode,
 	setDefaultExaminePerson,
 	setActivityFormData,
-	setApiType
+	setApiType,
+	setParkingMerchantId,
+	setParkingMerchantData
 } from '../utils/storage'
 
 var storage_prefix = process.env.VUE_APP_LOCAL_STORAGE_PREFIX;
@@ -136,6 +138,16 @@ const mutations = {
 		state.api_type = data
 	},
 
+	[types.SET_PARKING_MERCHANT_ID](state, data) {
+		setParkingMerchantId(storage_prefix, data)
+		state.parking_merchant_id = data
+	},
+	
+	[types.SET_PARKING_MERCHANT_DATA](state, data) {
+		setParkingMerchantData(storage_prefix, data)
+		state.parking_merchant_data = data
+	},
+
 }
 
 export default mutations

+ 5 - 1
src/store/state.js

@@ -17,7 +17,9 @@ import {
 	getInvitationCode,
 	getDefaultExaminePerson,
 	getActivityFormData,
-	getApiType
+	getApiType,
+	getParkingMerchantId,
+	getParkingMerchantData
 } from '../utils/storage'
 
 var storage_prefix = process.env.VUE_APP_LOCAL_STORAGE_PREFIX;
@@ -46,6 +48,8 @@ const state = {
 	default_examine_person: getDefaultExaminePerson(storage_prefix),
 	activity_form_data: getActivityFormData(storage_prefix),
 	api_type: getApiType(storage_prefix),
+	parking_merchant_id: getParkingMerchantId(storage_prefix),
+	parking_merchant_data: getParkingMerchantData(storage_prefix),
 	//这里由于include,需要默认为数组
 	keep_alive_components: [],
 }

+ 9 - 1
src/utils/storage.js

@@ -124,4 +124,12 @@ export const setActivityFormData = (channel, data) => set(channel + '_activity_f
 
 export const getApiType = (channel) => get(channel + '_api_type')
 
-export const setApiType = (channel, data) => set(channel + '_api_type', data)
+export const setApiType = (channel, data) => set(channel + '_api_type', data)
+
+export const getParkingMerchantId = (channel) => get(channel + '_parking_merchant_id')
+
+export const setParkingMerchantId = (channel, data) => set(channel + '_parking_merchant_id', data)
+
+export const getParkingMerchantData = (channel) => get(channel + '_parking_merchant_data')
+
+export const setParkingMerchantData = (channel, data) => set(channel + '_parking_merchant_data', data)