From f7aa204aa8d20b090d7943969ddeb9871a1fad76 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期四, 12 九月 2024 17:28:06 +0800
Subject: [PATCH] -

---
 src/pages/mine/index.vue |  163 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 95 insertions(+), 68 deletions(-)

diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue
index 84c9e81..48cc7ab 100644
--- a/src/pages/mine/index.vue
+++ b/src/pages/mine/index.vue
@@ -28,13 +28,13 @@
 					浼佷笟鏈嶅姟
 				</view>
 				<view class="tool_content">
-					<view class="tool_item" @click="toRelease">
+					<view class="tool_item" @click="toRelease" v-if="isAdmin">
 						<image src="@/static/image/fabu.png" mode="aspectFit" class="item_img"></image>
 						<view class="tool_label">
 							鍙戝竷鑱屼綅
 						</view>
 					</view>
-					<view class="tool_item" @click="toOrder">
+					<view class="tool_item" @click="toOrder" v-if="isAdmin">
 						<image src="@/static/image/guanli.png" mode="aspectFit" class="item_img"></image>
 						<view class="tool_label">
 							鑱屼綅绠$悊
@@ -46,7 +46,7 @@
 							鎴戠殑浼佷笟
 						</view>
 					</view>
-					<view class="tool_item" @click="toWorkerRecord">
+					<view class="tool_item" @click="toWorkerRecord" v-if="isAdmin">
 						<image src="@/static/image/record.png" mode="aspectFit" class="item_img"></image>
 						<view class="tool_label">
 							鎵撳崱璁板綍
@@ -80,18 +80,21 @@
             </view>
         </view> -->
 		<view class="nav-box" v-if="identity=='enterprise'">
-			<view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
-				v-for="(item, index) in navList" :key="item.name">
-				<view class="nav-title">
-					<view :class="'iconfont ' + item.icon"></view>
-					{{ item.name }}
-				</view>
+			<view class="" v-if="isAdmin">
+				<view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
+					v-for="(item, index) in navList" :key="item.name">
+					<view class="nav-title">
+						<view :class="'iconfont ' + item.icon"></view>
+						{{ item.name }}
+					</view>
 
-				<view class="nav-icon">
-					<view v-if="item.num || item.num === 0">{{ item.num }}</view>
-					<view class="iconfont iconarrow"></view>
+					<view class="nav-icon">
+						<view v-if="item.num || item.num === 0">{{ item.num }}</view>
+						<view class="iconfont iconarrow"></view>
+					</view>
 				</view>
 			</view>
+
 		</view>
 		<view class="nav-box" v-else>
 			<view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
@@ -113,23 +116,23 @@
 </template>
 
 <script>
