即时通信 IM

介绍 即时通信IM产品简介
应用场景

1. 社交沟通

即时通信 IM 为应用于社交沟通提供能力支持,可实现单聊、群聊、弹幕等多种聊天模式,支持文字、图片、语音、短视频等多种消息类型,实时消息推送满足消息到达率的要求,并可支持实时音视频通话,有效提升用户粘性与活跃度。
示例场景:应用内聊天
推荐功能:消息管理、群组管理
客户案例:QQ、微信

2. 智能客服

即时通信 IM 满足商家与用户多场景沟通的需要,为客户提供专属客服服务,提升服务效率,与智能机器人相结合,可有效降低人力成本,沉淀客户价值。
示例场景:线上商城客服
推荐功能:在线客服
客户案例:阳光约车

3. 企业通讯

即时通信 IM 为企业客户提供解决方案,可覆盖桌面和移动端,设备无缝切换,实现企业沟通和办公的高效协同。
示例场景:企业内部通信
推荐功能:即时通信
客户案例:百世快递

4.系统消息通知

即时通信 IM 提供在线推送与离线推送服务,让系统消息精准到达。
示例场景:App 系统通知
推荐功能:消息推送
客户案例:货拉拉

5.游戏交流

即时通信 IM 可为游戏客户端提供大厅、小队、全服等多种聊天室类型,支持文字、语音、表情、短视频等多种消息类型,可通过自定义消息轻松实现游戏内道具赠送、交易等业务场景;同时,即时通信 IM 支持全球业务,我们已经在海外数十个国家部署专用服务器,为您的即时通信全球化提供强大动力。
示例场景:大厅群聊
推荐功能:多种群组类型、全球接入
客户案例:王者荣耀助手、腾讯游戏助手

6.在线教育

即时通信 IM 为在线课堂提供丰富的技术支持。可实现白板画笔轨迹保存、聊天室、小班教学实时音视频以及万人及以上直播课弹幕等功能。可轻松实现开课提醒、在线签到、班级管理、师生互动、白板教学、提问以及作业布置等功能。
示例场景:在线课堂、直播课
推荐功能:全球接入、直播群、自定义消息、群组管理
客户案例:Classin、中华会计网校、VIPkid、混沌大学

小程序接入(用户、客服端)两端使用在同一个小程序

直接上代码
先说一下

小程序一旦在导航页**用户端**接入聊天咨询
在第二端**客服端**也会调用导航页的聊天咨询 tim.on(.........)方法

因为是使用同一个 SDKAppID在这里插入图片描述


SDK腾讯云API文档

代码展示:
先安装:

在这里插入代码片// IM Web SDK
// 从v2.11.2起,SDK 支持了 WebSocket,推荐接入;v2.10.2及以下版本,使用 HTTP
npm install tim-js-sdk --save
// 发送图片、文件等消息需要腾讯云即时通信 IM 上传插件
npm install tim-upload-plugin --save
或者另外一版本
npm install cos-wx-sdk-v5 --save

真心话:算了全部代码直接展示了吧,刚入行的小伙,别压力太大。。。这是以下是没做优化的。
两端能正常聊天就不错了唉。。。。一个小程序还做两端。心累。。。。
以后再也不进做小程序的小公司了。天马行空

用户端

在小程序用户导航,咨询页面pages/news/news中添加

