shang před 1 rokem
rodič
revize
909ef61c96
3 změnil soubory, kde provedl 71 přidání a 24 odebrání
  1. 2 0
      config/api.js
  2. 9 3
      pages/index/index.vue
  3. 60 21
      pages/user/login.vue

+ 2 - 0
config/api.js

@@ -259,6 +259,8 @@ const syncpost = (f, m, d) => {
 export const register = (data, callback) => post('register', data, callback, 'discover/User');
 // 登录
 export const login = (data, callback) => post('login', data, callback, 'user/login');
+// 自动登录
+export const autoLogin = (data, callback) => post('dutyAutoLogin', data, callback, 'user');
 // 退出登录
 export const logout = (data, callback) => post('logout', data, callback, 'discover/User');
 // 上传头像

+ 9 - 3
pages/index/index.vue

@@ -857,6 +857,11 @@ export default {
 	},
 	beforeDestroy() {
 		this.stopTimer();
+		console.log('index.beforeDestroy.stopTimer');
+	},
+
+	onLoad(e) {
+		console.log('index');
 	},
 	methods: {
 		/* 搜索筛选树形结构数据 */
@@ -866,6 +871,7 @@ export default {
 		},
 		/* 刷新了 */
 		refreshBtn() {
+			console.log('index.methods.refreshBtn');
 			window.location.reload();
 		},
 		/*获取 树形数据 */
@@ -905,6 +911,7 @@ export default {
 				that.opennessTimeList = res.data;
 			});
 		},
+
 		/* 修改时间 */
 		modifyTime() {
 			this.$api.setCrOpenHoursConfig(
@@ -927,6 +934,7 @@ export default {
 		/* 开启定时获取最新事件 */
 		startTimer() {
 			if (!this.timer) {
+				console.log('getLatestEvent');
 				this.timer = setInterval(() => {
 					this.getLatestEvent();
 				}, 5000);
@@ -943,6 +951,7 @@ export default {
 				const newData = res.data;
 
 				if (newData !== null) {
+					this.latestEvents = newData;
 					if (newData.address !== undefined) {
 						if (!this.showWarn) {
 							this.showWarn = true;
@@ -957,9 +966,6 @@ export default {
 						}
 					}
 				}
-				if (newData !== null) {
-					this.latestEvents = newData;
-				}
 
 				// console.log(this.latestEvents, '最新事件');
 			});

+ 60 - 21
pages/user/login.vue

@@ -2,14 +2,13 @@
 	<view class="body2">
 		<u-navbar title="湖里区不可移动文物数字化监管平台" bgColor="#071d4f" :leftIconSize="0" titleStyle=" font-weight:bold;color:#25d7f2"></u-navbar>
 		<block>
-			<!--  #ifndef  MP-WEIXIN	 -->
 			<view class="login-bg">
 				<view class="login-card">
 					<view class="login-head">
 						<image class="logoimg" src="@/static/img/safe.png" mode="widthFix"></image>
 					</view>
 					<view class="login-input login-margin-b">
-						<input v-model="username" placeholder="请输入手机号" />
+						<input v-model="username" placeholder="请输入号" />
 					</view>
 					<view class="login-input">
 						<!-- <input :password="true" v-model="password" placeholder="请输入密码(6-16位)" /> -->
@@ -25,14 +24,12 @@
 					</view> -->
 				</view>
 			</view>
-			<!--  #endif -->
-
-			<!--  #ifdef  MP-WEIXIN	 -->
 		</block>
 	</view>
 </template>
 
 <script>
+import { registerRuntimeCompiler } from 'vue';
 var _this;
 
 export default {
@@ -51,21 +48,25 @@ export default {
 			userAgent: navigator.userAgent
 		};
 	},
-	mounted() {
-		_this = this;
-	},
+	mounted() {},
 	onLoad(e) {
-		console.log(e);
-		if (e.redirect) {
-			this.redirect = e.redirect;
+		_this = this;
+		console.log(e, 88888);
+		if (e.sign && e.time && e.username) {
+			_this.autoLogin(e.username, e.time, e.sign);
+			return;
 		}
 	},
 	onShow() {
 		this.user = this.$common.userInfo();
 		console.log('this.user: ', this.user);
-		if (typeof this.user == 'undefined' || this.user == '' || this.user == null) {
+		if (this.user == 'undefined' || this.user == '' || this.user == null) {
+			console.log('login');
 		} else {
-			this.$common.navigateTo('index');
+			console.log('/pages/index/index');
+			uni.navigateTo({
+				url: '/pages/index/index'
+			});
 		}
 		// #ifdef MP-WEIXIN
 		this.wxLogin();
@@ -73,6 +74,44 @@ export default {
 	},
 
 	methods: {
+		// 自动登录
+		autoLogin(username, time, sign) {
+			_this.$api.autoLogin(
+				{
+					username,
+					time,
+					sign
+				},
+				(data) => {
+					console.log(data, 11);
+					if (data.code == 1) {
+						try {
+							_this.$db.set('upload', 1);
+							_this.$db.set('login', 1);
+							_this.$db.set('token', data.data.userinfo.token);
+							_this.$db.set('user', data.data.userinfo);
+							_this.$db.set('auth', data.data.userinfo);
+							_this.$store.commit('setAccessToken', data.data.userinfo.token);
+							_this.$store.commit('setActivityId', 0);
+						} catch (e) {}
+						_this.loading = false;
+						_this.$common.successToShow(data.msg, function () {
+							_this.$common.navigateTo('index');
+							uni.switchTab({
+								url: '/pages/index/index'
+							});
+						});
+					} else {
+						_this.loading = false;
+						uni.showToast({
+							duration: 1500,
+							icon: 'none',
+							title: data.msg
+						});
+					}
+				}
+			);
+		},
 		changePassword: function () {
 			this.showPassword = !this.showPassword;
 		},
@@ -92,14 +131,14 @@ export default {
 		},
 		login() {
 			_this.loading = true;
-			// if (_this.username == '' || _this.username.length < 11) {
-			// 	uni.showToast({
-			// 		icon: 'none',
-			// 		title: '请输入正确的手机号'
-			// 	});
-			// 	_this.loading = false;
-			// 	return;
-			// }
+			if (_this.username == '') {
+				uni.showToast({
+					icon: 'none',
+					title: '请输入账号'
+				});
+				_this.loading = false;
+				return;
+			}
 			if (_this.password == '') {
 				uni.showToast({
 					icon: 'none',