<template>
	<view>
		<!-- 生成公众号二维码 -->
		<we-qrcode @generate="(e) => qrcodeResult(e)"></we-qrcode>

		<officialAccount followIndex="order" :wechatAcQrcode="wechatAcQrcode" v-if="showOfficialAccount" @close="modelClose($event, 'officialAccount')" />
		<!-- <Drainage  v-model="showDrainage" @close="modelClose($event, 'drainage')" /> -->
		<attractPopup type="order" ref="attractPopupRef" />
	</view>
</template>
<script setup>
import weQrcode from '@/components/wechat-ac-qrcode.vue';

import attractPopup from '@/components/attract-popup.vue';
import { ref, watch, computed, reactive, toRaw } from 'vue';
import officialAccount from '@/components/official-account.vue';
import Drainage from '@/components/drainage.vue';

const attractPopupRef = ref(null);

const showDrainage = defineModel({
	type: Boolean,
	default: false
});

watch(showDrainage, (newVal, oldVal) => {
	console.log('modelValue 变化：', { newVal, oldVal });
	if (newVal == true) {
		attractPopupRef.value.configAjax();
	}
});

const showOfficialAccount = ref(false);

function modelClose(e, type) {
	if (type == 'drainage') {
		showOfficialAccount.value = true;
		return;
	}
}
const wechatAcQrcode = ref('');
const userinfo = uni.cache.get('userInfo') || {};
const codeVal = ref(userinfo.wechatAcQrcode || '');
console.log('codeVal', codeVal.value);
function qrcodeResult(e) {
	wechatAcQrcode.value = e;
}
</script>
