<template>
	<div>
		<div>
			<el-button type="primary" @click="getjson">getjson</el-button>
			<el-button type="primary" @click="postjson">postjson</el-button>
		</div>
		<div><el-button type="primary" @click="getxwww">getxwww</el-button>
			<el-button type="primary" @click="postxwww">postxwww</el-button>
		</div>
		{{text}}
	</div>
</template>

<script setup>
	import {
		ref,
		onBeforeMount,
		getCurrentInstance,

	} from 'vue'
	const {
		proxy
	} = getCurrentInstance()


	import {
		onBeforeRouteUpdate
	} from 'vue-router'

	onBeforeMount(() => {
		getPublicKey()
	})



	const username = ref('admin!@#+{}')
	const password = ref('123SDf啊啊啊啊对对对')
	const text = ref('')
	const getjson = () => {
		text.value = ''
		var url = 'framework/Test/testGetJSON'
		var param = {
			username: username.value,
			password: password.value
		}
		proxy.$axios.get(url, param, 'application/json').then(response => {
			if (response.data.code == '0') {
				console.log(response.data.data)
				text.value = response.data.data
			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		});
	}

	const postjson = () => {
		text.value = ''
		var url = 'framework/Test/testPostJSON'
		var param = {
			username: username.value,
			password: password.value
		}
		proxy.$axios.post(url, param, 'application/json').then(response => {
			if (response.data.code == '0') {
				console.log(response.data.data)
				text.value = response.data.data
			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		});
	}


	const getxwww = () => {
		text.value = ''
		var url = 'framework/Test/testGetXWWW'
		var param = {
			username: username.value,
			password: password.value
		}
		proxy.$axios.get(url, param).then(response => {
			if (response.data.code == '0') {
				console.log(response.data.data)
				text.value = response.data.data
			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		});
	}

	const postxwww = () => {
		text.value = ''
		var url = 'framework/Test/testPostXWWW'
		var param = {
			username: username.value,
			password: password.value
		}
		proxy.$axios.post(url, param).then(response => {
			if (response.data.code == '0') {
				console.log(response.data.data)
				text.value = response.data.data
			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		});
	}


	const getPublicKey = () => {
		console.log('getPublicKey')
		var url = 'framework/SysLogin/queryPublicKey'
		var param = {}
		proxy.$axios.post(url, param).then(response => {
			if (response.data.code == '0') {
				localStorage.setItem('publicKey', response.data.data)
				 
			} else {
				 
			}
		});
	}
</script>

<style>
</style>