-	var app = getApp();
+	import {
+		mapActions,
+		mapGetters,
+		mapMutations
+	} from 'vuex'
 	export default {
-
 		data() {
 			return {
-				identity: '',
-				navList: [
-					// 	{
-					// 	icon: 'icon-huabanfuben',
-					// 	name: '宸ヤ汉鎵撳崱璁板綍',
-					// 	cb: function() {
-					// 		uni.navigateTo({
-					// 			url: '/pages/company/index'
-					// 		});
-					// 	}
-					// },
-				],
+				navList: [{
+					icon: 'icon-huabanfuben',
+					name: '鍛樺伐绠$悊',
+					cb: function() {
+						uni.navigateTo({
+							url: '/pages/company/staff'
+						});
+					}
+				}, ],
 				navList1: [{
 						icon: 'icon-wanshanxinxi',
 						name: '瀹屽杽璧勬枡',
@@ -150,41 +153,48 @@
 						cb: this.toMyRecord
 					},
 				],
-				isLogin: false,
-				userInfo: {},
-				balance: '0.00'
+				token: this.$db.get('userToken')||''
 			};
 		},
 		onLoad: function() {
 
-
 		},
 		onShow: function() {
-			let that = this
-			this.userInfo = this.$db.get('userInfo') ? JSON.parse(this.$db.get('userInfo')) : {}
-			this.token = this.$db.get('userToken') ? this.$db.get('userToken') : ''
-			uni.getStorage({
-				key: 'identity',
-				success: function(res) {
-					that.identity = res.data
-					if (res.data == 'worker') {
-						if (that.userInfo.userWorker) {
-							that.balance = that.$common.moneySub(that.userInfo.userWorker.tiXianZonge, that
-								.userInfo.userWorker.yiTiXianJine)
-						}
+			this.getUserInfo()
+		},
+		computed: {
+			...mapGetters(['userInfo', 'identity']),
+			isAdmin() {
+				return this.userInfo.userCompany ? this.userInfo.userCompany.isAdmin : false
+			},
+			isLogin() {
+				return this.token ? true : false;
+			},
+			balance() {
+				if (this.identity == 'worker') {
+					if (this.userInfo.userWorker) {
+						return this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
+							.userWorker
+							.yiTiXianJine)
 					} else {
-						if (that.userInfo.userCompany) {
-							that.balance = that.userInfo.userCompany.chongZhiYue ? that.userInfo
-								.userCompany.chongZhiYue : '0.00'
-						}
+						return '0.00'
+					}
+				} else {
+					if (this.userInfo.userCompany) {
+						return this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
+							.chongZhiYue :
+							'0.00'
+					} else {
+						return '0.00'
 					}
 				}
-			});
-			// this.userInfo = this.$db.get('userInfo') ? JSON.parse(this.$db.get('userInfo')) : {}
-			// this.token = this.$db.get('userToken') ? this.$db.get('userToken') : ''
-			this.isLogin = this.token ? true : false;
+			}
 		},
 		methods: {
+			...mapActions([
+				'getUserInfo'
+			]),
+			...mapMutations(['setIdentity']),
 			tologin() {
 				if (this.isLogin) {
 					uni.navigateTo({
@@ -198,6 +208,9 @@
 			},
 			toOrder() {
 				if (!this.userInfo.userCompany) {
+					uni.navigateTo({
+						url: '/pages/enterprise/enterprise'
+					});
 					this.$util.showToast({
 						title: '璇峰厛瀹屽杽浼佷笟璧勬枡锛�'
 					})
@@ -209,6 +222,9 @@
 			},
 			toRelease() {
 				if (!this.userInfo.userCompany) {
+					uni.navigateTo({
+						url: '/pages/enterprise/enterprise'
+					});
 					this.$util.showToast({
 						title: '璇峰厛瀹屽杽浼佷笟璧勬枡锛�'
 					})
@@ -225,6 +241,9 @@
 			},
 			toWorkerRecord() {
 				if (!this.userInfo.userCompany) {
+					uni.navigateTo({
+						url: '/pages/enterprise/enterprise'
+					});
 					this.$util.showToast({
 						title: '璇峰厛瀹屽杽浼佷笟璧勬枡锛�'
 					})
@@ -236,6 +255,9 @@
 			},
 			toMyWork() {
 				if (!this.userInfo.userWorker) {
+					uni.navigateTo({
+						url: '/pages/mine/apply'
+					});
 					this.$util.showToast({
 						title: '璇峰厛瀹屽杽璧勬枡锛�'
 					})
@@ -245,8 +267,11 @@
 					url: '/pages/order/myorder'
 				});
 			},
-			toMyRecord(){
+			toMyRecord() {
 				if (!this.userInfo.userWorker) {
+					uni.navigateTo({
+						url: '/pages/mine/apply'
+					});
 					this.$util.showToast({
 						title: '璇峰厛瀹屽杽璧勬枡锛�'
 					})
@@ -257,23 +282,25 @@
 				});
 			},
 			changRole() {
-				this.identity = this.identity === 'enterprise' ? 'worker' : 'enterprise'
-				console.log(this.identity, 'this.identity');
-				uni.setStorage({
-					key: 'identity',
-					data: this.identity,
-				});
-				if (this.identity == 'worker') {
-					if (this.userInfo.userWorker) {
-						this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo.userWorker
-							.yiTiXianJine)
-					}
-				} else {
-					if (this.userInfo.userCompany) {
-						this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany.chongZhiYue :
-							'0.00'
-					}
-				}
+				this.$store.commit('setIdentity', this.identity === 'enterprise' ? 'worker' : 'enterprise')
+				// this.$db.set('identity', this.identity === 'enterprise' ? 'worker' : 'enterprise')
+				// this.identity = this.identity === 'enterprise' ? 'worker' : 'enterprise'
+				console.log(this.identity, this.$db.get('identity'), 'this.identity');
+				// uni.setStorage({
+				// 	key: 'identity',
+				// 	data: this.identity,
+				// });
+				// if (this.identity == 'worker') {
+				// 	if (this.userInfo.userWorker) {
+				// 		this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo.userWorker
+				// 			.yiTiXianJine)
+				// 	}
+				// } else {
+				// 	if (this.userInfo.userCompany) {
+				// 		this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany.chongZhiYue :
+				// 			'0.00'
+				// 	}
+				// }
 			},
 			goWallet() {
 				uni.navigateTo({

--
Gitblit v1.9.1