hsb hace 4 meses
padre
commit
0358e56088
Se han modificado 6 ficheros con 125 adiciones y 160 borrados
  1. 10 0
      pages.json
  2. 43 32
      pages/info/info.vue
  3. 5 3
      pages/info/userInfo.vue
  4. 16 2
      pages/login/login.vue
  5. 46 106
      pages/login/register.vue
  6. 5 17
      pages/ucenter/settings.vue

+ 10 - 0
pages.json

@@ -24,6 +24,16 @@
 			}
 		},
 		{
+			"path": "pages/login/register",
+			"style": {
+				"navigationBarTitleText": "注册",
+				"app-plus": {
+					"animationType": "none",
+					"popGesture": "none"
+				}
+			}
+		},
+		{
 			"path": "pages/info/userInfo",
 			"style": {
 				"navigationBarTitleText": "用户信息",

+ 43 - 32
pages/info/info.vue

@@ -10,9 +10,11 @@
 			<view class="userInfo" @click.capture="toUserInfo">
 				<!-- <u-avatar :src="userInfo.avatar" size="120rpx"></u-avatar> -->
 				<view class="logo-title">
-					<view class="user-name">
-						<span>退出登录</span>
+					<view class="user-name" v-if="hasLogin"> 
+						<span>{{userInfo.displayName||userInfo.username}}</span>
+						<!-- <span>退出登录</span> -->
 					</view>
+						<text class="user-name" v-else>{{$t('mine.notLogged')}}</text>
 				</view>
 			</view>
 		</view>
@@ -190,37 +192,46 @@
 				setUserInfo: "user/login",
 			}),
 			toUserInfo() {
-					uni.showModal({
-						title: this.$t('settings.tips'),
-						content: this.$t('settings.exitLogin'),
-						cancelText: this.$t('settings.cancelText'),
-						confirmText: this.$t('settings.confirmText'),
-						success: res => {
-							if (res.confirm) {
-								uni.removeStorageSync('token')
-								uni.removeStorageSync('tenantId')
-								uni.removeStorageSync('userId')
-								uni.removeStorageSync('userName')
-								uni.removeStorageSync('userInfo')
-								uni.removeStorageSync('userType')
-								uni.removeStorageSync('tenantInfo')
-								uni.removeStorageSync('currentTenantId')
-								uni.removeStorageSync('currentVehicleInfo')
-								uni.removeStorageSync('isAuditUser')
-								uni.removeStorageSync('isDealerUser')
-								uni.removeStorageSync('isDriverUser')
-								uni.removeStorageSync('enterpriseInfo')
-								uni.removeStorageSync('serverAddress');
-								uni.removeStorageSync('serverPrefix');
-								uni.reLaunch({
-									url: '/pages/login/login'
-								});
-								getApp().globalData.tabIndex = 'home';
-							}
-						},
-						fail: () => {},
-						complete: () => {}
+				if(this.hasLogin){
+					uni.navigateTo({
+						url: "/pages/info/userInfo?changePwd=0",
 					});
+					// uni.showModal({
+					// 	title: this.$t('settings.tips'),
+					// 	content: this.$t('settings.exitLogin'),
+					// 	cancelText: this.$t('settings.cancelText'),
+					// 	confirmText: this.$t('settings.confirmText'),
+					// 	success: res => {
+					// 		if (res.confirm) {
+					// 			uni.removeStorageSync('token')
+					// 			uni.removeStorageSync('tenantId')
+					// 			uni.removeStorageSync('userId')
+					// 			uni.removeStorageSync('userName')
+					// 			uni.removeStorageSync('userInfo')
+					// 			uni.removeStorageSync('userType')
+					// 			uni.removeStorageSync('tenantInfo')
+					// 			uni.removeStorageSync('currentTenantId')
+					// 			uni.removeStorageSync('currentVehicleInfo')
+					// 			uni.removeStorageSync('isAuditUser')
+					// 			uni.removeStorageSync('isDealerUser')
+					// 			uni.removeStorageSync('isDriverUser')
+					// 			uni.removeStorageSync('enterpriseInfo')
+					// 			uni.removeStorageSync('serverAddress');
+					// 			uni.removeStorageSync('serverPrefix');
+					// 			uni.reLaunch({
+					// 				url: '/pages/login/login'
+					// 			});
+					// 			getApp().globalData.tabIndex = 'home';
+					// 		}
+					// 	},
+					// 	fail: () => {},
+					// 	complete: () => {}
+					// });
+				}else{
+					uni.reLaunch({
+						url: "/pages/login/login"
+					})
+				}	
 			},
 			toPage(url) {
 				uni.navigateTo({

+ 5 - 3
pages/info/userInfo.vue

@@ -60,7 +60,7 @@
 			</u-form>
 		</view>
 		<view class="edit-btn">
-			<button @click="submit">{{$t("base.button.confirm")}}</button>
+			<u-button type="primary" @click="submit">{{$t("base.button.confirm")}}</u-button>
 		</view>
 
 	</view>
@@ -253,6 +253,8 @@
 						if (res.statusCode == 200 && res.data.code == 0) {
 							uni.$u.toast(_this.$t("userinfo.setSucceeded"))
 							this.updataUserInfo()
+						}else{
+							uni.$u.toast(res.data.msg)
 						}
 					})
 				}).catch(errors => {
@@ -306,8 +308,8 @@
 		.edit-btn {
 			position: fixed;
 			bottom: 0;
-			height: 150rpx;
-			padding: 0 64rpx;
+			// height: 150rpx;
+			padding: 24rpx 64rpx;
 			width: calc(100% - 128rpx);
 			background-color: #fff;
 			border-top-right-radius: 60rpx;

+ 16 - 2
pages/login/login.vue

@@ -1,8 +1,8 @@
 <template>
 	<view class="content">
 		<view class="logo">
-			<image style="height:104rpx;width:104rpx" src="/static/czzn-img/login/logo.png" mode="aspectFit" />
-			<view class="app-name">{{$t('login.e')}}</view>
+			<image style="height:104rpx;width:104rpx" src="/static/logo.png" mode="aspectFit" />
+			<view class="app-name">计数通</view>
 		</view>
 		<!-- 账号密码登录 -->
 		<template v-if="loginType == 1">
@@ -30,6 +30,13 @@
 			<u-button type="primary" shape="circle" :disabled="!agree[0]"
 				@click="loginType == 1 ? onAccountLogin() : onPhoneLogin()">{{ $t('login.login') }}</u-button>
 		</view>
+		<!-- 切换登陆方式/注册 -->
+		<view class="login-opertion">
+			<!-- <span class="flex" @click="changeLoginType">{{ loginType == 1 ? $t('login.phoneLogin') : $t('login.pwdLogin')
+			}}</span>
+			<span class="line"></span> -->
+			<span class="flex" @click="toRegister">{{ $t('login.register') }}</span>
+		</view>
 	</view>
 </template>
 
@@ -96,6 +103,12 @@
 			...mapMutations({
 				setUserInfo: 'user/login'
 			}),
+			//去注册
+			toRegister() {
+				uni.navigateTo({
+					url: '/pages/login/register'
+				})
+			},
 			//账号登录
 			onAccountLogin() {
 				console.log("登录信息、", this.loginForm);
@@ -162,6 +175,7 @@
 							icon: "none",
 							duration: 2500,
 						})
+						this.setUserInfo(res.data.data.sysUser)
 					} else if (res.statusCode != 200 || res.data.code === 1) {
 						uni.showToast({
 							title: res.data.error || res.data.msg,

+ 46 - 106
pages/login/register.vue

@@ -3,71 +3,57 @@
 		<view  class="logo">
 			<image
 				style="height:104rpx;width:104rpx"
-				src="/static/czzn-img/login/logo.jpg"
+				src="/static/logo.png"
 				mode="aspectFit"
 			/>
-			<view class="app-name">{{$t('login.e')}}</view>
 		</view>
 		<view class="login-title">
 			<span>{{$t('login.register')}}</span>
 		</view>
-		<!-- 公司编号 -->
+		<!-- 账号密码登录 -->
 		<view class="inp_box">
-			<input type="text" v-model="registerForm.code" :placeholder="this.$t('login.codePlaceholder')" @blur="getUrl" />
+			<u-input type="text" :border="false" v-model="registerForm.phone" placeholder="请输入用户名" />
 		</view>
-		<!-- 名称 -->
+		<!-- 账号密码登录 -->
 		<view class="inp_box">
-			<input type="text" v-model="registerForm.displayName" :placeholder="this.$t('login.displayNamePlaceholder')" />
+			<u-input type="text" :border="false" v-model="registerForm.displayName" placeholder="请输入显示名" />
 		</view>
-		<!-- 手机号 -->
+		<!-- 账号密码登录 -->
 		<view class="inp_box">
-			<input type="text" maxlength="11" @input="phoneInput" v-model="registerForm.phone" :placeholder="this.$t('login.phonePlaceholder')" />
+			<u-input type="password" :border="false" v-model="registerForm.password" placeholder="请输入密码" />
 		</view>
-		<!-- 密码 -->
+
 		<view class="inp_box">
-			<input type="text" v-model="registerForm.password" :placeholder="this.$t('login.passwordPlaceholder')" />
+			<u-input type="password" :border="false" v-model="registerForm.password2" placeholder="请输入确认密码" />
 		</view>
-		<!-- 验证码
-		<view class="inp_box">
-			<input v-model="registerForm.verificationCode"
-				:placeholder="this.$t('login.verifyCodePlaceholder')" />
-			<button :class="time!=0?'load-reget':''" @click="getCode" :disabled='time!=0'
-				class="get-code-btn">{{isGetCode?$t("login.reGetCode"):$t("login.getCode")}}{{time?`(${time}s)`:''}}</button>
-		</view> -->
-		<view class="btn-wrap">
 
-			<button @click="phoneLogin" :class="urlFlag ? 'bind-btn' : 'btn-disabled'" :disabled="!urlFlag">{{$t('login.register')}}</button>
-		</view>
+		<u-button type="primary" shape="circle" @click="phoneLogin">{{$t('login.register')}}</u-button>
 	</view>
 </template>
 <script>
 	import {
 		getRegTelCode,
-		register,
-		getUrlByCode,
-		bindNameCode
+		register
 	} from '../../api/login'
 	export default {
 		data() {
 			return {
-				serverStatus:'',
-				agree: [],
 				time: 0,
 				timer: '',
 				isGetCode: false,
+
 				option: [{
 					text: '',
 					value: 1,
 				}],
 				registerForm: {
-					code:"",
 					phone: "",
 					password:"",
 					displayName: "",
 					verificationCode: "",
 					type: "",
+					password2:'',
 				},
-				urlFlag:false,
 				roleList: [{
 						value: 0,
 						text: this.$t("login.dealer")
@@ -76,48 +62,13 @@
 						value: 1,
 						text: this.$t("login.driver")
 					}
-				]
+				],
 			}
 		},
 		onLoad(options) {
-			this.registerForm.type = options.type
-			this.serverStatus=uni.getStorageSync('serverStatus');
+			this.registerForm.type = '3'
 		},
 		methods: {
-			//手机号输入
-			phoneInput(){
-				if(this.registerForm.phone.length >11){
-					uni.showToast({
-						title: this.$t('base.smsCode.phoneTooLong'),
-						icon: 'none'
-					})
-				}
-			},
-			//获取请求地址
-			getUrl(){
-				if (this.registerForm.code == '') {
-					uni.showToast({
-						title: this.$t('login.codePlaceholder'),
-						icon: "none",
-						duration: 2500,
-					})
-				}else{
-					getUrlByCode(this.registerForm.code).then(r=>{
-						if (r.statusCode === 200 && r.data.code === 0) {
-							let data = r.data.data
-							uni.setStorageSync('serverAddress', data.requestUrl);
-							uni.setStorageSync('serverPrefix', data.methodPrefix);
-							this.urlFlag = true
-						}else{
-							uni.showToast({
-								title: r.data.msg,
-								icon: "none",
-								duration: 2500,
-							})
-						}
-					})
-				}
-			},
 			backLogin() {
 				uni.navigateBack({
 					delta: 1
@@ -125,7 +76,7 @@
 			},
 			//获取验证码
 			getCode() {
-				let phone = /^\d{9}$/
+				let phone = /^1[3-9]\d{9}$/
 				if (!this.registerForm.type) {
 					uni.showToast({
 						title: this.$t('login.displayNamePlaceholder'),
@@ -152,7 +103,7 @@
 				}
 				if (!this.registerForm.phone) {
 					uni.showToast({
-						title: this.$t('login.phonePlaceholder'),
+						title: "请输入用户名",
 						icon: "none",
 						duration: 2500,
 					})
@@ -191,15 +142,7 @@
 			},
 			//注册并登录
 			phoneLogin() {
-				let phone = /^\d{9}$/
-				if (this.registerForm.code == '' || !this.urlFlag) {
-					uni.showToast({
-						title: this.$t('login.codePlaceholder'),
-						icon: "none",
-						duration: 2500,
-					})
-					return;
-				}
+				let phone = /^1[3-9]\d{9}$/
 				if (this.registerForm.displayName == '') {
 					uni.showToast({
 						title: this.$t('login.displayNamePlaceholder'),
@@ -218,7 +161,7 @@
 				}
 				if (this.registerForm.phone == '') {
 					uni.showToast({
-						title: this.$t('login.phonePlaceholder'),
+						title: "请输入用户名",
 						icon: "none",
 						duration: 2500,
 					})
@@ -232,27 +175,27 @@
 				// 	})
 				// 	return;
 				// }
-				// if (this.registerForm.verificationCode == '') {
-				// 	uni.showToast({
-				// 		title: this.$t('login.verifyCodePlaceholder'),
-				// 		icon: "none",
-				// 		duration: 2500,
-				// 	})
-				// 	return;
-				// }
-				let datasss = JSON.parse(JSON.stringify(this.registerForm))
-				datasss.tenantId = this.registerForm.code
-				register(datasss).then(res => {
-					if (res.statusCode == 200 && res.data.code==0) {
-						let data = {
-						username: this.registerForm.phone,
-						companyCode: this.registerForm.code
-					}
-					bindNameCode(data).then(res=>{
-						if (res.statusCode === 200 && res.data.data.code === 0) {
-							uni.showToast({
-							title: '注册成功',
+				if (this.registerForm.password!=this.registerForm.password2) {
+					uni.showToast({
+						title: '两次密码不一样',
+						icon: "none",
+						duration: 2500,
+					})
+					return;
+				}
+
+				this.registerForm.username=this.registerForm.phone
+				uni.showLoading({
+					title: '注册中',
+					mask: true
+				})
+				register(this.registerForm).then(res => {
+					console.log(res);
+					if (res.data == this.registerForm.phone) {
+						uni.showToast({
+							title: '注册成功,稍等跳转',
 							icon: "none",
+							mask:true,
 							duration: 2000,
 						})
 						setTimeout(() => {
@@ -260,17 +203,14 @@
 								url: `/pages/login/login?username=${this.registerForm.phone}`
 							})
 						}, 2000)
-						}else{
-							this.canLogin = false
-							uni.showToast({
-								title: res.data.data.msg,
-								icon: "none",
-								duration: 2500,
-							})
-						}
-					})
-						
 					}
+					uni.hideLoading()
+					// this.registerForm.phone=''
+					this.registerForm.password=''
+					this.registerForm.password2=''
+					this.registerForm.displayName=''
+				}).finally(()=>{
+					uni.hideLoading()
 				})
 
 			},

+ 5 - 17
pages/ucenter/settings.vue

@@ -7,33 +7,20 @@
 			</uni-list-item>
 			<!-- <uni-list-item v-if="userInfo.mobile" :title="$t('settings.changePassword')" :to="'/subpages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber='+ userInfo.mobile" link="navigateTo"></uni-list-item> -->
 		</uni-list>
-		<uni-list class="mt10" :border="false">
+		<!-- <uni-list class="mt10" :border="false">
 			<uni-list-item :title="$t('settings.changePassword')" to="/pages/info/userInfo?changePwd=1"
 				link="navigateTo">
 			</uni-list-item>
-			<!-- <uni-list-item v-if="userInfo.mobile" :title="$t('settings.changePassword')" :to="'/subpages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber='+ userInfo.mobile" link="navigateTo"></uni-list-item> -->
-		</uni-list>
-		<uni-list class="mt10" :border="false">
-			<!-- #ifndef H5 -->
+		</uni-list> -->
 			<!-- #ifdef APP-PLUS -->
-			<!-- 检查push过程未结束不显示,push设置项 -->
+		<uni-list class="mt10" :border="false">
 			<uni-list-item :title="$t('settings.clearTmp')" @click="clearTmp" link></uni-list-item>
-			<!-- <uni-list-item v-show="pushIsOn != 'wait'" :title="$t('settings.pushServer')" @click.native="pushIsOn?pushServer.off():pushServer.on()"  showSwitch :switchChecked="pushIsOn"></uni-list-item> -->
-			<!-- #endif -->
-			<!-- <uni-list-item v-if="supportMode.includes('fingerPrint')" :title="$t('settings.fingerPrint')" @click.native="startSoterAuthentication('fingerPrint')" link></uni-list-item> -->
-			<!-- <uni-list-item v-if="supportMode.includes('facial')" :title="$t('settings.facial')" @click="startSoterAuthentication('facial')" link></uni-list-item> -->
-			<!-- #endif -->
-			<!-- <uni-list-item  :title="$t('settings.changeLanguage')" @click="changeLanguage"
-				:rightText="currentLanguage" link></uni-list-item> -->
-			<!-- #ifdef APP-PLUS -->
 			<uni-list-item :title="$t('settings.version')" @click="onVersionClick" link></uni-list-item>
-			<!-- #endif -->
 		</uni-list>
-		<!-- #ifdef MP-WEIXIN -->
+			<!-- #endif -->
 		<uni-list class="mt10" :border="false">
 			<uni-list-item clickable @click="deactivate" :title="$t('settings.deactivate')"></uni-list-item>
 		</uni-list>
-		<!-- #endif -->
 		<!-- 退出/登录 按钮 -->
 		<view class="bottom-back">
 			<u-button type="primary" @click="clickLogout">{{hasLogin?$t('settings.logOut'):$t('settings.login')}}</u-button>
@@ -460,6 +447,7 @@
 
 	.bottom-back {
 		padding: 0 40rpx;
+		margin: 20rpx 0;
 	}
 
 	.bottom-back-text {