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

按小程序要求, 调整 不允许一进去就要求登录

zhengkaixin пре 1 месец
родитељ
комит
c894e9c15e

+ 11 - 9
components/componentLogin.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<u-popup v-model="show" mode="center" border-radius="24" :closeable="false" :mask-close-able="false" @close="close">
+		<u-popup v-model="show" mode="center" border-radius="24" :closeable="false" :mask-close-able="true" @close="close">
 			<view class="u-mode-center-main">
 		
 		
@@ -52,7 +52,8 @@
 		},
 		data() {
 			return {
-				show:false
+				show:false,
+				userInfo:{},
 			};
 		},
 		methods: {
@@ -72,7 +73,7 @@
 					openId: this.jphelp.getOpenId(),
 					noerror: true
 				}).then((res) => {
-					
+					this.userInfo=res.data.regUser;
 					this.jphelp.setPersonInfo(res.data.regUser);
 					this.jphelp.setToken(res.data.token);
 					this.jphelp.setPersonInfoPlus(res.data);
@@ -93,14 +94,15 @@
 			},
 			close() {
 				// #ifdef MP-WEIXIN
-				if (this.userInfo.id) {
 				
-				} else {
-					uni.switchTab({
-						url: "/pages/index/index"
-					})
-				}
 				// #endif
+				// if (this.userInfo.id) {
+				
+				// } else {
+				// 	uni.switchTab({
+				// 		url: "/pages/index/index"
+				// 	})
+				// }
 			},
 			createUser(phone) {
 				this.show=false

+ 4 - 4
config/.env.dev.js

@@ -8,13 +8,13 @@ const UNI_APP = {
 	NODE_ENV :"dev",
 	SIMPLE_RUN:false,// 无视权限控制跳转页面   , 用于样式人员快速访问各种功能 ,快速测试等
 
-	openId:"oK9Wr5zv8lvirni3txbxRkmpg8d0",//shuzhan test
+	//openId:"oK9Wr5zv8lvirni3txbxRkmpg8d0",//shuzhan test
 	
-	//openId:"oZqT965CNt_9dQYUlQf_MVuMo7E0",//zkx prod
+	openId:"oZqT965CNt_9dQYUlQf_MVuMo7E0",//zkx prod
 	//openId:"oZqT960soc9gDkD7XQ6BTsDgcofs",//lgx
 	
-	openId:"oZqT96_BOFyBWx6rq_SIxQq67u5A",
-	openId:"oZqT967cBtMmxcW7g3Z0HYJHd_fc",
+	//openId:"oZqT96_BOFyBWx6rq_SIxQq67u5A",
+	//openId:"zkx001",
 }  
 
 module.exports = UNI_APP;

+ 11 - 1
main.js

@@ -74,7 +74,17 @@ Vue.mixin({
 				return distance.toFixed(2)+'公里'
 			}
 		},
-		gotoUrl(url,tab) {
+		gotoUrl(url,isLogin) {
+			
+			if(isLogin){
+				if(!this.jphelp.getPersonInfo().id){
+					uni.showToast({
+						title: "当前用户未登录",
+						icon: "none"
+					})	
+					return 
+				}
+			}
 			uni.navigateTo({
 				url: "/" + url
 			})

+ 19 - 8
pages/business/lockInfo.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<componentLogin ref="refLogin"  :check="1"
+		<componentLogin ref="refLogin"  :check="0"
 		@findByOpenId="findByOpenId"></componentLogin>
 		<u-popup v-model="showMessage" mode="bottom" border-radius="30">
 			<view class="showMessage">
@@ -169,6 +169,10 @@
 				ref="uModal" title="提示" content="是否结束使用当前地锁?" confirm-text="结束"></u-modal>
 			
 			
+			<u-modal v-model="loginBl" @confirm="loginconfirm" confirm-color="#fa3534" :show-cancel-button="true"
+				ref="uModal" title="提示" content="当前用户未登录,是否前往登录" confirm-text="结束"></u-modal>
+			
+			
 			<u-modal v-model="openModalBl" @confirm="confirmPhone" confirm-text="拨打电话" confirm-color="#606266"
 				:show-cancel-button="true" ref="uModal" :asyncClose="true" title="客服电话" :content="content"
 				:content-style="{fontSize: '24px',color: '#101010'}"></u-modal>
@@ -267,6 +271,13 @@
 		},
 		onReady() {
 			this.$refs.refLogin.findByOpenId()
+			this.setIntervalId = setInterval(() => {
+				this.getFloorlockDetails(1)
+			}, 1000 * 3)
+			
+			this.jphelp.setInterval("lockInfo",this.setIntervalId)
+			
+			this.getFloorlockDetails()
 			
 		},
 		onUnload() {
@@ -279,13 +290,7 @@
 		methods: {
 			findByOpenId(res) {
 				
-				this.setIntervalId = setInterval(() => {
-					this.getFloorlockDetails(1)
-				}, 1000 * 3)
 				
-				this.jphelp.setInterval("lockInfo",this.setIntervalId)
-				
-				this.getFloorlockDetails()
 				
 			},
 			confirmPhone() {
@@ -379,9 +384,15 @@
 			},
 			lockStatus0(){
 				this.openModalBl=true;
+			},
+			loginconfirm(){
+				this.$refs.refLogin.ashow()
 			},
 			operateBtn() {
-				if(this.floorlockInfo.status==0){
+				if(!this.jphelp.getPersonInfo().id){
+					this.loginBl=true;
+					
+				}else if(this.floorlockInfo.status==0){
 					this.lockStatus0()
 				}else{
 					if(this.floorlockInfo.lockStatus==4){

+ 18 - 24
pages/index/center.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="jpmain  ">
-		<componentLogin ref="refLogin"  :check="1" @findByOpenId="findByOpenId"></componentLogin>
+		<componentLogin ref="refLogin"  :check="0" @findByOpenId="findByOpenId"></componentLogin>
 		<view class="gradient-header">
 			<view class="jpback">
 
@@ -9,43 +9,26 @@
 
 		<view class="body">
 
-			<view class="page-top" @click="gotoUrl('pages/information/information')" >
+			<view class="page-top" @click="gotoInformation" >
 
 				<view class="name">
 					<view class="photo">
 						<img class="img" :src="userInfo.headImg" v-if="userInfo.headImg" alt="">
 					</view>
 					<view class="text">
-						<view class="text1">{{userInfo.nickName}}</view>
-						<view class="text2">{{userInfo.phone}}</view>
+						<view class="text1">{{userInfo.id?userInfo.nickName:'未登录'}}</view>
+						<view class="text2">{{userInfo.id?userInfo.phone:'点击登录'}}</view>
 					</view>
 				</view>
 				<view class="value">
 					<u-icon name="arrow-right" size="24" color="#fff"></u-icon>
 				</view>
 			</view>
-			<view class="page" v-if="0">
-				<view class="page-main">
-
-					<view class="item"   @click="gotoUrl('pages/mylock/myLock')" 
-					v-if="userInfoPlus&&userInfoPlus.myAllList" >
-						<view class="name">{{userInfoPlus.myAllList.length}}</view>
-						<view class="value">车位</view>
-					</view>
-					<view class="item2">
-
-					</view>
-					<view class="item"  @click="gotoUrl('pages/mylock/myWhite')"  >
-						<view class="name">{{whiteNum}}</view>
-						<view class="value">白名单</view>
-					</view>
-
-				</view>
-			</view>
+	
 			<view class="page">
 
 				<view class="page-content">
-					<view class="item" @click="gotoUrl('pages/mylock/myLock')" >
+					<view class="item" @click="gotoUrl('pages/mylock/myLock',1)" >
 						<view class="title">
 							<img class="img" src="@/assets/img/center/icon1.svg" alt="">
 							我的地锁
@@ -55,7 +38,7 @@
 						</view>
 					</view>
 					<view class="item" 
-					@click="gotoUrl('pages/information/parkingRecord')" >
+					@click="gotoUrl('pages/information/parkingRecord',1)" >
 						<view class="title">
 							<img class="img" src="@/assets/img/center/icon2.svg" alt="">
 							停车记录
@@ -107,6 +90,10 @@
 			this.$refs.refLogin.findByOpenId()
 		},
 		onShow() {
+			if(this.$refs.refLogin){
+				this.$refs.refLogin.findByOpenId()
+			}
+			
 			this.userInfo = this.jphelp.getPersonInfo()
 			this.userInfoPlus=this.jphelp.getPersonInfoPlus()
 			if(this.isReady){
@@ -115,6 +102,13 @@
 		
 		},
 		methods: {
+			gotoInformation(){
+				if(this.jphelp.getPersonInfo().id){
+					this.gotoUrl('pages/information/information',1)
+				}else{
+					this.$refs.refLogin.ashow()
+				}
+			},
 			getWhiteFloorlockList(){
 				uni.showLoading({
 					title: "加载中",

+ 5 - 3
pages/index/index.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="jpmain body">
-		<componentLogin ref="refLogin"  :check="1"
+		<componentLogin ref="refLogin"  :check="0"
 		@findByOpenId="findByOpenId"></componentLogin>
 
 		<view class="Area Area1" v-if="pointAuthorize">
@@ -84,7 +84,7 @@
 				longitude: 112.240222,
 			
 				allList: [],
-				isReady:false,
+				isReady:true,
 				point: false, //是否获取了定位
 			}
 		},
@@ -94,6 +94,7 @@
 		},
 		onReady() {
 			this.$refs.refLogin.findByOpenId()
+			//this.getParkingList()
 			
 		},
 		onShow() {
@@ -235,7 +236,8 @@
 
 <style scoped lang="scss">
 	.body {
-		padding: 32rpx;
+		padding: 32rpx;
+		padding-top:40rpx;
 	}
 	
 	.value-slot {

+ 15 - 9
pages/index/main/parkingDetails.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="jpmain ">
-		<componentLogin ref="refLogin"  :check="1"
+		<componentLogin ref="refLogin"  :check="0"
 		@findByOpenId="findByOpenId"></componentLogin>
 		<view class="title">
 			<view class="name">
@@ -202,7 +202,14 @@
 			
 		},
 		onReady() {
-			this.$refs.refLogin.findByOpenId()
+			//this.$refs.refLogin.findByOpenId()
+			this.isReady=true;
+			this.getParkingDetails()
+			
+			this.setIntervalId=setInterval(()=>{
+				this.getParkingFloorlockList(1)
+			},1000*3)
+			this.jphelp.setInterval("parkingDetails",this.setIntervalId)
 			
 		},
 		onUnload() {
@@ -227,17 +234,16 @@
 		},
 		methods: {
 			findByOpenId(res) {
-				this.isReady=true;
-				this.getParkingDetails()
 				
-				this.setIntervalId=setInterval(()=>{
-					this.getParkingFloorlockList(1)
-				},1000*3)
-				this.jphelp.setInterval("parkingDetails",this.setIntervalId)
 			},
 			clickStar(){
 				//this.isStar=!this.isStar
-				this.setPreferred()
+				if(this.jphelp.getPersonInfo().id){
+					this.setPreferred()
+				}else{
+					this.$refs.refLogin.ashow()
+				}
+				
 			},
 			gotoMain(){
 				uni.switchTab({

+ 2 - 2
pages/information/parkingInfo.vue

@@ -91,7 +91,7 @@
 			
 		</view>
 		
-		<view class="main">
+		<view class="main" v-if="0">
 			<view class="item">
 				<view class="name">
 					地锁状态
@@ -101,7 +101,7 @@
 					{{info.floorlockInfo.lockStatusN}}
 				</view>
 			</view>
-			<view class="item" v-if="0">
+			<view class="item" >
 				<view class="name">
 					电池电量