From 682182cf67a5aa9fed34335fea22d4673f30f10c Mon Sep 17 00:00:00 2001
From: Mr.Shi <1878285526@qq.com>
Date: 星期一, 04 九月 2023 11:59:44 +0800
Subject: [PATCH] 小程序

---
 minipro_standard/store/index.js                          |   90 +++++++++++------
 minipro_standard/pages/mine/mine.vue                     |   73 +++++++++++--
 minipro_standard/util/api/index.js                       |    5 +
 minipro_standard/pages/updatePhone/updatePhone.vue       |   41 +++++++
 minipro_standard/util/request/requestInterceptors.js     |    5 
 minipro_standard/pages/workbench/workbench.vue           |    4 
 minipro_standard/pages/personal/personal.vue             |   20 ++-
 minipro_standard/pages/login/login.vue                   |    3 
 minipro_standard/pages/changePassword/changePassword.vue |   35 ++++++
 9 files changed, 213 insertions(+), 63 deletions(-)

diff --git a/minipro_standard/pages/changePassword/changePassword.vue b/minipro_standard/pages/changePassword/changePassword.vue
index a975dd8..311f0d2 100644
--- a/minipro_standard/pages/changePassword/changePassword.vue
+++ b/minipro_standard/pages/changePassword/changePassword.vue
@@ -25,7 +25,7 @@
 			</view>
 		</view>
 		<view class="password_footer">
-			<button v-preventReClick class="password_footer_submit">
+			<button class="password_footer_submit" @click="submit">
 				<text>瀹屾垚</text>
 			</button>
 		</view>
@@ -33,6 +33,7 @@
 </template>
 
 <script>
+	import { updatePwd } from '@/util/api/PersonalAPI'
 	export default {
 		data() {
 			return {
@@ -42,6 +43,38 @@
 					confirmPassword: ''
 				}
 			};
+		},
+		methods: {
+			// 蹇樿瀵嗙爜
+			forgotPassword() {
+				
+			},
+			// 鎻愪氦淇敼
+			submit() {
+				if (!this.form.originalPassword) {
+					uni.showToast({ title: '鍘熷瘑鐮佷笉鑳戒负绌�', icon: 'none', duration: 2000 });
+				} else if (!this.form.newPassword) {
+					uni.showToast({ title: '鏂板瘑鐮佷笉鑳戒负绌�', icon: 'none', duration: 2000 });
+				} else if (!/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{6,}$/.test(this.form.newPassword)) {
+					uni.showToast({ title: '瀵嗙爜鏍煎紡涓嶆纭�', icon: 'none', duration: 2000 });
+				} else if (!this.form.confirmPassword) {
+					uni.showToast({ title: '纭瀵嗙爜涓嶈兘涓虹┖', icon: 'none', duration: 2000 });
+				} else if (this.form.newPassword !== this.form.confirmPassword) {
+					uni.showToast({ title: '涓ゆ杈撳叆鐨勫瘑鐮佷笉涓�鑷�', icon: 'none', duration: 2000 });
+				} else {
+					updatePwd({
+						newPwd: this.form.newPassword,
+						oldPwd: this.form.originalPassword
+					}).then(res => {
+						if (res.code === 200) {
+							uni.showToast({ title: '淇敼鎴愬姛', icon: 'success', duration: 2000, mask: true });
+							setTimeout(() => {
+								uni.navigateBack({ delta: 1 });
+							}, 2000)
+						}
+					})
+				}
+			}
 		}
 	}
 </script>
