From 1583d37aeb150564b54b2a8b6826eb76d1f05683 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 03 Nov 2023 11:47:39 +0800
Subject: [PATCH] 首页场所采集跳转,扫一扫跳转

---
 pages/home/index.vue |  152 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 102 insertions(+), 50 deletions(-)

diff --git a/pages/home/index.vue b/pages/home/index.vue
index 26e48a1..d58065f 100644
--- a/pages/home/index.vue
+++ b/pages/home/index.vue
@@ -1,6 +1,7 @@
 <template>
 	<view class="">
-		<u-navbar height="48" :autoBack="false" safeAreaInsetTop placeholder  @leftClick="selectBoxShow = !selectBoxShow">
+		<u-navbar height="48" :autoBack="false" safeAreaInsetTop placeholder
+			@leftClick="selectBoxShow = !selectBoxShow">
 			<view slot="left" class="flex">
 				<text class="top">{{curSelectSite.name?curSelectSite.name:'暂无绑定' +roleTypeName+'信息'}}</text>
 				<u-icon name="/static/icon/change-icon.png"></u-icon>
@@ -11,13 +12,13 @@
 				<u-swiper :list="swiperList"></u-swiper>
 			</view>
 			<view class="" v-if="roleType != 1">
-				<u-grid :border="false"  :col="roleType == 2?3:4">
+				<u-grid :border="false" :col="roleType == 2?3:4">
 					<u-grid-item v-for="(i,k) in cellList" :key="k" @click.native="toPage(i)">
 						<u-icon :name="i.icon" :size="45"></u-icon>
 						<text class="f-26 mt-20">{{i.text}}</text>
 					</u-grid-item>
-					<u-grid-item  @click.native="navTo()" v-if="roleType == 3">
-						<u-icon name="/static/icon/nav-04.png"  width="90rpx" height="90rpx"></u-icon>
+					<u-grid-item @click.native="navTo()" v-if="roleType == 3">
+						<u-icon name="/static/icon/nav-04.png" width="90rpx" height="90rpx"></u-icon>
 						<text class="f-26 mt-20">租客上报</text>
 					</u-grid-item>
 				</u-grid>
@@ -37,7 +38,7 @@
 			</view>
 
 			<view class="block flex a-i-c j-c-s-b" v-if="roleType == 1">
-				<view class="block-item">
+				<view @click="scan" class="block-item">
 					<image class="block-item-bg" src="/static/icon/nav-bg-04.png" mode="aspectFill" />
 					<view class="block-item-box flex a-i-c ">
 						<u-icon name="/static/icon/nav-05.png" width="90rpx" height="90rpx"></u-icon>
@@ -60,7 +61,7 @@
 				</view>
 			</view>
 
-			<view class=""  v-if="hasMenu('楼盘表').length>0">
+			<view class="" v-if="hasMenu('楼盘表').length>0">
 				<view class="caption">
 					<view class="flex a-i-c">
 						<view class="line"></view>
@@ -68,14 +69,15 @@
 					</view>
 				</view>
 				<view class="flex flex-wrap">
-					<view class="cell bgc-main flex a-i-c" v-for="(item, index) in houseDataList.slice(0, 6)"  @click.native="pushPage(item)">
+					<view class="cell bgc-main flex a-i-c" v-for="(item, index) in houseDataList.slice(0, 6)"
+						@click.native="pushPage(item)">
 						<u-icon name="/static/icon/floor.png" width="32rpx" height="32rpx"></u-icon>
 						<text class="cell-text f-26 c-ff">{{item.title}}</text>
 					</view>
 				</view>
 			</view>
 
-			<view class=""  v-if="roleType == 1">
+			<view class="" v-if="roleType == 1">
 				<view class="caption">
 					<view class="flex a-i-c">
 						<view class="line"></view>
@@ -83,9 +85,9 @@
 					</view>
 				</view>
 				<u-grid :border="false" col="4">
-					<u-grid-item v-for="(item, index) in jobList" :index="index" :key="index"
-						:customStyle="{paddingTop:20+'rpx'}">
-						<view class="grid-item flex f-d-c a-i-c"  :style="{background:item.style.background}">
+					<u-grid-item @click="navigatorPage(item)" v-for="(item, index) in jobList" :index="index"
+						:key="index" :customStyle="{paddingTop:20+'rpx'}">
+						<view class="grid-item flex f-d-c a-i-c" :style="{background:item.style.background}">
 							<u-icon :name="item.icon" width="60rpx" height="60rpx"></u-icon>
 							<text class="grid-text f-24 mt-10">{{item.text}}</text>
 						</view>
@@ -93,7 +95,7 @@
 				</u-grid>
 			</view>
 
-			<view class="mt-40"    v-if="roleType != 3">
+			<view class="mt-40" v-if="roleType != 3">
 				<view class="caption">
 					<view class="flex a-i-c">
 						<view class="line"></view>
@@ -153,7 +155,7 @@
 				</view>
 			</view>
 			<u-picker :title="roleTypeName" :show="selectBoxShow" keyName="name" ref="uPicker" :columns="siteColumns"
-				@confirm="confirmSite" @change="changeSite"  @cancel="selectBoxShow = false"></u-picker>
+				@confirm="confirmSite" @change="changeSite" @cancel="selectBoxShow = false"></u-picker>
 		</view>
 
 	</view>
@@ -175,17 +177,17 @@
 				cellList: [{
 						icon: "/static/icon/nav-01.png",
 						text: "扫一扫",
-						path:''
+						path: ''
 					},
 					{
 						icon: "/static/icon/nav-02.png",
 						text: "报事报修",
-						path:''
+						path: ''
 					},
 					{
 						icon: "/static/icon/nav-03.png",
 						text: "便民热线",
-						path:''
+						path: ''
 					},
 				],
 				navList: [{
@@ -288,7 +290,7 @@
 					}
 				],
 				roleType: 1, // 1网格员/系统管理员 、2场所负责人、  3居民
