Browse Source

登录方式

renmy 10 months ago
parent
commit
9b4229694f
1 changed files with 22 additions and 13 deletions
  1. 22 13
      pages/index/index.vue

+ 22 - 13
pages/index/index.vue

@@ -49,7 +49,7 @@
 				<view class="page-home-supplier-title">
 					换电站供应商
 				</view>
-				<!-- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"> -->
+				<template v-if="datalist.length > 0">
 					<view class="page-home-supplier-items" v-for="(item,index) in datalist" :key="index" @click="gotoSupplier(item)">
 						<view class="page-home-supplier-items-title">
 							{{item.stationName}}
@@ -58,13 +58,13 @@
 							{{item.supCount}}
 						</view>
 					</view>
-				<!-- </mescroll-body> -->
+				</template>
+				<view class="page-home-no-data" v-else>
+					暂无数据
+				</view>
 			</view>
 		</view>
-		
-		<!-- <tab-bar></tab-bar> -->
 	</view>
-
 </template>
 
 <script>
@@ -90,15 +90,16 @@
 		beforeCreate() {
 			const _that = this;
 			let token = uni.getStorageSync('token')
-			if(!token) {
-				let url = '/pages/ucenter/index'
-				uni.navigateTo({
-					url: '/pages/public/login?topage=' + url
-				})
-			} else {
+			if(token) {
 				_that.isLogin = token;
-				_that.$http.getInfoData().then(response => {
-					_that.$storage.setJson("user",response.user)
+				_that.$http.getInfoData().then(res => {
+					if(res.code == 401) {
+						uni.navigateTo({
+							url: '/pages/public/login'
+						})
+					} else if(res.code == 200) {
+						_that.$storage.setJson("user",res.user)
+					}
 				})
 			}
 		},
@@ -301,6 +302,14 @@
 						right: 10rpx;
 					}
 				}
+				.page-home-no-data {
+					font-size: 28rpx;
+					font-family: PingFang SC-Regular, PingFang SC;
+					font-weight: 400;
+					color: #1D2129;
+					line-height: 200rpx;
+					text-align: center;
+				}
 			}
 		}
 	}