diff --git a/minipro_standard/pages/login/login.vue b/minipro_standard/pages/login/login.vue
index 8446015..46d088a 100644
--- a/minipro_standard/pages/login/login.vue
+++ b/minipro_standard/pages/login/login.vue
@@ -49,7 +49,7 @@
 									let info = await getUserInfo()
 									if (info.code === 200) {
 										await that.$store.commit('setEntrance', 'WX')
-										await that.$store.commit('setUserInfo', info.data)
+										await that.$store.commit('SETUSERINFO', info.data)
 										await that.$store.dispatch('getMenuList', 2)
 										uni.switchTab({
 											url: '/pages/workbench/workbench'
@@ -71,6 +71,7 @@
 				if (!this.from.password) return uni.showToast({ title: '瀵嗙爜涓嶈兘涓虹┖', icon:"error", duration: 2000 });
 				let res = await wxAccountLogin(this.from)
 				if (res.code === 200) {
+					await this.$store.commit('SETSESSION', res.data)
 					let user = await getUserInfo({})
 					if (user.code === 200) {
 						await this.$store.commit('SETUSERINFO', user.data)
diff --git a/minipro_standard/pages/mine/mine.vue b/minipro_standard/pages/mine/mine.vue
index 18f9c4f..19d9808 100644
--- a/minipro_standard/pages/mine/mine.vue
+++ b/minipro_standard/pages/mine/mine.vue
@@ -2,11 +2,11 @@
 <view>
 	<div class="box">
 		<div class="box_info" :style="{background: 'url(' + img + ')'}">
-			<image src="@/static/2@2x.png" mode="widthFix" />
+			<image :src="userInfo.avatar ? userInfo.avatar : avatar" mode="widthFix" />
 			<div class="box_info_box">
-				<text>寮犱笁</text>
-				<div class="box_info_box_x" @click="show = true">
-					<text>璞嗙背绉戞妧</text>
+				<text>{{userInfo.realname}}</text>
+				<div class="box_info_box_x" @click="switchOrganization">
+					<text>{{userInfo.curComDepartment ? userInfo.curComDepartment.name : ''}}</text>
 					<image src="@/static/mine_ic_change@2x.png" alt="" />
 				</div>
 			</div>
@@ -22,20 +22,26 @@
 				</div>
 			</div>
 		</div>
-		<div class="box_out"><text>閫�鍑虹櫥褰�</text></div>
+		<div class="box_out" @click="loginOut"><text>閫�鍑虹櫥褰�</text></div>
 	</div>
 	<!-- 閮ㄩ棬閫夋嫨鍣� -->
-	<u-picker :show="show" :columns="columns" @confirm="confirm"></u-picker>
+	<u-picker :show="show" :columns="columns" @confirm="onConfirm" @cancel="show = false"></u-picker>
 	<myTabbar :index="2" />
 </view>
 </template>
 
 <script>
+	import { changeCom, getDepartmentListByConditon } from '@/util/api/PersonalAPI'
 	import myTabbar from "@/components/myTabber.vue"
+	import { wxLoginOut } from '@/util/api'
+	import { mapState } from 'vuex'
 	export default {
 		components: {
 			myTabbar
 		},
+		computed: mapState([
+			'userInfo'
+		]),
 		data() {
 			return {
 				MENU: [
@@ -47,22 +53,61 @@
 					{ name: '淇敼瀵嗙爜', url: '/pages/changePassword/changePassword', icon: require('@/static/mine_ic_xiugaimima@2x.png') },
 				],
 				img: require('@/static/mine_bg@2x.png'),
+				avatar: require('@/static/2@2x.png'),
 				show: false,
-				columns: [
-					['涓浗', '缇庡浗', '鏃ユ湰']
-				]
+				columns: []
 			}
 		},
 		onLoad() {
 			uni.hideTabBar()
 		},
 		methods: {
-			jump(url) {
-				uni.navigateTo({ url })
+			// 閫�鍑虹櫥褰�
+			loginOut() {
+				wxLoginOut({
+					companyUserId: this.userInfo.companyUser.id
+				}).then(res => {
+					if (res.code === 200) {
+						this.$store.commit('clearCache')
+						uni.reLaunch({
+							url: '/pages/login/login'
+						});
+					}
+				})
 			},
-			confirm(val) {
-				console.log(val)
-				this.show = false
+			// 纭鍒囨崲缁勭粐
+			onConfirm(e) {
+				changeCom(e.value[0].id).then(res => {
+					if (res.code === 200) {
+						this.show = false
+						uni.showToast({ title: '鏇存柊缁勭粐鎴愬姛', icon: 'success', duration: 2000 });
+						this.$store.dispatch('getUserInfos')
+					}
+				})
+			},
+			// 鑾峰彇缁勭粐
+			switchOrganization() {
+				getDepartmentListByConditon({
+					type: 0
+				}).then(res => {
+					if (res.code === 200) {
+						this.columns = []
+						let arr = []
+						res.data.forEach((item) => {
+							let obj = {
+								text: item.name, id: item.id
+							}
+							arr.push(obj)
+						})
+						this.columns.push(arr)
+						this.show = true
+					}
+				})
+			},
+			// 璺宠浆椤甸潰
+			jump(url) {
+				if (!url) return
+				uni.navigateTo({ url })
 			}
 		}
 	}
diff --git a/minipro_standard/pages/personal/personal.vue b/minipro_standard/pages/personal/personal.vue
index 22f5c25..3677e11 100644
--- a/minipro_standard/pages/personal/personal.vue
+++ b/minipro_standard/pages/personal/personal.vue
@@ -1,41 +1,45 @@
 <template>
 	<view class="info">
 		<view class="info_portrait">
-			<image src="@/static/2@2x.png" mode="widthFix" />
+			<image :src="userInfo.avatar ? userInfo.avatar : avatar" mode="widthFix" />
 			<text>鐢ㄦ埛鍚�</text>
 		</view>
 		<view class="info_list">
 			<view class="info_list_item">
 				<text>鏄电О</text>
-				<text>鏆傛棤鏄电О</text>
+				<text>{{userInfo.realname ? userInfo.realname : '鏆傛棤鏄电О'}}</text>
 			</view>
 			<view class="info_list_item">
 				<text>鎵嬫満鍙�</text>
-				<text>鏆傛棤鎵嬫満鍙�</text>
+				<text>{{userInfo.companyUser.phone ? userInfo.companyUser.phone : '鏆傛棤鎵嬫満鍙�'}}</text>
 			</view>
 			<view class="info_list_item">
 				<text>鎵�灞為儴闂�</text>
-				<text>鏆傛棤鎵�灞為儴闂�</text>
+				<text>{{userInfo.department.name ? userInfo.department.name : '鏆傛棤鎵�灞為儴闂�'}}</text>
 			</view>
 			<view class="info_list_item">
 				<text>宀椾綅</text>
-				<text>鏆傛棤宀椾綅</text>
+				<text>{{userInfo.companyUser.positionName ? userInfo.companyUser.positionName : '鏆傛棤宀椾綅'}}</text>
 			</view>
 			<view class="info_list_item">
 				<text>褰撳墠缁勭粐</text>
-				<text>鏆傛棤缁勭粐</text>
+				<text>{{userInfo.rootDepartment.name ? userInfo.rootDepartment.name : '鏆傛棤缁勭粐'}}</text>
 			</view>
 		</view>
 	</view>
 </template>
 
 <script>
+	import { mapState } from 'vuex'
 	export default {
 		data() {
 			return {
-				
+				avatar: require('@/static/2@2x.png'),
 			};
-		}
+		},
+		computed: mapState([
+			'userInfo'
+		])
 	}
 </script>
 
diff --git a/minipro_standard/pages/updatePhone/updatePhone.vue b/minipro_standard/pages/updatePhone/updatePhone.vue
index b70fb79..46dd2ba 100644
--- a/minipro_standard/pages/updatePhone/updatePhone.vue
+++ b/minipro_standard/pages/updatePhone/updatePhone.vue
@@ -8,7 +8,7 @@
 			<view class="password_list_item">
 				<text>褰撳墠缁戝畾</text>
 				<view class="password_list_item_box">
-					<input type="number" disabled v-model="form.currentPhone" maxlength="11">
+					<input type="number" disabled v-model="userInfo.companyUser.phone" maxlength="11">
 				</view>
 			</view>
 			<view class="password_list_item">
@@ -22,7 +22,7 @@
 				<view class="password_list_item_box">
 					<input type="text" v-model="form.verificationCode" maxlength="4" placeholder="璇疯緭鍏ユ墜鏈洪獙璇佺爜">
 					<p @click="getVerificationCode" v-if="!code.isOpen">鑾峰彇楠岃瘉鐮�</p>
-					<p @click="getVerificationCode" v-else>{{code.num}}</p>
+					<p v-else>{{code.num}}</p>
 				</view>
 			</view>
 		</view>
@@ -35,15 +35,50 @@
 </template>
 
 <script>
+	import { mapState } from 'vuex'
+	import { phoneRegular } from '@/common/config.js'
 	export default {
 		data() {
 			return {
 				form: {
-					currentPhone: '',
 					newPhone: '',
 					verificationCode: ''
+				},
+				code: {
+					num: 60,
+					isOpen: false,
+					timer: 0
 				}
 			};
+		},
+		computed: mapState([
+			'userInfo'
+		]),
+		methods: {
+			// 鑾峰彇楠岃瘉鐮�
+			getVerificationCode() {
+				this.code.isOpen = true
+				this.code.timer = setInterval(() => {
+					if (this.code.num === 0) {
+						clearInterval(this.code.timer)
+						this.code.isOpen = false
+						this.code.num = 60
+					}
+					this.code.num = this.code.num - 1
+				}, 1000)
+			},
+			// 鎻愪氦淇敼
+			submit() {
+				if (!this.form.newPhone) {
+					uni.showToast({ title: '鏂版墜鏈哄彿涓嶈兘涓虹┖', icon: 'none', duration: 2000 });
+				} else if (!phoneRegular.test(this.form.newPhone)) {
+					uni.showToast({ title: '鎵嬫満鍙蜂笉鍚堟硶', icon: 'none', duration: 2000 });
+				} else if (!this.form.verificationCode) {
+					uni.showToast({ title: '楠岃瘉鐮佷笉鑳戒负绌�', icon: 'none', duration: 2000 });
+				} else {
+					console.log('鍙互鎻愪氦')
+				}
+			}
 		}
 	}
 </script>
diff --git a/minipro_standard/pages/workbench/workbench.vue b/minipro_standard/pages/workbench/workbench.vue
index 089312b..fa678a3 100644
--- a/minipro_standard/pages/workbench/workbench.vue
+++ b/minipro_standard/pages/workbench/workbench.vue
@@ -1,7 +1,7 @@
 <template>
 	<view class="index">
 		<view class="menu">
-			<!-- <view class="menu_list" v-for="(row, i) in Menu" :key="i">
+			<view class="menu_list" v-for="(row, i) in Menu" :key="i">
 				<view class="menu_list_head">
 					<span>{{row.label}}</span>
 				</view>
@@ -14,7 +14,7 @@
 					<view class="menu_list_zw"></view>
 					<view class="menu_list_zw"></view>
 				</div>
-			</view> -->
+			</view>
 		</view>
 		<myTabbar :index="1" />
 	</view>
diff --git a/minipro_standard/store/index.js b/minipro_standard/store/index.js
index c5561c5..2d5b182 100644
--- a/minipro_standard/store/index.js
+++ b/minipro_standard/store/index.js
@@ -1,6 +1,10 @@
 import Vue from 'vue'
-import Vuex from 'vuex'
-import { pageCount, getTreeList } from '@/util/api/index.js'
+import Vuex from 'vuex'
+import {
+	pageCount,
+	getTreeList,
+	getUserInfo
+} from '@/util/api/index.js'
 
 Vue.use(Vuex) // vue鐨勬彃浠舵満鍒�
 
@@ -10,7 +14,7 @@
 const token = uni.getStorageSync('token');
 const userInfo = uni.getStorageSync('userInfo');
 const Menu = uni.getStorageSync('MenuList');
-const session = uni.getStorageSync('session');
+const session = uni.getStorageSync('session');
 
 
 // Vuex.Store 鏋勯�犲櫒閫夐」
@@ -18,18 +22,18 @@
 	// 涓轰簡涓嶅拰椤甸潰鎴栫粍浠剁殑data涓殑閫犳垚娣锋穯锛宻tate涓殑鍙橀噺鍓嶉潰寤鸿鍔犱笂$绗﹀彿
 	state: {
 		// 鐢ㄦ埛淇℃伅
-		userInfo: userInfo || null,
+		userInfo: userInfo || null,
 		token: token || null,
 		menuButtonWidth: menuButtonWidth || '0',
 		statusbarHeight: statusbarHeight || '0',
 		navHeight: navHeight || '0',
 		session: session ? session : '',
 		// 鑿滃崟鏉冮檺
-		Menu: Menu ? Menu : [],
-		// 寰呭姙鏁伴噺
-		upcomingNum: {
-			d: 0,
-			y: 0
+		Menu: Menu ? JSON.parse(Menu) : [],
+		// 寰呭姙鏁伴噺
+		upcomingNum: {
+			d: 0,
+			y: 0
 		},
 	},
 	mutations: {
@@ -41,31 +45,42 @@
 			uni.setStorageSync('statusbarHeight', val.statusbarHeight);
 			uni.setStorageSync('menuButtonWidth', val.menuButtonWidth);
 		},
-		SETTOKEN(state, val) {
-			state.token = val
-			uni.setStorageSync('token', val);
-		},
-		SETUSERINFO(state, val) {
-			state.userInfo = val
-			uni.setStorageSync('userInfo', val);
-		},
-		SETNUM(state, val) {
-			state.upcomingNum.d = val.d
-			state.upcomingNum.y = val.y
+		SETTOKEN(state, val) {
+			state.token = val
+			uni.setStorageSync('token', val);
 		},
-		SETMENU (state, data) {
+		SETUSERINFO(state, val) {
+			state.userInfo = val
+			uni.setStorageSync('userInfo', val);
+		},
+		SETNUM(state, val) {
+			state.upcomingNum.d = val.d
+			state.upcomingNum.y = val.y
+		},
+		SETMENU(state, data) {
 			state.Menu = data
 			uni.setStorageSync('MenuList', JSON.stringify(data));
 		},
-		SETSESSION (state, data) {
+		SETSESSION(state, data) {
 			state.session = data;
 			uni.setStorageSync('session', data);
+		},
+		clearCache(state) {
+			state.userInfo = ''
+			state.token = ''
+			state.session = ''
+			state.Menu = []
+			state.upcomingNum.d = 0
+			state.upcomingNum.y = 0
+			uni.clearStorageSync()
 		}
 	},
 	actions: {
 		// 鍚戝悗绔幏鍙栬彍鍗曟爮鏉冮檺
-		async getMenuList (content, type) {
-			let res = await getTreeList({ type: type })
+		async getMenuList(content, type) {
+			let res = await getTreeList({
+				type: type
+			})
 			if (res.code === 200) {
 				content.commit('SETMENU', res.data)
 			}
@@ -84,14 +99,25 @@
 				height,
 				menuButtonWidth
 			})
-		},
-		async getUpcomingNum() {
-			let res = await pageCount({})
-			if (res.code === 200) {
-				content.commit('SETNUM', { d: res.data.startNum, y: res.data.endNum })
-			}
-		}
+		},
+		async getUpcomingNum() {
+			let res = await pageCount({})
+			if (res.code === 200) {
+				content.commit('SETNUM', {
+					d: res.data.startNum,
+					y: res.data.endNum
+				})
+			}
+		},
+		// 鍚戝悗绔幏鍙栦釜浜轰俊鎭�
+		async getUserInfos(content) {
+			let res = await getUserInfo()
+			if (res.code === 200) {
+				content.commit('SETUSERINFO', res.data)
+				return true;
+			}
+		}
 	}
 })
 
-export default store
+export default store
\ No newline at end of file
diff --git a/minipro_standard/util/api/index.js b/minipro_standard/util/api/index.js
index a41a10f..dfd23bc 100644
--- a/minipro_standard/util/api/index.js
+++ b/minipro_standard/util/api/index.js
@@ -42,4 +42,9 @@
 // 寰俊灏忕▼搴忕櫥褰�
 export function wxProgramLogin(params) {
 	return http.get('/system/wxProgramLogin', {params})
+}
+
+// 寰俊閫�鍑虹櫥褰�
+export function wxLoginOut(data) {
+	return http.post('/system/wxLoginOut', data)
 }
\ No newline at end of file
diff --git a/minipro_standard/util/request/requestInterceptors.js b/minipro_standard/util/request/requestInterceptors.js
index 8f37f89..fa7a17c 100644
--- a/minipro_standard/util/request/requestInterceptors.js
+++ b/minipro_standard/util/request/requestInterceptors.js
@@ -4,8 +4,9 @@
  */
 module.exports = (vm) => {
 	uni.$u.http.interceptors.request.use((config) => { // 鍙娇鐢╝sync await 鍋氬紓姝ユ搷浣�
-		console.log(config)
-		config.header['Cookie'] = 'eva-auth-token=' + vm.$store.state.session
+		if (vm.$store.state.session) {
+			config.header['Cookie'] = 'eva-auth-token=' + vm.$store.state.session
+		}
 		uni.showLoading({ title: '璇锋眰涓�' });
 		config.data = config.data || {}
 		return config

--
Gitblit v1.9.3