From a5f75b8c4acff2ffd49d490c314d95a8c5f5db7e Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期一, 16 六月 2025 11:46:10 +0800
Subject: [PATCH] 提交

---
 wx/pages/index/index.vue |  203 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 153 insertions(+), 50 deletions(-)

diff --git a/wx/pages/index/index.vue b/wx/pages/index/index.vue
index 9c150f2..ed12673 100644
--- a/wx/pages/index/index.vue
+++ b/wx/pages/index/index.vue
@@ -1,57 +1,75 @@
 <template>
 	<view class="content">
 		<view class="content_head" :style="{backgroundImage: 'url(' + backgroundImg + ')'}">
-			<text>{{userInfo.company.name}}</text>
+			<view class="content_head_company" @click="show = true">
+				<text>{{userInfo.company.name}}</text>
+				<u-icon name="arrow-down-fill" color="#ffffff" size="16"></u-icon>
+			</view>
 			<text>褰撳墠鍦ㄤ繚锛歿{num}}浜�</text>
 		</view>
 		<view class="content_box">
 			<view class="content_box_list">
-				<view class="content_box_list_left" @click="jump(1)" :style="{backgroundImage: 'url(' + backgroundImg1 + ')'}">
+				<view class="content_box_list_left" @click="jump(1)"
+					:style="{backgroundImage: 'url(' + backgroundImg1 + ')'}">
 					<text>鎶曚繚鐢宠</text>
 					<text>绠�鍗曚究鎹�</text>
 				</view>
 				<view class="content_box_list_right">
-					<view class="content_box_list_right_row" @click="jump(2)" :style="{backgroundImage: 'url(' + backgroundImg2 + ')'}">
+					<view class="content_box_list_right_row" @click="jump(2)"
+						:style="{backgroundImage: 'url(' + backgroundImg2 + ')'}">
 						<text>鎴戠殑淇濆崟</text>
 						<text>鍏ㄩ潰绠′繚鍗�</text>
 					</view>
-					<view class="content_box_list_right_row" @click="jump(3)" :style="{backgroundImage: 'url(' + backgroundImg3 + ')'}">
+					<view class="content_box_list_right_row" @click="jump(3)"
+						:style="{backgroundImage: 'url(' + backgroundImg3 + ')'}">
 						<text>鍦ㄧ嚎鎶ユ</text>
 						<text>鏂逛究杩呴��</text>
 					</view>
 				</view>
 			</view>
 			<view class="content_box_list1">
-				<view class="content_box_list1_item" @click="jump(4)" :style="{backgroundImage: 'url(' + backgroundImg4 + ')'}">
+				<view class="content_box_list1_item" @click="jump(4)"
+					:style="{backgroundImage: 'url(' + backgroundImg4 + ')'}">
 					<text>鍔犲噺淇濈敵璇�</text>
 					<text>澧炲姞/鍑忓皯鎶曚繚浜�</text>
 				</view>
-				<view class="content_box_list1_item" @click="jump(5)" :style="{backgroundImage: 'url(' + backgroundImg5 + ')'}">
+				<view class="content_box_list1_item" @click="jump(5)"
+					:style="{backgroundImage: 'url(' + backgroundImg5 + ')'}">
 					<text>鍔犲噺淇濊褰�</text>
 					<text>鏌ョ湅璁板綍</text>
 				</view>
-				<view class="content_box_list1_item" @click="jump(6)" :style="{backgroundImage: 'url(' + backgroundImg6 + ')'}">
+				<view class="content_box_list1_item" @click="jump(6)"
+					:style="{backgroundImage: 'url(' + backgroundImg6 + ')'}">
 					<text>鏇存崲娲鹃仯\n鍗曚綅</text>
 					<!-- <text>鏇存崲娲鹃仯鍗曚綅</text> -->
 				</view>
-				<view class="content_box_list1_item" @click="jump(7)" :style="{backgroundImage: 'url(' + backgroundImg7 + ')'}">
+				<view class="content_box_list1_item" @click="jump(7)"
+					:style="{backgroundImage: 'url(' + backgroundImg7 + ')'}">
 					<text>鏇存崲娲鹃仯\n鍗曚綅璁板綍</text>
 					<!-- <text>鏌ョ湅璁板綍</text> -->
 				</view>
-				<view class="content_box_list1_item" @click="jump(8)" :style="{backgroundImage: 'url(' + backgroundImg8 + ')'}">
+				<view class="content_box_list1_item" @click="jump(8)"
+					:style="{backgroundImage: 'url(' + backgroundImg8 + ')'}">
 					<text>鍛樺伐绠$悊</text>
 					<text>鏌ョ湅浜哄憳鎶曚繚淇℃伅</text>
 				</view>
 			</view>
+			<!-- <button @click="test">韬唤璇佽瘑鍒�</button> -->
 		</view>
 		<view class="content_loginout">
-			<u-button type="primary" shape="circle" color="#437CB3" :plain="true" text="閫�鍑虹櫥褰�" @click="loginOut"></u-button>
+			<u-button type="primary" shape="circle" color="#437CB3" :plain="true" text="閫�鍑虹櫥褰�"
+				@click="loginOut"></u-button>
 		</view>
