<template>
  <view>
    <!-- 生成公众号二维码 -->

    <view class="qrcode-box" v-if="codeOptions.code">
      <w-qrcode
        :options="codeOptions"
        ref="wQrcode"
        @generate="(e) => qrcodeResult(e)"
      ></w-qrcode>
    </view>
  </view>
</template>

<script setup>
import wQrcode from "@/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue";
import { onMounted ,ref} from "vue";
const codeOptions = ref({
  size: 200,
  code: "",
});

onMounted(() => {
  // 页面加载完成后生成二维码
  const userInfo = uni.cache.get("userInfo") || {};
  const wechatAcQrcode = userInfo.wechatAcQrcode || "";
  if(!userInfo.isAc){
    codeOptions.value.code = wechatAcQrcode;
  }
});
const emit = defineEmits(["generate"]);
function qrcodeResult(e) {
  const userInfo = uni.cache.get("userInfo") || {};
  if(!userInfo.isAc){
    emit("generate", e.img.tempFilePath);

  }

}
</script>

<style scoped>
.qrcode-box {
  position: relative;
  overflow: hidden;
  left: -400px;
  width: 1px;
  height: 1px;
  opacity: 0;
  z-index: -1;
}
</style>