<script setup>
import DraggableButton from "@/pages/components/goHome.vue";

	/**
	 * name：
	 * user：sa0ChunLuyu
	 * date：2024年8月7日 21:01:52
	 */
	import {
		ref
	} from 'vue'
	import {
		$api,
		$response
	} from '@/api'
	import {
		onShow
	} from '@dcloudio/uni-app'
	import JWeixin from "weixin-js-sdk"

	const latitude = ref('39.867671')
	const longitude = ref('119.514223')
	const mapClick = () => {
		let url = '/pages/main/map/map?'
		let query_arr = []
		query_arr.push(`type=gcj02`)
		query_arr.push(`latitude=${latitude.value}`)
		query_arr.push(`longitude=${longitude.value}`)
		query_arr.push(`scale=18`)
		query_arr.push(`name=${encodeURIComponent('测试地址')}`)
		query_arr.push(`address=${encodeURIComponent('测试地址测试地址123 测试地址')}`)
		url = url + query_arr.join('&')
		JWeixin.miniProgram.navigateTo({
			url: url,
		});
	}

	const total = ref('1')
	const openid = ref('ourv44tbkA8yLB8X60GhmvhetVTM')
	const payClick = async () => {
		let total_number = Number(total.value)
		if (!total_number) uni.$lu.toast('请输入正确金额')
		const response = await $api('DemoPay', {
			total: total_number,
			openid: openid.value,
		})
		$response(response, () => {
			let p = JSON.stringify({
				...response.data.pay,
				url: 'https://h5.hainan2024.ziqian.online/h5/#/pages/main/dev/dev'
			})
			let url = '/pages/main/pay/pay?'
			let query_arr = []
			query_arr.push(`p=${encodeURIComponent(p)}`)
			url = url + query_arr.join('&')
			JWeixin.miniProgram.navigateTo({
				url: url,
			});
		})
	}
</script>
<template>
	<DraggableButton />
	<view>
		<view>
			<view>
				<input class="uni-input" v-model="latitude" />
				<input class="uni-input" v-model="longitude" />
				<button @click="mapClick()">地图测试</button>
			</view>

			<view>
				<input class="uni-input" v-model="total" />
				<input class="uni-input" v-model="openid" />
				<button @click="payClick()">支付测试</button>
			</view>
		</view>
		<view class="blank_wrapper"></view>
	</view>
</template>
<style scoped>

</style>