// pages/news/news.js
import request from '../../network/request.js';
import util from '../../utils/util.js';
import * as watch from '../../utils/watch.js';
import TIM from 'tim-wx-sdk';
import COS from "cos-wx-sdk-v5";
var app = getApp();
Page({/*** 页面的初始数据*/data: {//消息列表res: [],lock: true,state: null,num: 0,succeed: false,path:'pages/news/news'},/*** 生命周期函数--监听页面加载*/onLoad: function (options) {let that =thisif (wx.getStorageSync('token') == '' || !wx.getStorageSync('token')) {util.isLogin();return;}var options = {SDKAppID: app.globalData.SDKAppID}let tim = TIM.create(options);tim.setLogLevel(1); // 普通级别,日志量较多,接入时建议使用// 注册 COS SDKtim.registerPlugin({'cos-wx-sdk': COS});let promise = tim.login({userID: wx.getStorageSync('userid'),userSig: wx.getStorageSync('userSig')});promise.then(function (imResponse2) {const onSdkReady = function (event) {if (!that.data.lock) {return;}let promise1 = tim.getConversationList();promise1.then(function (imResponse) {if (imResponse.data.conversationList.length <= 0) {wx.hideLoading();return;}let conversationList = imResponse.data.conversationList; // 会话列表,用该列表覆盖原有的会话列表that.setData({conversationList,allget: true,succeed: false})}).catch(function (imError) {console.warn('getConversationList error:', imError); // 获取会话列表失败的相关信息-});};// 监听事件,例如:tim.on(TIM.EVENT.CONVERSATION_LIST_UPDATED, onSdkReady, that);that.setData({succeed: true})})}, // 换算时间showTime(val) {let newData = new Date().getTime()let timeDifference = newData - val //时间差let today = this.Format(newData)let yesterday = this.Format(newData - 24 * 60 * 60 * 1000) //昨天let timeDay = this.Format(val) //时间是几号if (timeDay == today) {if (timeDifference < 1 * 60 * 1000) {return "刚刚"} else if (1 * 60 * 1000 <= timeDifference && timeDifference < 60 * 60 * 1000) {return parseInt(timeDifference / 60 / 1000) + "分钟前"} else if (timeDifference >= 60 * 60 * 1000) {return parseInt(timeDifference / 60 / 60 / 1000) + "小时前"}} else if (timeDay == yesterday) {return "昨天"} else if (24 * 60 * 60 * 1000 <= timeDifference && timeDifference < 30 * 24 * 60 * 60 * 1000) {return parseInt(timeDifference / 24 / 60 / 60 / 1000) + "天前"} else if (30 * 24 * 60 * 60 * 1000 <= timeDifference && timeDifference < 12 * 30 * 24 * 60 * 60 * 1000) {return parseInt(timeDifference / 30 / 24 / 60 / 60 / 1000) + "个月前"} else if (timeDifference > 12 * 30 * 24 * 60 * 60 * 1000) {return parseInt(timeDifference / 12 / 30 / 24 / 60 / 60 / 1000) + "年前"}},// 年月日Format(val) {return new Date(val).getFullYear() + "-" + new Date(val).getMonth() + "-" + new Date(val).getDate()},authorization() {wx.showModal({title: '您还未登录',content: '请先登录再进行操作',success: function (res) {if (res.confirm) {wx.reLaunch({url: '../warrant/warrant'})} else {wx.reLaunch({url: '../home/home'})}}})},chatList() {// im会话列表var that = this;var options = {SDKAppID: app.globalData.SDKAppID}let tim = TIM.create(options);tim.setLogLevel(1);tim.registerPlugin({'cos-wx-sdk': COS});let logout = tim.logout();logout.then(function (imResponse) {}).catch(function (imError) {});let promise5 = tim.login({userID: wx.getStorageSync('userid'),userSig: wx.getStorageSync('userSig')});promise5.then(function (imResponse2) {const onSdkReady = function (event) {if (!that.data.lock) {return;}let promise1 = tim.getConversationList();promise1.then(function (imResponse) {if (imResponse.data.conversationList.length <= 0) {wx.hideLoading();return;}let conversationList = imResponse.data.conversationList; // 会话列表,用该列表覆盖原有的会话列表that.setData({conversationList,allget: true,succeed: false})}).catch(function (imError) {console.warn('getConversationList error:', imError); // 获取会话列表失败的相关信息});};// 监听事件,例如:tim.on(TIM.EVENT.CONVERSATION_LIST_UPDATED, onSdkReady, that);// 开始登录 \that.setData({succeed: true})}).catch(() => {that.setData({succeed: false})})},watch: {// 监听返回的信息列表conversationList: function (newVal, oldVal) {console.log('监听',this.data.path, oldVal);let that = this;let counselorIds = [];if (newVal.length !== 0) {if(that.data.path==='pages/news/news' || that.data.path ==='pages/nesItem/nesItem'){newVal.map(ele => {counselorIds.push(ele.userProfile.userID)})var arr = [];var messageList = wx.getStorageSync('messageList') || [];//调用客服表获取头像名字request('/admin/consult/wx/counselor/list', 'post', {counselorIds}).then(res => {let obj = {noUser: true}//消息let data = res.data.data || objdata.map((item2) => {newVal.map((item1) => {if (item1.userProfile.userID == item2.counselorId) {item2.text = item1.lastMessage.messageForShow == '[自定义消息]' ? item1.lastMessage.payload.description : item1.lastMessage.messageForShow;item2.isRevoked = item1.lastMessage.isRevoked;item2.isPeerRead = true;let arr = wx.getStorageSync('storageList');if (arr.length > 0) {arr.forEach((item, index) => {if (item.id == item1.userProfile.userID && item.time == item1.lastMessage.lastTime * 1000) {item2.isPeerRead = false;}})}let lastTime = item1.lastMessage.lastTime * 1000;let xz = new Date().getTime();item2.time = that.showTime(lastTime);item2.text = item2.text && item2.text.split("{").length > 1 ? JSON.parse(item2.text).title : item2.textreturn item2}})})that.setData({res: data}, () => {wx.hideLoading();wx.setStorageSync('messageList', messageList)})})clearInterval(that.data.state);return}else if(that.data.path==='consuLtant/pages/home/home' || that.data.path==='consuLtant/pages/nesItem/nesItem'){app.globalData.counselorIds=newVal;}}},},/*** 生命周期函数--监听页面初次渲染完成*/onReady: function () {//启用数据监听watch.setWatcher(this);// this.chatList()},/*** 生命周期函数--监听页面显示*/onShow: function () {console.log('onShow')let _this = thisif (!wx.getStorageSync('token')) {return;}this.data.lock = true;wx.onAppRoute((res) => {this.setData({path:res.path})if (res.path === 'pages/news/news') {this.chatList()if (!this.data.state) {clearInterval(_this.data.state);_this.setData({state: null})let num = 0_this.setData({state: setInterval(() => {num++;console.log(num);_this.chatList()if (num > 5) {clearInterval(_this.data.state);//如果不放心还可以把句柄置为null_this.setData({state: null})num = 0}}, 100)})}}else if(res.path === 'consuLtant/pages/home/home' && wx.getStorageSync('do_access_token')){var options = {SDKAppID: app.globalData.SDKAppID}let tim = TIM.create(options)let logout = tim.logout();logout.then(function (imResponse) {});let promise = tim.login({userID: wx.getStorageSync('do_userid'),userSig: wx.getStorageSync('do_userSig')});promise.then((imResponse) => {})return}})/*** 生命周期函数--监听页面隐藏*/onHide: function () {var options = {SDKAppID: app.globalData.SDKAppID}let tim = TIM.create(options);let logout = tim.logout();logout.then(function (imResponse) {}).catch(function (imError) {});},/*** 生命周期函数--监听页面卸载*/onUnload() {this.data.lock = false;var options = {SDKAppID: app.globalData.SDKAppID}let tim = TIM.create(options);let logout = tim.logout();logout.then(function (imResponse) {}).catch(function (imError) {});},/*** 页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh: function () {},/*** 页面上拉触底事件的处理函数*/onReachBottom: function () {},/*** 用户点击右上角分享*/onShareAppMessage: function () {}
})

上面才获取列表,还没获取聊天详情呢


用户聊天;

// pages/nesItem/nesItem.js
import request from '../../network/request.js';
import TIM from 'tim-wx-sdk';
import COS from "cos-wx-sdk-v5";
import util from "../../utils/util"var app = getApp();
Page({/*** 页面的初始数据*/data: {list: [], //消息列表yyImge: true, //默认显示输入文字options: "", //上一页传过来的参数token: null,userid: null,userSig: null,innerAudioContext: null, //创建内部 audio 上下文 InnerAudioContext 对象SDKAppID: {SDKAppID: app.globalData.SDKAppID},nextReqMessageID: "", //用于续拉,分页续拉时需传入该字段scrollTop: 0, //聊天页面滚动条的长度showScrollTop: 0, //需要滚动到的位置tim:null,userUrl: "",doctorUrl: "",uesrName: "",userMsg: "", //用户信息doctorMsg: "", //医生信息iputText: "",fsIputText: "", //发送的内容jp_height: 0, //键盘高度footer_bottom: 0, //键盘相对位置bottomlock: true,copyType: true, //true可复制thisPage: true,isIos: wx.getStorageSync('model') == "ios" ? true : false,tipsText: "请输入内容", //自定义提示文字showTips: false, //true为显示自定义提示moveUp: false, //true表示输入区需要上移},/*** 生命周期函数--监听页面加载*/onLoad: function (options) {console.log('options',options);this.initialization()this.setData({options: options,token: wx.getStorageSync('token'),userid: wx.getStorageSync('userid'),userSig: wx.getStorageSync('userSig'),uesrName: options.name || ""})wx.setNavigationBarTitle({title: decodeURIComponent(options.name) || ""//动态标题})this.useTim()this.getUserUrl()this.getDoctorUrl()},// 引入使用腾讯云useTim() {if (!this.data.lock) return;this.data.lock = false;this.setData({tim: TIM.create(this.data.SDKAppID)})let tim = this.data.tim// 设置 SDK 日志输出级别,详细分级请参见 setLogLevel 接口的说明tim.setLogLevel(0); // 普通级别,日志量较多,接入时建议使用// 注册 COS SDKtim.registerPlugin({'cos-wx-sdk': COS});// this.getMessageList();let _this = this;let promise = tim.login({ userID: this.data.userid, userSig: this.data.userSig});promise.then(function(imResponse) {console.log(imResponse.data); // 登录成功if (imResponse.data.repeatLogin === true) {// 标识帐号已登录,本次登录操作为重复登录。v2.5.1 起支持_this.getMessageList();console.log(imResponse.data.errorInfo);}}).catch(function(imError) {console.warn('login error:', imError); // 登录失败的相关信息});},// 重登timrestLoginTim(callback) {// let logout = this.data.tim.logout();// logout.then(function (imResponse) {}).catch(function (imError) {});let login = this.data.tim.login({userID: this.data.userid,userSig: this.data.userSig})login.then((imResponse) => {this.timReady()callback()}).catch(function (imError) {console.warn('login error:', imError); // 登录失败的相关信息});},timReady() { this.data.tim.on(TIM.EVENT.SDK_READY, () => {if (this.data.lock) returnthis.data.lock = true;this.getMessageList()if (!this.data.list.length) {this.getNewNews()}})},// 获取用户信息getUserUrl() {request('/admn/patient/wx/geo', 'get').then(res => {this.setData({userMsg: res.data.data,uesrName: res.data.data.realName,userUrl:res.data.data.avatar})if (!this.data.options.name) {wx.setNavigationBarTitle({title: res.data.data.realName})}})
},
// 获取医生信息getDoctorUrl() {request(`/admin/consult/counselor/findByCounId/${this.data.options.id}`, 'post',{}).then(res => {this.setData({doctorUrl: res.data.data.counselorImg,doctorMsg: res.data.data})})},// 获取聊天记录getMessageList() {this.getFooterBottom()  let promise = this.data.tim.getMessageList({conversationID: 'C2C' + this.data.options.id, //id为对应聊天人的userIDcount: 15 //一次拉取的聊天条数});//初始化渲染消息列表promise.then((imResponse) => {let list = imResponse.data.messageListlet nextReqMessageID = imResponse.data.nextReqMessageID; // 用于续拉,分页续拉时需传入该字段。let arr = this.publicFindList(list)this.setData({list: arr,nextReqMessageID}, () => {this.setStorageList()this.scrollTop()})})},// 下拉获取更多聊天记录dropDownGetList() {this.scrollTop("change")this.getFooterBottom()let promise = this.data.tim.getMessageList({conversationID: 'C2C' + this.data.options.id, //id为对应聊天人的userIDnextReqMessageID: this.data.nextReqMessageID, //用于续拉,分页续拉时需传入该字段count: 15 //一次拉取的聊天条数});//初始化渲染消息列表promise.then((imResponse) => {let list = imResponse.data.messageListif (!list.length) returnlet nextReqMessageID = imResponse.data.nextReqMessageID; // 用于续拉,分页续拉时需传入该字段。let arr = this.publicFindList(list)this.setData({list: [...arr, ...this.data.list],nextReqMessageID}, () => {this.scrollTop("show")})})},// 获取消息列表更改赋值公有方法publicFindList(list) {let arr = []list.find(item => {let text = item.type == 'TIMCustomElem' ? item.payload.description : item.payload.textarr.push({state: item.from == this.data.userid ? true : false, //true为我发送的,则对方data: item.payload.text && item.payload.text.split("{").length > 1 ? JSON.parse(item.payload.text) : "", //预约提示的自定义消息text: text, //语音视频提示或者发的消息isLink: this.judgeLink(text), //判断是否为链接type: item.type, //表示是自定义消息img: item.payload.imageInfoArray ? item.payload.imageInfoArray[0].imageUrl : '', //图片url: item.payload.url, //语音地址second: item.payload.second, //语音时长fjh: item.payload.extension, //房间号types: item.payload.data, //自定义消息属性time: item.time * 1000,showTime: this.showTime(item.time * 1000)})})return arr},// 判断是否为链接judgeLink(val) {let text = /^((http|https):\/\/)?(([A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\.)+([A-Za-z]+)[/\?\:]?.*$/return text.test(val)},// 换算时间showTime(val) {let newData = new Date().getTime()let timeDifference = newData - val //时间差let today = this.Format(newData)let yesterday = this.Format(newData - 24 * 60 * 60 * 1000) //昨天let nowDayOfWeek = new Date().getDay(); //今天本周的第几天let lastWeek = newData - nowDayOfWeek * 24 * 60 * 60 * 1000 //上周星期天let thisYear = new Date().getFullYear() //今年let thisMonth = new Date().getMonth() + 1 //本月let newVal = new Date(val)let timeDay = this.Format(val) //时间是几号let newYear = newVal.getFullYear() //年let newMonth = newVal.getMonth() + 1 //月份let newDate = newVal.getDate() //日let newHours = newVal.getHours() > 9 ? newVal.getHours() : "0" + newVal.getHours() //时let newMinutes = newVal.getMinutes() > 9 ? newVal.getMinutes() : "0" + newVal.getMinutes() //分let time = newHours + ":" + newMinutes// if (timeDifference < 2 * 60 * 1000 && timeDay == today) {//   return "刚刚"// } elseif (timeDay == today) {return time} else if (timeDay == yesterday) {return "昨天  " + time} else if (val > lastWeek) {let arr = ["一", "二", "三", "四", "五", "六"]switch (new Date(val).getDay()) {case 7:return "星期日  " + timedefault:return "星期" + arr[new Date(val).getDay() - 1] + "  " + time}} else {return newYear + "年" + newMonth + "月" + newDate + "日  " + time}},// 年月日Format(val) {return new Date(val).getFullYear() + "-" + new Date(val).getMonth() + "-" + new Date(val).getDate()},// 获取jp_heightgetFooterBottom() {let model = wx.getStorageSync('model')let heightif (model == "ios") {height = this.data.jp_height ? 0 : this.data.jp_heightconsole.log('键盘高度',height);} else {height = this.data.jp_heightconsole.log('键盘高度',height);}this.setData({footer_bottom: height})},// 收到推送的新消息getNewNews() {this.data.tim.on(TIM.EVENT.MESSAGE_RECEIVED, (event) => {let length = this.data.list.lengthlet list = this.data.listlet data = event.data[0]if (data.from != this.data.options.id) return// 监听对方消息let text = data.type == 'TIMCustomElem' ? data.payload.description : data.payload.textlist[length] = {state: data.from == this.data.userid ? true : false, //true是我,则对方data: data.payload.text && data.payload.text.split("{").length > 1 ? JSON.parse(data.payload.text) : "", //预约提示的自定义消息text: text, //自定义消息或者发的消息isLink: this.judgeLink(text), //判断是否为链接type: data.type,img: data.payload.imageInfoArray ? data.payload.imageInfoArray[0].imageUrl : '', //发来的图片url: data.payload.url, //语音second: data.payload.second, //语音时长fjh: data.payload.extension, //房间号types: data.payload.data, //自定义消息属性time: data.time * 1000,showTime: this.showTime(new Date().getTime())}this.setData({list})this.setStorageList()this.getFooterBottom()this.scrollTop()});},// 关闭键盘hideKeyboard() {wx.hideKeyboard()this.setData({jp_height: 0,footer_bottom: 0})},// 获取输入框消息inpValue(e) {this.setData({iputText: e.detail.value})},// 输入框聚焦focus() {this.getFooterBottom()this.scrollTop()},// 发送信息sendComments() {console.log('点击',this.data.iputText)this.getFooterBottom()if (!this.data.iputText.replace(/ /g, '')) {this.customize("请输入内容")return;}// 判断是否有网if (wx.getStorageSync('nonetwork')) {wx.showToast({title: '网络连接失败',icon: 'none',duration: 1000})return}this.data.fsIputText = this.data.iputTextthis.setData({iputText: '',})let message = this.data.tim.createTextMessage({to: this.data.options.id,conversationType: TIM.TYPES.CONV_C2C,payload: {text: this.data.fsIputText}});let promise = this.data.tim.sendMessage(message);let fn = promise.then((imResponse) => {let data = imResponse.data.messagethis.getMessageList()this.consultmessage(1, data.payload.text)}).catch((imError) => {this.restLoginTim(fn)// 发送失败console.warn('sendMessage error:', imError);});},// 预览图片previewImg(e) {let url = e.currentTarget.dataset.urllet list = []this.data.list.find(item => {if (item.img) {list.push(item.img)}})wx.previewImage({current: url,urls: list})},// 发送图片chooseimage: function () {this.getFooterBottom()this.hideKeyboard()let that = this// 1. 选择图片wx.chooseImage({sourceType: ['album'], // 从相册选择count: 1, // 只选一张,目前 SDK 不支持一次发送多张图片success: (res) => {this.qiniuUpload(2, res)// 2. 创建消息实例,接口返回的实例可以上屏let message = this.data.tim.createImageMessage({to: this.data.options.id,conversationType: TIM.TYPES.CONV_C2C,payload: {file: res},onProgress: function (event) {}});let promise = this.data.tim.sendMessage(message);promise.then((imResponse) => {that.getMessageList()}).catch((imError) => {console.warn('sendMessage error:', imError);});}})},// 键盘高度发生变化bindkeyboardheightchange(e) {let height = e.detail.heightthis.setData({jp_height: height,footer_bottom: height})},// 滚动条到底部scrollTop(bool) {const query = wx.createSelectorQuery()query.select('.scroll').boundingClientRect()query.exec((res) => {let num = res[0] && res[0].height || 0if (bool == "change") {this.data.scrollTop = numreturn}let showNum = bool == "show" ? num - this.data.scrollTop + 20 : num + 20this.setData({showScrollTop: showNum})})},copyTextEnd() {this.data.copyEnd = true;this.data.startTime = new Date().getTime()},// 自定义提示消息customize(text) {this.data.tipsStartTime = new Date().getTime()this.setData({showTips: true,tipsText: text}, setTimeout(() => {this.data.tipsEndTime = new Date().getTime()let time = this.data.tipsEndTime - this.data.tipsStartTimeif (time >= 1000) {this.setData({showTips: false})}}, 1000))},// 存消息consultmessage(type, text) {// type 1普通文本 2图片 3语音 4视频 5功能性 6其他// ly发送方 1用户 2医生request(`/admin/consult/consultmessage/userSave?id=${this.data.options.id}&ly=${1}&type=${type}&text=${text}`, 'post', {   }).then(res => {})},// 存数据setStorageList() {let listLength = this.data.list.lengthlet id = this.data.options.idconst storageList = wx.getStorageSync('storageList') || [] //本地存储消息列表信息let storageListLength = storageList.lengthlet idList = storageListLength > 0 ? storageList.map(item => {return item.id}) : []// 以前存在过if (listLength > 0) {if (idList.indexOf(id) > -1) {storageList.find(item => {if (item.id == id) {item.time = this.data.list[listLength - 1].timeitem.iputText = this.data.iputText}})} else {storageList.push({id: id,time: this.data.list[listLength - 1].time,iputText: this.data.iputText})}if (this.data.thisPage) {wx.setStorageSync('storageList', storageList)}}},// 进入页面给默认显示的信息(如:未发送的文本)initialization() {let model = wx.getStorageSync('phoneObj').modelthis.setData({moveUp: model.includes("iPhone XR"),})this.data.thisPage = truelet listLength = this.data.list.lengthlet id = this.data.options.idconst storageList = wx.getStorageSync('storageList') || [] //本地存储消息列表信息let storageListLength = storageList.lengthlet idList = storageListLength > 0 ? storageList.map(item => {return item.id}) : []if (storageListLength > 0) {if (idList.indexOf(id) > -1) {storageList.find(item => {if (item.id == id) {this.setData({iputText: item.iputText})}})} else {this.setData({iputText: ""})}}},// 离开页面需要做的处理leavePage() {//  this.data.innerAudioContext.pause()this.setStorageList()this.data.thisPage = false},/*** 生命周期函数--监听页面初次渲染完成*/onReady: function () {this.restLoginTim()},/*** 生命周期函数--监听页面显示*/onShow: function () {this.initialization()this.getMessageList()},/*** 生命周期函数--监听页面隐藏*/onHide: function () {this.leavePage()},/*** 生命周期函数--监听页面卸载*/onUnload: function () {this.leavePage()},
})

还有客服端哦
不想写了,有人就用加油吧。我改改写写2天多才就那样
html样式也就那样,就不复制了

TIM腾讯聊天(即时通信 IM)(咨询客服业务)相关推荐

  1. [Web端接入经验分享] 腾讯云即时通信TIM、实时音视频TRTC

    [Web端接入经验分享] 腾讯云即时通信TIM.实时音视频TRTC 即时通信TIM官网地址 即时通信TIM SDK API文档地址 实时音视频TRTC官网地址 实时音视频TRTC SDK API文档地 ...

  2. vue 使用腾讯IM即时通信

    最近在做商城类的项目,需要使用到客服系统, 用户选择的腾讯IM即时通信,文档很.... 对Web很不友好, 弄了半天,总算出来. 1. 先安装依赖 cnpm i cos-js-sdk-v5 cnpm ...

  3. 对腾讯云即时通信 IM快速入门(Web H5)TUIKit的改造

    快速入门组件非常容易上手,然后对于初学者,我对官方例子有个疑惑,例子中用户登录写在main.ts中,我想通过用户自主输入用户id的方式登录,无法在main.ts加载前,用vue实现一个输入框. imp ...

  4. 微信小程序集成腾讯云即时通信IM

    这里写自定义目录标题 腾讯云即时通信IM 新的改变 功能快捷键 合理的创建标题,有助于目录的生成 如何改变文本的样式 插入链接与图片 如何插入一段漂亮的代码片 生成一个适合你的列表 创建一个表格 设定 ...

  5. Java 开发在线客服系统源码,企业网站官网客服系统源码,网页版聊天咨询客服源码

    开发环境:Java + Spring boot + mysql + 通信技术:netty框架客服系统,是一个多渠道融合的客户支持服务平台,包含邮件,短信等接入渠道. 1. WebIM在线客服 客服提供 ...

  6. 微信小程序-腾讯云即时通信 IM 小程序直播(一)

    一.这里我们先讲讲使用腾讯云直播 流程 请先将1.2.3的都去简单的过一遍 就是组件的参数了解一下 1.准备推流跟拉流地址 (登录腾讯云在控制台 在直播工具箱 找到创建推流跟拉流)推流跟拉流的地址是不 ...

  7. 环信 即时通讯sdk实现客服功能

    仅适用于已经集成环信 即时通讯sdk,又需求实现客服功能,而不更换sdk. 下面的api环信 即时通讯并没有在文档中暴露,是我咨询了环信客服后知道的 核心就是 给 Message对象  setAttr ...

  8. 网友诉苦:app体验差就算了!咨询客服被骂“滚”!这么霸气?

    处在现在社会的人,"app"一词已经是一个常用词了,app充斥着每个人的生活当中,每个人的手机上起码不有个几十上百个app, 这些app基本上可以涵盖生活的90%以上的内容,可以社 ...

  9. 苹果模仿对手推商户聊天:iMessage变身企业客服中心

    两年前,Facebook在Messenger推出了企业聊天功能,以便让聊天工具成为企业商户和消费者进行沟通.服务的平台.时至今日,WhatsApp等越来越多的聊天服务也推出了企业和商户功能. 而据外媒 ...

最新文章

  1. asp.net python 开发web 效率_【Django】Python web开发:几个模板系统的性能对比(转)...
  2. 谷歌浏览器插件,当前网页地址的二维码
  3. java swing控件大全_java swing 组件大全(新手快进)
  4. 【HIMI转载推荐之三】新手教程之如何向APP STORE提交应用
  5. 成功解决win系统电脑中网络仅看到自己计算机图文教程
  6. 阿里云 Serverless 事件总线 EventBridge 重磅发布
  7. 嵌入式开发中常用的几种通信接口总结
  8. Signal处理中的函数可重入问题
  9. springboot怎么返回404_Spring Boot2 系列教程(十三)Spring Boot 中的全局异常处理
  10. vim 编辑器 打开GB2312、GBK文件乱码解决方法
  11. java 数据转成xml_java转换CSV文件生成xml格式数据
  12. Ubuntu安装Atom编辑器
  13. php之使用file_get_contents对百度orc进行文字识别(二维码识别同理)--base64编码方式(解决image format error)
  14. Linux 软件包管理器 rpm
  15. 快速复制一个网站的前端代码的工具-仿站工具
  16. PTAM特征点法跟踪和建图 SLAM FAST Patch
  17. 什么是bug?bug的分类
  18. 局域网或者本地开发https自签名证书解决办法
  19. 计算机学报编辑待遇,《计算机学报》编辑委员会
  20. 关于travis scott的网名_女生时尚好听的qq网名

热门文章

  1. 支持在线大数据SQL查询平台开源项目
  2. 台式cpu温度过高的两个原因及解决方法
  3. 如何进入docker系统
  4. C++五子棋源码(Qt版)
  5. 人工智能实验--汉诺塔规约图(四个盘子)
  6. 惠普HP Deskjet D2660 打印机驱动
  7. PDF转PPT怎么转?一键完成格式转换,太方便了
  8. 乐趣国学—品读“富润屋,德润身。”中的智慧
  9. 微信小程序手把手教你实现类似Android中ViewPager控件效果
  10. eLife:情绪学习对人脑记忆整合的回溯性促进机制