123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269 |
- <template>
- <div class="autoBox box">
- <div>
- <div class="sessionArea">
- <!--会话名称-->
- <div class="title">
- <span style="font-size: 18px;line-height: 49px;">
- <!-- {{sessionAreaTitle}}-->
- {{$i18n.locale=='zh'?'能联全球':'World of Energy Interconnection'}}
- </span>
- </div>
- <!--会话窗口-->
- <div class="session">
- <div id="sessionContent" style="width: 100%;height: 100%;position: relative;overflow: auto;">
- <!--转人工客服-->
- <div style="width: calc(100% - 40px);height: 47px;text-align: right;font-size: 14px;margin-bottom: 6px;
- position: absolute;left: 20px;z-index: 100;padding-top: 10px;box-sizing: border-box;"
- :style="{top:(sessionContentScrollTop+'px')}">
- <span style="border-radius: 3px;padding: 9px 19px;box-sizing: border-box;cursor:pointer;display: inline-block;;
- background-color: #2c5589;color: white;line-height: 22px;"
- @click="changeService">
- <span v-show="serviceStatus=='ROBERT'">
- {{i18n('toCustomerService')}}
- </span>
- <span v-show="serviceStatus=='Artificial'">
- {{$i18n.locale=='zh'?'转智能客服':'Switch to intelligent customer service'}}
- </span>
- </span>
- </div>
- <!--会话记录-->
- <div style="width: calc(100% - 40px);font-size: 12px;position: absolute;top: 0;left: 20px;z-index: 10">
- <div v-for="(item,index) in messages"
- style="width: 100%;font-size: 14px;line-height: 26px;color: black;margin: 20px 0;">
- <!--客服-->
- <div v-if="!(item.messageUserType=='USER')">
- <!--ROBERT-->
- <div v-show="item.messageUserType=='ROBERT'"
- style="display: flex;justify-content: flex-start;">
- <!--头像-->
- <div style="width: 50px;height: 50px">
- <div style="width: 38px;height: 38px;margin: 0 6px 6px 6px;">
- <img v-if="item.userImage" :src="imageAddPath(item.userImage)" alt=""
- style="width: 100%;height: 100%;border-radius: 50%">
- <img v-else src="@/assets/logo11.png" alt=""
- style="width: 100%;height: 100%;border-radius: 50%">
- </div>
- </div>
- <!--内容-->
- <div style="max-width: 650px;margin-left: 5px;">
- <!--用户名/客服-->
- <div>
- <p style="margin: 5px 0;font-size: 16px;">{{item.userName}}</p>
- </div>
- <!-- 文本 -->
- <div style="position: relative">
- <div>
- <div style="max-width: 650px;padding: 12px 15px 12px 15px;background-color: white;border-radius: 5px;display: inline-block;"
- v-show="item.messageContent.messageContentType != 'HTML'">
- <!-- +FAQ -->
- <p style="margin: 0;">
- {{item.messageContent.content}}<!-- 内容 -->
- </p>
- <div v-show="item.messageContent.messageContentType != 'ML'">
- <p v-for="(ele) in item.messageContent.messageContentList"
- style="margin: 0;cursor: pointer;"
- @click="sessionFAQClick(item,index)">
- {{ele.content}}<!-- 内容 -->
- </p>
- </div>
- </div>
- <div style="max-width: 650px;padding: 12px 15px 12px 15px;background-color: white;border-radius: 5px;display: inline-block;"
- v-show="item.messageContent.messageContentType == 'HTML'"
- v-html="item.messageContent.content"></div>
- </div>
- <!-- 左侧小三角形 ==> -->
- <!-- <div style="width:0;position: absolute;top:20px;left:-10px;border: 5px solid transparent;border-right: 5px solid white;"></div>-->
- <!-- <== 左侧小三角形 -->
- <!-- +快捷入口 -->
- <div style="margin-top: 7px;display: inline-block;"
- v-show="item.messageContent.messageContentType == 'ML'">
- <!--<div v-for="(ele,indexs) in item.messageContent.messageContentList"
- style="width: 80px;height: 80px;border-radius: 3px;background-color: white;float: left;margin-left: 6px;cursor: pointer;"
- :style="{marginLeft:indexs==0?'0':'6px'}"
- @click="sessionQuickClick(ele,indexs)">
- <div style="text-align: center;margin-top: 15px;width: 100%;height: 30px;">
- <img v-if="ele.imagePath" :src="ele.imagePath" alt="" style="width: 30px;height: 30px;">
- <img v-else src="" alt="" style="width: 30px;height: 30px;">
- </div>
- <div style="text-align: center;">
- <span style="font-size: 14px;color: #959595;">{{ele.content}}</span>
- </div>
- </div>
- <div style="clear: both;"></div>-->
- <div v-for="(ele,indexs) in item.messageContent.messageContentList"
- style="border-radius: 3px;background-color: white;cursor: pointer;margin-top: 6px;"
- @click="sessionQuickClick(ele,indexs)">
- <div style="text-align: center;width: 80px;height: 100%;float: left;">
- <img v-if="ele.imagePath" :src="imageAddPath(ele.imagePath)"
- alt=""
- style="width: 30px;height: 30px;margin-top: 15px;">
- <img v-else :src="imageAddPath('helpCenter/shuji.jpg')"
- alt=""
- style="width: 30px;height: 30px;margin-top: 15px;">
- </div>
- <div style="float: left;line-height:30px;padding: 0 25px 0 0;max-width: 80%;margin-top: 14px;">
- <span style="font-size: 14px;color: #959595;">{{ele.content}}</span>
- </div>
- <div style="clear: both;"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!--人工-->
- <div v-show="item.messageUserType=='CUSTOMER'"
- style="display: flex;justify-content: flex-start;">
- <!--头像-->
- <div style="width: 50px;height: 50px">
- <div style="width: 38px;height: 38px;margin: 0 6px 6px 6px;">
- <img v-if="item.userImage" :src="imageAddPath(item.userImage)" alt=""
- style="width: 100%;height: 100%;border-radius: 50%">
- <img v-else src="@/assets/logo11.png" alt=""
- style="width: 100%;height: 100%;border-radius: 50%">
- </div>
- </div>
- <!--内容-->
- <div style="max-width: 650px;margin-left: 5px;">
- <!--用户名/客服-->
- <div>
- <p style="margin: 5px 0;font-size: 16px;">{{item.userName}}</p>
- </div>
- <!-- 文本 -->
- <div style="position: relative">
- <div>
- <div style="max-width: 650px;padding: 12px 15px 12px 15px;background-color: white;border-radius: 5px;display: inline-block;">
- <p style="margin: 0;">
- {{item.messageContent.content}}<!-- 内容 -->
- </p>
- </div>
- </div>
- <!-- 左侧小三角形 ==> -->
- <!-- <div style="width:0;position: absolute;top:20px;left:-10px;border: 5px solid transparent;border-right: 5px solid white;"></div>-->
- <!-- <== 左侧小三角形 -->
- </div>
- </div>
- </div>
- <!--时间-->
- <div style="padding-left: 55px;box-sizing: border-box;">
- <p style="margin: 5px 0;color:#999a9c;font-size: 12px">{{item.messageTime}}</p>
- </div>
- </div>
- <!--用户-->
- <div v-else style="text-align: right;">
- <div style="display: inline-block;">
- <div style="display: flex;justify-content: flex-end;">
- <!--内容-->
- <div style="max-width: 650px;margin-right: 5px;">
- <!--用户名/用户-->
- <div>
- <p style="margin: 5px 0;">{{item.userName}}</p>
- </div>
- <!-- 文本 -->
- <div style="position: relative;">
- <div>
- <div style="max-width: 650px;padding: 12px 15px 12px 15px;background-color: white;border-radius: 5px;display: inline-block;">
- <p style="margin: 0;text-align: left;">
- {{item.messageContent.content}}<!-- 内容 -->
- </p>
- </div>
- </div>
- <!-- 左侧小三角形 ==> -->
- <!-- <div style="width:0;position: absolute;top:20px;right:-5px;border: 5px solid transparent;border-left: 5px solid white;"></div>-->
- <!-- <== 左侧小三角形 -->
- </div>
- </div>
- <!--头像-->
- <div style="width: 50px;height: 50px">
- <div style="width: 38px;height: 38px;margin: 0 6px 6px 6px;">
- <img v-if="item.userImage" :src="imageAddPath(item.userImage)"
- alt=""
- style="width: 100%;height: 100%;border-radius: 50%">
- <img v-else src="@/assets/img/helpCenter/headPortrait.png" alt=""
- style="width: 100%;height: 100%;border-radius: 50%">
- </div>
- </div>
- </div>
- <!--时间-->
- <div style="padding-right: 55px;box-sizing: border-box;">
- <p style="margin: 5px 0;color:#999a9c;font-size: 12px">
- {{item.messageTime}}</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!--类别-->
- <div class="classes">
- <div v-for="(item,index) in sessionAreaClasses"
- style="height: 100%;margin-left: 6px;float: left;margin-top: 11px;">
- <span style="padding: 0 12px;font-size: 14px;line-height: 25px;border: 1px solid #285185;border-radius: 25px;color: #999999;cursor: pointer;"
- :style="{backgroundColor:sessionAreaClassesFlag.value==item.value?'#71a7ef':'transparent',
- color:sessionAreaClassesFlag.value==item.value?'white':'#999999',
- border:sessionAreaClassesFlag.value==item.value?'1px solid transparent':'1px solid #285185'}"
- @click="filtrateClasses(item,index)">
- <!-- {{i18n(item.label)}}-->
- {{item.value}}
- </span>
- </div>
- <div style="clear: both;"></div>
- </div>
- <!--输入区域-->
- <div class="inputText">
- <!--表情/图片-->
- <!--<div style="height: 32px;width: 100%;padding-top: 6px;box-sizing: border-box;">
- <div v-for="(item,index) in sessionAreaFunction"
- style="width: 20px;height: 20px;display: inline-block;margin-left: 6px;cursor: pointer;">
- <emoji v-if="item.value=='表情'" style="float:left;">
- <div slot="icon" style="float:left;">
- <i v-if="item.iconName" :class="item.iconName" style="font-size: 20px;color: #5b5f68;"
- @click="sendkind(item,index)"></i>
- <img v-else :src="item.iconImg" alt="" @click="sendkind(item,index)">
- </div>
- </emoji>
- <div v-else-if="item.value=='图片'" style="float:left;">
- <i v-if="item.iconName" :class="item.iconName" style="font-size: 20px;color: #5b5f68;"
- @click="sendkind(item,index)"></i>
- <img v-else :src="item.iconImg" alt="" @click="sendkind(item,index)">
- </div>
- </div>
- </div>-->
- <!--<div style="height: 32px;width: 100%;padding-top: 6px;box-sizing: border-box;">
- <div v-for="(item,index) in sessionAreaFunction"
- style="width: 20px;height: 20px;display: inline-block;margin-left: 6px;cursor: pointer;">
- <emoji v-if="item.value=='表情'" style="float:left;" class="items" ref="qqemoji" @select="qqemoji_selectFace">
- <div slot="icon" style="float:left;">
- <i v-if="item.iconName" :class="item.iconName"
- style="font-size: 20px;color: #5b5f68;"
- @click="sendkind(item,index)"></i>
- <img v-else :src="item.iconImg" alt="" @click="sendkind(item,index)">
- </div>
- </emoji>
- <div v-else-if="item.value=='图片'" style="float:left;">
- <i v-if="item.iconName" :class="item.iconName" style="font-size: 20px;color: #5b5f68;"
- @click="sendkind(item,index)"></i>
- <img v-else :src="item.iconImg" alt="" @click="sendkind(item,index)">
- </div>
- </div>
- </div>-->
- <!--输入内容-->
- <div style="height: 103px;width: 100%;padding-bottom: 6px;box-sizing: border-box;overflow: hidden;">
- <el-input
- type="textarea"
- :rows="4"
- resize="none"
- :placeholder="$i18n.locale=='zh'?'请输入内容':'Please enter content'"
- v-model="senderMessage"
- maxlength="50"
- show-word-limit
- @keyup.alt="onStop(1)"
- @keydown.alt="onStop(11)"
- @keyup.alt.enter.native="onStop(3)"
- @keydown.alt.enter.native="onStop(33)"
- @keyup.ctrl.enter.native="onStop(4)"
- @keydown.ctrl.enter.native="onStop(44)"
- @keyup.enter.native="toSend(senderMessage)">
- </el-input>
- <!--<div
- maxlength="500"
- class="inputContent common_chat_emoji-wrapper-global"
- id="common_chat_input"
- contenteditable="true"
- @paste.stop="inputContent_paste"
- @drop="inputContent_drop"
- @keydown="inputContent_keydown"
- @mouseup="inputContent_mouseup"
- ></div>-->
- </div>
- <!--发送-->
- <div style="height: 32px;width: 100%;text-align: right;">
- <button v-if="senderMessage" type="button" style="width: 87px; height: 32px;border-radius: 4px;color: white;cursor:pointer;
- font-size: 16px;line-height: 30px;text-align: center;border: none;background-color: #2c5589;outline:none;"
- @click="toSend(senderMessage)">
- {{i18n('Send')}}
- </button>
- <button v-else type="button" style="width: 87px; height: 32px;border-radius: 4px;color: white;cursor:not-allowed;
- font-size: 16px;line-height: 30px;text-align: center;border: none;background-color: #71a7ef;outline:none;">
- {{i18n('Send')}}
- </button>
- </div>
- </div>
- </div>
- <div class="functionalArea">
- <!--常见问题-->
- <div class="content">
- <!--标题-->
- <div style="width: 100%;height: 50px;border-bottom: 1px solid #e1e1e3;padding:0 15px;box-sizing: border-box;">
- <span style="float:left;;font-size: 18px;line-height: 50px; color: #1d202f;">
- {{$i18n.locale=='zh'?'常见问题':'FAQ'}}
- </span>
- <span style="float: right;font-size: 16px;line-height: 50px; color: #365282;cursor: pointer;"
- @click="changeTheBatch()">
- {{i18n('ChangeTheBatch')}}
- </span>
- <div style="clear: both;"></div>
- </div>
- <!--正文-->
- <div style="width: 100%;padding: 6px 20px 6px 36px;box-sizing: border-box">
- <ul v-for="(item,index) in FAQ">
- <li style="font-size: 14px;line-height: 26px; color: #365282;" @click="toFAQ(item,index)">
- <span style="cursor: pointer;">{{item.label}}</span>
- </li>
- </ul>
- <div style="clear: both;"></div>
- </div>
- </div>
- <!--平台服务-->
- <div class="content">
- <!--标题-->
- <div style="width: 100%;height: 50px;border-bottom: 1px solid #e1e1e3;padding:0 15px;box-sizing: border-box;">
- <span style="float:left;;font-size: 18px;line-height: 50px; color: #1d202f;">
- {{$i18n.locale=='zh'?'平台服务':'Platform services'}}
- </span>
- <div style="clear: both;"></div>
- </div>
- <!--正文-->
- <div style="width: 100%;padding: 0 15px 5px 15px;box-sizing: border-box;">
- <div v-for="(item,index) in services"
- style="float: left;width: 25%; height: 92px;">
- <div style="width: 100%;height: 33px;text-align: center;margin-top: 14px">
- <img :src="item.icon" alt="" style="width: 33px;height: 33px;cursor: pointer;"
- @click="toServices(item,index)">
- </div>
- <div style="width: 100%;height: 33px;text-align: center;margin-top: 8px;">
- <span style="font-size: 12px;cursor: pointer;" @click="toServices(item,index)">
- <!-- {{i18n(item.label)}}-->
- {{item.label}}
- </span>
- </div>
- </div>
- <div style="clear: both;"></div>
- </div>
- </div>
- <!--快捷入口-->
- <div class="content">
- <!--标题-->
- <div style="width: 100%;height: 50px;border-bottom: 1px solid #e1e1e3;padding:0 15px;box-sizing: border-box;">
- <span style="float:left;;font-size: 18px;line-height: 50px; color: #1d202f;">
- {{$i18n.locale=='zh'?'快捷入口':'Quick entry'}}
- </span>
- <div style="clear: both;"></div>
- </div>
- <!--正文-->
- <div style="width: 100%;box-sizing: border-box;">
- <div v-for="(item,index) in quick"
- style="float: left;width: 155px; height: 66px;margin: 15px 0 0 15px;background-size:100% 100%;padding-left: 14px;box-sizing: border-box;cursor: pointer;
- display: flex;align-items:center;"
- :style="{backgroundImage:'url('+ item.backImg +')'}"
- @click="toQuick(item,index)">
- <span style="display: inline-block;width:100%;float:left;;font-size: 14px;color: #1d202f;">
- <!-- {{i18n(item.label)}}-->
- {{item.label}}
- </span>
- </div>
- <div style="clear: both;"></div>
- </div>
- </div>
- </div>
- <div style="clear: both;"></div>
- </div>
- <!--登录提示-->
- <el-dialog
- :title="$i18n.locale=='zh'?'提示':'Reminder'"
- :visible.sync="toViewLogin"
- :width="$i18n.locale=='zh'?'500px':'750px'"
- :height="$i18n.locale=='zh'?'300px':'386px'"
- :before-close="toViewLoginChange"
- >
- <div style="width: 100%;height: 100%;">
- <img src="@/assets/img/loginTips.png" alt="" style="width: 180px;height: 180px;margin-left: 20px;">
- <div style="float: right;margin-right: 20px;" :style="$i18n.locale=='zh'?'width: 49%;margin-top: 10px;':'width: 453px;margin-top: -25px;'">
- <div style="font-size: 20px;font-weight: normal;color: #333333;
- font-family: HiraginoSansGB-W3, HiraginoSansGB;
- line-height: 40px;">
- {{$t('common.ReminderFirst')}}
- </div>
- <div style="font-size: 16px;font-family: HiraginoSansGB-W3, HiraginoSansGB;
- font-weight: normal;color: #666666;line-height: 30px;">
- {{$t('common.ReminderSecond')}} <span style="color: #0091FF;font-size: 18px;">{{num}}</span> {{$t('common.ReminderThird')}}
- </div>
- <div style="font-size: 14px;font-family: HiraginoSansGB-W3, HiraginoSansGB;
- font-weight: normal;color: #666666;line-height: 30px;">
- {{$t('common.ReminderForth')}}
- </div>
- <div style="font-size: 14px;font-family: HiraginoSansGB-W3, HiraginoSansGB;
- height:33px;line-height:60px;font-weight: normal;color: #0091FF;">
- <span style="margin-left: 40px;" class="cursor" @click="toViewLocal('login')">
- {{$t('common.ReminderFifth')}}
- </span>
- <span style="margin-left: 10px;" class="cursor" @click="toViewLocal('Register')">
- {{$t('common.ReminderSixth')}}
- </span>
- </div>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {getDicts} from "@/api/dict";
- import Base from "@/views/base/Base";
- import {getToken, resetToken} from "@/utils/auth";
- import {robertClientMessages, getOperationListByOperationType} from "@/api/customer/customerServiceRobert"
- import {artificialClientMessages} from "@/api/customer/customerServiceStaff"
- import {getHelpCenterLanguages} from "@/api/operation/help/helpCenterLanguage"
- import {getHelpColumnContent} from '@/api/operation/help/helpCenterEntity'
- import emoji from "./emoji.vue";
- export default {
- extends: Base,
- components: {
- emoji: emoji
- },
- data() {
- return {
- num:5,
- timer:'',
- toViewLogin:false,
- isEnterStop: false,
- initWeb: false,
- //socket连接
- socket: null,
- //本地重连状态
- lockReconnect: false,
- tt: {},
- //socket连接地址
- socketUrl: '',
- artificial: {
- userId: '',
- userName: '',
- userImage: '',
- },
- user: {
- userId: '',
- userName: '',
- userImage: '',
- },
- //FAQ分页页码
- FAQPageNo: 1,
- // 当前客服状态
- serviceStatus: 'ROBERT', // ROBERT/Artificial
- staffService: 'off-line', // on-line/off-line
- //转人工客服(悬浮块)
- sessionContentScrollTop: Number,
- /*** 会话区数据 ***/
- //会话title
- sessionAreaTitle: '能联全球',
- //类别
- sessionAreaClassesFlag: '', //已选择类别
- sessionAreaClasses: [
- // {
- // label: 'MemberApply',
- // value: '入会申请',
- // },
- // {
- // label: 'ActivityRegistration',
- // value: '活动报名',
- // },
- // {
- // label: 'ForgetPassword',
- // value: '忘记密码',
- // },
- // {
- // label: 'AllianceApply',
- // value: '入盟申请',
- // },
- ],
- //表情、图片
- sessionAreaFunction: [
- {
- value: '表情',
- index: 0,
- iconName: 'el-icon-stopwatch',
- iconImg: '',
- },
- {
- value: '图片',
- index: 1,
- iconName: 'el-icon-picture-outline-round',
- iconImg: '',
- // iconImg:require(''),
- },
- ],
- //输入内容
- senderMessage: '',
- messageCount: 'FIRST',
- sendRequestMessageContent: {
- messageContentType: 'STR',
- content: "",
- language: this.$i18n.locale.toUpperCase(),
- },
- sendRequestMessage: {
- "userId": "0",
- "userName": "游客",
- "userImage": "helpCenter/logo11.png",
- "messageTime": 1223123412341,
- "messageType": "USER",
- "messageUserType": "USER",
- "messageTypeExtend": "",
- "language": this.$i18n.locale.toUpperCase(),
- "messageContent": "",
- },
- //心跳检测
- heartCheck: {},
- messages: [],
- /*** 功能区数据 语言包在user_zh/user_en ***/
- FAQ: [
- // {label: '如何开通平台账号'},
- // {label: '自动生成的账号可以修改吗'},
- // {label: '如何修改实名认证手机'},
- // {label: '如何开通平台账号'},
- // {label: '如何开通平台账号'},
- // {label: '如何开通平台账号'},
- // {label: '如何开通平台账号'},
- ],
- services: [
- // {
- // icon:require('@/assets/img/home/discussion3.png'),
- // label:'ConferenceService',
- // value:'会议服务',
- // },
- // {
- // icon:require('@/assets/img/helpCenter/zuanshi.jpg'),
- // label:'vipService',
- // value:'会员服务',
- // },
- // {
- // icon:require('@/assets/img/home/finance3.png'),
- // label:'FinancialServices',
- // value:'金融服务',
- // },
- // {
- // icon:require('@/assets/img/home/share3.png'),
- // label:'ResourceSharing',
- // value:'资源共享服务',
- // },
- // {
- // icon:require('@/assets/img/home/Exhibition3.png'),
- // label:'ExhibitionService',
- // value:'会展服务',
- // },
- ],
- quick: [
- // {
- // backImg:require('@/assets/img/helpCenter/quickBackImg1.jpg'),
- // label:'applyMembership1',
- // value:'申请入会',
- // },
- // {
- // backImg:require('@/assets/img/helpCenter/quickBackImg2.jpg'),
- // label:'applyMembership2',
- // value:'申请入盟',
- // },
- // {
- // backImg:require('@/assets/img/helpCenter/quickBackImg3.jpg'),
- // label:'Donation',
- // value:'资助洽商',
- // },
- // {
- // backImg:require('@/assets/img/helpCenter/quickBackImg4.jpg'),
- // label:'applyCustomizedServices',
- // value:'申请定制服务',
- // },
- // {
- // backImg:require('@/assets/img/helpCenter/quickBackImg5.png'),
- // label:'resourceApplicationResearch',
- // value:'申请调研',
- // },
- ],
- }
- },
- mounted() {
- // console.log('mounted')
- // this.initWeb = true
- // this.enterKeyup();
- this.sendRequestMessage.language = this.$i18n.locale.toUpperCase();
- this.sendRequestMessageContent.language = this.$i18n.locale.toUpperCase();
- // this.initdata();
- this.$nextTick(() => {
- const el = document.getElementById('sessionContent');
- el.onscroll = () => {
- let scrollTop = el.scrollTop;
- this.sessionContentScrollTop = scrollTop;
- };
- if (el.scrollHeight > el.clientHeight) {
- el.scrollTop = el.scrollHeight;
- }
- });
- // if(this.$i18n.locale.toUpperCase() == 'EN'){
- this.messages = [];
- this.messageCount = 'FIRST';
- this.initdata();
- // this.initWeb = false;
- // }
- },
- watch: {
- /*'$i18n.locale'(val, oldval) {
- console.log('watch')
- console.log(val)
- if (val == 'zh') {
- if (this.mountedEnd == true) {
- this.mountedEnd = false;
- } else {
- // this.slideShowImgFlag=0;
- this.sendRequestMessage.language = this.$i18n.locale.toUpperCase();
- this.sendRequestMessageContent.language = this.$i18n.locale.toUpperCase();
- this.messages = [];
- this.messageCount = 'FIRST'
- this.initdata();
- }
- } else {
- this.sendRequestMessage.language = this.$i18n.locale.toUpperCase();
- this.sendRequestMessageContent.language = this.$i18n.locale.toUpperCase();
- this.messages = [];
- this.messageCount = 'FIRST'
- this.initdata();
- }
- },*/
- '$i18n.locale': {
- handler(val, oldval) {
- // console.log('$i18n')
- this.sendRequestMessage.language = this.$i18n.locale.toUpperCase();
- this.sendRequestMessageContent.language = this.$i18n.locale.toUpperCase();
- this.messages = [];
- this.messageCount = 'FIRST';
- if (this.$i18n.locale.toUpperCase() == 'ZH') {
- this.user.userName = '游客';
- this.sendRequestMessage.userName = '游客';
- } else {
- this.user.userName = 'Tourist';
- this.sendRequestMessage.userName = 'Tourist';
- }
- this.initdata();
- },
- },
- 'messages.length'() {
- this.$nextTick(() => {
- const el = document.getElementById('sessionContent');
- if (el.scrollHeight > el.clientHeight) {
- el.scrollTop = el.scrollHeight;
- }
- })
- },
- "toViewLogin"(){
- if(this.toViewLogin==true){
- this.loginTipsChange();
- }
- }
- },
- methods: {
- //拦截alt+enter\ctrl+enter事件
- onStop(ele) {
- console.log(ele)
- this.senderMessage = ''
- this.isEnterStop = true;
- },
- //连接地址补全
- linkAddPath(path) {
- var str = new RegExp("http");
- const origin = document.location.origin
- if (!str.test(path)) {
- return origin + "/#/" + path;
- } else {
- return path
- }
- },
- //图片地址补全
- imageAddPath(path) {
- const origin = document.location.origin
- // console.log(origin + "/common/opt/file/pub/" + path)
- return origin + "/api/file/pub/" + path;
- },
- //通用跳转方法
- toView(href) {
- window.open(href, '_blank');
- },
- toViewLocal(router, json) {
- // let rpath = { name: router, query: {key:JSON.stringify(json)}};
- clearInterval(this.timer);
- let rpath = { name: 'customerService'};
- sessionStorage.setItem('pathReminder', JSON.stringify(rpath));
- this.$router.push({ name: router, params: {key:json} });
- },
- //初始化方法
- initdata() {
- // this.initWeb = true;
- this.checkUser();
- //第一次请求
- this.toSend("");
- //获取常见问题
- this.getFAQ();
- //获取快捷点击栏
- this.getSessionAreaClasses();
- //获取平台服务数据
- this.getServices();
- //获取快捷入口数据
- this.getQuicks();
- // this.initWeb = false;
- },
- checkUser() {
- let that = this;
- let user = window.localStorage.getItem("user");
- var users = JSON.parse(user);
- if (users != null) {
- this.user.userId = users.userId;
- this.user.userName = users.username;
- this.sendRequestMessage.userId = this.user.userId;
- // if(users.umsUser.userNickName){
- // this.sendRequestMessage.userName = users.umsUser.userNickName;
- // }else{
- this.sendRequestMessage.userName = this.user.userName;
- // }
- if (users.umsUser.userPic) {
- this.user.userImage = users.umsUser.userPic;
- this.sendRequestMessage.userImage = this.user.userImage;
- }
- } else if (that.user.userId == '') {
- this.user.userId = new Date().getTime();
- this.sendRequestMessage.userId = this.user.userId;
- if (this.$i18n.locale.toUpperCase() == 'ZH') {
- this.user.userName = '游客';
- this.sendRequestMessage.userName = '游客';
- } else {
- this.user.userName = 'Tourist';
- this.sendRequestMessage.userName = 'Tourist';
- }
- this.user.userImage = '';
- this.sendRequestMessage.userImage = this.user.userImage;
- }
- },
- //换一页功能
- changeTheBatch() {
- if (this.FAQPageNo < 3) {
- this.FAQPageNo++
- } else {
- this.FAQPageNo = 1;
- }
- this.getFAQ(this.FAQPageNo);
- },
- //获取常见问题
- async getFAQ(pageNo) {
- let that = this;
- let param={
- pageSize:5,
- pageNo: this.FAQPageNo ? this.FAQPageNo : 1,
- businessType:'help_center',
- language:'',
- approveStatusDict:3,
- }
- param.language =this.$i18n.locale.toUpperCase();
- getHelpColumnContent(param).then((res) =>{
- this.FAQ = []
- res.data.cmsInformationViews.forEach(item => {
- this.FAQ.push({label: item.title, id: item.businessId});
- })
- if (that.FAQPageNo >= res.data.page.totalPage) {
- that.FAQPageNo = 0
- }
- })
- },
- //快捷点击栏
- async getQuicks() {
- let that = this;
- var operationType = "QUICKACCESS"
- var language = this.$i18n.locale.toUpperCase();
- getOperationListByOperationType(operationType, language).then((res) => {
- if ('200' == res.status) {
- this.quick = [];
- res.data.customerOperations.forEach(item => {
- this.quick.push({
- label: item.modelContent,
- value: item.modelContent,
- backImg: that.imageAddPath(item.imagePath),
- link: that.linkAddPath(item.linkPath),
- })
- })
- }
- });
- },
- //获取服务列表
- async getServices() {
- let that = this;
- var operationType = "PLATFORMSERVICES"
- var language = this.$i18n.locale.toUpperCase();
- getOperationListByOperationType(operationType, language).then((res) => {
- if ('200' == res.status) {
- this.services = [];
- res.data.customerOperations.forEach(item => {
- this.services.push({
- label: item.modelContent,
- value: item.modelContent,
- icon: that.imageAddPath(item.imagePath),
- link: that.linkAddPath(item.linkPath),
- })
- })
- }
- });
- },
- //获取类别列表
- async getSessionAreaClasses() {
- var operationType = "QUICKLIST"
- var language = this.$i18n.locale.toUpperCase();
- getOperationListByOperationType(operationType, language).then((res) => {
- if ('200' == res.status) {
- this.sessionAreaClasses = [];
- res.data.customerOperations.forEach(item => {
- this.sessionAreaClasses.push({
- label: item.modelContent,
- value: item.modelContent,
- link: item.linkPath,
- })
- })
- }
- });
- },
- /*** 会话区事件 ***/
- //转人工客服/转智能客服
- changeService() {
- if (this.serviceStatus == 'ROBERT') {
- this.serviceStatus = 'Artificial'
- this.openSocket();
- } else if (this.serviceStatus == 'Artificial') {
- this.serviceStatus = 'ROBERT'
- this.socket.close()
- this.heartCheck.stop();
- }
- },
- //类别
- async filtrateClasses(ele, index) {
- this.sessionAreaClassesFlag = ele;
- this.toSend(ele.value)
- },
- //表情、图片
- async sendkind(ele, index) {
- if (index == 0) {
- // 表情事件
- console.log(ele)
- console.log(index)
- }
- if (index == 1) {
- // 图片事件
- console.log(ele)
- console.log(index)
- }
- },
- // 发送内容
- async toSend(senderMessage) {
- if (this.isEnterStop) {
- this.isEnterStop = false;
- } else {
- let that = this;
- if (senderMessage) {
- if (senderMessage.match(/^\s+$/)) {
- return this.senderMessage = '';
- }
- if (senderMessage.match(/^[ ]+$/)) {
- return this.senderMessage = '';
- }
- if (senderMessage.match(/^[ ]*$/)) {
- return this.senderMessage = '';
- }
- if (senderMessage.match(/^\s*$/)) {
- return this.senderMessage = '';
- }
- }
- if (this.serviceStatus == 'ROBERT') {
- // this.messageCount= 'CHAT';
- this.sendRequestMessageContent.content = senderMessage;
- this.sendRequestMessage.messageContent = this.sendRequestMessageContent;
- this.sendRequestMessage.messageTime = this.dateFormat("YYYY-mm-dd HH:MM:SS", new Date());
- let messageCount = JSON.parse(JSON.stringify(this.messageCount));
- if (this.messageCount != 'FIRST') {
- let sendRequestMessageget = JSON.parse(JSON.stringify(this.sendRequestMessage));
- that.messages.push(sendRequestMessageget)
- }
- robertClientMessages(messageCount, JSON.stringify(this.sendRequestMessage)).then((res) => {
- if (res.status == '200') {
- if (messageCount == 'FIRST') {
- that.messages = []
- }
- that.messages.push(res.data.messages)
- this.messageCount = 'CHAT'
- }
- });
- } else if (this.serviceStatus == 'Artificial') {
- this.sendRequestMessageContent.content = senderMessage;
- this.sendRequestMessage.messageContent = this.sendRequestMessageContent;
- this.sendRequestMessage.messageTime = this.dateFormat("YYYY-mm-dd HH:MM:SS", new Date());
- var message = {
- userId: "",
- message: "",
- messageType: "ARTM",
- }
- message.message = this.sendRequestMessage
- message.userId = this.artificial.userId
- this.socket.send(JSON.stringify(message));
- let sendRequestMessageget = JSON.parse(JSON.stringify(this.sendRequestMessage));
- that.messages.push(sendRequestMessageget)
- this.messageCount = 'CHAT'
- // artificialClientMessages(this.artificial.userId,JSON.stringify(this.sendRequestMessage)).then((res) => {
- // if (res.status == '200') {
- // let sendRequestMessageget = JSON.parse(JSON.stringify(this.sendRequestMessage));;
- // that.messages.push(sendRequestMessageget)
- // this.messageCount = 'CHAT'
- // }
- // });
- console.log(this.artificial)
- }
- this.senderMessage = ''; //清空输入框
- }
- },
- async toSendMessage(data) {
- // 发送请求
- },
- async toPushSession(data) {
- this.message.push(data)
- },
- //智能客服
- sessionFAQClick(ele, index) {
- alert("sessionFAQClick")
- },
- sessionQuickClick(ele, index) {
- // alert("sessionQuickClick")
- // 快捷点击
- console.log('ele,index')
- console.log(ele,index)
- this.toSend(ele.content);
- },
- /*** 功能区事件 ***/
- // 常见问题事件
- async toFAQ(ele, index) {
- this.$store.commit('modify', 'helpCenter');
- window.localStorage.setItem('router', 'helpCenter');
- const {href} = this.$router.resolve({
- name: 'helpCenter',
- query: {
- key: ele.id
- }
- });
- window.open(href, '_blank');
- },
- // 平台服务事件
- async toServices(ele, index) {
- this.toView(ele.link);
- },
- // 快捷入口事件
- async toQuick(ele, index) {
- if (!this.$Cookies.get('token')){
- this.toViewLogin = true;
- }else{
- this.toView(ele.link);
- }
- // this.$router.push({ name: 'IntroductionMemberProfile', query: { data: row, key: 'custom', disable: true, index: this.taberIndex } })
- },
- // 国际化
- i18n(data) {
- return this.$t('common.' + data);
- },
- dateFormat(fmt, date) {
- let ret;
- const opt = {
- "Y+": date.getFullYear().toString(), // 年
- "m+": (date.getMonth() + 1).toString(), // 月
- "d+": date.getDate().toString(), // 日
- "H+": date.getHours().toString(), // 时
- "M+": date.getMinutes().toString(), // 分
- "S+": date.getSeconds().toString() // 秒
- // 有其他格式化字符需求可以继续添加,必须转化成字符串
- };
- for (let k in opt) {
- ret = new RegExp("(" + k + ")").exec(fmt);
- if (ret) {
- fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
- }
- ;
- }
- ;
- return fmt;
- },
- //socket
- openSocket() {
- let that = this;
- if (typeof WebSocket == "undefined") {
- console.log("您的浏览器不支持WebSocket");
- } else {
- console.log("您的浏览器支持WebSocket");
- //实现化WebSocket对象,指定要连接的服务器地址与端口 建立连接
- this.createSocket();
- }
- },
- //创建Socket连接
- createSocket() {
- let that = this;
- let user = window.localStorage.getItem("user");
- var users = JSON.parse(user);
- if (users != null) {
- that.user = users;
- } else if (that.user.userId == '') {
- that.user.userId = new Date().getTime();
- }
- var islocalhost = 'localhost' == document.location.hostname ? true : false;
- if (islocalhost) {
- this.socketUrl =
- "http://localhost:7028/userConn/" + this.$i18n.locale.toUpperCase() + "/" + that.user.userId;
- } else {
- const origin = document.location.origin
- this.socketUrl =
- origin + "/userConn/" + this.$i18n.locale.toUpperCase() + "/" + that.user.userId;
- }
- this.socketUrl = this.socketUrl.replace("https", "wss").replace("http", "ws");
- console.log(this.socketUrl);
- if (this.socket != null) {
- this.socket.close();
- this.socket = null;
- }
- this.socket = new WebSocket(this.socketUrl);
- this.initSocketFunction()
- },
- initHeartCheck() {
- let that = this;
- this.heartCheck = {
- timeout: 30000,
- timeoutObj: null,
- serverTimeoutObj: null,
- socket: this.socket,
- start: function () {
- console.log('start');
- var self = this;
- this.timeoutObj && clearTimeout(this.timeoutObj);
- this.serverTimeoutObj && clearTimeout(this.serverTimeoutObj);
- this.timeoutObj = setTimeout(function () {
- //这里发送一个心跳,后端收到后,返回一个心跳消息,
- var message = {
- userId: "",
- message: "",
- messageType: "PING",
- }
- var a = JSON.stringify(message);
- that.socket.send(a);
- self.serverTimeoutObj = setTimeout(function () {
- console.log(that.socket);
- that.socket.close();
- }, self.timeout);
- }, this.timeout)
- },
- stop: function () {
- window.clearTimeout(this.timeoutObj);
- window.clearTimeout(this.serverTimeoutObj);
- return this;
- },
- }
- },
- //初始化socket对应操作方法
- initSocketFunction() {
- let that = this
- //初始化心跳
- this.initHeartCheck()
- //打开事件
- this.socket.onopen = function () {
- console.log("websocket已打开");
- that.heartCheck.start();
- //socket.send("这是来自客户端的消息" + location.href + new Date());
- };
- //获得消息事件
- this.socket.onmessage = function (msg) {
- that.heartCheck.start();
- console.log(msg);
- var message = JSON.parse(msg.data);
- if (message.messageType == 'PONG') {
- console.log(message)
- } else {
- console.log(message)
- that.artificial.userId = message.userId;
- that.artificial.userName = message.userName;
- that.messages.push(message)
- }
- //发现消息进入 开始处理前端触发逻辑
- };
- //关闭事件
- this.socket.onclose = function () {
- console.log("websocket已关闭");
- };
- //发生了错误事件
- this.socket.onerror = function () {
- console.log("websocket发生了错误");
- that.reconnect(this.socketUrl);
- };
- },
- //重连方法
- reconnect() {
- let that = this;
- if (this.lockReconnect) {
- return;
- }
- ;
- this.lockReconnect = true;
- //没连接上会一直重连,设置延迟避免请求过多
- this.tt && window.clearTimeout(this.tt);
- this.tt = window.setTimeout(function () {
- that.createSocket();
- that.lockReconnect = false;
- }, 4000);
- },
- // enterKey(event) {
- // const code = event.keyCode
- // ? event.keyCode
- // : event.which
- // ? event.which
- // : event.charCode;
- // if (code == 13) {
- // console.log("asdfasdfasdfadsf")
- // }
- // },
- // enterKeyup() {
- // document.addEventListener("keyup", this.enterKey);
- // },
- //人工消息发布
- sendMessage() {
- if (typeof WebSocket == "undefined") {
- console.log("您的浏览器不支持WebSocket");
- } else {
- console.log("您的浏览器支持WebSocket");
- console.log(
- '{"toUserId":"' +
- this.toUserId +
- '","contentText":"' +
- this.content +
- '"}'
- );
- this.socket.send(
- '{"toUserId":"' +
- this.toUserId +
- '","contentText":"' +
- this.content +
- '"}'
- );
- }
- },
- // 判断未登录跳转是否关闭
- toViewLoginChange(done){
- this.toViewLogin=false;
- this.num=5;
- clearInterval(this.timer);
- },
- loginTipsChange(){
- const that=this;
- this.num =5;
- // clearInterval(timer_interval);
- this.timer = setInterval(function() {
- if (that.num > 0) {
- that.num--;
- } else {
- if(that.toViewLogin==true){
- clearInterval(that.timer);
- that.toViewLocal('login');
- }else {
- clearInterval(that.timer);
- }
- }
- }, 1000)
- },
- },
- }
- </script>
- <style scoped>
- .oneLine {
- /* 隐藏溢出元素 */
- overflow: hidden;
- /* 单行显示 */
- white-space: nowrap;
- /* 溢出显示省略号 */
- text-overflow: ellipsis;
- }
- .box {
- background: #fff;
- padding: 10px 0 109px 0;
- }
- .sessionArea {
- width: 833px;
- height: 792px;
- border: 1px solid #e1e1e3;
- float: left;
- }
- .sessionArea .title {
- width: 100%;
- height: 50px;
- background-color: #e6e7eb;
- border-bottom: 1px solid #e1e1e3;
- padding-left: 19px;
- box-sizing: border-box;
- }
- .sessionArea .session {
- width: 100%;
- height: 519px;
- background-color: #eef3f7;
- }
- .sessionArea .classes {
- width: 100%;
- height: 44px;
- border-bottom: 1px solid #e1e1e3;
- padding-left: 13px;
- box-sizing: border-box;
- }
- .sessionArea .inputText {
- width: 100%;
- height: 179px;
- padding: 6px 13px;
- box-sizing: border-box;
- }
- .sessionArea .inputText .items {
- clear: both;
- overflow: hidden;
- }
- .functionalArea {
- width: 357px;
- height: 792px;
- border: 1px solid #e1e1e3;
- float: right;
- }
- .functionalArea .content {
- width: 100%;
- }
- .functionalArea .content ul {
- list-style-type: disc;
- }
- </style>
- <style>
- .inputText .el-textarea {
- /*overflow:hidden*/
- }
- .inputText .el-textarea .el-textarea__inner {
- border: none;
- /*overflow-y: auto;*/
- }
- </style>
|