Просмотр исходного кода

feat(mine/setting): 登出功能
style(login): 登陆页面样式优化 引入了colorui.css

wangpx 1 год назад
Родитель
Сommit
4c1bed92aa

+ 5 - 2
App.vue

@@ -22,9 +22,12 @@
 			    this.checkLogin()
 			  },
       checkLogin() {
+				console.log('!getUserInfo()', !getUserInfo());
         if (!getUserInfo()) {
-          $tab.reLaunch('/pages/login') 
-        }
+          $tab.reLaunch('/pages/login')
+        } else {
+          $tab.reLaunch('/pages/message/index')
+				}
       }
 		}
 	}

+ 12 - 0
api/login.js

@@ -10,4 +10,16 @@ export function login(username, password) {
 			}
 		}
 	})
+}
+
+export function logout() {
+	// return request({
+	// 	'data': {
+	// 		'serviceId': 'eu_2013V01login',
+	// 		'params': {
+ //        "userName": username,
+ //        "password": password
+	// 		}
+	// 	}
+	// })
 }

+ 8 - 8
pages.json

@@ -1,5 +1,13 @@
 {
 	"pages": [
+		{
+			"path" : "pages/login",
+			"style" : 
+			{
+				"navigationBarTitleText" : "登录",
+				"enablePullDownRefresh" : false
+			}
+		},
 		{
 			"path": "pages/message/index",
 			"style": {
@@ -143,14 +151,6 @@
 			{
 				"navigationBarTitleText" : "AI客服"
 			}
-		},
-		{
-			"path" : "pages/login",
-			"style" : 
-			{
-				"navigationBarTitleText" : "登录",
-				"enablePullDownRefresh" : false
-			}
 		}
 	],
 	"tabBar": {

+ 1 - 1
pages/contacts/index.vue

@@ -42,7 +42,7 @@
 
 <script setup lang="ts">
 	import { onMounted, ref } from 'vue'
-	import headImg from "/static/images/mine/headImg.jpg";
+	import headImg from "@/static/images/mine/headImg.jpg";
 	import $tab from '@/plugins/tab.js'
 	import { getContactAllUser } from '@/api/contacts.js'
 	onMounted(() => {

+ 7 - 11
pages/login.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="normal-login-container">
 		<view class="logo-content align-center justify-center flex">
-			<image style="width: 100rpx;height: 100rpx;"
+			<image style="width: 200rpx;height: 200rpx;"
 				src="https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png" mode="widthFix">
 			</image>
 			<text class="title">OA移动端登录</text>
@@ -23,22 +23,15 @@
 </template>
 
 <script setup lang="ts">
-	import { onMounted, ref } from 'vue'
+	import { ref } from 'vue'
 	import { useUserStore } from '@/store/user.js'
-	import { onLoad } from '@dcloudio/uni-app'
 	import $modal from '@/plugins/modal.js'
 	import $tab from '@/plugins/tab.js'
-	const toPath = ref('')
-	onLoad((option) => {
-		toPath.value = option.url || '/pages/message/index'
-	})
 	const userStore = useUserStore()
 	const loginForm = ref({
 		username: '',
 		password: ''
 	})
-	onMounted(() => {
-	})
 	function handleLogin() {
 		const username = loginForm.value.username
 		const password = loginForm.value.password
@@ -55,11 +48,14 @@
 		}
 	}
 	function loginSuccess() {
-		$tab.reLaunch(toPath.value)
+		$tab.reLaunch('/pages/message/index')
 	}
 </script>
 
 <style lang="scss">
+	@import "@/static/scss/colorui.css";
+	@import '@/static/font/iconfont.css';
+
 	page {
 		background-color: #ffffff;
 	}
@@ -102,7 +98,6 @@
 
 				.input {
 					width: 100%;
-					font-size: 14px;
 					line-height: 20px;
 					text-align: left;
 					padding-left: 15px;
@@ -113,6 +108,7 @@
 			.login-btn {
 				margin-top: 40px;
 				height: 45px;
+				border-radius: 20px;
 			}
 		}
 	}

+ 6 - 6
pages/message/index.vue

@@ -100,15 +100,15 @@
 	import { onMounted, reactive, ref } from 'vue';
 	import $tab from '@/plugins/tab.js';
 	import processList from '@/components/ygoa/processList.vue'
+	import { useUserStore } from '@/store/user.js'
 	onMounted(() => {
 		onClickItem({ currentIndex: 0 })
 	})
-	function changeIndexGrid(e) {
-
-	}
+	const userStore = useUserStore()
 	function clickCheckIn() {
-		console.log('clickCheckIn');
-		$tab.navigateTo('/pages/mine/clockIn/clockIn')
+		console.log('clickCheckIn', userStore.user);
+		// console.log('getUserInfo', getUserInfo());
+		// $tab.navigateTo('/pages/mine/clockIn/clockIn')
 	}
 	// 分段器选项列表
 	const items = reactive(['全部', '已读', '未读'])
@@ -155,7 +155,7 @@
 			step: 0
 		},
 	])
