Quellcode durchsuchen

微信授权界面

like vor 5 Monaten
Ursprung
Commit
a37687d8da

+ 4 - 0
snowy-admin-web/src/api/coldchain/alarmUserApi.js

@@ -29,5 +29,9 @@ export default {
 	// 获取报警接收人详情
 	alarmUserDetail(data) {
 		return request('detail', data, 'get')
+	},
+	// 点击确定获取微信用户信息
+	getwxUserInfo(data) {
+		return request('getUserInfo', data, 'get')
 	}
 }

+ 16 - 0
snowy-admin-web/src/router/whiteList.js

@@ -15,6 +15,22 @@ const constRouters = [
 	{
 		path: '/callback'
 	},
+	{
+		path: '/wx',
+		name: 'wx',
+		component: () => import('@/views/wx/index.vue'),
+		meta: {
+			title: '授权'
+		}
+	},
+	{
+		path: '/success',
+		name: 'success',
+		component: () => import('@/views/success/index.vue'),
+		meta: {
+			title: '授权成功'
+		}
+	},
 	{
 		path: '/other',
 		name: 'other',

+ 24 - 0
snowy-admin-web/src/views/success/index.vue

@@ -0,0 +1,24 @@
+<template>
+	<div class="wx">
+		{{ data }}
+	</div>
+</template>
+
+<script setup>
+	import { useRoute } from 'vue-router'
+	const data = ref()
+	const Route = useRoute()
+	onMounted(() => {
+		if (Route.query.data) {
+			data.value = Route.query.data
+		}
+	})
+</script>
+
+<style lang="less" scoped>
+	.wx {
+		height: 400px;
+		text-align: center;
+		padding-top: 45%;
+	}
+</style>

+ 89 - 0
snowy-admin-web/src/views/wx/index.vue

@@ -0,0 +1,89 @@
+<template>
+	<div class="wx">
+		<div class="title">请选择您要绑定的组织</div>
+
+		<a-select
+			ref="select"
+			v-model:value="orgId"
+			:options="options"
+			allowClear
+			style="width: 200px"
+			:field-names="{ label: 'name', value: 'id' }"
+		/>
+
+		<div class="btn">
+			<a-button type="primary" @click="onSubmit" :disabled="!orgId" :loading="loading">确定</a-button>
+		</div>
+	</div>
+</template>
+
+<script setup>
+	import { useRoute } from 'vue-router'
+	import router from '@/router'
+	import { message } from 'ant-design-vue'
+	import orgApi from '@/api/sys/orgApi.js'
+	import alarmUserApi from '@/api/coldchain/alarmUserApi'
+
+	const orgId = ref() //选中的机构
+	const options = ref([]) //机构数据
+	const loading = ref(false) //按钮加载
+	const queryObj = ref({}) //携带的参数
+	const Route = useRoute()
+
+	onMounted(() => {
+		getOrg()
+		if (Route.query.code) {
+			queryObj.value = Route.query
+		}
+	})
+
+	// 获取机构信息
+	const getOrg = () => {
+		orgApi.orgList().then((res) => {
+			options.value = res || []
+		})
+	}
+	// 确定
+	const onSubmit = () => {
+		if (queryObj.value && queryObj.value.code) {
+			this.loading = true
+			alarmUserApi
+				.getwxUserInfo({ code: queryObj.value.code, orgId: orgId.value })
+				.then((res) => {
+					loading.value = false
+
+					router.push({
+						path: '/success',
+						query: {
+							data: res.data
+						}
+					})
+				})
+				.catch((err) => {
+					loading.value = false
+					message.error('当前无权授权')
+				})
+		} else {
+			loading.value = false
+			message.error('当前无权授权')
+		}
+	}
+</script>
+
+<style lang="less" scoped>
+	.wx {
+		height: 400px;
+		text-align: center;
+		padding-top: 45%;
+
+		.title {
+			font-size: 13px;
+			margin: 20px 0;
+			color: #303133;
+		}
+
+		.btn {
+			margin: 20px 0;
+		}
+	}
+</style>