<template>
	<view></view>
</template>

<script>
export default {
	data() {
		return {
			type: ''
		}
	},
	onLoad(options) {
		this.type = options.type
		this.handleCheck(this.type)
	},
	methods: {
		handleCheck(type) {
			uni.login({
				provider: 'weixin',
				success: (res) => {
					this.handleQuery(type, res.code)
				}
			})
		},
		// 查询请求
		async handleQuery(type, code) {
			if (type === '1') {
				// 查询商家是否绑定
				const res = await this.$myRequest({
					url: '/mhotel/appget_user_ma.action',
					data: {
						code
					}
				})
				if (res.code === 200) {
					let data = JSON.stringify(res.data)
					uni.navigateTo({
						url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
					})
				} else {
					uni.navigateTo({
						url: '/pages/shop/shop'
					})
				}
			} else if (type === '2') {
				// 查询业主是否已绑定
				const res = await this.$myRequest({
					url: '/mhotel/appgetUser.action',
					data: {
						code
					}
				})
				if (res.code === 200) {
					let data = JSON.stringify(res.data)
					uni.navigateTo({
						url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
					})
				} else {
					uni.navigateTo({
						url: '/pages/shop2/shop2'
					})
				}
			}
		}
	}
}
</script>

<style lang="scss" scoped></style>
