<script setup lang="ts">
import HomeTabs from "./components/HomeTabs.vue";
import HomeList from "./components/HomeList.vue";
import { ref, reactive, onMounted } from "vue";
import { login } from "@/hooks/useIsLogin";
import { onLaunch, onShow } from "@dcloudio/uni-app";
import { chooseImageApi } from "@/utils/js_sdk_utils";
const companyName = ref<string>("");

const phoneGet = ref<any>();

onLaunch(() => {
  //进入到页面的时候查看解析页面路径查看页面路径中是含有code
  //如果含有code 则根据code 获取openid
  //如果没有 则访问微信路径，然后重定向到我们的页面
  //然后根据返回的信息有没有手机号，如果没有则调用手机号登录界面
  //接下来调试---调用扫描接口看看sdk可以用吗
});
onMounted(() => {
  //我来了
});
onShow(() => {
  console.log("onshow");
  login();
});
//点击进行扫码
const scanFun = async () => {
  const res = await chooseImageApi();
  console.log("-------------1------------");
  console.log(res);
  //点击进行扫码
};
//调用子组件
const phoneGetFun = () => {
  phoneGet.value.open();
};
const validFun = () => {
  //判断用户授权登录没有
  phoneGetFun();
  //跳转到邀请用户页面
  // uni.navigateTo({ url: "/pages/index/inviteUser" });
};
</script>
<template>
  <!-- 引入头部安全区域组件 -->
  <view class="home_padding">
    <button @click="scanFun">获取图片</button>
    <ShuiWuTop />
    <HomeTabs @jumpInvite="validFun" />
    <view class="list_search">
      <uni-easyinput type="text" v-model="companyName" placeholder="请输入公司名称" />
    </view>
    <HomeList class="home_list_com" />
    <ShuiWuGetPhone ref="phoneGet" />
  </view>
</template>
<style>
.list_search >>> .is-input-border {
  display: flex;
  box-sizing: border-box;
  flex-direction: row;
  align-items: center;
  border: 1px solid #dcdfe6;
  border-radius: 400px !important;
}
</style>
<style lang="scss">
page {
  height: 100%;
  background-color: rgb(243, 250, 248);
}
.home_padding {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0rpx 20rpx;
  .home_list_com {
    flex: 1;
    overflow: scroll;
  }
  .list_search {
    margin-top: 40rpx;
  }
}
</style>
