<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport"
    content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no, viewport-fit=cover" />
  <title>待办任务</title>
  <!-- 引入样式文件 -->
  <link rel="stylesheet"
    href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1758012584633/vant.css" />
  <link rel="stylesheet" href="../css/page-return.css">
    <!-- 必须先引入vue，  后使用vant-ui -->
  <script
    src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
  <!-- 引入vant的组件库-->
  <!-- 引入 Vant 的 JS 文件 -->
  <script
    src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1758012748487/vant.min.js"></script>

  <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
  <script src="../js/page-return.js"></script>
  <!-- <script src="../js/vconsole.min.js"></script>
    <script>
  		  var vConsole = new window.VConsole();
  		</script> -->
</head>
<style>
  body {
    margin: 0;
    padding: 0;
  }

  .box {
    width: 100vw;
    height: 100vh;
    box-sizing: border-box;
    background: #F7F9FC;
  }

  .page5 {
    width: 100vw;
    box-sizing: border-box;
    padding: 15px 10px 39px;
  }

  .task_list {}

  .task_item {
    width: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, #FFFFFF 100%);
    border-radius: 15px;
    border: 1px solid #FFFFFF;
    box-sizing: border-box;
    margin-bottom: 15px;
  }

  .task_item:last-child {
    margin-bottom: 0;
  }

  .task_item_title {
    display: flex;
    align-items: center;
    padding: 15px 15px 0;
  }

  .task_item_title img {
    width: 53px;
    height: 53px;
    border-radius: 10px;
    margin-right: 10px;
  }

  .task_item_text {
    font-weight: 500;
    font-size: 16px;
    color: #222222;
    line-height: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .client_name {
    display: flex;
  }
  .client_remark {
    font-size: 12px;
    color: #999999;
    padding-left: 5px;
  }
  .task_item_time {
    font-size: 12px;
    color: #999999;
  }
  .client_tag {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 0 15px 9px;
    gap: 8px;
  }
  .client_tag_title {
    font-size: 12px;
    color: #999999;
    line-height: 17px;
    white-space: nowrap;
    padding-right: 5px;
  }
  
  .client_tag span {
    height: 21px;
    font-size: 12px;
    color: #1677FF;
    line-height: 17px;
    border-radius: 5px;
    padding: 2px 8px;
    background: rgba(22, 119, 255, 0.1);
    box-sizing: border-box;
    white-space: nowrap;
  }

  .task_item_line {
    width: 100%;
    height: 1px;
    margin: 15px 0 14px;
    background: linear-gradient(90deg, rgba(217,219,227,0) 0%, #D9DBE3 49%, rgba(217,219,227,0) 100%);
  }

  .task_des_title {
    font-size: 14px;
    color: #222222;
    line-height: 20px;
    padding-bottom: 17px;
  }

  .task_des {
    font-size: 12px;
    color: #999999;
    line-height: 18px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .task_detail {
    padding: 15px 15px 20px;
    background: linear-gradient( 180deg, rgba(255,255,255,0.8) 0%, #FFFFFF 100%);
    border-radius: 15px;
    border: 1px solid #FFFFFF;
    margin-bottom: 15px;
  }

  .task_btn {
    width: 100%;
    height: 40px;
    background: #1677FF;
    border-radius: 22px;
    font-weight: bold;
    font-size: 14px;
    color: #FFFFFF;
    line-height: 40px;
    text-align: center;
    margin-top: 25px;
  }
  .task_detail_con {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 20px;
  }
  .task_detail_con_item {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: #666666;
  }
  .task_detail_con_data {
    font-weight: 500;
    font-size: 14px;
    color: #136DFB;
    line-height: 20px;
    padding-top: 10px;
  }
  .inten_title {
    font-weight: 500;
    font-size: 14px;
    color: #222222;
    line-height: 20px;
    padding-bottom: 15px;
    padding-left: 5px;
    position: relative;
    display: flex;
    align-items: center;
  }
  .inten_title::after {
    position: absolute;
    left: 0;
    content: '';
    width: 2px;
    height: 12px;
    background: #FF4141;
    border-radius: 1px;
  }
  .ai_title {
    font-size: 12px;
    color: #666666;
    line-height: 17px;
    padding-bottom: 10px;
  }
  .task_ai_des {
    font-size: 14px;
    color: #222222;
    line-height: 23px;
  }
  .clue_data {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
  }
  .clue_data_item {
    display: flex;
    flex-direction: column;
  }
  .clue_data_time {
    font-weight: 500;
    font-size: 14px;
    color: #136DFB;
    line-height: 20px;
  }

  .followup_list {
    width: 100%;
    padding: 0 10px 20px;
    background: #FFFFFF;
    border-radius: 5px;
    box-sizing: border-box;
  }
  .follow_time {
    display: flex;
    align-items: center;
    font-weight: 400;
    font-size: 14px;
    color: #222222;
    margin-bottom: 15px;
  }
  .time_dot {
    background: #E6F0FF;
    padding: 3px;
    border-radius: 50%;
    margin-right: 10px;
    box-sizing: border-box;
  }
  .dot {
    width: 6px;
    height: 6px;
    background: #1677FF;
    border-radius: 50%;
  }
  .follow_item {
    padding-right: 10px;
    padding-left: 15px;
    padding-bottom: 5px;
  }
  .follow_padding {
    padding-top: 15px; 
    padding-bottom: 5px;
    background: #F7F9FC;
    border-radius: 5px;
  }
  .follow_item_time {
    font-weight: 500;
    font-size: 14px;
    color: #222222;
    display: flex;
    align-items: center;
    margin-bottom: 3px;
  }
  .item_time {
    font-weight: 400;
    font-size: 12px;
    color: #999999;
    padding-right: 10px;
  }
  .item_box {
    display: flex;
    align-items: flex-end;
  }
  .follow_item_line {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 13px;
    padding-right: 21px;
  }
  .line_dot {
    width: 6px;
    height: 6px;
    background: #1677FF;
    border-radius: 50%;
    margin-bottom: 5px;
  }
  .line {
      width: 1px;
      height: 66px;
      border-left: 1px dashed #1677FF;
    }
  .item_content {
    background: #FFFFFF;
    border-radius: 5px;
    padding: 10px;
    font-weight: 400;
    font-size: 12px;
    color: #222222;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
  }
  .item_content img {
    width: 37px;
    height: 37px;
    margin-right: 10px;
  }
  .item_tip {
    font-size: 12px;
    color: #222222;
    line-height: 18px;
    max-width: 120px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .item_tip2 {
    font-size: 12px;
    color: #222222;
    line-height: 17px;
    gap: 5px;
    max-width: 120px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .foot_box {
    display: flex;
    justify-content: center;
    padding: 0 25px;
    margin-bottom: 10px;
  }
  .foot_btn {
    width: 100%;
    height: 50px;
    background: #1677FF;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
    color: #FFFFFF;
    line-height: 50px;
    text-align: center;
  }

  /* 客户SOP任务详情 */
  
  .top_tip {
    background: #afdefd;
    display: flex;
    justify-content: center;
    color: #FFF;
    font-size: 14px;
    padding: 6px 0;
  }

  .logo {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }

  .content {
    padding: 20px;
    margin-bottom: 10px;
    background: #FFF;
  }

  .icon_logo {
    width: 20px;
    vertical-align: bottom;
  }

  .sop_content {
    background: #f1f9ff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
  }

  .font {
    color: #1890ff;
  }

  .send_title {
    padding: 20px;
    background: #FFF;
    border-bottom: 1px solid #d2d3d4;
  }

  .send_content {
    padding: 20px;
    background: #FFF;
    margin-bottom: 10px;
  }

  .send_item {
    background: #F8F8F8;
    padding: 20px;
    margin-bottom: 10px;
    border-radius: 10px;
    font-size: 14px;
  }

  .send_logo {
    width: 100px;
    border-radius: 10px;
  }

  .follow_client {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    font-size: 14px;
    background: #FFF;
  }

  .client_msg {
    display: flex;
    flex-direction: column;
  }

  .avatar {
    width: 60px;
    height: 60px;
    border-radius: 10px;
  }

  .follow_btn {
    background: #f1f9ff;
    color: #1890ff;
    padding: 5px;
    border-radius: 4px;
    font-size: 12px;
  }
  /* 客户SOP任务详情结束 */
</style>

<body>
  <div id="box" class="box">
    <div class="page5">
      <!-- 任务详情 -->
      <div v-if="type === 'CLIENT_SOP'">
        <div class="content">
          <div class="sop_content">
            <img class="icon_logo" :src="taskData.clientAvatar || '../img/qw/mem_icon.png'"></img>
            <span>「{{taskData.clientName}}」在「{{timeFormat(taskData.triggerTime, 'yyyy/MM/dd hh:mm:ss')}}」</span>
            <span class="font" v-if="taskData.triggerType">添加好友后触发客户SOP任务，</span>
            <span class="font" v-else>打上标签后触发客户SOP任务，</span>
            <span>快去跟进吧</span>
          </div>
        </div>
        <div class="send_title">推送内容</div>
        <div class="send_content" v-if="taskData.contentText">
          <div class="send_item">
            <div class="sop_c">
              <span>文字：{{ taskData.contentText }}</span>
            </div>
          </div>
        </div>
        <div class="send_content" v-if="taskData.matters && taskData.matters.length > 0">
          <div class="send_item" v-for="(m, index) in taskData.matters" :key="index">
            <div v-if="m.contentType === 0" class="sop_c">
              <span>文章：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 31" class="sop_c">
              <span>海报：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 2" class="sop_c">
              <span>表单：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 3" class="sop_c">
              <span>文件：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 15" class="sop_c">
              <span>视频：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 16" class="sop_c">
              <span>视频链接：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 51" class="sop_c">
              <span>视频号：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 33" class="sop_c">
              <span>小程序：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 17" class="sop_c">
              <span>图集：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 19" class="sop_c">
              <span>图集项图片：{{ m.title }}</span>
            </div>
            <div v-if="m.contentType === 4" class="sop_c">
              <span>外部链接：{{ m.title }}</span>
            </div>
          </div>
        </div>
        <div class="send_content" v-if="taskData.ctOthers && taskData.ctOthers.length > 0">
          <div class="send_item" v-for="(item, index) in taskData.ctOthers" :key="index">
            <div class="sop_c" v-if="item.matterType === 0">
              <span>{{ item.matterText }}</span>
            </div>
            <div class="sop_c" v-if="item.matterType === 1">
              <img class="send_logo" :src="item.imgUrl" />
            </div>
            <div class="sop_c" v-if="item.matterType === 5">
              <span>{{ item.linkTitle }}</span>
            </div>
            <div class="sop_c" v-if="item.matterType === 2">
              <span>自定义视频</span>
            </div>
            <div class="sop_c" v-if="item.matterType === 4">
              <span>{{ item.fileName }}</span>
            </div>
          </div>
        </div>
        <div class="send_title">跟进客户</div>
        <div class="follow_client">
          <img class="avatar" :src="taskData.clientAvatar || '../img/qw/mem_icon.png'"></img>
          <div class="client_msg">
            <span class="font">{{taskData.clientName}}</span>
            <span>添加时间：{{timeFormat(taskData.addTime, 'yyyy/MM/dd hh:mm:ss')}}</span>
          </div>
          <div class="follow_btn" @click="toFollow">去跟进</div>
        </div>
      </div>
      <div v-else>
        <div class="task_item">
          <div class="task_item_title">
            <img :src="taskData.clientAvatar || '../img/qw/mem_icon.png'" alt="">
            <div class="task_item_text">
              <div class="client_name">{{taskData.clientName}}
                <span class="client_remark">({{taskData.clientRemark}})</span>
              </div>
              <div class="task_item_time">任务时间: {{formatDate(taskData.createdTime)}}</div>
            </div>
          </div>
          <div class="task_item_line"></div>
          <div class="client_tag">
            <div class="client_tag_title">客户标签：</div>
            <span v-for="(item, index) in taskData.clientTags" :key="index">{{item}}</span>
          </div>
        </div>
        <div class="task_detail" v-if="type === 'SELL_PROCESS'">
          <div class="task_des_title">{{taskData.sellProcessName}}</div>
          <div class="task_detail_con">
            <div class="task_detail_con_item">
              <div>进入当前阶段：</div>
              <div class="task_detail_con_data">{{taskData.sellProcessName}}</div>
            </div>
            <div class="task_detail_con_item">
              <div>停留时间：</div>
              <div class="task_detail_con_data">{{formatTimeDiff(taskData.processTime).simpleFormat()}}</div>
            </div>
            <div class="task_detail_con_item">
              <div>上次联系时间：</div>
              <div class="task_detail_con_data">{{taskData.lastContactTime}}</div>
            </div>
            <div class="task_detail_con_item">
              <div>未联系时间：</div>
              <div class="task_detail_con_data">{{formatTimeDiff(taskData.lastContactTime).simpleFormat()}}</div>
            </div>
          </div>
        </div>
        <div v-if="type === 'INTENTION_SESSION' && taskData.intentionGroupList && taskData.intentionGroupList.length > 0">
          <div class="task_detail" v-for="(item, index) in taskData.intentionGroupList" :key="index">
            <div class="inten_title">{{item.nameList[0]}}</div>
            <div class="ai_title">AI分析：</div>
            <div class="task_ai_des">{{item.reason}}</div>
          </div>
        </div>
        <div class="task_detail" v-if="type === 'SESSION_CLUE'">
          <div class="clue_data">
            <div class="clue_data_item">
              <div class="ai_title">添加企微时间：</div>
              <div class="clue_data_time">{{timeFormat(taskData.clientAddTime)}}</div>
            </div>
            <div class="clue_data_item">
              <div class="ai_title">线索分类：</div>
              <div class="clue_data_time">
                <span>{{taskData.category}}</span>
                <span style="color: #CCCCCC;">—</span>
                <span style="color: #7D97BF;">{{taskData.subCategory}}</span></div>
            </div>
          </div>
          <div class="ai_title">线索依据：</div>
          <div class="task_ai_des" style="margin-bottom: 20px;">{{taskData.clueMsg}}</div>
          <div class="ai_title">AI分析：</div>
          <div class="task_ai_des">{{taskData.analysisReason}}</div>
        </div>
        <div class="task_detail" v-if="type === 'SENTIMENT_SESSION'">
          <div class="ai_title">AI情绪分析：</div>
          <div class="task_ai_des">{{taskData.sentimentReason}}</div>
        </div>
        <div class="task_detail" style="padding: 20px 10px;" v-if="type === 'CLIENT_LOG'">
          <div class="followup_list" v-for="(item, key) in taskData.clientLogDetails" :key="key">
            <div class="follow_time">
              <div class="time_dot">
                <div class="dot"></div>
              </div>
              <span>{{item.createdTime}}</span>
            </div>
            <div class="follow_padding">
              <div class="follow_item">
                <div class="follow_item_time">
                  <span class="item_time">{{timeFormat(item.createdTime, 'hh:mm')}}</span>
                  <span v-if="item.bizCode === 'READ'">{{item.title}}</span>
                  <span v-else-if="item.bizCode === 'SUBMIT'">留资</span>
                </div>
                <div class="item_box">
                  <div class="follow_item_line">
                    <div class="line_dot"></div>
                    <div class="line"></div>
                  </div>
                  <div class="item_content">
                    <img :src="item.cover || '../img/qw/mem_icon.png'" alt="">
                    <div class="item_tip" v-if="item.bizCode === 'READ'">{{item.content}}</div>
                    <div class="item_tip2" v-else-if="item.bizCode === 'SUBMIT'">
                      <div>{{item.name}}</div>
                      <div>{{item.phone}}</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="foot_box">
        <div class="foot_btn" @click="toFollow">去跟进</div>
      </div>
    </div>
    <!-- 底部返回栏 -->
    <page-return></page-return>
  </div>
</body>
<script>
  new Vue({
    el: '#box',
    data() {
      return {
        httpUrl: '',
        bId: null,
        env: '',
        taskId: null,
        businessId: null,
        type: null,
        taskData: {}
      }
    },
    created() {
      this.bId = this.getQueryParam('bId')
      this.env = this.getQueryParam('env')
      this.taskId = this.getQueryParam('taskId')
      this.businessId = this.getQueryParam('businessId')
      this.type = this.getQueryParam('type')
      if (!this.env || this.env === 'prod') {
        this.httpUrl = 'https://wlapi.wefanbot.com'
      } else {
        this.httpUrl = 'http://test.wefanbot.com:18993'
      }
      this.toRead()
      this.getDetail()
      this.getQyWxSign()
    },
    methods: {
      toRead() {
        fetch(this.httpUrl + `/scrm/v1/wxcp-member-todo-task/p/read?taskId=${this.type === 'CLIENT_SOP' ? this.businessId : this.taskId}`)
          .then(res => {
            return res.json()
          }).then(result => {
            let { data, code, msg } = result
            if (code === 1) {
            } else {
              vant.Toast.fail(msg)
            }
          })
      },
      getDetail() {
        let url = ''
        if (this.type === 'SELL_PROCESS') {
          // 销售进程
          url = `/wxcp/sell-process/p/member/todo-task-info?todoTaskId=${this.taskId}`
        } else if (this.type === 'INTENTION_SESSION') {
          // 意向客户
          url = `/scrm/v1/wxc-intention-session/p/member/todo-task-info?todoTaskId=${this.taskId}`
        } else if (this.type === 'SESSION_CLUE') {
          // 会话线索
          url = `/wxcp/sessionClue/p/member/todo-task-info?todoTaskId=${this.taskId}`
        } else if (this.type === 'SENTIMENT_SESSION') {
          // 投诉
          url = `/scrm/v1/wxc-sentiment-session/p/member/todo-task-info?todoTaskId=${this.taskId}`
        } else if (this.type === 'CLIENT_LOG') {
          // 客户动态
          url = `/scrm/v1/client-log/p/member/todo-task-info?todoTaskId=${this.taskId}`
        } else if (this.type === 'CLIENT_SOP') {
          // 客户SOP
          url = `/scrm/v1/wxcp-sop/p/h5SopHistory?historyId=${this.taskId}`
        }
        fetch(this.httpUrl + url)
          .then(res => {
            return res.json()
          }).then(result => {
            let { data, code, msg } = result
            if (code === 1) {
              this.taskData = data
            } else {
              vant.Toast.fail(msg)
            }
          })
      },
      timeFormat(time, format = 'yyyy-MM-dd hh:mm:ss') {
        if (time === undefined || time === '' || time === null) {
          return '/';
        }

        const date = new Date(time);
        const o = {
          'M+': date.getMonth() + 1, // 月份
          'd+': date.getDate(),      // 日
          'h+': date.getHours(),     // 小时
          'm+': date.getMinutes(),   // 分钟
          's+': date.getSeconds(),   // 秒
          'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
          'S': date.getMilliseconds() // 毫秒
        };

        // 处理年份
        if (/(y+)/.test(format)) {
          format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
        }

        // 处理日期和时间部分
        for (let k in o) {
          if (new RegExp('(' + k + ')').test(format)) {
            let value = o[k];
            let padding = RegExp.$1.length === 1 ? '' : '00'; // 根据格式字符串中的长度决定是否补零
            format = format.replace(RegExp.$1, ('' + value).padStart(padding.length + value.toString().length - value.toString().length, '0'));
          }
        }

        // 如果格式只包含时间部分，移除日期部分可能的占位符
        if (!/(M+|d+)/.test(format)) {
          // 移除任何可能存在的日期占位符（如：'yyyy-MM-dd '）
          format = format.replace(/(\s*-\s*){2}/g, ''); // 移除两个'-'之间的任何内容
          format = format.replace(/^\s*yyyy-\s*/, ''); // 移除开头的'yyyy-'
        }

        // 如果格式只包含日期部分，移除时间部分可能的占位符
        if (!/(h+|m+|s+)/.test(format)) {
          // 移除任何可能存在的时间占位符（如：' hh:mm:ss'）
          format = format.replace(/(\s*:\s*){2}/g, ''); // 移除两个':'之间的任何内容
          format = format.replace(/\s*hh:\s*$/, ''); // 移除结尾的' hh:'
        }

        return format;
      },
      formatDate(input) {
        // 创建 Date 对象（兼容不同浏览器）
        const date = new Date(input)

        // 提取年、月、日
        const year = date.getFullYear()
        const month = String(date.getMonth() + 1).padStart(2, '0') // 月份从0开始，需要+1
        const day = String(date.getDate()).padStart(2, '0')

        return `${year}-${month}-${day}`
      },
      formatTimeDiff(targetTimeStr) {
        const pageEnterTime = new Date();
        // 解析目标时间
        const targetTime = new Date(targetTimeStr);

        // 计算时间差（毫秒）
        const timeDiff = Math.abs(pageEnterTime - targetTime);

        // 计算天、时、分
        const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
        const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        const minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));


        return {
          days,
          hours,
          minutes,
          totalDiff: timeDiff,
          format: () => {
            return `${days}天${hours}时${minutes}分`;
          },
          simpleFormat: () => `${days}天${hours}时${minutes}分`
        };
      },
      toFollow() {
        if (!this.taskData.clientExternalUserId && !this.taskData.externalUserid) {
          vant.Toast.fail('无效')
          return
        }
        wx.openEnterpriseChat({
          externalUserIds: this.taskData.clientExternalUserId || this.taskData.externalUserid, // 参与会话的外部联系人列表，格式为userId1;userId2;…，用分号隔开。
          groupName: "",  // 会话名称。单聊时该参数传入空字符串""即可。
          chatId: "",
          success: function (res) {
            var chatId = res.chatId; //返回当前群聊ID，仅当使用agentConfig注入该接口权限时才返回chatId
            // 回调
            console.log('成功', res);

          },
          fail: function (res) {
            // 回调
            if (res.errMsg.indexOf('function not exist') > -1) {
              alert('版本过低请升级');
            }
            console.log('失败', res);
          },
          complete: function (res) {
            // 回调
            console.log('完成', res);
          }
        });

      },
      getQyWxSign() {
        fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
          method: 'post',
          body: JSON.stringify({
            bid: this.bId,
            url: window.location.href,
          }),
          headers: {
            'Content-Type': 'application/json'
          }
        }).then(res => {
          return res.json()
        }).then(result => {
          let { data, code, msg } = result
          if (code === 1) {
            wx.config({
              beta: true,
              debug: false,
              appId: data.corpid, // 必填，企业号的唯一标识，此处填写企业号corpid
              timestamp: data.timestamp, // 必填，生成签名的时间戳
              nonceStr: data.nonceStr, // 必填，生成签名的随机串
              signature: data.agentSignature, // 必填，签名，见附录1
              jsApiList: ['checkJsApi', 'openEnterpriseChat'] // 必填，需要使用的JS接口列表
            })
            wx.agentConfig({
              corpid: data.corpid,
              agentid: data.agentId,
              timestamp: data.timestamp, // 必填，生成签名的时间戳
              nonceStr: data.nonceStr, // 必填，生成签名的随机串
              signature: data.agentSignature, // 必填，签名，见附录1
              jsApiList: ['openEnterpriseChat'], // 必填，需要使用的JS接口列表
              success: function (res) {
                // 回调
                console.log('agentConfig成功', res);

              },
              fail: function (res) {
                if (res.errMsg.indexOf('function not exist') > -1) {
                  alert('版本过低请升级');
                }
              },
              complete: function (res) {
                // 回调
                console.log('complete', res);
              }
            });

          } else {
            this.$message({
              message: msg,
              type: 'warning'
            })
          }
        })
      },
      // 截取url中的数据
      getQueryParam(paramName) {
        // 获取当前URL的查询字符串部分  
        const queryString = window.location.search;
        // 创建一个URLSearchParams对象  
        const urlParams = new URLSearchParams(queryString);
        // 返回指定参数的值，如果不存在则返回null  
        return urlParams.get(paramName);
      },
    }
  })   
</script>

</html>