<template>
	<view class="content">
		<view class="text-area"><text class="title">OneId 小程序演示demo</text></view>
		<view class="text-area"><text class="title">appid:</text><text class="title">{{appid}}</text></view>
		<view class="text-area"><text class="title">version:</text><text class="title">{{version}}</text></view>
		<view class="text-area"><text class="title">oneid:</text><text class="title">{{oneid}}</text></view>



			<button type="primary" @click="queryLBS">queryLBS</button>
			<text class="title">queryLBS result:{{queryresult}}</text>

	</view>
</template>

<script>
	import OneID from '../../utils/gtoneid-all.js'

	export default {
		data() {
			return {
				appid: 'rA2G1vfKeE7NlXKPHZrr73',
				version: '',
				oneid: '',
				queryresult: ''
			}
		},
		onLoad() {
			let that = this
			this.version = OneID.getVersion()
			OneID.init({
				appId: 'rA2G1vfKeE7NlXKPHZrr73',
				onSuccess: function(res) {
					let r = JSON.stringify(res)
					console.log('OneID init success', r)
					that.oneid = 'OneID init success' + r
				},
				onFailure: function(res) {
					console.log('OneID init failure', res)
					that.oneid = 'OneID init failure' + res
				}
			})
			// this.queryLBS()
		},
		methods: {
			queryLBS() {
				let that = this
				OneID.queryLBS(5, {
					onSuccess: function(res) {
						let r = JSON.stringify(res)
						console.log('OneID queryLBS success', r)
						that.queryresult = r
					},
					onFailure: function(res) {
						let r = JSON.stringify(res)
						console.log('OneID queryLBS failure', r)
						that.queryresult = r
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: center;
		margin-top: 20rpx;
	}

	.button_layout {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin-top: 20rpx;
	}

	.button {
		margin-left: 20rpx;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: flex-start;
		margin-top: 20rpx;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>