-				roleTypeName:"街道社区网格",
+				roleTypeName: "街道社区网格",
 				selectBoxShow: false,
 				siteColumns: [],
 				curSelectSite: {},
@@ -297,13 +299,13 @@
 					title: '-',
 					useSlot: true
 				}],
-				menuList:[]
+				menuList: []
 			}
 		},
 
 		onLoad() {
 			this.init()
-			uni.$on('refresh',()=>{
+			uni.$on('refresh', () => {
 				console.log("<====>")
 				this.init()
 			})
@@ -318,23 +320,23 @@
 					} else {
 						return []
 					}
-		
+
 				}
 			}
 		},
 
 		methods: {
-             
-			 //初始化
-			 init() {
-			 	this.curSelectSite = {}
-			 	this.menuList = uni.getStorageSync("menu")
-			 	this.selectRole = uni.getStorageSync("activeRole")
-			 	console.log(uni.getStorageSync("activeRole"))
-			 	this.getMenuList()
-			 	this.getSiteList()
-			 	// uni.hideTabBar()
-			 },
+
+			//初始化
+			init() {
+				this.curSelectSite = {}
+				this.menuList = uni.getStorageSync("menu")
+				this.selectRole = uni.getStorageSync("activeRole")
+				console.log(uni.getStorageSync("activeRole"))
+				this.getMenuList()
+				this.getSiteList()
+				// uni.hideTabBar()
+			},
 
 			//获取场所列表
 			async getSiteList() {
@@ -378,7 +380,7 @@
 			async getHouseDataList(code) {
 				const param = {
 					type: 1,
-					code:code
+					code: code
 				}
 				const res = await getHouseList(param)
 				res.data.forEach(item => {
@@ -414,7 +416,7 @@
 				this.curSelectSite = e.value[e.value.length - 1]
 				this.selectBoxShow = false
 				this.getHouseDataList(e.value[1].id)
-				console.log("curSite=>",this.curSelectSite);
+				console.log("curSite=>", this.curSelectSite);
 			},
 			getMenu(menuName, menuList, resultArr) {
 				// console.log(menuList, menuName)
@@ -442,9 +444,9 @@
 				if (resultArr.length == 0) {
 					return
 				}
-			
+
 				const topMenu = resultArr[0]
-			
+
 				topMenu.children.forEach(menu => {
 					this.gridDataList.push({
 						title: menu.name,
@@ -453,7 +455,7 @@
 					})
 				})
 			},
-			
+
 			//获取生活菜单
 			getLiveList() {
 				this.liveList = []
@@ -461,9 +463,9 @@
 				if (resultArr.length == 0) {
 					return
 				}
-			
+
 				const topMenu = resultArr[0]
-			
+
 				topMenu.children.forEach(menu => {
 					this.liveList.push({
 						imgUrl: menu.source,
@@ -471,7 +473,7 @@
 					})
 				})
 			},
-			
+
 			//获取工作台菜单
 			getWorkbenchList() {
 				// this.jobList = []
@@ -479,9 +481,9 @@
 				if (resultArr.length == 0) {
 					return
 				}
-			
+
 				const topMenu = resultArr[0]
-			
+
 				// topMenu.children.forEach(menu => {
 				// 	this.jobList.push({
 				// 		imgUrl: menu.source,
@@ -489,29 +491,79 @@
 				// 	})
 				// })
 			},
-			
+
 			// 页面跳转
-			pushPage({id, title}) {
+			pushPage({
+				id,
+				title
+			}) {
 				if (id !== void 0) {
 					let url = `/subPackage/house/list/index?id=${id}&title=${title}`
 					this.$u.func.globalNavigator(url, "navTo")
 				}
 			},
-			
+
 			// 页面跳转
-			toPage({id, title, path }) {
+			toPage({
+				id,
+				title,
+				path
+			}) {
 				let url = `${path}`
 				this.$u.func.globalNavigator(url, "navTo")
 				if (id !== void 0) {
-					
+
 				}
 			},
-			
-			
-			navTo(){
+
+
+			navTo() {
 				this.$u.func.globalNavigator("/subPackage/bs/views/zhsb", "navTo")
+			},
+
+			navigatorPage() {
+				let url = "/subPackage/workbench/views/cscj"
+				this.$u.func.globalNavigator(url, "navTo")
+			},
+
+			scan() {
+				const that = this
+				uni.scanCode({
+					success: function(res) {
+						console.log(res)
+
+
+						console.log('条码类型:' + res.scanType);
+						console.log('条码内容:' + res.result);
+
+
+						let obj = that.getUrlParams(res.result)
+						console.log(obj)
+
+						let url = "/subPackage/workbench/views/cscj?stdId=" + obj.stdId
+						console.log(url)
+						that.$u.func.globalNavigator(url, "navTo")
+
+
+					}
+				});
+			},
+
+			getUrlParams(url) {
+				// 通过 ? 分割获取后面的参数字符串
+				let urlStr = url.split('?')[1]
+				// 创建空对象存储参数
+				let obj = {};
+				// 再通过 & 将每一个参数单独分割出来
+				let paramsArr = urlStr.split('&')
+				for (let i = 0, len = paramsArr.length; i < len; i++) {
+					// 再通过 = 将每一个参数分割为 key:value 的形式
+					let arr = paramsArr[i].split('=')
+					obj[arr[0]] = arr[1];
+				}
+				return obj
 			}
-			
+
 		}
 	}
 </script>

--
Gitblit v1.9.3