<template>
  <div class="AppWxworkQrcode">
    <div class="header">
      <AiSelect v-model="id" :list="dictList" @name="v=> idName = v">
        <span class="label" v-if="id">{{ idName }}</span>
        <span v-else class="col-666">请选择群聊</span>
        <u-icon name="arrow-down" color="#666" size="24" style="margin-left: 4px"></u-icon>
      </AiSelect>
      <div class="qrcode-content">
        <AiImage :src="picUrl" class="qrcode-img" v-if="picUrl" preview/>
        <div v-else class="tips">
          <AiEmpty :description="`暂未选择群聊`" class="emptyWrap"/>
        </div>
      </div>
      
      <div class="jionGroup"> 
        长按识别二维码或扫码加入群聊
        <!-- 通过扫一扫加入、与通过插件加入只能选一种 -->
        <!-- <cell class="group" @startmessage="startmessage" @completemessage="completemessage" 
        url='picUrl' v-if="picUrl"></cell> -->
      </div>

      <div class="pic">
        <img src="https://cdn.cunwuyun.cn/fengdu/mdpi_img-chongqing.png" alt="">
      </div>
    </div>
  </div>
</template>
<script>
import {mapState} from 'vuex'
export default {
  name: "AppWxworkQrcode",
  appName: "居民社群",
  computed: {
    ...mapState(['user'])
  },
  data() {
    return {
      dictList: [],
      id: '',
      current: 0,
      list: [],
      picUrl: '',
      idName: '',
    }
  },
  onShow() {
    this.getSelect()
  },
  watch: {
    id: {
      handler(v) {
        if(v) {
          this.picUrl = this.list.filter(i=> i.id == v)[0].qrCode
        }
      }
    }
  },
  methods: {
    getSelect() {
      const {areaId} = this.user
      areaId && this.$instance.post(`/app/wxcp/wxgroup/listByAreaId`, null, {
        params: {
          areaId: areaId,
          current: this.current,
          size: 3000,
        }
      }).then(res => {
        if (res?.data) {
          this.list = res.data.records
          this.dictList = res.data.records.map(e=> {
            return {
              value: e.id,
              label: e.name
            }
          })
        }
      })
    },
  },
}
</script>
<style scoped lang="scss">
.AppWxworkQrcode {
  width: 100%;
  height: 100%;
  padding: 32px;
  box-sizing: border-box;

  ::v-deep .AiSelect {
    width: 100%;
    text-align: center;
    padding: 12% 72px 0;
    box-sizing: border-box;
  }

  ::v-deep .AiSelect .display {
    justify-content: center;
  }

  .jionGroup {
    width: 100%;
    height: 40px;
    line-height: 40px;
    padding: 0 72px;
    box-sizing: border-box;
    color: #666;
    text-align: center;
    font-size: 28px;
    // ::v-deep functional-page-navigator {
    //   width: 100%;
    //   height: 100%;
    //   text-align: center;
    //   background: #2D7DFF;
    //   border-radius: 40px;
    //   view {
    //     text {
    //       color: #FFFFFF !important;
    //       margin: 0;
    //     }
    //     image {
    //       display: none;
    //     }
    //   }
    // }
  }
  ::v-deep .group_chat_icon {
    display: none;
  }

  .header {
    width: 100%;
    height: 100%;
    background: #FFF;
    border-radius: 16px;

    .qrcode-content {
      width: 542px;
      height: 542px;
      margin: 10% auto 10%;
      background: #F6F9FF;
      border-radius: 12px;
      border: 8px solid #f6f5f8;
      padding: 36px;
      box-sizing: border-box;

      ::v-deep AiImage {
        width: 100%;
        height: 100%;
      }

      ::v-deep .qrcode-img {
        width: 470px;
        height: 470px;

        image {
          width: 470px;
          height: 470px;
        }
      }
      .tips {
        width: 100%;
        height: 100%;
      }
      

      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;
      }
    }
  }
  .pic {
    margin-top: 10%;
    width: 100%;
    height: 266px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .col-666 {
    color: #666;
  }
}
</style>