+		<!-- 鍒囨崲浼佷笟 -->
+		<u-picker :show="show" keyName="companyName" @confirm="confirmCompany" @cancel="cancel"
+			:columns="[userInfo.companyPermissionList || []]"></u-picker>
 	</view>
 </template>
 
 <script>
-	import { mapState } from 'vuex'
+	import {
+		mapState
+	} from 'vuex'
 	export default {
 		computed: {
 			...mapState(['userInfo', 'cookies'])
@@ -59,6 +77,8 @@
 		data() {
 			return {
 				num: 0,
+				show: false,
+				companyList: [],
 				backgroundImg: require('@/static/background/home_bg@2x.png'),
 				backgroundImg1: require('@/static/background/home_ic_toubao@2x.png'),
 				backgroundImg2: require('@/static/background/home_ic_baodan@2x.png'),
@@ -74,6 +94,59 @@
 			this.getNum()
 		},
 		methods: {
+			test() {
+				// 閫夋嫨鍥剧墖
+				wx.chooseImage({
+					count: 1,
+					success: async function(res) {
+						console.log(new wx.serviceMarket.CDN({ type: 'filePath', filePath: res.tempFilePaths[0] }))
+						try {
+							const invokeRes = await wx.serviceMarket.invokeService({
+								service: 'wx79ac3de8be320b71',
+								api: 'OcrAllInOne',
+								data: {
+									// 鐢� CDN 鏂规硶鏍囪瑕佷笂浼犲苟杞崲鎴� HTTP URL 鐨勬枃浠�
+									img_url: new wx.serviceMarket.CDN({
+										type: 'filePath',
+										filePath: res.tempFilePaths[0],
+									}),
+									data_type: 3,
+									ocr_type: 1
+								},
+							})
+							console.log('invokeService success', invokeRes)
+							wx.showModal({ title: 'success', content: JSON.stringify(invokeRes) })
+						} catch (err) {
+							console.log(JSON.stringify(err))
+							wx.showModal({ title: 'fail', content: err })
+						}
+					},
+					fail: function(res) {},
+					complete: function(res) {},
+				})
+			},
+			cancel() {
+				this.show = false
+			},
+			confirmCompany(e) {
+				if (e.value[0].companyId === this.userInfo.companyId) {
+					uni.showToast({
+						title: '涓嶈兘鍒囨崲褰撳墠浼佷笟',
+						icon: 'none'
+					})
+					return
+				}
+				this.$u.api.switchCompany({
+						companyId: e.value[0].companyId
+					})
+					.then(async res => {
+						let user = await this.$u.api.getUserInfo()
+						if (user.code === 200) {
+							this.$store.commit('setUserInfo', user.data)
+							this.show = false
+						}
+					})
+			},
 			getNum() {
 				this.$u.api.guaranteeNum()
 					.then(res => {
@@ -99,12 +172,12 @@
 						url: '/pages/login/login'
 					})
 				}
-				switch(type) {
+				switch (type) {
 					case 1:
 						// if (this.userInfo.permissions.filter(item => item === 'business:insuranceapply:query').length > 0) {
-							uni.navigateTo({
-								url: '/pages/insuranceApplication/insuranceApplication'
-							})
+						uni.navigateTo({
+							url: '/pages/insuranceApplication/insuranceApplication'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -114,9 +187,9 @@
 						break
 					case 2:
 						// if (this.userInfo.permissions.filter(item => item === 'business:myPolicy:query').length > 0) {
-							uni.navigateTo({
-								url: '/pages/myPolicy/myPolicy'
-							})
+						uni.navigateTo({
+							url: '/pages/myPolicy/myPolicy'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -126,9 +199,9 @@
 						break
 					case 3:
 						// if (this.userInfo.permissions.filter(item => item === 'business:onlineReporting:create').length > 0) {
-							uni.navigateTo({
-								url: '/pages/online_reporting/online_reporting'
-							})
+						uni.navigateTo({
+							url: '/pages/online_reporting/online_reporting'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -138,9 +211,9 @@
 						break
 					case 4:
 						// if (this.userInfo.permissions.filter(item => item === 'business:addsubtract:apply').length > 0) {
-							uni.navigateTo({
-								url: '/pages/addition_subtraction_application/addition_subtraction_application'
-							})
+						uni.navigateTo({
+							url: '/pages/addition_subtraction_application/addition_subtraction_application'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -150,9 +223,9 @@
 						break
 					case 5:
 						// if (this.userInfo.permissions.filter(item => item === 'business:addsubtractInsuranceRecords:query').length > 0) {
-							uni.navigateTo({
-								url: '/pages/add_subtract_insurance/add_subtract_insurance'
-							})
+						uni.navigateTo({
+							url: '/pages/add_subtract_insurance/add_subtract_insurance'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -162,9 +235,9 @@
 						break
 					case 6:
 						// if (this.userInfo.permissions.filter(item => item === 'business:factoryChange:create').length > 0) {
-							uni.navigateTo({
-								url: '/pages/factoryChange/factoryChange'
-							})
+						uni.navigateTo({
+							url: '/pages/factoryChange/factoryChange'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -174,9 +247,9 @@
 						break
 					case 7:
 						// if (this.userInfo.permissions.filter(item => item === 'business:factoryChange:query').length > 0) {
-							uni.navigateTo({
-								url: '/pages/dispatch_unit_records/dispatch_unit_records'
-							})
+						uni.navigateTo({
+							url: '/pages/dispatch_unit_records/dispatch_unit_records'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -186,9 +259,9 @@
 						break
 					case 8:
 						// if (this.userInfo.permissions.filter(item => item === 'system:user:query').length > 0) {
-							uni.navigateTo({
-								url: '/pages/employee_management/employee_management'
-							})
+						uni.navigateTo({
+							url: '/pages/employee_management/employee_management'
+						})
 						// } else {
 						// 	uni.showToast({
 						// 		title: '鎮ㄦ病鏈夋潈闄�',
@@ -205,6 +278,7 @@
 <style lang="scss" scoped>
 	.content {
 		width: 100%;
+
 		.content_loginout {
 			width: 200rpx;
 			// margin: 0 auto;
@@ -213,6 +287,7 @@
 			position: fixed;
 			bottom: calc(env(safe-area-inset-bottom) + 40rpx);
 		}
+
 		.content_head {
 			width: 100%;
 			height: 292rpx;
@@ -223,26 +298,41 @@
 			display: flex;
 			flex-direction: column;
 			position: relative;
-			text {
-				&:nth-child(1) {
-					width: 100%;
-					overflow: hidden;
-					white-space: nowrap;
-					text-overflow: ellipsis;
+
+			.content_head_company {
+				width: 100%;
+				display: flex;
+				align-items: center;
+
+				text {
 					font-weight: 600;
 					font-size: 44rpx;
 					color: #FFFFFF;
 					font-style: normal;
-				}
-				&:nth-child(2) {
-					font-weight: 500;
-					font-size: 28rpx;
-					color: #FFFFFF;
-					font-style: normal;
-					margin-top: 24rpx;
+					margin-right: 15rpx;
 				}
 			}
+
+			text {
+				// &:nth-child(1) {
+				// 	width: 100%;
+				// 	overflow: hidden;
+				// 	white-space: nowrap;
+				// 	text-overflow: ellipsis;
+				// 	font-weight: 600;
+				// 	font-size: 44rpx;
+				// 	color: #FFFFFF;
+				// 	font-style: normal;
+				// }
+				// &:nth-child(2) {
+				font-weight: 500;
+				font-size: 28rpx;
+				color: #FFFFFF;
+				font-style: normal;
+				// }
+			}
 		}
+
 		.content_box {
 			width: 100%;
 			padding: 0 30rpx;
@@ -250,6 +340,7 @@
 			position: relative;
 			top: -100rpx;
 			left: 0;
+
 			.content_box_list1 {
 				width: 100%;
 				margin-top: 20rpx;
@@ -257,6 +348,7 @@
 				align-items: center;
 				justify-content: space-between;
 				flex-wrap: wrap;
+
 				.content_box_list1_item {
 					width: 336rpx;
 					height: 160rpx;
@@ -268,9 +360,11 @@
 					background-size: 100% 100%;
 					display: flex;
 					flex-direction: column;
+
 					&:nth-child(2n) {
 						margin-right: 0 !important;
 					}
+
 					text {
 						&:nth-child(1) {
 							font-weight: 500;
@@ -278,6 +372,7 @@
 							color: #222222;
 							font-style: normal;
 						}
+
 						&:nth-child(2) {
 							font-weight: 400;
 							font-size: 24rpx;
@@ -288,12 +383,14 @@
 					}
 				}
 			}
+
 			.content_box_list {
 				width: 100%;
 				height: 336rpx;
 				display: flex;
 				align-items: center;
 				justify-content: space-between;
+
 				.content_box_list_left {
 					width: 336rpx;
 					height: 100%;
@@ -303,6 +400,7 @@
 					flex-direction: column;
 					padding: 24rpx 28rpx;
 					box-sizing: border-box;
+
 					text {
 						&:nth-child(1) {
 							font-weight: 500;
@@ -310,6 +408,7 @@
 							color: #222222;
 							font-style: normal;
 						}
+
 						&:nth-child(2) {
 							font-weight: 400;
 							font-size: 24rpx;
@@ -319,12 +418,14 @@
 						}
 					}
 				}
+
 				.content_box_list_right {
 					width: 336rpx;
 					height: 100%;
 					display: flex;
 					flex-direction: column;
 					justify-content: space-between;
+
 					.content_box_list_right_row {
 						width: 100%;
 						height: 160rpx;
@@ -334,6 +435,7 @@
 						background-size: 100% 100%;
 						display: flex;
 						flex-direction: column;
+
 						text {
 							&:nth-child(1) {
 								font-weight: 500;
@@ -341,6 +443,7 @@
 								color: #222222;
 								font-style: normal;
 							}
+
 							&:nth-child(2) {
 								font-weight: 400;
 								font-size: 24rpx;
@@ -354,4 +457,4 @@
 			}
 		}
 	}
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3