소스 검색

feature:新增账号密码登录

shuchang 10 시간 전
부모
커밋
5cbf8971d8

+ 2 - 1
common/config/api.js

@@ -24,7 +24,8 @@ export const getMsgCountUrl = (data) => http.get('/prod-api/system/notice/myNoti
 // 修改消息
 export const modifyMsgUrl = (params, config = {}) => http.post('/prod-api/system/notice/setIsRead', params, config);
 
-
+// 账号密码登录
+export const loginByPwdUrl = (params, config = {}) => http.post('/prod-api/api/wechat/wxlogin', params, config);
 
 
 

+ 3 - 2
manifest.json

@@ -50,11 +50,12 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wxa5c97dfa28e626a9",
+        "appid" : "wx2548ce44d5cab80f",
         "setting" : {
             "urlCheck" : false,
             "postcss" : true,
-            "minified" : true
+            "minified" : true,
+            "es6" : true
         },
         "usingComponents" : true,
         "mergeVirtualHostAttributes" : true,

+ 7 - 0
pages.json

@@ -129,6 +129,13 @@
 					"navigationStyle": "custom",
 					"navigationBarTitleText": "护理打卡-死亡表单"
 				}
+			},
+			{
+				"path": "login-pwd/login-pwd",
+				"style": {
+					"navigationStyle": "custom",
+					"navigationBarTitleText": "账号密码登录"
+				}
 			}
 		]
 	}],

+ 179 - 0
pages/subpack/login-pwd/login-pwd.vue

@@ -0,0 +1,179 @@
+<template>
+	<view class="flex-column" style="height: 100vh;">
+		<up-navbar title="特困户看护" bgColor="transparent" leftIcon='' :title-style="{fontWeight:'bold'}">
+		</up-navbar>
+		<image src="/pages/subpack/static/images/logo-header-bg.png" style="width: 750rpx;height: 510rpx;"
+			mode="aspectFill"></image>
+		<view class="flex-column flex-1 bg-white px-5"
+			style="margin-top: -50rpx;z-index: 9;border-radius: 48rpx 48rpx 0rpx 0rpx;padding-top: 48rpx;">
+
+			<view class="flex-row align-center" style="margin-left: 18rpx;">
+				<image src="/pages/subpack/static/images/login-phone-icon.png" style="width: 36rpx;height: 36rpx;"
+					mode="aspectFill">
+				</image>
+				<text class="font-md ml-08" style="color: #002F61;">用户名</text>
+			</view>
+			<view class="flex-column justify-center mt-08 px-4"
+				style="height: 88rpx;border-radius: 50rpx;background: rgba(215, 231, 255, 0.3);">
+				<u-input placeholder="请输入用户名" v-model.trim="phone" border="none" :maxlength="11"
+					:fontSize="16" clearable></u-input>
+			</view>
+
+			<view class="flex-row align-center" style="margin-left: 18rpx;margin-top: 36rpx;">
+				<image class="ml-08" src="/pages/subpack/static/images/login-pwd-icon.png"
+					style="width: 36rpx;height: 36rpx;" mode="aspectFill">
+				</image>
+				<text class="font-md ml-08" style="color: #002F61;">密码</text>
+			</view>
+			<view class="flex-row align-center justify-between mt-08 px-4"
+				style="height: 88rpx;border-radius: 50rpx;background: rgba(215, 231, 255, 0.3);">
+				<u-input placeholder="请输入密码" v-model.trim="password" :maxlength="16" border="none" :fontSize="16"
+					:password="sawPwd"></u-input>
+				<image
+					:src="sawPwd?'/pages/subpack/static/images/eye-close.png':'/pages/subpack/static/images/saw-pwd.png'"
+					style="width: 48rpx;height: 48rpx;margin-left: 20rpx;" mode="aspectFill" @click="sawPwd = !sawPwd">
+				</image>
+			</view>
+			<view v-if="formType === 1" class="flex-row align-center" style="margin-top: 6rpx;">
+				<image src="/pages/subpack/static/images/login-warn.png" style="width: 36rpx;height: 36rpx;"
+					mode="aspectFill">
+				</image>
+				<text style="font-size: 22rpx;margin-left: 8rpx;">8-16位字符,必须包含大写字母、小写字母、数字以及特殊字符</text>
+			</view>
+
+			<view class="flex-column align-center" style="margin-top: 220rpx;">
+				<view class="flex-row align-center justify-center w-100p"
+					style="height: 88rpx;background: linear-gradient(100deg, #477EFF 11%, #3CE5FF 92%);box-shadow: 0px 6px 16px 0px rgba(71, 197, 255, 0.5);border-radius: 56px;"
+					@click="checkForm">
+					<text class="font-md text-white">{{formType === 1?'注册':'登录'}}</text>
+				</view>
+				<!-- <text class="font-md" style="margin-top: 68rpx;color: #4794FF;"
+					@click="goRegister">{{formType === 1?'我有账号,去登录':'还没有账号,去注册'}}</text> -->
+			</view>
+
+		</view>
+	</view>
+</template>
+
+<script>
+	import {
+		loginByPwdUrl,
+		getUserInfoUrl
+	} from '@/common/config/api.js'
+	// import {
+	// 	checkPwdPattern
+	// } from '@/utils/common-utils.js'
+	export default {
+		data() {
+			return {
+				phone: '',
+				sawPwd: true,
+				password: '',
+				// 0-登录 1-注册
+				formType: 0
+			}
+		},
+		methods: {
+			checkForm() {
+				if (!this.phone) {
+					return uni.$u.toast('请输入用户名')
+				}
+				// if (!uni.$u.test.mobile(this.phone)) {
+				// 	return uni.$u.toast('请输入正确的手机号码')
+				// }
+				// if (this.password.length < 8) {
+				// 	return uni.$u.toast('请输入8-16位的密码')
+				// }
+
+				if (this.formType === 0) {
+					return this.startLogin()
+				}
+
+				// if (!checkPwdPattern(this.password)) {
+				// 	return uni.$u.toast('密码必须包含大写字母、小写字母、数字以及特殊字符')
+				// }
+				this.startRegister();
+			},
+			// 注册
+			startRegister() {
+				uni.showLoading({
+					title: '注册中...'
+				})
+				registerUrl({
+						// nickName: '用户' + this.phone.slice(-4),
+						phoneNumber: this.phone,
+						password: this.password
+					})
+					.then(res => {
+						console.log('注册: ', res);
+						uni.hideLoading();
+						uni.$u.toast('注册成功,请登录');
+						this.goRegister();
+					})
+					.catch(err => {
+						console.log('err: ', err);
+						uni.hideLoading();
+					})
+			},
+			// 登录
+			startLogin() {
+				uni.showLoading({
+					title: '登录中'
+				})
+				loginByPwdUrl({
+						username: this.phone,
+						password: this.password
+					})
+					.then(res => {
+						console.log('登录: ', res);
+						// proxy.$u.vuex('vuex_userId', res)
+						// 获取用户信息
+						this.$u.vuex('vuex_token', res.token);
+						this.getUserInfo(res.token);
+					})
+					.catch(err => {
+						uni.hideLoading();
+						console.log('err: ', err);
+					})
+			},
+			// 获取用户信息
+			getUserInfo(userId) {
+				getUserInfoUrl()
+					.then(res => {
+						console.log('用户信息: ', res);
+						uni.hideLoading();
+						let user = {
+							avatar: '',
+							nickName: res.user.nickName,
+							phonenumber: res.user.phonenumber,
+							roles: res.roles
+						}
+						this.$u.vuex('vuex_user', user);
+						uni.switchTab({
+							url: '/pages/tabbar/application/application'
+						})
+					})
+					.catch(err => {
+						console.log('err: ', err);
+						uni.hideLoading();
+					})
+			},
+			// 改变成注册
+			goRegister() {
+				if (this.formType === 0) {
+					this.formType = 1;
+				} else {
+					this.formType = 0;
+				}
+				// 重置表单
+				this.phone = '';
+				this.password = '';
+				this.sawPwd = true;
+			}
+		}
+	}
+</script>
+
+<style>
+
+</style>

