<template>
  <div class="AppWxworkQrcode">
    <div class="header-content">
      <img src="https://cdn.cunwuyun.cn/dvcp/villgroup/group.png" alt="" class="group-img">
      <div class="group-name">{{ info.areaName || '' }}</div>
      <p>已有{{ info.peopleNum || 0 }}户居民</p>
      <img src="https://cdn.cunwuyun.cn/dvcp/villgroup/head.png" alt="" class="banner-img">
      <div v-if="info.codeUrl" class="qrcode-content">
        <AiImage :src="info.codeUrl" class="qrcode-img" preview/>
        <div>长按识别二维码或扫码入群</div>
      </div>
      <div v-else class="qrcode-content flex column">
        <div>请先去个人中心进行实名认证</div>
        <div class="mar-t8 btn pad-v8 pad-h16" @click="goAuth">去实名</div>
      </div>
    </div>
  </div>
</template>
<script>
import {mapState} from 'vuex'

export default {
  name: "AppWxworkQrcode",
  appName: "群二维码",
  computed: {
    ...mapState(['user'])
  },
  data() {
    return {
      info: {}
    }
  },
  onShow() {
    this.getDetail()
  },
  methods: {
    getDetail() {
      const {areaId} = this.user
      areaId && this.$instance.post(`/app/wxcp/wxgroup/listByAreaId`, null, {
        params: {areaId}
      }).then(res => {
        if (res?.data) {
          this.info = res.data
        }
      })
    },
    goAuth() {
      uni.navigateTo({url: "/mods/AppAuth/AppAuth"})
    }
  },
  onShareAppMessage() {
    return {
      title: '入群二维码',
      path: `/mods/AppWxworkQrcode/AppWxworkQrcode`
    }
  }
}
</script>
<style scoped lang="scss">
.AppWxworkQrcode {
  width: 100vw;
  height: auto;
  padding-top: 30px;
  background-color: #f3f6f9;
  padding-bottom: 48px;

  .header-content {
    padding: 40px 70px 56px;
    width: 690px;
    background: #FFF;
    border-radius: 16px;
    margin: 0 0 24px 30px;
    box-sizing: border-box;

    .group-img {
      width: 92px;
      height: 96px;
      border-radius: 8px;
      margin-bottom: 22px;
    }

    .group-name {
      font-size: 36px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333;
      line-height: 50px;
      margin-bottom: 4px;
    }

    p {
      font-size: 24px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #999;
      line-height: 34px;
      margin-bottom: 38px;
    }

    .banner-img {
      width: 100%;
      height: 110px;
    }

    .qrcode-content {
      width: 100%;
      height: 592px;
      background: #F6F9FF;
      border-radius: 12px;
      border: 2px solid #E6EEFF;
      padding: 56px 66px;
      box-sizing: border-box;
      margin-top: -8px;
      justify-content: center;

      ::v-deep .qrcode-img {
        width: 420px;
        height: 420px;
        margin-bottom: 24px;

        image {
          width: 420px;
          height: 420px;
        }
      }

      div {
        font-size: 26px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #333;
        line-height: 36px;
        text-align: center;
      }

      .btn {
        background: #26f;
        color: #fff;
        border-radius: 8px;
      }
    }
  }
}
</style>
