<template>
  <div>
    <van-nav-bar title="邀请成员" left-text="返回" @click-left="$route_back" left-arrow></van-nav-bar>
    <div class="body_com has_header">
      <scroller>
        <van-cell-group>
          <van-cell is-link title="微信邀请" clickable class="employee_cell" @click="query_share(item)" v-for="(item, index) in shares" :key="index" label="发送给微信好友">
            <template slot="icon">
              <img src="static/images/jiaru.jpg" class="employee_cell_head_img"/>
            </template>
          </van-cell>
          <van-cell is-link title="二维码邀请" clickable class="employee_cell" label="扫描二维码进入公司">
            <template slot="icon">
              <img src="static/images/jiaru.jpg" class="employee_cell_head_img"/>
            </template>
          </van-cell>
        </van-cell-group>
        <!-- <van-button @click="query_share(item)" v-for="(item, index) in shares">{{item.id}}</van-button> -->
      </scroller>
    </div>
  </div>
</template>
<script>
  import Vue from 'vue'
  export default {
    data () {
      return {
        user_info: this.$store.getters.user_info,
        shares: []
      }
    },
    watch: {
    },
    methods: {
      query_share (s) {
        if (s.id == 'weixin') {
          let pictures = '_www/static/images/logo.png'
          if(plus.os.name == 'Android'){
            pictures = plus.io.convertLocalFileSystemURL(pictures)
          }
          s.send({
            extra: {scene:'WXSceneSession'},
            type: 'web',
            title: this.user_info.name + '邀请你加入', // + this.company_info.name
            content: '我们的同事都在用功道云，点击立即申请加入',
            thumbs: [pictures],
            href: 'https://g107.com/#/site_id=' + this.user_info.site_id + '&employee_id=' + this.user_info.id + '&company_name=', // + this.company_info.name
          }, function () {
            alert('分享成功！')
          }, function (e) {
            alert('分享失败：' + e.message)
          })
        }
      }
    },
    created () {
      let self = this
      if (window.plus) {
        window.plus.share.getServices(function(s){
          self.shares = s;
        }, function(e){
          alert("获取分享服务列表失败："+e.message);
        });
      }
    }
  }
</script>

<style scoped>
.body_com{height: calc(100% - 1rem); position: relative;}

  .employee_cell_head_img {
    width: 0.8rem;
    height: 0.8rem;
    -webkit-border-radius: 0.1rem;
    -moz-border-radius: 0.1rem;
    border-radius: 0.1rem;
    margin-right: 0.24rem;
  }

  .employee_cell {
    padding: 0.16rem 0.32rem;
  }

  .employee_cell .van-cell__right-icon{margin-top:0.2rem;}
</style>