+ 27 - 6
pages/subpack/pages/login/login.vue

@@ -15,6 +15,14 @@
 					<text class="text-white font-md font-weight-500">一键快捷登录</text>
 				</view>
 			</view>
+
+			<view class="w-750 flex-column align-center" style="margin-top: 20rpx;">
+				<view class="flex-row align-center justify-center"
+					style="width: 606rpx;height: 96rpx;background: linear-gradient( 90deg, #2086FF 0%, #305BFF 100%);box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(48,91,255,0.32);border-radius: 50rpx;border: 2rpx solid #FFFFFF;"
+					@click="handleLoginPwd">
+					<text class="text-white font-md font-weight-500">账号密码登录</text>
+				</view>
+			</view>
 		</view>
 
 	</view>
@@ -30,12 +38,20 @@
 			return {}
 		},
 		methods: {
+
+			handleLoginPwd() {
+				uni.navigateTo({
+					url:'/pages/subpack/login-pwd/login-pwd'
+				})
+			},
+
 			getUserInfo() {
-				getUserInfoUrl({
-						custom: {
-							catch: true
-						}
-					})
+				// {
+				// 	custom: {
+				// 		catch: true
+				// 	}
+				// }
+				getUserInfoUrl()
 					.then(res => {
 						uni.hideLoading();
 						console.log('用户信息', res);
@@ -65,9 +81,14 @@
 					})
 					.then(res => {
 						console.log('微信登录', res);
+						// return uni.$u.route('/pages/subpack/pages/bindInfo/bindInfo', {
+						// 	openId: res.openId
+						// });
+
+
 						if (res.token) {
 							this.$u.vuex('vuex_token', res.token);
-							this.getUserInfo();
+							return this.getUserInfo();
 						};
 						if (res.openId) {
 							// 没有注册过

BIN
pages/subpack/static/images/eye-close.png


BIN
pages/subpack/static/images/login-phone-icon.png


BIN
pages/subpack/static/images/login-pwd-icon.png


BIN
pages/subpack/static/images/login-warn.png


BIN
pages/subpack/static/images/logo-header-bg.png


BIN
pages/subpack/static/images/saw-pwd.png


+ 7 - 0
pages/tabbar/application/application.vue

@@ -49,6 +49,13 @@
 		getUserInfoUrl,
 		getMsgCountUrl
 	} from '@/common/config/api.js'
+	
+	import {
+		getDict
+	} from '@/common/status/index.js'
+	import {
+		getCareInfo
+	} from '@/common/config/application-api.js'
 	export default {
 		data() {
 			return {

+ 1 - 1
utils/request/index.js

@@ -10,7 +10,7 @@ import {
 //  初始化请求配置
 const initRequest = (vm) => {
 	http.setConfig((defaultConfig) => {
-		defaultConfig.baseURL = 'http://8.155.45.217' /* 根域名 */
+		defaultConfig.baseURL = 'https://www.nctkh.cn/' /* 根域名 */
 		// defaultConfig.baseURL = 'http://tkhtest.natapp1.cc' /* 根域名 */
 		// defaultConfig.baseURL = 'http://127.0.0.1' /* 根域名 */
 		defaultConfig = {