-	
+
 	// 点击消息分段器
 	function onClickItem({ currentIndex }) {
 		current.value = currentIndex

+ 8 - 4
pages/mine/index.vue

@@ -75,10 +75,14 @@
 		onMounted
 	} from 'vue';
 
-	import headImg from "/static/images/mine/headImg.jpg"
-	import $tab from "../../plugins/tab.js"
-
-
+	import headImg from "@/static/images/mine/headImg.jpg"
+	import $tab from "@/plugins/tab.js"
+	import { useUserStore } from '@/store/user.js'
+	const userStore = useUserStore()
+	// const userInfo = ref({})
+	onMounted(() => {
+		console.log('userStore', userStore.user);
+	})
 	// 用户信息的响应式对象
 	const userInfo = reactive({
 		id: '123321',

+ 1 - 1
pages/mine/personal_message/personal_message.vue

@@ -50,7 +50,7 @@
 
 <script setup>
 	import { ref } from 'vue';
-	import headImg from "/static/images/mine/headImg.jpg";
+	import headImg from "@/static/images/mine/headImg.jpg";
 	import {
 		onLoad
 	} from '@dcloudio/uni-app'

+ 5 - 2
pages/mine/setting/setting.vue

@@ -35,7 +35,9 @@
 </template>
 
 <script setup>
-	import $tab from "../../../plugins/tab.js"
+	import $tab from "@/plugins/tab.js"
+	import { useUserStore } from '@/store/user.js'
+	const userStore = useUserStore()
 	// 退出登录
 	function logOut() {
 		uni.showModal({
@@ -43,7 +45,8 @@
 			content: '确定注销并退出系统吗?',
 			success: function(res) {
 				if (res.confirm) {
-					console.log('用户点击确定');
+					userStore.LogOut()
+					$tab.reLaunch('/pages/login')
 				} else if (res.cancel) {
 					console.log('用户点击取消');
 				}

+ 1 - 1
pages/mine/waitWork/waitWork.vue

@@ -62,7 +62,7 @@ import {
 } from 'vue';
 
 
-import $tabs from "../../../plugins/tab.js"
+import $tabs from "@/plugins/tab.js"
 // 定义待办任务数据
 const todos = reactive([{
 	id: 1,

+ 4 - 4
pages/work/index.vue

@@ -175,14 +175,14 @@
 	function closeClearCachePopup() { // 关闭清除缓存弹出层
 		clearCacheDialog.value.close()
 	}
-	const userStore = useUserStore()
+	// const userStore = useUserStore()
 	function clearCache() {
 		const userInfo = getUserInfo()
 		uni.clearStorageSync();
-		console.log('userStore.user', userStore.user.value);
-		console.log('userInfo', userInfo);
+		// console.log('userStore.user', userStore.user);
+		// console.log('userInfo', userInfo);
 		uni.setStorageSync('userInfo', userInfo)
-		console.log('userInfo', userStore.user.value);
+		// console.log('userInfo', userStore.user);
 		// 提示用户缓存清理成功
 		uni.showToast({
 			title: '缓存清理成功',

+ 27 - 11
static/font/ygoa/iconfont.css

@@ -2,9 +2,9 @@
   font-family: "ygoa-icon"; /* Project id 4740271 */
   /* Color fonts */
   src: 
-       url('iconfont.woff2?t=1731396840757') format('woff2'),
-       url('iconfont.woff?t=1731396840757') format('woff'),
-       url('iconfont.ttf?t=1731396840757') format('truetype');
+       url('iconfont.woff2?t=1731636858551') format('woff2'),
+       url('iconfont.woff?t=1731636858551') format('woff'),
+       url('iconfont.ttf?t=1731636858551') format('truetype');
 }
 
 .ygoa-icon {
@@ -15,6 +15,30 @@
   -moz-osx-font-smoothing: grayscale;
 }
 
+.icon-goOut:before {
+  content: "\e608";
+}
+
+.icon-absenteeism:before {
+  content: "\e606";
+}
+
+.icon-user:before {
+  content: "\e605";
+}
+
+.icon-leaveEarly:before {
+  content: "\e61b";
+}
+
+.icon-late:before {
+  content: "\e61d";
+}
+
+.icon-password:before {
+  content: "\e604";
+}
+
 .icon-checkIn:before {
   content: "\e60a";
 }
@@ -23,10 +47,6 @@
   content: "\f493";
 }
 
-.icon-businessTrip:before {
-  content: "\e6bc";
-}
-
 .icon-attendance:before {
   content: "\e61c";
 }
@@ -35,10 +55,6 @@
   content: "\e607";
 }
 
-.icon-clockIn1:before {
-  content: "\e852";
-}
-
 .icon-leave:before {
   content: "\e614";
 }

BIN
static/font/ygoa/iconfont.ttf


BIN
static/font/ygoa/iconfont.woff


BIN
static/font/ygoa/iconfont.woff2


Разница между файлами не показана из-за своего большого размера
+ 3952 - 0
static/scss/colorui.css


+ 3 - 3
store/counter.js

@@ -4,9 +4,9 @@ import { defineStore } from 'pinia'
 // (比如 `useUserStore`,`useCartStore`,`useProductStore`)
 // 第一个参数是你的应用中 Store 的唯一 ID。
 export const useCounterStore = defineStore('counter', () => {
-  const count = ref(0)
-  const doubleCount = computed(() => count.value * 2)
-  function increment() {
+  const count = ref(0) // state
+  const doubleCount = computed(() => count.value * 2) // getters
+  function increment() { // actions
     count.value++
   }
 

+ 17 - 8
store/user.js

@@ -1,22 +1,20 @@
-// store/user.js
 import { defineStore } from 'pinia'
 import { ref } from 'vue'
-import { login } from '@/api/login.js'
+import { login, logout } from '@/api/login.js'
 import { getUserInfo } from '@/utils/auth'
 
 export const useUserStore = defineStore('user', () => {
-	const user = ref({})
-	user.value = getUserInfo()
+	const user = ref(getUserInfo())
+	// user.value = getUserInfo()
 	// 登录方法
 	function Login(userInfo) {
-		const username = userInfo.username.trim()
+		const username = userInfo.username
 		const password = userInfo.password
 		return new Promise((resolve, reject) => {
 			login(username.trim(), password)
 				.then(res => {
 					uni.setStorageSync('userInfo', res.returnParams)
-					user.value = res.returnParams
-					console.log('user', user.value)
+					user.value = res.returnParams // 抽离进 GetInfo中
 					// 可以在这里设置 token 或用户信息
 					// setToken(res.token)
 					resolve(res)
@@ -26,6 +24,17 @@ export const useUserStore = defineStore('user', () => {
 				})
 		})
 	}
+	function LogOut() {
+		return new Promise((resolve, reject) => {
+			// logout().then(() => {
+				user.value = {}
+				uni.clearStorageSync()
+				resolve()
+			}).catch(error => {
+				reject(error)
+			})
+		// })
+	}
 
-	return { user, Login }
+	return { user, Login, LogOut }
 })

Некоторые файлы не были показаны из-за большого количества измененных файлов