Kaynağa Gözat

IM消息优化

xiaobin.zhang 2 yıl önce
ebeveyn
işleme
6683e7e5db

+ 10 - 10
App.vue

@@ -83,14 +83,15 @@
 				},
 
 				onClosed() {
-					uni.showToast({
-						title: "退出登录",
-						icon: "none",
-						duration: 2000,
-					});
-					uni.redirectTo({
-						url: "../login/login",
-					});
+					// uni.showToast({
+					// 	title: "退出登录",
+					// 	icon: "none",
+					// 	duration: 2000,
+					// });
+					console.log('>>>>>>>>>>>IM被退出登录>>>>>>>>>>>>>>>>>')
+					// uni.redirectTo({
+					// 	url: "../login/login",
+					// });
 					me.globalData.conn.closed = true;
 					WebIM.conn.close();
 				},
@@ -290,7 +291,6 @@
 				},
 			});
 			this.globalData.checkIsIPhoneX();
-
 		},
 		onShow(options) {
 			let scene = options.scene;
@@ -344,7 +344,6 @@
 
 			getUserInfo(cb) {
 				var me = this;
-
 				if (this.userInfo) {
 					typeof cb == "function" && cb(this.userInfo);
 				} else {
@@ -655,6 +654,7 @@
 					return result + chatMsgs.length;
 				}, 0);
 				getApp().globalData.unReadMessageNum = count;
+				
 				disp.fire("em.unreadspot", message);
 			},
 		});

+ 2 - 0
card/index/index.vue

@@ -312,6 +312,8 @@ import util from '../../utils/util.js';
 		},
 
 		methods: {
+			
+			
 			loadCodeParams() {
 				let _ts = this;
 				return new Promise((resolve, reject) => {

+ 24 - 0
chat/chatroom/chatroom.vue

@@ -5,6 +5,7 @@
 <script>
 	let disp = require("../../hxChatSDK/utils/broadcast");
 	import chat from "../../chat/components/chat/chat.vue";
+	var WebIM = require("../../hxChatSDK/utils/WebIM")["default"];
 
 	export default {
 		data() {
@@ -37,6 +38,7 @@
 			uni.setNavigationBarTitle({
 				title: userNameText
 			});
+			// this.subscribePresence();
 		},
 
 		onUnload(options) {
@@ -51,6 +53,28 @@
 			uni.stopPullDownRefresh();
 		},
 		methods: {
+
+			/**
+			 * 需要到环信开通功能才能生效(增值功能)
+			 */
+			subscribePresence() {
+				let option = {
+					usernames: [this.username.your],
+					expiry: 7 * 24 * 3600 // 单位为秒
+				}
+				WebIM.conn.subscribePresence(option).then(res => {
+					console.log('subscribePresence>>>>>', res)
+				})
+
+				WebIM.conn.addEventHandler('MESSAGES', {
+					onPresenceStatusChange: function(msg) {
+						// 这里可以处理订阅用户状态更新后的逻辑。
+						console.log('状态更新', msg);
+					},
+				})
+			},
+
+
 			onClickMsg(msg) {
 				msg.action = 'join'
 				uni.navigateTo({

+ 32 - 0
chat/components/chat/chat.css

@@ -2,3 +2,35 @@
 	width: 100%;
 	height: 100%;
 }
+
+/* 邀请码弹窗 */
+.ceng2{position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(0,0,0,.5);z-index: 99;}
+.code-pop{
+	position: fixed;
+	top:50%;
+	left:50%;
+	transform: translate(-50%,-50%);
+	width: 574rpx;
+	background: #FFFFFF;
+	border-radius: 20rpx 20rpx 20rpx 20rpx;
+	z-index: 100;
+}
+.code-text{
+	line-height: 41rpx;
+	color: #151515;
+	font-size: 28rpx;
+	margin: 51rpx 47rpx 50rpx;
+	text-align: center;
+}
+.code-content image{
+	width: 365rpx;
+	height: 365rpx;
+	margin: 50rpx auto 30rpx;
+}
+.code-btn{
+	padding: 25rpx;
+	text-align: center;
+	font-size: 28rpx;
+	color: #2A82FD;
+	border-top: 1px solid #E9E9E9;
+}

+ 45 - 2
chat/components/chat/chat.vue

@@ -5,7 +5,7 @@
 			</chatSuitAudio>
 
 			<chatMsglist ref="chatMsglist" :username="username" @msglistTap="normalScroll" @clickMsg="clickMsg"
-				id="chat-msglist"></chatMsglist>
+				id="chat-msglist" @showWeChatCodePop="showWeChatPop"></chatMsglist>
 		</view>
 		<chatInputbar ref="chatInputbar" :username="username" :chatType="chatType" @newTextMsg="saveSendMsg"
 			@newImageMsg="saveSendMsg" @newLocationMsg="saveSendMsg" @newVideoMsg="saveSendMsg"
@@ -14,6 +14,27 @@
 
 		<chatEmediaInvite :username="username" :action="action" @onStartConfr="onStartConfr" @goBack="onGoBack"
 			v-if="showEmediaInvite" />
+
+
+		<!-- 复制微信弹窗 -->
+		<view class="ceng2" v-if="isShowCodePop" @click="isShowCodePop = false" @touchmove.stop.prevent="moveHandle">
+		</view>
+		<view class="code-pop" v-if="isShowCodePop">
+			<view class="code-content" v-if="recommendCard.visitingCardDTO.wechatCode">
+				<image
+					:src="recommendCard.visitingCardDTO.wechatCode?recommendCard.visitingCardDTO.wechatCode:'/static/images/wxCode.jpg'"
+					show-menu-by-longpress="true"></image>
+				<view style="text-align: center;font-size: 24rpx;color: #999;margin-bottom: 50rpx;">长按识别微信二维码</view>
+			</view>
+			<view class="code-text" v-else>
+				<view>微信号</view>
+				<view>{{recommendCard.visitingCardDTO.wechat}}</view>
+			</view>
+			<view class="code-btn" @click="copy(recommendCard.visitingCardDTO.wechat)">
+				复制微信号
+			</view>
+		</view>
+
 	</view>
 
 </template>
@@ -45,7 +66,9 @@
 				multiEmediaVisible: 'block',
 				confrId: '',
 				groupId: '',
-				confrMember: []
+				confrMember: [],
+				isShowCodePop: false,
+				recommendCard: {}
 			};
 		},
 
@@ -86,6 +109,26 @@
 				this.$refs.chatSuitAudio.toggleRecordModal();
 			},
 
+
+			showWeChatPop(isShowCodePop, evn) {
+				this.isShowCodePop = isShowCodePop;
+				this.recommendCard = evn;
+			},
+
+			copy(val) {
+				this.isShowCodePop = false
+				uni.setClipboardData({
+					data: val,
+					complete() {
+						uni.showToast({
+							title: '复制成功',
+							icon: 'none'
+						});
+					}
+				})
+			},
+
+
 			normalScroll() {
 				this.$refs.chatMsglist.normalScroll();
 				this.$refs.chatInputbar.cancelEmoji();

+ 485 - 447
chat/components/chat/msglist/msglist.vue

@@ -1,459 +1,497 @@
-<template>
-	<view scroll-y="true" :class="view + ' wrap ' + (isIPX?'scroll_view_X': '')" @tap="onTap" upper-threshold="-50"
-		:scroll-into-view="toView">
-		<view>
-			<u-modal v-model="show" title="消息举报" ref="uModal" confirm-text="举报" :async-close="true"
-				@confirm="reportMsg">
-				<view class="slot-content">
-					<u-field v-model="reason" label="举报原因" placeholder="请填写举报原因" type="textarea" :auto-height="false"
-						:clearable="false" maxlength="100">
-					</u-field>
-				</view>
-			</u-modal>
-			<u-action-sheet :list="list" @click="onMenuClick" v-model="showRpt"></u-action-sheet>
-			<u-action-sheet :list="typeList" @click="onReportTypeClick" v-model="showRptType"></u-action-sheet>
-		</view>
+<template>
+
+	<view scroll-y="true" :class="view + ' wrap ' + (isIPX?'scroll_view_X': '')" @tap="onTap" upper-threshold="-50"
+		:scroll-into-view="toView">
+		<view>
+			<u-modal v-model="show" title="消息举报" ref="uModal" confirm-text="举报" :async-close="true"
+				@confirm="reportMsg">
+				<view class="slot-content">
+					<u-field v-model="reason" label="举报原因" placeholder="请填写举报原因" type="textarea" :auto-height="false"
+						:clearable="false" maxlength="100">
+					</u-field>
+				</view>
+			</u-modal>
+			<u-action-sheet :list="list" @click="onMenuClick" v-model="showRpt"></u-action-sheet>
+			<u-action-sheet :list="typeList" @click="onReportTypeClick" v-model="showRptType"></u-action-sheet>
+		</view>
 		<!-- <view class="tips">本应用仅用于环信产品功能开发测试,请勿用于非法用途。任何涉及转账、汇款、裸聊、网恋、网购退款、投资理财等统统都是诈骗,请勿相信!</view> -->
-		<view class="chat-top ddflex">
-			<view class="li ddflex">
-				<image src="../../../static/chat_wx.png"></image>
+		<view class="chat-top ddflex" v-if="recommendCard&&recommendCard.userType==1">
+			<view class="li ddflex" v-if="recommendCard.visitingCardDTO.wechat" @click="showWeChatCodePop()">
+				<image src="../../../static/chat_wx.png">
+				</image>
 				<view>加微信</view>
 			</view>
-			<view class="li ddflex">
+			<view class="li ddflex" @click="callPhone(recommendCard.visitingCardDTO.phone)">
 				<image src="../../../static/chat_dh.png"></image>
 				<view>打电话</view>
 			</view>
-			<view class="li ddflex">
+			<view class="li ddflex" @click="jumpUrl('/card/index/index?cardId='+recommendCard.visitingCardDTO.id)">
 				<image src="../../../static/chat_wy.png"></image>
 				<view>进微页</view>
 			</view>
-		</view>
+		</view>
 		<view @longtap="onMsgTap(item)" class="message" v-for="item in chatMsg" :key="item.mid" :id="item.mid">
-			<view class="main-time">{{handleTime(item)}}</view>
-			<view class="main" :class="item.style">
-				<!-- yourname:就是消息的 from -->
-				<!-- <view class="user">
-					<text v-if="!item.style"
-						class="user-text">{{ showMessageListNickname(item) + ' ' + handleTime(item)}}</text>
-				</view> -->
-				<image class="avatar" :src="showMessageListAvatar(item)" />
-				<view class="msg">
-					<image class="err" :class="(item.style == 'self' && item.isFail) ?  'show' : 'hide'"
-						src="../../../static/msgerr.png" />
-
-					<image v-if="item.style == 'self'" src="../../../static/poprightarrow2x.png"
-						class="msg_poprightarrow" />
-					<image v-if="item.style == ''" src="../../../static/popleftarrow2x.png" class="msg_popleftarrow" />
-					<view v-if="item.msg.type == 'img' || item.msg.type == 'video'">
-						<image v-if="item.msg.type == 'img'" class="avatar" :src="item.msg.data"
-							style="width:90px; margin:2px auto;" mode="widthFix" @tap="previewImage"
-							:data-url="item.msg.data" />
-						<video v-if="item.msg.type == 'video'" :src="item.msg.data" controls style="width:300rpx;" />
-					</view>
-					<audio-msg v-if="item.msg.type == 'audio'" :msg="item"></audio-msg>
-					<file-msg v-if="item.msg.type == 'file'" :msg="item"></file-msg>
-					<view v-else-if="item.msg.type == 'txt' || item.msg.type == 'emoji'">
-						<view class="template" v-for="(d_item, d_index) in item.msg.data" :key="d_index">
-							<text :data-msg="item" @tap="clickMsg" v-if="d_item.type == 'txt'" class="msg-text"
-								style="float:left;" selectable="true">{{ d_item.data }}</text>
-
-							<image v-if="d_item.type == 'emoji'" class="avatar"
-								:src="'../../../static/faces/' + d_item.data"
-								style="width:25px; height:25px; margin:0 0 2px 0; float:left;" />
-						</view>
-					</view>
-				</view>
-			</view>
+			<view class="main-time">{{handleTime(item)}}</view>
+			<view class="main" :class="item.style">
+				<!-- yourname:就是消息的 from -->
+				<!-- <view class="user">
+					<text v-if="!item.style"
+						class="user-text">{{ showMessageListNickname(item) + ' ' + handleTime(item)}}</text>
+				</view> -->
+				<image class="avatar" :src="showMessageListAvatar(item)" />
+				<view class="msg">
+					<image class="err" :class="(item.style == 'self' && item.isFail) ?  'show' : 'hide'"
+						src="../../../static/msgerr.png" />
+
+					<image v-if="item.style == 'self'" src="../../../static/poprightarrow2x.png"
+						class="msg_poprightarrow" />
+					<image v-if="item.style == ''" src="../../../static/popleftarrow2x.png" class="msg_popleftarrow" />
+					<view v-if="item.msg.type == 'img' || item.msg.type == 'video'">
+						<image v-if="item.msg.type == 'img'" class="avatar" :src="item.msg.data"
+							style="width:90px; margin:2px auto;" mode="widthFix" @tap="previewImage"
+							:data-url="item.msg.data" />
+						<video v-if="item.msg.type == 'video'" :src="item.msg.data" controls style="width:300rpx;" />
+					</view>
+					<audio-msg v-if="item.msg.type == 'audio'" :msg="item"></audio-msg>
+					<file-msg v-if="item.msg.type == 'file'" :msg="item"></file-msg>
+					<view v-else-if="item.msg.type == 'txt' || item.msg.type == 'emoji'">
+						<view class="template" v-for="(d_item, d_index) in item.msg.data" :key="d_index">
+							<text :data-msg="item" @tap="clickMsg" v-if="d_item.type == 'txt'" class="msg-text"
+								style="float:left;" selectable="true">{{ d_item.data }}</text>
+
+							<image v-if="d_item.type == 'emoji'" class="avatar"
+								:src="'../../../static/faces/' + d_item.data"
+								style="width:25px; height:25px; margin:0 0 2px 0; float:left;" />
+						</view>
+					</view>
+				</view>
+			</view>
 		</view>
-		<view class="lixian ddflex">会话已结束,用时 05:30</view>
-		<view class="lixian ddflex">当前顾问处于离线状态,<button open-type="contact">点此联系智能客服</button></view>
-	</view>
-	<!-- <view style="height: 1px;"></view> -->
-</template>
-
-
-<script>
-	let msgStorage = require("../msgstorage");
-	let disp = require("../../../../hxChatSDK/utils/broadcast");
-	let timeFormats = require("../../../../hxChatSDK/utils/timeFormat");
-
-
-	let LIST_STATUS = {
-		SHORT: "scroll_view_change",
-		NORMAL: "scroll_view"
-	};
-	let page = 0;
-	let Index = 0;
-	let curMsgMid = '';
-	let isFail = false;
-	import audioMsg from "./type/audio/audio";
-	import fileMsg from "./type/file";
-	let WebIM = require("../../../../hxChatSDK/utils/WebIM")["default"];
-	export default {
-		data() {
-			return {
-				view: LIST_STATUS.NORMAL,
-				toView: "",
-				chatMsg: [],
-				__visibility__: false,
-				isIPX: false,
-				title: '消息举报',
-				list: [{
-					text: '举报'
-				}],
-				show: false,
-				showRpt: false,
-				showRptType: false,
-				rptMsgId: '', // 举报消息id
-				rptType: '', // 举报类型
-				reason: '',
-				typeList: [{
-						text: "涉政"
-					},
-					{
-						text: "涉黄"
-					},
-					{
-						text: "广告"
-					},
-					{
-						text: "辱骂"
-					},
-					{
-						text: "暴恐"
-					},
-					{
-						text: "违禁"
-					}
-				],
-				defaultAvatar: "../../../static/theme2x.png",
-				defaultGroupAvatar: "../../..//static/groupTheme.png"
-			};
-		},
-
-		components: {
-			audioMsg,
-			fileMsg
-		},
-		props: {
-			username: {
-				type: Object,
-				default: () => ({})
-			}
-		},
-
-		// lifetimes
-		created() {},
-
-		beforeMount() {
-			this.__visibility__ = true;
-			page = 0;
-			Index = 0;
-		},
-
-		moved() {},
-
-		destroyed() {
-			this.__visibility__ = false;
-			msgStorage.off("newChatMsg", this.dispMsg)
-		},
-
-		mounted(event) {
-
-			let me = this;
-			if (getApp().globalData.isIPX) {
-				this.setData({
-					isIPX: true
-				});
-			}
-
-			this.username = uni.username;
-			let username = this.username;
-			let myUsername = uni.getStorageSync("myUsername");
-			let sessionKey = username.groupId ? username.groupId + myUsername : username.your + myUsername;
-			let chatMsg = uni.getStorageSync(sessionKey) || [];
-			this.renderMsg(null, null, chatMsg, sessionKey);
-			uni.setStorageSync(sessionKey, null);
-			disp.on('em.error.sendMsgErr', function(err) {
-				// curMsgMid = err.data.mid;
-				isFail = true;
-				// return;
-				console.log('发送失败了');
-				return;
-				let msgList = me.chatMsg;
-				msgList.map(item => {
-					if (item.mid.substring(item.mid.length - 10) == curMsgMid.substring(curMsgMid.length -
-							10)) {
-						item.msg.data[0].isFail = true;
-						item.isFail = true;
-						me.setData({
-							chatMsg: msgList
-						});
-					}
-				});
-
-				// if (me.curChatMsg[0].mid == curMsgMid) {
-				//   me.curChatMsg[0].msg.data[0].isShow = false;
-				//   me.curChatMsg[0].isShow = false;
-				// }
-
-				uni.setStorageSync("rendered_" + sessionKey, msgList);
-			});
-			msgStorage.on("newChatMsg", this.dispMsg);
-		},
-		computed: {
-			
-			//处理时间显示
-			handleTime() {
-				return (item) => {
-					return timeFormats.timeFormat(item.time, 'mm/dd/hh:MM')
-				}
-			}
-		},
-		methods: {
-			normalScroll() {
-				this.setData({
-					view: LIST_STATUS.NORMAL
-				});
-			},
-			
-			//消息列表头像展示
-			showMessageListAvatar(item) {
-				// console.log('item>>>>>',item);
-				const imUserInfo = uni.getStorageSync("imUserInfo_" + item.info.from);
-				if (imUserInfo && imUserInfo.avatar) {
-					return imUserInfo.avatar;
-				} else {
-					return this.defaultAvatar;
-				}
-			},
-			//消息列表昵称显示
-			showMessageListNickname(item) {
-				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
-				const imUserInfo = uni.getStorageSync("imUserInfo_" + item.info.from);
-				if (imUserInfo && imUserInfo.nickName) {
-					return imUserInfo.nickName;
-				} else {
-					return item.yourname;
-				}
-			},
-			
-			dispMsg(renderableMsg, type, curChatMsg, sesskey) {
-				let me = this;
-				let username = this.username;
-				let myUsername = uni.getStorageSync("myUsername");
-				let sessionKey = username.groupId ? username.groupId + myUsername : username.your + myUsername;
-				me.curChatMsg = curChatMsg;
-
-				if (!me.__visibility__) return; // 判断是否属于当前会话
-
-				if (username.groupId) {
-					// 群消息的 to 是 id,from 是 name
-					if (renderableMsg.info.from == username.groupId || renderableMsg.info.to == username.groupId) {
-						if (sesskey == sessionKey) {
-							me.renderMsg(renderableMsg, type, curChatMsg, sessionKey, 'newMsg');
-						}
-					}
-				} else if (renderableMsg.info.from == username.your || renderableMsg.info.to == username.your) {
-					if (sesskey == sessionKey) {
-						me.renderMsg(renderableMsg, type, curChatMsg, sessionKey, 'newMsg');
-					}
-				}
-			},
-			onInput(e) {
-				this.setData({
-					reason: e.target.value
-				})
-			},
-			shortScroll() {
-				this.setData({
-					view: LIST_STATUS.SHORT
-				});
-			},
-
-			onTap() {
-				this.$emit("msglistTap", null, {
-					bubbles: true
-				});
-			},
-
-			onMsgTap(item) {
-				// 别人发的消息
-				if (item.style !== 'self') {
-					this.setData({
-						showRpt: true,
-						rptMsgId: item.id
-					})
-				}
-			},
-
-			onMenuClick(idx) {
-				if (idx === 0) {
-					this.setData({
-						showRptType: true
-					})
-				}
-			},
-
-			reportMsg() {
-				let that = this
-				if (this.reason === '') {
-					this.$refs.uModal.clearLoading();
-					uni.showToast({
-						title: "请填写举报原因",
-						icon: 'none'
-					});
-					return false
-				}
-				WebIM.conn
-					.reportMessage({
-						reportType: that.rptType, // 举报类型
-						reportReason: that.reason, // 举报原因。
-						messageId: that.rptMsgId // 上报消息id
-					})
-					.then(() => {
-						uni.showToast({
-							title: "举报成功",
-							icon: 'none'
-						});
-					})
-					.catch((e) => {
-						uni.showToast({
-							title: "举报失败",
-							icon: 'none'
-						});
-					}).finally(() => {
-						that.setData({
-							reason: '',
-							rptType: '',
-							rptMsgId: '',
-							show: false
-						})
-					});
-			},
-
-			onReportTypeClick(idx) {
-				// 设置举报类型
-				this.setData({
-					rptType: this.typeList[idx].text,
-					show: true
-				})
-			},
-
-
-			previewImage(event) {
-				var url = event.target.dataset.url;
-				uni.previewImage({
-					urls: [url] // 需要预览的图片 http 链接列表
-				});
-			},
-
-			getHistoryMsg() {
-				let me = this;
-				let username = this.username;
-				let myUsername = uni.getStorageSync("myUsername");
-				let sessionKey = username.groupId ? username.groupId + myUsername : username.your + myUsername;
-				let historyChatMsgs = uni.getStorageSync("rendered_" + sessionKey) || [];
-
-				if (Index < historyChatMsgs.length) {
-					let timesMsgList = historyChatMsgs.slice(-Index - 10, -Index);
-					this.setData({
-						chatMsg: timesMsgList.concat(me.chatMsg),
-						toView: timesMsgList[timesMsgList.length - 1].mid
-					});
-					Index += timesMsgList.length;
-
-					if (timesMsgList.length == 10) {
-						page++;
-					}
-
-					uni.stopPullDownRefresh();
-				}
-			},
-
-			renderMsg(renderableMsg, type, curChatMsg, sessionKey, isnew) {
-				let me = this;
-
-				var historyChatMsgs = uni.getStorageSync("rendered_" + sessionKey) || [];
-
-				historyChatMsgs = historyChatMsgs.concat(curChatMsg);
-
-				if (!historyChatMsgs.length) return;
-
-				if (isnew == 'newMsg') {
-					this.setData({
-						chatMsg: this.chatMsg.concat(curChatMsg),
-						// 跳到最后一条
-						toView: historyChatMsgs[historyChatMsgs.length - 1].mid
-					});
-				} else {
-					this.setData({
-						chatMsg: historyChatMsgs.slice(-10),
-						// 跳到最后一条
-						toView: historyChatMsgs[historyChatMsgs.length - 1].mid
-					});
-				}
-
-				uni.setStorageSync("rendered_" + sessionKey, historyChatMsgs);
-				let chatMsg = uni.getStorageSync(sessionKey) || [];
-				chatMsg.map(function(item, index) {
-					curChatMsg.map(function(item2, index2) {
-						if (item2.mid == item.mid) {
-							chatMsg.splice(index, 1);
-						}
-					});
-				});
-				uni.setStorageSync(sessionKey, chatMsg);
-				Index = historyChatMsgs.slice(-10).length;
-				// setTimeout 兼容支付宝小程序
-				setTimeout(() => {
-					uni.pageScrollTo({
-						scrollTop: 5000,
-						duration: 300,
-						fail: (e) => {
-							//console.log('滚失败了', e)
-						}
-					});
-				}, 100)
-
-				if (isFail) {
-					this.renderFail(sessionKey);
-				}
-			},
-
-			renderFail(sessionKey) {
-				let me = this;
-				let msgList = me.chatMsg;
-				msgList.map(item => {
-					if (item.mid.substring(item.mid.length - 10) == curMsgMid.substring(curMsgMid.length - 10)) {
-						item.msg.data[0].isFail = true;
-						item.isFail = true;
-						me.setData({
-							chatMsg: msgList
-						});
-					}
-				});
-
-				if (me.curChatMsg[0].mid == curMsgMid) {
-					me.curChatMsg[0].msg.data[0].isShow = false;
-					me.curChatMsg[0].isShow = false;
-				}
-
-				uni.setStorageSync("rendered_" + sessionKey, msgList);
-				isFail = false;
-			},
-
-			clickMsg(event) {
-				if (typeof(event.target.dataset.msg) == 'object' &&
-					event.target.dataset.msg.msg.ext &&
-					event.target.dataset.msg.msg.ext.msg_extension) {
-					this.$emit("clickMsg", event.target.dataset.msg.msg.ext)
-				}
-			}
-
-		}
-	};
-</script>
-<style>
-	@import "./msglist.css";
+		<!-- <view class="lixian ddflex">会话已结束,用时 05:30</view>
+		<view class="lixian ddflex">当前顾问处于离线状态,<button open-type="contact">点此联系智能客服</button></view>
+	 -->
+	</view>
+	<!-- <view style="height: 1px;"></view> -->
+</template>
+
+
+<script>
+	let req = require('../../../../utils/request');
+	let msgStorage = require("../msgstorage");
+	let disp = require("../../../../hxChatSDK/utils/broadcast");
+	let timeFormats = require("../../../../hxChatSDK/utils/timeFormat");
+
+
+	let LIST_STATUS = {
+		SHORT: "scroll_view_change",
+		NORMAL: "scroll_view"
+	};
+	let page = 0;
+	let Index = 0;
+	let curMsgMid = '';
+	let isFail = false;
+	import audioMsg from "./type/audio/audio";
+	import fileMsg from "./type/file";
+	let WebIM = require("../../../../hxChatSDK/utils/WebIM")["default"];
+	export default {
+		data() {
+			return {
+				view: LIST_STATUS.NORMAL,
+				toView: "",
+				chatMsg: [],
+				visibility: false,
+				isIPX: false,
+				title: '消息举报',
+				list: [{
+					text: '举报'
+				}],
+				show: false,
+				showRpt: false,
+				showRptType: false,
+				rptMsgId: '', // 举报消息id
+				rptType: '', // 举报类型
+				reason: '',
+				typeList: [{
+						text: "涉政"
+					},
+					{
+						text: "涉黄"
+					},
+					{
+						text: "广告"
+					},
+					{
+						text: "辱骂"
+					},
+					{
+						text: "暴恐"
+					},
+					{
+						text: "违禁"
+					}
+				],
+				defaultAvatar: "../../../static/theme2x.png",
+				defaultGroupAvatar: "../../..//static/groupTheme.png",
+				recommendCard: '',
+				isShowCodePop: false,
+			};
+		},
+
+		components: {
+			audioMsg,
+			fileMsg
+		},
+		props: {
+			username: {
+				type: Object,
+				default: () => ({})
+			}
+		},
+
+		// lifetimes
+		created() {},
+
+		beforeMount() {
+			this.visibility = true;
+			page = 0;
+			Index = 0;
+		},
+
+		moved() {},
+
+		destroyed() {
+			this.visibility = false;
+			msgStorage.off("newChatMsg", this.dispMsg)
+		},
+
+		mounted(event) {
+
+			let me = this;
+			if (getApp().globalData.isIPX) {
+				this.setData({
+					isIPX: true
+				});
+			}
+
+			this.username = uni.username;
+			let username = this.username;
+			let myUsername = uni.getStorageSync("myUsername");
+			let sessionKey = username.groupId ? username.groupId + myUsername : username.your + myUsername;
+			let chatMsg = uni.getStorageSync(sessionKey) || [];
+			this.renderMsg(null, null, chatMsg, sessionKey);
+			uni.setStorageSync(sessionKey, null);
+			disp.on('em.error.sendMsgErr', function(err) {
+				// curMsgMid = err.data.mid;
+				isFail = true;
+				// return;
+				console.log('发送失败了');
+				return;
+				let msgList = me.chatMsg;
+				msgList.map(item => {
+					if (item.mid.substring(item.mid.length - 10) == curMsgMid.substring(curMsgMid.length -
+							10)) {
+						item.msg.data[0].isFail = true;
+						item.isFail = true;
+						me.setData({
+							chatMsg: msgList
+						});
+					}
+				});
+
+				// if (me.curChatMsg[0].mid == curMsgMid) {
+				//   me.curChatMsg[0].msg.data[0].isShow = false;
+				//   me.curChatMsg[0].isShow = false;
+				// }
+
+				uni.setStorageSync("rendered_" + sessionKey, msgList);
+			});
+			msgStorage.on("newChatMsg", this.dispMsg);
+			this.getUserInfo();
+		},
+		computed: {
+
+			//处理时间显示
+			handleTime() {
+				return (item) => {
+					return timeFormats.timeFormat(item.time, 'mm/dd/hh:MM')
+				}
+			}
+		},
+		methods: {
+			jumpUrl(url) {
+				uni.navigateTo({
+					url: url
+				})
+			},
+
+			showWeChatCodePop() {
+				this.$emit("showWeChatCodePop", true, this.recommendCard);
+			},
+
+			//获取用户数据
+			getUserInfo() {
+				// this.username = uni.username;
+				var id = this.username.your.replace('rs_', '');
+				req.getRequest('/api/user/userInfoById', {
+					userId: id
+				}, data => {
+					this.recommendCard = data;
+				});
+			},
+
+			// 拨打电话
+			callPhone(val) {
+				if (!val) return false
+				uni.makePhoneCall({
+					phoneNumber: val
+				});
+			},
+
+
+
+			normalScroll() {
+				this.setData({
+					view: LIST_STATUS.NORMAL
+				});
+			},
+
+			//消息列表头像展示
+			showMessageListAvatar(item) {
+				// console.log('item>>>>>',item);
+				const imUserInfo = uni.getStorageSync("imUserInfo_" + item.info.from);
+				if (imUserInfo && imUserInfo.avatar) {
+					return imUserInfo.avatar;
+				} else {
+					return this.defaultAvatar;
+				}
+			},
+			//消息列表昵称显示
+			showMessageListNickname(item) {
+				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				const imUserInfo = uni.getStorageSync("imUserInfo_" + item.info.from);
+				if (imUserInfo && imUserInfo.nickName) {
+					return imUserInfo.nickName;
+				} else {
+					return item.yourname;
+				}
+			},
+
+			dispMsg(renderableMsg, type, curChatMsg, sesskey) {
+				let me = this;
+				let username = this.username;
+				let myUsername = uni.getStorageSync("myUsername");
+				let sessionKey = username.groupId ? username.groupId + myUsername : username.your + myUsername;
+				me.curChatMsg = curChatMsg;
+
+				if (!me.visibility) return; // 判断是否属于当前会话
+
+				if (username.groupId) {
+					// 群消息的 to 是 id,from 是 name
+					if (renderableMsg.info.from == username.groupId || renderableMsg.info.to == username.groupId) {
+						if (sesskey == sessionKey) {
+							me.renderMsg(renderableMsg, type, curChatMsg, sessionKey, 'newMsg');
+						}
+					}
+				} else if (renderableMsg.info.from == username.your || renderableMsg.info.to == username.your) {
+					if (sesskey == sessionKey) {
+						me.renderMsg(renderableMsg, type, curChatMsg, sessionKey, 'newMsg');
+					}
+				}
+			},
+			onInput(e) {
+				this.setData({
+					reason: e.target.value
+				})
+			},
+			shortScroll() {
+				this.setData({
+					view: LIST_STATUS.SHORT
+				});
+			},
+
+			onTap() {
+				this.$emit("msglistTap", null, {
+					bubbles: true
+				});
+			},
+
+			onMsgTap(item) {
+				// 别人发的消息
+				if (item.style !== 'self') {
+					this.setData({
+						showRpt: true,
+						rptMsgId: item.id
+					})
+				}
+			},
+
+			onMenuClick(idx) {
+				if (idx === 0) {
+					this.setData({
+						showRptType: true
+					})
+				}
+			},
+
+			reportMsg() {
+				let that = this
+				if (this.reason === '') {
+					this.$refs.uModal.clearLoading();
+					uni.showToast({
+						title: "请填写举报原因",
+						icon: 'none'
+					});
+					return false
+				}
+				WebIM.conn
+					.reportMessage({
+						reportType: that.rptType, // 举报类型
+						reportReason: that.reason, // 举报原因。
+						messageId: that.rptMsgId // 上报消息id
+					})
+					.then(() => {
+						uni.showToast({
+							title: "举报成功",
+							icon: 'none'
+						});
+					})
+					.catch((e) => {
+						uni.showToast({
+							title: "举报失败",
+							icon: 'none'
+						});
+					}).finally(() => {
+						that.setData({
+							reason: '',
+							rptType: '',
+							rptMsgId: '',
+							show: false
+						})
+					});
+			},
+
+			onReportTypeClick(idx) {
+				// 设置举报类型
+				this.setData({
+					rptType: this.typeList[idx].text,
+					show: true
+				})
+			},
+
+
+			previewImage(event) {
+				var url = event.target.dataset.url;
+				uni.previewImage({
+					urls: [url] // 需要预览的图片 http 链接列表
+				});
+			},
+
+			getHistoryMsg() {
+				let me = this;
+				let username = this.username;
+				let myUsername = uni.getStorageSync("myUsername");
+				let sessionKey = username.groupId ? username.groupId + myUsername : username.your + myUsername;
+				let historyChatMsgs = uni.getStorageSync("rendered_" + sessionKey) || [];
+
+				if (Index < historyChatMsgs.length) {
+					let timesMsgList = historyChatMsgs.slice(-Index - 10, -Index);
+					this.setData({
+						chatMsg: timesMsgList.concat(me.chatMsg),
+						toView: timesMsgList[timesMsgList.length - 1].mid
+					});
+					Index += timesMsgList.length;
+
+					if (timesMsgList.length == 10) {
+						page++;
+					}
+
+					uni.stopPullDownRefresh();
+				}
+			},
+
+			renderMsg(renderableMsg, type, curChatMsg, sessionKey, isnew) {
+				let me = this;
+
+				var historyChatMsgs = uni.getStorageSync("rendered_" + sessionKey) || [];
+
+				historyChatMsgs = historyChatMsgs.concat(curChatMsg);
+
+				if (!historyChatMsgs.length) return;
+
+				if (isnew == 'newMsg') {
+					this.setData({
+						chatMsg: this.chatMsg.concat(curChatMsg),
+						// 跳到最后一条
+						toView: historyChatMsgs[historyChatMsgs.length - 1].mid
+					});
+				} else {
+					this.setData({
+						chatMsg: historyChatMsgs.slice(-10),
+						// 跳到最后一条
+						toView: historyChatMsgs[historyChatMsgs.length - 1].mid
+					});
+				}
+
+				uni.setStorageSync("rendered_" + sessionKey, historyChatMsgs);
+				let chatMsg = uni.getStorageSync(sessionKey) || [];
+				chatMsg.map(function(item, index) {
+					curChatMsg.map(function(item2, index2) {
+						if (item2.mid == item.mid) {
+							chatMsg.splice(index, 1);
+						}
+					});
+				});
+				uni.setStorageSync(sessionKey, chatMsg);
+				Index = historyChatMsgs.slice(-10).length;
+				// setTimeout 兼容支付宝小程序
+				setTimeout(() => {
+					uni.pageScrollTo({
+						scrollTop: 5000,
+						duration: 300,
+						fail: (e) => {
+							//console.log('滚失败了', e)
+						}
+					});
+				}, 100)
+
+				if (isFail) {
+					this.renderFail(sessionKey);
+				}
+			},
+
+			renderFail(sessionKey) {
+				let me = this;
+				let msgList = me.chatMsg;
+				msgList.map(item => {
+					if (item.mid.substring(item.mid.length - 10) == curMsgMid.substring(curMsgMid.length - 10)) {
+						item.msg.data[0].isFail = true;
+						item.isFail = true;
+						me.setData({
+							chatMsg: msgList
+						});
+					}
+				});
+
+				if (me.curChatMsg[0].mid == curMsgMid) {
+					me.curChatMsg[0].msg.data[0].isShow = false;
+					me.curChatMsg[0].isShow = false;
+				}
+
+				uni.setStorageSync("rendered_" + sessionKey, msgList);
+				isFail = false;
+			},
+
+			clickMsg(event) {
+				if (typeof(event.target.dataset.msg) == 'object' &&
+					event.target.dataset.msg.msg.ext &&
+					event.target.dataset.msg.msg.ext.msg_extension) {
+					this.$emit("clickMsg", event.target.dataset.msg.msg.ext)
+				}
+			}
+
+		}
+	};
+</script>
+<style>
+	@import "./msglist.css";
 </style>

+ 690 - 705
chat/conversation/conversation.vue

@@ -1,60 +1,62 @@
-<template>
-	<view>
-		<!-- <view>
-			<view class="search" v-if="search_btn">
-				<view @tap="openSearch">
-					<icon type="search" size="12"></icon>
-					<text>搜索</text>
-				</view>
-			</view>
-		</view> -->
-
-		<!-- <view class="chat_list_wraper" > -->
-		<scroll-view scroll-y="true" :class="
-      'chat_list_wraper ' + (gotop ? (isIPX ? 'goTopX' : 'goTop') : 'goback')
-    " :style="'padding-bottom: ' + (isIPX ? '270rpx' : '226rpx')">
-			<!-- <view class="search_input" v-if="search_chats">
-				<view>
-					<icon type="search" size="12"></icon>
-					<input placeholder="搜索" placeholder-style="color:#9B9B9B;line-height:21px;font-size:15px;"
-						auto-focus confirm-type="search" type="text" @confirm="onSearch" @input="onInput"
-						v-model="input_code" />
-					<icon type="clear" size="12" @tap.stop="clearInput" v-if="show_clear"></icon>
-				</view>
-				<text @tap="cancel">取消</text>
-			</view> -->
-			<view v-for="(item, index) in conversationList" :key="index" class="chat_list" :data-item="item"
-				@tap.stop="del_chat" @longpress="longpress">
-				<swipe-delete>
-					<!-- 通知模块 -->
-					<!-- <view class="tap_mask" @tap.stop="into_inform" :data-item="item" v-if="item.chatType == 'INFORM'">
-						<view class="list_box">
-							<view class="list_left">
-								<view class="list_pic">
-									<view v-if="unReadTotalNotNum > 0" class="em-unread-spot2">
-										{{ unReadTotalNotNum}}
-									</view>
-									<image :class="unReadTotalNotNum > 0 ? 'haveSpot' : ''" src="../static/inform.png">
-									</image>
-								</view>
-								<view class="list_text">
-									<text class="list_user"> 系统通知 </text>
-									<text class="list_word"
-										v-if="item.chatType == 'INFORM'">申请通知来自:{{ item.info.from }}</text>
-								</view>
-							</view>
-							<view class="list_right">
-								<text :data-username="item.username">{{ handleTime(item) }}</text>
-							</view>
-						</view>
-					</view> -->
-
-					<view class="tap_mask" @tap.stop="into_chatRoom" :data-item="JSON.stringify(item)">
+<template>
+	<view>
+		<!-- <view>
+			<view class="search" v-if="search_btn">
+				<view @tap="openSearch">
+					<icon type="search" size="12"></icon>
+					<text>搜索</text>
+				</view>
+			</view>
+		</view> -->
+
+		<!-- <view class="chat_list_wraper" > -->
+		<scroll-view scroll-y="true" :class="
+      'chat_list_wraper ' + (gotop ? (isIPX ? 'goTopX' : 'goTop') : 'goback')
+    " :style="'padding-bottom: ' + (isIPX ? '270rpx' : '226rpx')">
+			<!-- <view class="search_input" v-if="search_chats">
+				<view>
+					<icon type="search" size="12"></icon>
+					<input placeholder="搜索" placeholder-style="color:#9B9B9B;line-height:21px;font-size:15px;"
+						auto-focus confirm-type="search" type="text" @confirm="onSearch" @input="onInput"
+						v-model="input_code" />
+					<icon type="clear" size="12" @tap.stop="clearInput" v-if="show_clear"></icon>
+				</view>
+				<text @tap="cancel">取消</text>
+			</view> -->
+			<view v-for="(item, index) in conversationList" :key="index" class="chat_list" :data-item="item"
+				@tap.stop="del_chat" @longpress="longpress">
+				<swipe-delete>
+					<!-- 通知模块 -->
+					<!-- <view class="tap_mask" @tap.stop="into_inform" :data-item="item" v-if="item.chatType == 'INFORM'">
+						<view class="list_box">
+							<view class="list_left">
+								<view class="list_pic">
+									<view v-if="unReadTotalNotNum > 0" class="em-unread-spot2">
+										{{ unReadTotalNotNum}}
+									</view>
+									<image :class="unReadTotalNotNum > 0 ? 'haveSpot' : ''" src="../static/inform.png">
+									</image>
+								</view>
+								<view class="list_text">
+									<text class="list_user"> 系统通知 </text>
+									<text class="list_word"
+										v-if="item.chatType == 'INFORM'">申请通知来自:{{ item.info.from }}</text>
+								</view>
+							</view>
+							<view class="list_right">
+								<text :data-username="item.username">{{ handleTime(item) }}</text>
+							</view>
+						</view>
+					</view> -->
+
+					<view class="tap_mask" @tap.stop="into_chatRoom" :data-item="JSON.stringify(item)">
 						<!-- 消息列表 -->
 						<view class="list_box ddflex">
 							<view class="list-left fflex ddflex">
 								<view class="list_pic">
-									<view class="em-msgNum" v-if="item.unReadCount > 0  && !pushConfigData.includes(item.chatType === 'chat' ? item.username : item.info.to)">{{ item.unReadCount > 99 ? '99+':item.unReadCount}}</view>
+									<view class="em-msgNum"
+										v-if="item.unReadCount > 0  && !pushConfigData.includes(item.chatType === 'chat' ? item.username : item.info.to)">
+										{{ item.unReadCount > 99 ? '99+':item.unReadCount}}</view>
 									<image :src="showConversationAvatar(item)"></image>
 								</view>
 								<view class="list_texts fflex">
@@ -75,658 +77,641 @@
 									</view>
 								</view>
 							</view>
-						</view>
-						<!-- <view class="list_box">
-							<view class="list_left" :data-username="item.username">
-								<view class="list_pic">
-									<view class="em-msgNum"
-										v-if="item.unReadCount > 0  && !pushConfigData.includes(item.chatType === 'chat' ? item.username : item.info.to)">
-										{{ item.unReadCount > 99 ? '99+':item.unReadCount}}
-									</view>
-
-									<image :src="showConversationAvatar(item)"></image>
-								</view>
-								<view class="list_text">
-									<text class="list_user">{{ showConversationName(item) }}</text>
-									<text class="list_word" v-if="item.msg.data[0].data">
-										{{item.msg.data[0].data}}
-									</text>
-									<text class="list_word" v-if="item.msg.type == 'img'">[图片]</text>
-									<text class="list_word" v-if="item.msg.type == 'audio'">[语音]</text>
-									<text class="list_word" v-if="item.msg.type == 'file'">[附件]</text>
-									<text class="list_word" v-if="item.msg.type == 'video'">[视频]</text>
-								</view>
-							</view>
-							<view class="list_right">
-								<text :data-username="item.username">{{ handleTime(item) }}</text>
-							</view>
-						</view> -->
-					</view>
-				</swipe-delete>
-			</view>
-
-			<long-press-modal :winSize="winSize" :popButton="popButton" @change="pickerMenuChange" :showPop="showPop"
-				@hidePop="hidePop" :popStyle="popStyle" />
-			<view v-if="conversationList && conversationList.length == 0" class="chat_noChat">
-				<image class="ctbg" src="../static/ctbg.png"></image>
-				暂无聊天消息
-			</view>
-			<!-- </view> -->
-		</scroll-view>
-		<!-- bug: margin-bottom 不生效 需要加一个空标签-->
-		<view style="height: 1px"></view>
-		<view class="mask" @tap="close_mask" v-if="show_mask"></view>
-	</view>
-</template>
-
-<script>
-	const req = require("../../utils/request.js");
-	let disp = require("../../hxChatSDK/utils/broadcast");
-	let timeFormats = require("../../hxChatSDK/utils/timeFormat");
-	var WebIM = require("../../hxChatSDK/utils/WebIM")["default"];
-	let isfirstTime = true;
-	import swipeDelete from "../../chat/components/chat/swipedelete/swipedelete";
-	import longPressModal from "../../chat/components/chat/longPressModal/index";
-	export default {
-		data() {
-			return {
-				search_btn: true,
-				search_chats: false,
-				show_mask: false,
-				yourname: "",
-				unReadSpotNum: 0,
-				unReadNoticeNum: 0,
-				messageNum: 0,
-				unReadTotalNotNum: 0,
-				conversationList: [
-					{
-						unReadCount: 5,
-						chatType: 'chat',
-						username: 'Lancy',
-						info: {
-							to: 'Bin'
-						},
-						msg: {
-							type: 'img',
-							data: [
-								{
-									data: '666'
-								}
-							]
+						</view>
+						<!-- <view class="list_box">
+							<view class="list_left" :data-username="item.username">
+								<view class="list_pic">
+									<view class="em-msgNum"
+										v-if="item.unReadCount > 0  && !pushConfigData.includes(item.chatType === 'chat' ? item.username : item.info.to)">
+										{{ item.unReadCount > 99 ? '99+':item.unReadCount}}
+									</view>
+
+									<image :src="showConversationAvatar(item)"></image>
+								</view>
+								<view class="list_text">
+									<text class="list_user">{{ showConversationName(item) }}</text>
+									<text class="list_word" v-if="item.msg.data[0].data">
+										{{item.msg.data[0].data}}
+									</text>
+									<text class="list_word" v-if="item.msg.type == 'img'">[图片]</text>
+									<text class="list_word" v-if="item.msg.type == 'audio'">[语音]</text>
+									<text class="list_word" v-if="item.msg.type == 'file'">[附件]</text>
+									<text class="list_word" v-if="item.msg.type == 'video'">[视频]</text>
+								</view>
+							</view>
+							<view class="list_right">
+								<text :data-username="item.username">{{ handleTime(item) }}</text>
+							</view>
+						</view> -->
+					</view>
+				</swipe-delete>
+			</view>
+
+			<long-press-modal :winSize="winSize" :popButton="popButton" @change="pickerMenuChange" :showPop="showPop"
+				@hidePop="hidePop" :popStyle="popStyle" />
+			<view v-if="conversationList && conversationList.length == 0" class="chat_noChat">
+				<image class="ctbg" src="../static/ctbg.png"></image>
+				暂无聊天消息
+			</view>
+			<!-- </view> -->
+		</scroll-view>
+		<!-- bug: margin-bottom 不生效 需要加一个空标签-->
+		<view style="height: 1px"></view>
+		<view class="mask" @tap="close_mask" v-if="show_mask"></view>
+	</view>
+</template>
+
+<script>
+	const req = require("../../utils/request.js");
+	let disp = require("../../hxChatSDK/utils/broadcast");
+	let timeFormats = require("../../hxChatSDK/utils/timeFormat");
+	var WebIM = require("../../hxChatSDK/utils/WebIM")["default"];
+	let isfirstTime = true;
+	import swipeDelete from "../../chat/components/chat/swipedelete/swipedelete";
+	import longPressModal from "../../chat/components/chat/longPressModal/index";
+	export default {
+		data() {
+			return {
+				search_btn: true,
+				search_chats: false,
+				show_mask: false,
+				yourname: "",
+				unReadSpotNum: 0,
+				unReadNoticeNum: 0,
+				messageNum: 0,
+				unReadTotalNotNum: 0,
+				conversationList: [],
+				show_clear: false,
+				member: "",
+				isIPX: false,
+				gotop: false,
+				input_code: "",
+				groupName: {},
+				winSize: {},
+				popButton: ["删除该聊天"],
+				showPop: false,
+				popStyle: "",
+				currentVal: '',
+				pushConfigData: [],
+				defaultAvatar: "../static/theme2x.png",
+				defaultGroupAvatar: "../static/groupTheme.png"
+			};
+		},
+
+		components: {
+			swipeDelete,
+			longPressModal,
+		},
+		props: {},
+
+		onLoad() {
+			this.getWindowSize();
+			//监听加好友申请
+			disp.on("em.subscribe", this.onChatPageSubscribe);
+			//监听解散群
+			disp.on("em.invite.deleteGroup", this.onChatPageDeleteGroup);
+			//监听未读消息数
+			disp.on("em.unreadspot", this.onChatPageUnreadspot);
+			//监听未读加群“通知”
+			disp.on("em.invite.joingroup", this.onChatPageJoingroup);
+			//监听好友删除
+			disp.on("em.contacts.remove", this.onChatPageRemoveContacts);
+			//监听好友关系解除
+			disp.on("em.unsubscribed", this.onChatPageUnsubscribed)
+			if (!uni.getStorageSync('listGroup')) {
+				this.listGroups()
+			}
+			// if (!uni.getStorageSync('member')) {
+				this.getRoster()
+			// }
+			this.readJoinedGroupName()
+		},
+
+		onShow: function() {
+			uni.hideHomeButton && uni.hideHomeButton();
+			setTimeout(() => {
+				this.getLocalConversationlist();
+			}, 100)
+			this.setData({
+				unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
+					"99+" : getApp().globalData.unReadMessageNum,
+				messageNum: getApp().globalData.saveFriendList.length,
+				unReadNoticeNum: getApp().globalData.saveGroupInvitedList.length,
+				unReadTotalNotNum: getApp().globalData.saveFriendList.length +
+					getApp().globalData.saveGroupInvitedList.length,
+			});
+
+			if (getApp().globalData.isIPX) {
+				this.setData({
+					isIPX: true,
+				});
+			}
+		},
+		onUnload() {
+			//页面卸载同步取消onload中的订阅,防止重复订阅事件。
+			disp.off('em.subscribe', this.onChatPageSubscribe)
+			disp.off("em.invite.deleteGroup", this.onChatPageDeleteGroup)
+			disp.off("em.unreadspot", this.onChatPageUnreadspot)
+			disp.off("em.invite.joingroup", this.onChatPageJoingroup)
+			disp.off("em.contacts.remove", this.onChatPageRemoveContacts)
+			disp.off("em.unsubscribed", this.onChatPageUnsubscribed)
+		},
+		computed: {
+			//会话头像展示
+			showConversationAvatar() {
+				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				return (item) => {
+					if (item.chatType === 'singleChat' || item.chatType === 'chat') {
+
+						// if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.avatarurl) {
+						// 	return friendUserInfoMap.get(item.username).avatarurl
+						// } else {
+						// 	return this.defaultAvatar
+						// }
+						const imUserInfo = uni.getStorageSync("imUserInfo_" + item.username);
+						if (imUserInfo && imUserInfo.avatar) {
+							return imUserInfo.avatar;
+						} else {
+							return this.defaultAvatar;
+						}
+
+					} else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
+						return this.defaultGroupAvatar
+					}
+				}
+			},
+			//会话name展示
+			showConversationName() {
+				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				return (item) => {
+					if (item.chatType === 'singleChat' || item.chatType === 'chat') {
+						// if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.nickname) {
+						// 	return friendUserInfoMap.get(item.username).nickname
+						// } else {
+						// 	return item.username
+						// }
+						const imUserInfo = uni.getStorageSync("imUserInfo_" + item.username);
+						if (imUserInfo && imUserInfo.nickName) {
+							return imUserInfo.nickName;
+						} else {
+							return item.username;
+						}
+					} else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
+						return item.groupName
+					}
+				}
+			},
+			//处理时间显示
+			handleTime() {
+				return (item) => {
+					return timeFormats.timeFormat(item.time, 'mm/dd/hh:MM')
+				}
+			}
+		},
+		methods: {
+			listGroups() {
+				var me = this;
+				return WebIM.conn.getGroup({
+					limit: 50,
+					success: function(res) {
+						uni.setStorage({
+							key: "listGroup",
+							data: res.data,
+						});
+						me.readJoinedGroupName()
+						me.getLocalConversationlist();
+					},
+					error: function(err) {
+						console.log(err);
+					},
+				});
+			},
+			getRoster() {
+				let me = this;
+				let rosters = {
+					success(roster) {
+						console.log('roster', roster)
+						var member = [];
+						for (let i = 0; i < roster.length; i++) {
+							if (roster[i].subscription == "both") {
+								member.push(roster[i]);
+							}
+						}
+						uni.setStorage({
+							key: "member",
+							data: member,
+						});
+						me.setData({
+							member: member
+						});
+						//if(!systemReady){
+						disp.fire("em.main.ready");
+						//systemReady = true;
+						//}
+						me.getLocalConversationlist()
+						me.setData({
+							unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
+								"99+" : getApp().globalData.unReadMessageNum,
+						});
+					},
+					error(err) {
+						console.log(err);
+					},
+				};
+				WebIM.conn.getContacts(rosters);
+			},
+			readJoinedGroupName() {
+				const joinedGroupList = uni.getStorageSync('listGroup')
+				const groupList = joinedGroupList?.data || joinedGroupList || []
+				let groupName = {};
+				groupList.forEach((item) => {
+					groupName[item.groupid] = item.groupname;
+				});
+				this.setData({
+					groupName: groupName,
+				});
+			},
+
+			// 包含陌生人版本
+			getLocalConversationlist() {
+				const myName = uni.getStorageSync("myUsername");
+				const me = this;
+				uni.getStorageInfo({
+					success: function(res) {
+						let storageKeys = res.keys;
+						let newChatMsgKeys = [];
+						let historyChatMsgKeys = [];
+						let len = myName.length;
+						storageKeys.forEach((item) => {
+							if (item.slice(-len) == myName && item.indexOf("rendered_") == -1) {
+								newChatMsgKeys.push(item);
+							} else if (
+								item.slice(-len) == myName &&
+								item.indexOf("rendered_") > -1
+							) {
+								historyChatMsgKeys.push(item);
+							} else if (item === "INFORM") {
+								newChatMsgKeys.push(item);
+							}
+						});
+						me.packageConversation(newChatMsgKeys, historyChatMsgKeys);
+					},
+				});
+			},
+			//组件会话列表方法
+			packageConversation(newChatMsgKeys, historyChatMsgKeys) {
+				const me = this;
+				const myName = uni.getStorageSync("myUsername");
+				let conversationList = [];
+				let lastChatMsg; //最后一条消息
+				for (let i = historyChatMsgKeys.length; i > 0, i--;) {
+					let index = newChatMsgKeys.indexOf(historyChatMsgKeys[i].slice(9));
+					if (index > -1) {
+						let newChatMsgs = uni.getStorageSync(newChatMsgKeys[index]) || [];
+						if (newChatMsgs.length) {
+							lastChatMsg = newChatMsgs[newChatMsgs.length - 1];
+							lastChatMsg.unReadCount = newChatMsgs.length;
+							newChatMsgKeys.splice(index, 1);
+						} else {
+							let historyChatMsgs = uni.getStorageSync(historyChatMsgKeys[i]);
+							if (historyChatMsgs.length) {
+								lastChatMsg = historyChatMsgs[historyChatMsgs.length - 1];
+							}
 						}
+					} else {
+						let historyChatMsgs = uni.getStorageSync(historyChatMsgKeys[i]);
+						if (historyChatMsgs.length) {
+							lastChatMsg = historyChatMsgs[historyChatMsgs.length - 1];
+						}
+					}
+					if (
+						lastChatMsg &&
+						(lastChatMsg.chatType == "groupchat" ||
+							lastChatMsg.chatType == "chatRoom")
+					) {
+						lastChatMsg.groupName = me.groupName[lastChatMsg.info.to];
+					}
+					lastChatMsg && lastChatMsg.username != myName &&
+						conversationList.push(lastChatMsg);
+				}
+				for (let i = newChatMsgKeys.length; i > 0, i--;) {
+					let newChatMsgs = uni.getStorageSync(newChatMsgKeys[i]) || [];
+					if (newChatMsgs.length) {
+						lastChatMsg = newChatMsgs[newChatMsgs.length - 1];
+						lastChatMsg.unReadCount = newChatMsgs.length;
+						if (
+							lastChatMsg.chatType == "groupchat" ||
+							lastChatMsg.chatType == "chatRoom"
+						) {
+							lastChatMsg.groupName = me.groupName[lastChatMsg.info.to];
+						}
+						lastChatMsg.username != myName && conversationList.push(lastChatMsg);
 					}
-				],
-				show_clear: false,
-				member: "",
-				isIPX: false,
-				gotop: false,
-				input_code: "",
-				groupName: {},
-				winSize: {},
-				popButton: ["删除该聊天"],
-				showPop: false,
-				popStyle: "",
-				currentVal: '',
-				pushConfigData: [],
-				defaultAvatar: "../static/theme2x.png",
-				defaultGroupAvatar: "../static/groupTheme.png"
-			};
-		},
-
-		components: {
-			swipeDelete,
-			longPressModal,
-		},
-		props: {},
-
-		onLoad() {
-			this.getWindowSize();
-			//监听加好友申请
-			disp.on("em.subscribe", this.onChatPageSubscribe);
-			//监听解散群
-			disp.on("em.invite.deleteGroup", this.onChatPageDeleteGroup);
-			//监听未读消息数
-			disp.on("em.unreadspot", this.onChatPageUnreadspot);
-			//监听未读加群“通知”
-			disp.on("em.invite.joingroup", this.onChatPageJoingroup);
-			//监听好友删除
-			disp.on("em.contacts.remove", this.onChatPageRemoveContacts);
-			//监听好友关系解除
-			disp.on("em.unsubscribed", this.onChatPageUnsubscribed)
-			if (!uni.getStorageSync('listGroup')) {
-				this.listGroups()
-			}
-			if (!uni.getStorageSync('member')) {
-				this.getRoster()
-			}
-			this.readJoinedGroupName()
-		},
-
-		onShow: function() {
-			uni.hideHomeButton && uni.hideHomeButton();
-			setTimeout(() => {
-				this.getLocalConversationlist();
-			}, 100)
-			this.setData({
-				unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
-					"99+" : getApp().globalData.unReadMessageNum,
-				messageNum: getApp().globalData.saveFriendList.length,
-				unReadNoticeNum: getApp().globalData.saveGroupInvitedList.length,
-				unReadTotalNotNum: getApp().globalData.saveFriendList.length +
-					getApp().globalData.saveGroupInvitedList.length,
-			});
-
-			if (getApp().globalData.isIPX) {
-				this.setData({
-					isIPX: true,
-				});
-			}
-		},
-		onUnload() {
-			//页面卸载同步取消onload中的订阅,防止重复订阅事件。
-			disp.off('em.subscribe', this.onChatPageSubscribe)
-			disp.off("em.invite.deleteGroup", this.onChatPageDeleteGroup)
-			disp.off("em.unreadspot", this.onChatPageUnreadspot)
-			disp.off("em.invite.joingroup", this.onChatPageJoingroup)
-			disp.off("em.contacts.remove", this.onChatPageRemoveContacts)
-			disp.off("em.unsubscribed", this.onChatPageUnsubscribed)
-		},
-		computed: {
-			//会话头像展示
-			showConversationAvatar() {
-				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
-				return (item) => {
-					if (item.chatType === 'singleChat' || item.chatType === 'chat') {
-
-						// if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.avatarurl) {
-						// 	return friendUserInfoMap.get(item.username).avatarurl
-						// } else {
-						// 	return this.defaultAvatar
-						// }
-						const imUserInfo = uni.getStorageSync("imUserInfo_" + item.username);
-						if (imUserInfo && imUserInfo.avatar) {
-							return imUserInfo.avatar;
-						} else {
-							return this.defaultAvatar;
-						}
-						
-					} else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
-						return this.defaultGroupAvatar
-					}
-				}
-			},
-			//会话name展示
-			showConversationName() {
-				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
-				return (item) => {
-					if (item.chatType === 'singleChat' || item.chatType === 'chat') {
-						// if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.nickname) {
-						// 	return friendUserInfoMap.get(item.username).nickname
-						// } else {
-						// 	return item.username
-						// }
-						const imUserInfo = uni.getStorageSync("imUserInfo_" + item.username);
-						if (imUserInfo && imUserInfo.nickName) {
-							return imUserInfo.nickName;
-						} else {
-							return item.username;
-						}
-					} else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
-						return item.groupName
-					}
-				}
-			},
-			//处理时间显示
-			handleTime() {
-				return (item) => {
-					return timeFormats.timeFormat(item.time, 'mm/dd/hh:MM')
-				}
-			}
-		},
-		methods: {
-			listGroups() {
-				var me = this;
-				return WebIM.conn.getGroup({
-					limit: 50,
-					success: function(res) {
-						uni.setStorage({
-							key: "listGroup",
-							data: res.data,
-						});
-						me.readJoinedGroupName()
-						me.getLocalConversationlist();
-					},
-					error: function(err) {
-						console.log(err);
-					},
-				});
-			},
-			getRoster() {
-				let me = this;
-				let rosters = {
-					success(roster) {
-						console.log('roster', roster)
-						var member = [];
-						for (let i = 0; i < roster.length; i++) {
-							if (roster[i].subscription == "both") {
-								member.push(roster[i]);
-							}
-						}
-						uni.setStorage({
-							key: "member",
-							data: member,
-						});
-						me.setData({
-							member: member
-						});
-						//if(!systemReady){
-						disp.fire("em.main.ready");
-						//systemReady = true;
-						//}
-						me.getLocalConversationlist()
-						me.setData({
-							unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
-								"99+" : getApp().globalData.unReadMessageNum,
-						});
-					},
-					error(err) {
-						console.log(err);
-					},
-				};
-				WebIM.conn.getContacts(rosters);
-			},
-			readJoinedGroupName() {
-				const joinedGroupList = uni.getStorageSync('listGroup')
-				const groupList = joinedGroupList?.data || joinedGroupList || []
-				let groupName = {};
-				groupList.forEach((item) => {
-					groupName[item.groupid] = item.groupname;
-				});
-				this.setData({
-					groupName: groupName,
-				});
-			},
-
-			// 包含陌生人版本
-			getLocalConversationlist() {
-				const myName = uni.getStorageSync("myUsername");
-				const me = this;
-				uni.getStorageInfo({
-					success: function(res) {
-						let storageKeys = res.keys;
-						let newChatMsgKeys = [];
-						let historyChatMsgKeys = [];
-						let len = myName.length;
-						storageKeys.forEach((item) => {
-							if (item.slice(-len) == myName && item.indexOf("rendered_") == -1) {
-								newChatMsgKeys.push(item);
-							} else if (
-								item.slice(-len) == myName &&
-								item.indexOf("rendered_") > -1
-							) {
-								historyChatMsgKeys.push(item);
-							} else if (item === "INFORM") {
-								newChatMsgKeys.push(item);
-							}
-						});
-						me.packageConversation(newChatMsgKeys, historyChatMsgKeys);
-					},
-				});
-			},
-			//组件会话列表方法
-			packageConversation(newChatMsgKeys, historyChatMsgKeys) {
-				const me = this;
-				const myName = uni.getStorageSync("myUsername");
-				let conversationList = [];
-				let lastChatMsg; //最后一条消息
-				for (let i = historyChatMsgKeys.length; i > 0, i--;) {
-					let index = newChatMsgKeys.indexOf(historyChatMsgKeys[i].slice(9));
-					if (index > -1) {
-						let newChatMsgs = uni.getStorageSync(newChatMsgKeys[index]) || [];
-						if (newChatMsgs.length) {
-							lastChatMsg = newChatMsgs[newChatMsgs.length - 1];
-							lastChatMsg.unReadCount = newChatMsgs.length;
-							newChatMsgKeys.splice(index, 1);
-						} else {
-							let historyChatMsgs = uni.getStorageSync(historyChatMsgKeys[i]);
-							if (historyChatMsgs.length) {
-								lastChatMsg = historyChatMsgs[historyChatMsgs.length - 1];
-							}
-						}
-					} else {
-						let historyChatMsgs = uni.getStorageSync(historyChatMsgKeys[i]);
-						if (historyChatMsgs.length) {
-							lastChatMsg = historyChatMsgs[historyChatMsgs.length - 1];
-						}
-					}
-					if (
-						lastChatMsg &&
-						(lastChatMsg.chatType == "groupchat" ||
-							lastChatMsg.chatType == "chatRoom")
-					) {
-						lastChatMsg.groupName = me.groupName[lastChatMsg.info.to];
-					}
-					lastChatMsg && lastChatMsg.username != myName &&
-						conversationList.push(lastChatMsg);
-				}
-				for (let i = newChatMsgKeys.length; i > 0, i--;) {
-					let newChatMsgs = uni.getStorageSync(newChatMsgKeys[i]) || [];
-					if (newChatMsgs.length) {
-						lastChatMsg = newChatMsgs[newChatMsgs.length - 1];
-						lastChatMsg.unReadCount = newChatMsgs.length;
-						if (
-							lastChatMsg.chatType == "groupchat" ||
-							lastChatMsg.chatType == "chatRoom"
-						) {
-							lastChatMsg.groupName = me.groupName[lastChatMsg.info.to];
-						}
-						lastChatMsg.username != myName && conversationList.push(lastChatMsg);
-					}
-				}
-				conversationList.sort((a, b) => {
-					return b.time - a.time;
-				});
-				this.setData({
-					conversationList: conversationList,
-				});
-				console.log('消息》》》》', this.conversationList);
-			},
-			openSearch: function() {
-				this.setData({
-					search_btn: false,
-					search_chats: true,
-					gotop: true,
-				});
-
-				// this.into_singleChatRoom();
-
-
-			},
-
-			onSearch: function(val) {
-				let searchValue = val.detail.value;
-				var myName = uni.getStorageSync("myUsername");
-				const me = this;
-				let serchList = [];
-				let conversationList = [];
-				uni.getStorageInfo({
-					success: function(res) {
-						let storageKeys = res.keys;
-						let chatKeys = [];
-						let len = myName.length;
-						storageKeys.forEach((item) => {
-							if (item.slice(-len) == myName) {
-								chatKeys.push(item);
-							}
-						});
-						chatKeys.forEach((item, index) => {
-							if (item.indexOf(searchValue) != -1) {
-								serchList.push(item);
-							}
-						});
-						let lastChatMsg = "";
-						serchList.forEach((item, index) => {
-							let chatMsgs = uni.getStorageSync(item) || [];
-							if (chatMsgs.length) {
-								lastChatMsg = chatMsgs[chatMsgs.length - 1];
-								conversationList.push(lastChatMsg);
-							}
-						});
-						me.setData({
-							conversationList: conversationList
-						});
-					},
-				});
-			},
-
-			cancel: function() {
-				this.getLocalConversationlist();
-				this.setData({
-					search_btn: true,
-					search_chats: false,
-					unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
-						"99+" : getApp().globalData.unReadMessageNum,
-					gotop: false,
-				});
-			},
-			clearInput: function() {
-				this.setData({
-					input_code: "",
-					show_clear: false,
-				});
-			},
-			onInput: function(e) {
-				let inputValue = e.detail.value;
-				if (inputValue) {
-					this.setData({
-						show_clear: true,
-					});
-				} else {
-					this.setData({
-						show_clear: false,
-					});
-				}
-			},
-
-			close_mask: function() {
-				this.setData({
-					search_btn: true,
-					search_chats: false,
-					show_mask: false,
-				});
-			},
-
-			into_chatRoom: function(event) {
-				let detail = JSON.parse(event.currentTarget.dataset.item);
-				if (
-					detail.chatType == "groupchat" ||
-					detail.chatType == "chatRoom" ||
-					detail.groupName
-				) {
-					this.into_groupChatRoom(detail);
-				} else {
-					this.into_singleChatRoom(detail);
-				}
-			},
-			// 单聊
-			into_singleChatRoom: function(detail) {
-				var my = uni.getStorageSync("myUsername");
-				var nameList = {
-					myName: my,
-					your: detail.username,
-					// your: 'rs_316923182331'
-				};
-				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
-				if (friendUserInfoMap.has(nameList.your) && friendUserInfoMap.get(nameList.your)?.nickname) {
-					nameList.yourNickName = friendUserInfoMap.get(nameList.your).nickname;
-				}
-
-				console.log('JSON.stringify(nameList)》》》》', JSON.stringify(nameList));
-				uni.navigateTo({
-					url: "../chatroom/chatroom?username=" + JSON.stringify(nameList),
-				});
-			},
-			// 群聊 和 聊天室 (两个概念)
-			into_groupChatRoom: function(detail) {
-				var my = uni.getStorageSync("myUsername");
-				var nameList = {
-					myName: my,
-					your: detail.groupName,
-					groupId: detail.info.to,
-				};
-				uni.navigateTo({
-					url: "../groupChatRoom/groupChatRoom?username=" + JSON.stringify(nameList),
-				});
-			},
-
-			// into_inform: function() {
-			// 	uni.redirectTo({
-			// 		url: "../notification/notification",
-			// 	});
-			// },
-
-			removeAndRefresh: function(event) {
-				let removeId = event.currentTarget.dataset.item.info.from
-				let ary = getApp().globalData.saveFriendList
-				let idx
-				if (ary.length > 0) {
-					ary.forEach((v, k) => {
-						if (v.from == removeId) {
-							idx = k
-						}
-					})
-					getApp().globalData.saveFriendList.splice(idx, 1);
-				}
-				uni.removeStorageSync('INFORM')
-			},
-
-			del_chat: function(event) {
-				let detail = event.currentTarget.dataset.item;
-				let nameList = {};
-				let me = this;
-				// 删除当前选中群组聊天列表
-				if (detail.chatType == "groupchat" || detail.chatType == "chatRoom") {
-					nameList = {
-						your: detail.info.to,
-					};
-					//删除当前选中通知列表
-				} else if (detail.chatType === "INFORM") {
-					nameList = {
-						your: "INFORM",
-					};
-				}
-				//删除当前选中好友聊天列表
-				else {
-					nameList = {
-						your: detail.username,
-					};
-				}
-				var myName = uni.getStorageSync("myUsername");
-				var currentPage = getCurrentPages();
-
-				uni.showModal({
-					title: "确认删除?",
-					confirmText: "删除",
-					success: function(res) {
-						if (res.confirm) {
-							uni.removeStorageSync(nameList.your + myName);
-							uni.removeStorageSync("rendered_" + nameList.your + myName);
-							nameList.your === 'INFORM' && me.removeAndRefresh(event);
-							// if (Object.keys(currentPage[0]).length>0) {
-							//   currentPage[0].onShow();
-							// }
-							disp.fire("em.chat.session.remove");
-							me.getLocalConversationlist();
-						}
-					},
-					fail: function(err) {
-						console.log('删除列表', err);
-					},
-				});
-			},
-			removeLocalStorage: function(yourname) {
-				var myName = uni.getStorageSync("myUsername");
-				uni.removeStorageSync(yourname + myName);
-				uni.removeStorageSync("rendered_" + yourname + myName);
-			},
-			longpress: function(e) {
-				//将当前选中的值存在data中方便后续操作
-				this.currentVal = e
-				let [touches, style, index] = [e.touches[0], "", e.currentTarget.dataset.index, ];
-
-				/* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */
-				if (touches.clientY > this.winSize.height / 2) {
-					style = `bottom:${this.winSize.height - touches.clientY}px;`;
-				} else {
-					style = `top:${touches.clientY}px;`;
-				}
-				if (touches.clientX > this.winSize.witdh / 2) {
-					style += `right:${this.winSize.witdh - touches.clientX}px`;
-				} else {
-					style += `left:${touches.clientX}px`;
-				}
-
-				this.popStyle = style;
-				// this.pickerUserIndex = Number(index);
-				this.showShade = true;
-				this.$nextTick(() => {
-					setTimeout(() => {
-						this.showPop = true;
-					}, 10);
-				});
-			},
-			/* 获取窗口尺寸 */
-			getWindowSize() {
-				uni.getSystemInfo({
-					success: (res) => {
-						this.winSize = {
-							witdh: res.windowWidth,
-							height: res.windowHeight,
-						};
-					},
-				});
-			},
-			hidePop() {
-				this.showPop = false;
-			},
-			pickerMenuChange() {
-				this.del_chat(this.currentVal)
-			},
-			/*  disp event callback function */
-			onChatPageSubscribe() {
-				this.getLocalConversationlist();
-				this.setData({
-					messageNum: getApp().globalData.saveFriendList.length,
-					unReadTotalNotNum: getApp().globalData.saveFriendList.length +
-						getApp().globalData.saveGroupInvitedList.length,
-				});
-			},
-			onChatPageDeleteGroup(infos) {
-				this.listGroups();
-				this.getRoster();
-				this.getLocalConversationlist();
-				this.setData({
-					messageNum: getApp().globalData.saveFriendList.length,
-				});
-				//如果会话存在则执行删除会话
-				this.removeLocalStorage(infos.gid)
-			},
-			onChatPageUnreadspot(message) {
-				this.getLocalConversationlist();
-				let currentLoginUser = WebIM.conn.context.userId;
-				let id = message && message.chatType === 'groupchat' ? message?.to : message?.from;
-				let pushObj = uni.getStorageSync("pushStorageData");
-				let pushAry = pushObj[currentLoginUser] || []
-				this.setData({
-					pushConfigData: pushAry,
-				});
-				// if (message && pushValue.includes(id)) return
-				this.setData({
-					unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
-						"99+" : getApp().globalData.unReadMessageNum,
-				});
-			},
-			onChatPageJoingroup() {
-				this.setData({
-					unReadNoticeNum: getApp().globalData.saveGroupInvitedList.length,
-					unReadTotalNotNum: getApp().globalData.saveFriendList.length +
-						getApp().globalData.saveGroupInvitedList.length,
-				});
-				this.getLocalConversationlist();
-			},
-			onChatPageRemoveContacts() {
-				this.getLocalConversationlist();
-				this.getRoster();
-			},
-			onChatPageUnsubscribed(message) {
-				uni.showToast({
-					title: `与${message.from}好友关系解除`,
-					icon: "none",
-				});
-			}
-		},
-	};
-</script>
-<style>
-	@import "./chat.css";
+				}
+				conversationList.sort((a, b) => {
+					return b.time - a.time;
+				});
+				this.setData({
+					conversationList: conversationList,
+				});
+				console.log('消息》》》》', this.conversationList);
+			},
+			openSearch: function() {
+				this.setData({
+					search_btn: false,
+					search_chats: true,
+					gotop: true,
+				});
+
+				// this.into_singleChatRoom();
+
+
+			},
+
+			onSearch: function(val) {
+				let searchValue = val.detail.value;
+				var myName = uni.getStorageSync("myUsername");
+				const me = this;
+				let serchList = [];
+				let conversationList = [];
+				uni.getStorageInfo({
+					success: function(res) {
+						let storageKeys = res.keys;
+						let chatKeys = [];
+						let len = myName.length;
+						storageKeys.forEach((item) => {
+							if (item.slice(-len) == myName) {
+								chatKeys.push(item);
+							}
+						});
+						chatKeys.forEach((item, index) => {
+							if (item.indexOf(searchValue) != -1) {
+								serchList.push(item);
+							}
+						});
+						let lastChatMsg = "";
+						serchList.forEach((item, index) => {
+							let chatMsgs = uni.getStorageSync(item) || [];
+							if (chatMsgs.length) {
+								lastChatMsg = chatMsgs[chatMsgs.length - 1];
+								conversationList.push(lastChatMsg);
+							}
+						});
+						me.setData({
+							conversationList: conversationList
+						});
+					},
+				});
+			},
+
+			cancel: function() {
+				this.getLocalConversationlist();
+				this.setData({
+					search_btn: true,
+					search_chats: false,
+					unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
+						"99+" : getApp().globalData.unReadMessageNum,
+					gotop: false,
+				});
+			},
+			clearInput: function() {
+				this.setData({
+					input_code: "",
+					show_clear: false,
+				});
+			},
+			onInput: function(e) {
+				let inputValue = e.detail.value;
+				if (inputValue) {
+					this.setData({
+						show_clear: true,
+					});
+				} else {
+					this.setData({
+						show_clear: false,
+					});
+				}
+			},
+
+			close_mask: function() {
+				this.setData({
+					search_btn: true,
+					search_chats: false,
+					show_mask: false,
+				});
+			},
+
+			into_chatRoom: function(event) {
+				let detail = JSON.parse(event.currentTarget.dataset.item);
+				if (
+					detail.chatType == "groupchat" ||
+					detail.chatType == "chatRoom" ||
+					detail.groupName
+				) {
+					this.into_groupChatRoom(detail);
+				} else {
+					this.into_singleChatRoom(detail);
+				}
+			},
+			// 单聊
+			into_singleChatRoom: function(detail) {
+				var my = uni.getStorageSync("myUsername");
+				var nameList = {
+					myName: my,
+					your: detail.username,
+					// your: 'rs_316923182331'
+				};
+				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				if (friendUserInfoMap.has(nameList.your) && friendUserInfoMap.get(nameList.your)?.nickname) {
+					nameList.yourNickName = friendUserInfoMap.get(nameList.your).nickname;
+				}
+
+				console.log('JSON.stringify(nameList)》》》》', JSON.stringify(nameList));
+				uni.navigateTo({
+					url: "../chatroom/chatroom?username=" + JSON.stringify(nameList),
+				});
+			},
+			// 群聊 和 聊天室 (两个概念)
+			into_groupChatRoom: function(detail) {
+				var my = uni.getStorageSync("myUsername");
+				var nameList = {
+					myName: my,
+					your: detail.groupName,
+					groupId: detail.info.to,
+				};
+				uni.navigateTo({
+					url: "../groupChatRoom/groupChatRoom?username=" + JSON.stringify(nameList),
+				});
+			},
+
+			// into_inform: function() {
+			// 	uni.redirectTo({
+			// 		url: "../notification/notification",
+			// 	});
+			// },
+
+			removeAndRefresh: function(event) {
+				let removeId = event.currentTarget.dataset.item.info.from
+				let ary = getApp().globalData.saveFriendList
+				let idx
+				if (ary.length > 0) {
+					ary.forEach((v, k) => {
+						if (v.from == removeId) {
+							idx = k
+						}
+					})
+					getApp().globalData.saveFriendList.splice(idx, 1);
+				}
+				uni.removeStorageSync('INFORM')
+			},
+
+			del_chat: function(event) {
+				let detail = event.currentTarget.dataset.item;
+				let nameList = {};
+				let me = this;
+				// 删除当前选中群组聊天列表
+				if (detail.chatType == "groupchat" || detail.chatType == "chatRoom") {
+					nameList = {
+						your: detail.info.to,
+					};
+					//删除当前选中通知列表
+				} else if (detail.chatType === "INFORM") {
+					nameList = {
+						your: "INFORM",
+					};
+				}
+				//删除当前选中好友聊天列表
+				else {
+					nameList = {
+						your: detail.username,
+					};
+				}
+				var myName = uni.getStorageSync("myUsername");
+				var currentPage = getCurrentPages();
+
+				uni.showModal({
+					title: "确认删除?",
+					confirmText: "删除",
+					success: function(res) {
+						if (res.confirm) {
+							uni.removeStorageSync(nameList.your + myName);
+							uni.removeStorageSync("rendered_" + nameList.your + myName);
+							nameList.your === 'INFORM' && me.removeAndRefresh(event);
+							// if (Object.keys(currentPage[0]).length>0) {
+							//   currentPage[0].onShow();
+							// }
+							disp.fire("em.chat.session.remove");
+							me.getLocalConversationlist();
+						}
+					},
+					fail: function(err) {
+						console.log('删除列表', err);
+					},
+				});
+			},
+			removeLocalStorage: function(yourname) {
+				var myName = uni.getStorageSync("myUsername");
+				uni.removeStorageSync(yourname + myName);
+				uni.removeStorageSync("rendered_" + yourname + myName);
+			},
+			longpress: function(e) {
+				//将当前选中的值存在data中方便后续操作
+				this.currentVal = e
+				let [touches, style, index] = [e.touches[0], "", e.currentTarget.dataset.index, ];
+
+				/* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */
+				if (touches.clientY > this.winSize.height / 2) {
+					style = `bottom:${this.winSize.height - touches.clientY}px;`;
+				} else {
+					style = `top:${touches.clientY}px;`;
+				}
+				if (touches.clientX > this.winSize.witdh / 2) {
+					style += `right:${this.winSize.witdh - touches.clientX}px`;
+				} else {
+					style += `left:${touches.clientX}px`;
+				}
+
+				this.popStyle = style;
+				// this.pickerUserIndex = Number(index);
+				this.showShade = true;
+				this.$nextTick(() => {
+					setTimeout(() => {
+						this.showPop = true;
+					}, 10);
+				});
+			},
+			/* 获取窗口尺寸 */
+			getWindowSize() {
+				uni.getSystemInfo({
+					success: (res) => {
+						this.winSize = {
+							witdh: res.windowWidth,
+							height: res.windowHeight,
+						};
+					},
+				});
+			},
+			hidePop() {
+				this.showPop = false;
+			},
+			pickerMenuChange() {
+				this.del_chat(this.currentVal)
+			},
+			/*  disp event callback function */
+			onChatPageSubscribe() {
+				this.getLocalConversationlist();
+				this.setData({
+					messageNum: getApp().globalData.saveFriendList.length,
+					unReadTotalNotNum: getApp().globalData.saveFriendList.length +
+						getApp().globalData.saveGroupInvitedList.length,
+				});
+			},
+			onChatPageDeleteGroup(infos) {
+				this.listGroups();
+				this.getRoster();
+				this.getLocalConversationlist();
+				this.setData({
+					messageNum: getApp().globalData.saveFriendList.length,
+				});
+				//如果会话存在则执行删除会话
+				this.removeLocalStorage(infos.gid)
+			},
+			onChatPageUnreadspot(message) {
+				this.getLocalConversationlist();
+				let currentLoginUser = WebIM.conn.context.userId;
+				let id = message && message.chatType === 'groupchat' ? message?.to : message?.from;
+				let pushObj = uni.getStorageSync("pushStorageData");
+				let pushAry = pushObj[currentLoginUser] || []
+				this.setData({
+					pushConfigData: pushAry,
+				});
+				// if (message && pushValue.includes(id)) return
+				this.setData({
+					unReadSpotNum: getApp().globalData.unReadMessageNum > 99 ?
+						"99+" : getApp().globalData.unReadMessageNum,
+				});
+			},
+			onChatPageJoingroup() {
+				this.setData({
+					unReadNoticeNum: getApp().globalData.saveGroupInvitedList.length,
+					unReadTotalNotNum: getApp().globalData.saveFriendList.length +
+						getApp().globalData.saveGroupInvitedList.length,
+				});
+				this.getLocalConversationlist();
+			},
+			onChatPageRemoveContacts() {
+				this.getLocalConversationlist();
+				this.getRoster();
+			},
+			onChatPageUnsubscribed(message) {
+				uni.showToast({
+					title: `与${message.from}好友关系解除`,
+					icon: "none",
+				});
+			}
+		},
+	};
+</script>
+<style>
+	@import "./chat.css";
 </style>

+ 18 - 7
components/msg-number/index.vue

@@ -3,7 +3,7 @@
 		<view class="lt-msg ddflex" @click="jumpConversation()">
 			<view class="ddflex" style="position: relative;width: 100%;height: 100%;">
 				<image src="../../static/pages/images/lt.png"></image>
-				<view class="lt-msg-num" v-if="getMsgNumber()>0">{{getMsgNumber()}}</view>
+				<view class="lt-msg-num" v-if="unReadSpotNum>0">{{unReadSpotNum}}</view>
 			</view>
 		</view>
 	</view>
@@ -12,30 +12,41 @@
 <script>
 	const app = getApp();
 	const req = require("../../utils/request.js");
+	let disp = require("../../hxChatSDK/utils/broadcast");
 
 	export default {
 		data() {
 			return {
 				picUrlss: req.public.picUrls,
+				unReadSpotNum: 0
 			};
 		},
 
 		components: {},
-		props: {
-		},
+		props: {},
 		watch: {},
 
 		mounted() {
-			
+			//发起获取未读消息通知
+			disp.fire("em.main.ready");
+			//监听未读消息数
+			disp.on("em.unreadspot", this.onChatPageUnreadspot);
+		},
+
+		onUnload() {
+			disp.off("em.unreadspot", this.onChatPageUnreadspot)
 		},
 
 		methods: {
+			onChatPageUnreadspot(message) {
+				this.unReadSpotNum = getApp().globalData.unReadMessageNum > 99 ?
+					"99+" : getApp().globalData.unReadMessageNum;
+			},
+
 			jumpConversation() {
 				req.jumpConversation();
 			},
-			getMsgNumber(){
-				return getApp().globalData.unReadMessageNum;
-			},
+
 		}
 	};
 </script>

+ 21 - 12
components/service-contact/index.vue

@@ -2,13 +2,14 @@
 	<view v-if="recommendCard">
 		<view style="height: 136rpx;"></view>
 		<view class="sc-box ddflex">
-			<image class="sc-header" :src="recommendCard.avatar?recommendCard.avatar:'../../static/images/userimg.png'"></image>
+			<image class="sc-header" :src="recommendCard.avatar?recommendCard.avatar:'../../static/images/userimg.png'">
+			</image>
 			<view class="sc-name">
 				<view>{{recommendCard.realName}}</view>
 				<view class="sc-tag">{{recommendCard.jobName}}</view>
 			</view>
 			<view class="sc-line"></view>
-			<view class="sc-contact" @click="jumpConversation">
+			<view class="sc-contact" @click="jumpSingleChatRoom()">
 				<image src="/static/images/wxChat.png"></image>
 				<view>聊一聊</view>
 			</view>
@@ -24,13 +25,12 @@
 	export default {
 		data() {
 			return {
-				recommendCard:{}
+				recommendCard: {}
 			};
 		},
 
 		components: {},
-		props: {
-		},
+		props: {},
 		watch: {},
 
 		mounted() {
@@ -39,17 +39,26 @@
 
 		methods: {
 			// 获取推荐销售
-			getRecommendCard(){
-				req.getRequest('/api/visiting/card/recommendCardInfo',{},res=>{
+			getRecommendCard() {
+				req.getRequest('/api/visiting/card/recommendCardInfo', {}, res => {
 					this.recommendCard = res
 				})
 			},
-			jumpConversation() {
-				req.jumpConversation();
+
+
+			jumpSingleChatRoom() {
+				if (this.recommendCard) {
+					req.jumpSingleChatRoom(this.recommendCard.userId, this.recommendCard.avatar, this.recommendCard
+						.realName);
+				}
+
 			},
-			toIndex(){
+			// jumpConversation() {
+			// 	req.jumpConversation();
+			// },
+			toIndex() {
 				uni.switchTab({
-					url:'/pages/index/index'
+					url: '/pages/index/index'
 				})
 			}
 		}
@@ -57,4 +66,4 @@
 </script>
 <style>
 	@import "./index.css";
-</style>
+</style>

+ 685 - 636
pages/index/index.vue

@@ -18,7 +18,8 @@
 		</view>
 		<view class="service-person" :style="'top:' + systems.ktxStatusHeight + 'rpx;'" v-if="recommendCard">
 			<view class="ddflex" @click="jumpUrl('/card/index/index?cardId='+recommendCard.id)">
-				<image class="service-person-header" :src="recommendCard.avatar?recommendCard.avatar:'../../static/pages/images/userimg.png'"></image>
+				<image class="service-person-header"
+					:src="recommendCard.avatar?recommendCard.avatar:'../../static/pages/images/userimg.png'"></image>
 				<view>
 					<view class="service-person-name ddflex">
 						<view>{{recommendCard.realName}}的微页</view>
@@ -49,7 +50,8 @@
 					</view>
 				</view>
 				<view class="ddflex">
-					<view class="service-person-phone" v-if="recommendCard.phone" @click="callPhone(recommendCard.phone)">
+					<view class="service-person-phone" v-if="recommendCard.phone"
+						@click="callPhone(recommendCard.phone)">
 						<image src="../../static/pages/images/dh.png"></image>
 						<view>电话</view>
 					</view>
@@ -64,12 +66,15 @@
 		<view v-for="(item, index) in contact" :key="index">
 			<!-- 弹窗广告 -->
 			<view style="position: absolute;top:290rpx;left: 0;right: 0;">
-				<banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url" :config="about" :couponList="couponList" :officeList="officeList" :districtTemplate="districtTemplate"></banner>
+				<banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url"
+					:config="about" :couponList="couponList" :officeList="officeList"
+					:districtTemplate="districtTemplate"></banner>
 			</view>
-			<district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url" :districtTemplate="districtTemplate"></district>
-			
+			<district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url"
+				:districtTemplate="districtTemplate"></district>
+
 		</view>
-		
+
 		<view class="index-box" style="margin-top: 10rpx;" v-if="hotActivityList.length>0">
 			<view class="index-box-title">热门活动</view>
 			<view class="ddflex" style="margin-top: 20rpx;">
@@ -80,13 +85,14 @@
 				<image class="pic480" :src="hotActivityList[2].pic"></image>
 			</view>
 		</view>
-		
+
 		<!-- 参与活动 -->
 		<view class="index-box" style="margin-top: 50rpx;" v-if="matchList.length>0">
 			<view class="index-box-title">更多活动</view>
 			<view class="map-ac">
-				<scroll-view scroll-x="true" class="map-acs" >
-					<view class="li" v-for="(item,index) in matchList" :key="index" @click="jumpUrl('/match/activityDetail/activityDetail?id='+item.id)">
+				<scroll-view scroll-x="true" class="map-acs">
+					<view class="li" v-for="(item,index) in matchList" :key="index"
+						@click="jumpUrl('/match/activityDetail/activityDetail?id='+item.id)">
 						<view style="position: relative;border-radius: 20rpx;overflow: hidden;">
 							<image :src="item.pic ? item.pic : '/static/images/def_zw1.png'" mode="aspectFill"></image>
 							<view class="ac-type" v-if="item.categoryName">{{ item.categoryName }}</view>
@@ -94,15 +100,16 @@
 						<view class="ac-title tovers">{{ item.title }}</view>
 					</view>
 				</scroll-view>
-			</view> 
+			</view>
 		</view>
-		
+
 		<!-- 投保案例 -->
 		<view class="index-box" style="margin:0;padding: 30rpx;background-color: #f5f5f5;" v-if="tbalList.length>0">
 			<view class="index-box-title">投保案例</view>
 			<view>
 				<view class="tbal-nav ddflex">
-					<view :class="'tbal-nav-item '+(tbalIndex==index?'tbal-nav-item-active':'' )" v-for="item,index in tbalList" @click="changeTbalTab(index)">
+					<view :class="'tbal-nav-item '+(tbalIndex==index?'tbal-nav-item-active':'' )"
+						v-for="item,index in tbalList" @click="changeTbalTab(index)">
 						<view>{{item.name}}</view>
 						<view class="tbal-nav-label">20~30岁</view>
 					</view>
@@ -119,36 +126,43 @@
 						<view class="tbal-nav-label">20~30岁</view>
 					</view> -->
 				</view>
-				
+
 				<block v-if="tbalList[tbalIndex].contentList">
-					<view class="tbal-item ddflex" v-for="it in tbalList[tbalIndex].contentList" @click="jumpUrl('/topic/alContent/alContent?id='+it.id)">
+					<view class="tbal-item ddflex" v-for="it in tbalList[tbalIndex].contentList"
+						@click="jumpUrl('/topic/alContent/alContent?id='+it.id)">
 						<image class="tbal-pic" :src="it.pic?it.pic:'/static/images/lj_img.png'"></image>
 						<view class="flex">
 							<view class="tbal-title">{{it.title}}</view>
 							<view class="ddflex">
 								<view class="ddflex flex">
-									<view class="tbal-price" >{{it.fieldValues&&it.fieldValues.yearMoney?it.fieldValues.yearMoney:'0'}}</view>
+									<view class="tbal-price">
+										{{it.fieldValues&&it.fieldValues.yearMoney?it.fieldValues.yearMoney:'0'}}
+									</view>
 									<view class="tbal-price-text">年缴费</view>
 								</view>
 								<view class="tbal-line"></view>
 								<view class="ddflex flex">
-									<view class="tbal-price" >{{it.fieldValues&&it.fieldValues.allMoney?it.fieldValues.allMoney:'0'}}</view>
+									<view class="tbal-price">
+										{{it.fieldValues&&it.fieldValues.allMoney?it.fieldValues.allMoney:'0'}}
+									</view>
 									<view class="tbal-price-text">总保额 </view>
 								</view>
 							</view>
 							<view class="tbal-btn">去看看</view>
 						</view>
-						<view class="tbal-tag" v-if="it.fieldValues&&it.fieldValues.version">{{it.fieldValues.version}}</view>
+						<view class="tbal-tag" v-if="it.fieldValues&&it.fieldValues.version">{{it.fieldValues.version}}
+						</view>
 					</view>
 				</block>
 			</view>
 		</view>
-		
+
 		<!-- 真实理赔故事 -->
 		<view class="index-box" v-if="lpalList.length>0">
 			<view class="index-box-title ddflex">
 				<text class="fflex">真实理赔故事</text>
-				<view class="fx-header-more ddflex" @click="jumpUrl('/topic/contentList/contentList?code='+lpalCode+'&title=理赔案例')">
+				<view class="fx-header-more ddflex"
+					@click="jumpUrl('/topic/contentList/contentList?code='+lpalCode+'&title=理赔案例')">
 					更多
 					<image src="/static/pages/images/more.png"></image>
 				</view>
@@ -161,7 +175,8 @@
 							<view>{{items.name}}</view>
 						</view>
 						<view class="lpgs-content">
-							<view class="lpgs-item-content ddflex" v-for="item in items.contentList" @click="jumpUrl('/topic/content/content?id='+item.id)">
+							<view class="lpgs-item-content ddflex" v-for="item in items.contentList"
+								@click="jumpUrl('/topic/content/content?id='+item.id)">
 								<view class="flex" style="min-width: 0;">
 									<view class="lpgs-item-content-title tovers">{{item.title}}</view>
 									<view class="lpgs-item-content-look ddflex">
@@ -169,19 +184,21 @@
 										<view>{{unitFormat(item.browse)}}</view>
 									</view>
 								</view>
-								<image class="lpgs-item-content-pic" :src="item.pic?item.pic:'/static/images/lj_img.png'"></image>
+								<image class="lpgs-item-content-pic"
+									:src="item.pic?item.pic:'/static/images/lj_img.png'"></image>
 							</view>
 						</view>
 					</view>
 				</scroll-view>
-			</view> 
+			</view>
 		</view>
-		
+
 		<!-- 发现 -->
 		<view class="index-box" style="margin:0;padding: 30rpx;background-color: #f5f5f5;" v-if="fxList.length>0">
 			<view class="map-ac">
 				<scroll-view scroll-x="true" class="map-acs ddflex" style="height: 70rpx;">
-					<view :class="'fx-nav '+(fxIndex==index?'fx-nav-active':'')" v-for="item,index in fxList" @click="changeFxTab(index)">{{item.name}}</view>
+					<view :class="'fx-nav '+(fxIndex==index?'fx-nav-active':'')" v-for="item,index in fxList"
+						@click="changeFxTab(index)">{{item.name}}</view>
 				</scroll-view>
 			</view>
 			<view class="fx-bar">
@@ -190,13 +207,15 @@
 						<view class="fx-header-title">{{fxList[fxIndex].name}}</view>
 						<view class="fx-header-more">2.2万人转发</view>
 					</view>
-					<view class="fx-header-more ddflex" @click="jumpUrl('/topic/contentList/contentList?code='+fxList[fxIndex].code+'&title='+fxList[fxIndex].name)">
+					<view class="fx-header-more ddflex"
+						@click="jumpUrl('/topic/contentList/contentList?code='+fxList[fxIndex].code+'&title='+fxList[fxIndex].name)">
 						更多
 						<image src="/static/pages/images/more.png"></image>
 					</view>
 				</view>
 				<view>
-					<view class="fx-item ddflex" v-for="item in fxContentList" @click="jumpUrl('/topic/content/content?id='+item.id)">
+					<view class="fx-item ddflex" v-for="item in fxContentList"
+						@click="jumpUrl('/topic/content/content?id='+item.id)">
 						<view class="flex" style="min-width: 0;">
 							<view class="fx-item-title tovers">{{item.title}}</view>
 							<view class="ddflex" style="margin-top: 24rpx;">
@@ -212,7 +231,7 @@
 				</view>
 			</view>
 		</view>
-		
+
 		<!-- <component v-for="(item,index) in contact" ></component> -->
 		<!-- <ad></ad> -->
 		<block v-if="contactShow">
@@ -243,15 +262,19 @@
 		</view>
 		<!-- <footer-copyright v-if="logo"></footer-copyright> -->
 		<!-- <contact-button img-url="/static/pages/images/kfico1_1.png" class-name="contact_index" button-text="客服"></contact-button> -->
-		<view class="guide" @tap="hideGuide" v-if="first"><image src="/static/pages/images/guide.png" mode="widthFix"></image></view>
+		<view class="guide" @tap="hideGuide" v-if="first">
+			<image src="/static/pages/images/guide.png" mode="widthFix"></image>
+		</view>
 		<!-- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 115) + 'rpx'"></view> -->
 		<foot channel="home" :isUpdate="isUpdate"></foot>
-		
-		
-		<view class="ceng2" v-if="isShowCodePop" @click="isShowCodePop = false"  @touchmove.stop.prevent="moveHandle"></view>
+
+
+		<view class="ceng2" v-if="isShowCodePop" @click="isShowCodePop = false" @touchmove.stop.prevent="moveHandle">
+		</view>
 		<view class="code-pop" v-if="isShowCodePop">
 			<view class="code-content" v-if="recommendCard.wechatCode">
-				<image :src="recommendCard.wechatCode?recommendCard.wechatCode:'/static/images/wxCode.jpg'" show-menu-by-longpress="true"></image>
+				<image :src="recommendCard.wechatCode?recommendCard.wechatCode:'/static/images/wxCode.jpg'"
+					show-menu-by-longpress="true"></image>
 				<view style="text-align: center;font-size: 24rpx;color: #999;margin-bottom: 50rpx;">长按识别微信二维码</view>
 			</view>
 			<view class="code-text" v-else>
@@ -263,9 +286,9 @@
 			</view>
 		</view>
 		<msgNumber></msgNumber>
-		
-		<view class="chat-fixed">
-			<view class="chat-box ddflex">
+
+		<view class="chat-fixed" v-if="recommendCard">
+			<view class="chat-box ddflex" @click="jumpSingleChatRoom()">
 				<image :src="recommendCard.avatar?recommendCard.avatar:'../../static/pages/images/userimg.png'"></image>
 				<view class="chat-lyl">聊一聊</view>
 			</view>
@@ -274,662 +297,688 @@
 </template>
 
 <script>
-//index.js
-//获取应用实例
-const app = getApp();
-const req = require('../../utils/request.js');
-const api = require('../../utils/api.js');
-const utils = require('../../utils/util.js');
-const mes = require('../../utils/requestmessage.js');
-const route = require('../../utils/route');
-const QQMapWX = require("../../utils/qqmap.js");
-import foot from '../../components/nav-bar/index';
-import footerCopyright from '../../components/footer-copyright/footer-copyright';
-import banner from '../../template/banner/banner';
-import district from '../../template/king_kong_district/king_kong_district';
-import msgNumber from '../../components/msg-number/index.vue';
-
-export default {
-	data() {
-		return {
-			skinNotColor: req.public.skinNotColor,
-			systems: {},
-			header: req.header,
-			bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
-			bannerList: [],
-			//产品分类列表
-			page: 1,
-			//产品列表
-			merchant: {},
-			activityGroup: {
-				products: []
-			},
-			couponList: {},//优惠券,
-			isUpdate: false,
-			// 是否更新消息
-			first: true,
-			//是否显示提示加入我的小程序
-			isLayerAd: true,
-			//广告
-			homeTemplate: [],
-			//首页栏目配置
-			storeShow: true,
-			templateType: {
-				module_ad: 'ad',
+	//index.js
+	//获取应用实例
+	const app = getApp();
+	const req = require('../../utils/request.js');
+	const api = require('../../utils/api.js');
+	const utils = require('../../utils/util.js');
+	const mes = require('../../utils/requestmessage.js');
+	const route = require('../../utils/route');
+	const QQMapWX = require("../../utils/qqmap.js");
+	import foot from '../../components/nav-bar/index';
+	import footerCopyright from '../../components/footer-copyright/footer-copyright';
+	import banner from '../../template/banner/banner';
+	import district from '../../template/king_kong_district/king_kong_district';
+	import msgNumber from '../../components/msg-number/index.vue';
+
+	export default {
+		data() {
+			return {
+				skinNotColor: req.public.skinNotColor,
+				systems: {},
+				header: req.header,
+				bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
+				bannerList: [],
+				//产品分类列表
+				page: 1,
+				//产品列表
+				merchant: {},
+				activityGroup: {
+					products: []
+				},
+				couponList: {}, //优惠券,
+				isUpdate: false,
+				// 是否更新消息
+				first: true,
+				//是否显示提示加入我的小程序
+				isLayerAd: true,
 				//广告
-				module_type_district: 'type_district',
-				//分类导航
-				module_king_kong_district: 'king_kong_district', //金刚区
-			},
-			isNotice: false,
-			joingroupList: {
-				products: []
-			},
-			//拼团
-			bargainList: {
-				products: []
-			},
-			//砍价
-			customersList: {
-				products: []
-			},
-			//新客
-			freshen: true,
-			url: '',
-			web: '',
-			site: '',
-			districtTemplate: {},
-			contact: [],
-			seckillList: {
-				products: []
-			},
-			about: {},
-			Is_Store_Price_Stock: '',
-			guarantee: [],
-			animationData: '',
-			content: '',
-			popAdList: {},
-			iscouponAd: false,
-			logo: false,
-			top: Boolean,
-			top_type: Boolean,
-			switchStoreShow: Boolean,
-			contactShow: true,
-			districtShow: false,
-			bannerShow: false,
-			officeList: [],//互动
-			hotActivityList:[],//热门活动
-			matchList:[],//活动列表
-			
-			tbalList:[],//投保案例
-			tbalIndex:0,//投保案例tab
-			
-			lpalList:[],//理赔案例
-			
-			fxList:[],//发现
-			fxIndex:0,
-			fxContentList:[],
-			
-			recommendCard:{},//销售
-			
-			isShowCodePop:false,
-			
-			lpalCode:req.public.lpalCode
-		};
-	},
-
-	components: {
-		foot,
-		footerCopyright,
-		banner,
-		district,
-		msgNumber
-	},
-	props: {},
-	onLoad: async function(options) {
-		// console.log("扫码进去参数===" + JSON.stringify(options));
-		// if (options.scene) {
-		//   // this.scene = options.scene || '1290926887903780865';
-		//   this.scene = options.scene;
-		//   await this.loadCodeParams();
-		// }
-		// wx.setNavigationBarColor({
-		//   frontColor: '#ffffff',
-		//   backgroundColor: req.public.titleTopBgColor,
-		// })
-		// this.getPopAd()
-		this.query = options;
-		req.silenceLogin(options.userId, '');
-		if (options.custom_params) {
-			let obj = decodeURIComponent(opt.custom_params);
-			obj = JSON.parse(obj);
-			// console.log(obj)
-			req.setStorage('pidCode', obj.userId);
-		}
-		if (options.isShare) {
-			if (options.userId) {
-				req.setStorage('pidCode', options.userId);
-			}
-		}
-		setInterval(() => {
-			this.setData({
-				isNotice: true
-			});
-		}, 10000); // this.init();
-		
-		QQMapWX.initMap();
-		req.getLocation(res => {
-			const to = {
-				latitude: res.latitude,
-				longitude: res.longitude
+				homeTemplate: [],
+				//首页栏目配置
+				storeShow: true,
+				templateType: {
+					module_ad: 'ad',
+					//广告
+					module_type_district: 'type_district',
+					//分类导航
+					module_king_kong_district: 'king_kong_district', //金刚区
+				},
+				isNotice: false,
+				joingroupList: {
+					products: []
+				},
+				//拼团
+				bargainList: {
+					products: []
+				},
+				//砍价
+				customersList: {
+					products: []
+				},
+				//新客
+				freshen: true,
+				url: '',
+				web: '',
+				site: '',
+				districtTemplate: {},
+				contact: [],
+				seckillList: {
+					products: []
+				},
+				about: {},
+				Is_Store_Price_Stock: '',
+				guarantee: [],
+				animationData: '',
+				content: '',
+				popAdList: {},
+				iscouponAd: false,
+				logo: false,
+				top: Boolean,
+				top_type: Boolean,
+				switchStoreShow: Boolean,
+				contactShow: true,
+				districtShow: false,
+				bannerShow: false,
+				officeList: [], //互动
+				hotActivityList: [], //热门活动
+				matchList: [], //活动列表
+
+				tbalList: [], //投保案例
+				tbalIndex: 0, //投保案例tab
+
+				lpalList: [], //理赔案例
+
+				fxList: [], //发现
+				fxIndex: 0,
+				fxContentList: [],
+
+				recommendCard: '', //销售
+
+				isShowCodePop: false,
+
+				lpalCode: req.public.lpalCode
 			};
-			QQMapWX.reverseGeocoder(to, resp => {
+		},
+
+		components: {
+			foot,
+			footerCopyright,
+			banner,
+			district,
+			msgNumber
+		},
+		props: {},
+		onLoad: async function(options) {
+			// console.log("扫码进去参数===" + JSON.stringify(options));
+			// if (options.scene) {
+			//   // this.scene = options.scene || '1290926887903780865';
+			//   this.scene = options.scene;
+			//   await this.loadCodeParams();
+			// }
+			// wx.setNavigationBarColor({
+			//   frontColor: '#ffffff',
+			//   backgroundColor: req.public.titleTopBgColor,
+			// })
+			// this.getPopAd()
+			this.query = options;
+			req.silenceLogin(options.userId, '');
+			if (options.custom_params) {
+				let obj = decodeURIComponent(opt.custom_params);
+				obj = JSON.parse(obj);
+				// console.log(obj)
+				req.setStorage('pidCode', obj.userId);
+			}
+			if (options.isShare) {
+				if (options.userId) {
+					req.setStorage('pidCode', options.userId);
+				}
+			}
+			setInterval(() => {
+				this.setData({
+					isNotice: true
+				});
+			}, 10000); // this.init();
+
+			QQMapWX.initMap();
+			req.getLocation(res => {
+				const to = {
+					latitude: res.latitude,
+					longitude: res.longitude
+				};
+				QQMapWX.reverseGeocoder(to, resp => {});
 			});
-		});
-	},
-
-	async onShow() {
-		let _ts = this;
-		await this.getConfig().then(res => {
-		});
-		await this.getHomeTemplateConfig();
-		uni.setNavigationBarColor({
-			frontColor: this.skinNotColor?'#000':'#ffffff',
-			backgroundColor: req.public.titleTopBgColor
-		});
-		_ts.setData({
-			isUpdate: !_ts.isUpdate
-		});
-		
-		this.getHotActivity()
-		this.getMatchList()
-		this.getTbal()
-		this.getLpal()
-		this.getFx()
-		this.getRecommendCard()
-		// console.log('this.freshen=='+this.freshen)
-		let first = req.getStorage('first');
-		if (first !== false)
-			_ts.setData({
-				first: true
+			
+		},
+
+		async onShow() {
+			let _ts = this;
+			await this.getConfig().then(res => {});
+			await this.getHomeTemplateConfig();
+			uni.setNavigationBarColor({
+				frontColor: this.skinNotColor ? '#000' : '#ffffff',
+				backgroundColor: req.public.titleTopBgColor
 			});
-		else
 			_ts.setData({
-				first: false
+				isUpdate: !_ts.isUpdate
 			});
-	},
-
-	onUnload() {
-		// this.isShowTime = false;
-		this.clearAllTimer(1);
-		this.clearAllTimer(2);
-		this.clearAllTimer(3);
-		this.clearAllTimer(4);
-	},
-
-	onHide() {
-		// this.isShowTime = false;
-		this.clearAllTimer(1);
-		this.clearAllTimer(2);
-		this.clearAllTimer(3);
-		this.clearAllTimer(4);
-	},
-	onShareAppMessage: function() {
-		
-	},
-	onShareTimeline() {
-		
-	},
-
-	onReachBottom() {},
-
-	methods: {
-		jumpUrl(url){
-			if(req.isLogins(false)){
-				uni.navigateTo({
-					url:url
-				})
-			}
-		},
-		// 获取推荐销售
-		getRecommendCard(){
-			req.getRequest('/api/visiting/card/recommendCardInfo',{},res=>{
-				this.recommendCard = res
-			})
-		},
-		// 获取热门活动
-		getHotActivity(){
-			req.getRequest('/api/banner',{code:'index_hot_activity'},res=>{
-				this.hotActivityList = res
-			})
+
+			this.getHotActivity()
+			this.getMatchList()
+			this.getTbal()
+			this.getLpal()
+			this.getFx()
+			this.getRecommendCard()
+			// console.log('this.freshen=='+this.freshen)
+			let first = req.getStorage('first');
+			if (first !== false)
+				_ts.setData({
+					first: true
+				});
+			else
+				_ts.setData({
+					first: false
+				});
 		},
-		// 获取更多活动
-		getMatchList(){
-			req.getRequest('/api/match/list',{page:1,limit:10},res=>{
-				this.matchList = res
-			})
+
+		onUnload() {
+			// this.isShowTime = false;
+			this.clearAllTimer(1);
+			this.clearAllTimer(2);
+			this.clearAllTimer(3);
+			this.clearAllTimer(4);
 		},
-		// 获取投保案例
-		async getTbal(){
-			this.tbalList = await this.getContentList(req.public.tbalCode)
-			this.tbalList[this.tbalIndex].contentList = await this.getContentPageList(this.tbalList[this.tbalIndex].code)
-			this.$forceUpdate()
+
+		onHide() {
+			// this.isShowTime = false;
+			this.clearAllTimer(1);
+			this.clearAllTimer(2);
+			this.clearAllTimer(3);
+			this.clearAllTimer(4);
 		},
-		// 获取理赔案例
-		async getLpal(){
-			this.lpalList = await this.getContentList(req.public.lpalCode)
-			this.lpalList.map(async item=>{
-				item.contentList = await this.getContentPageList(item.code)
-				this.$forceUpdate()
-			})
+		onShareAppMessage: function() {
+
 		},
-		// 获取发现
-		async getFx(){
-			this.fxList = await this.getContentList('faxian')
-			this.getFxContenteList(this.fxList[this.fxIndex].code)
+		onShareTimeline() {
+
 		},
-		
-		// 获取文章栏目列表
-		getContentList(code){
-			return new Promise((r,j)=>{
-				req.getRequest('/api/content/category/list',{parentCode:code},res=>{
-					r(res?res:[])
+
+		onReachBottom() {},
+
+		methods: {
+
+			jumpSingleChatRoom() {
+				if (this.recommendCard) {
+					req.jumpSingleChatRoom(this.recommendCard.userId, this.recommendCard.avatar, this.recommendCard
+						.realName);
+				}
+
+			},
+
+
+			jumpUrl(url) {
+				if (req.isLogins(false)) {
+					uni.navigateTo({
+						url: url
+					})
+				}
+			},
+			// 获取推荐销售
+			getRecommendCard() {
+				req.getRequest('/api/visiting/card/recommendCardInfo', {}, res => {
+					this.recommendCard = res
+					console.log('获取推荐销售》》》》》', res);
 				})
-			})
-		},
-		
-		// 获取文章列表
-		getContentPageList(code){
-			return new Promise((r,j)=>{
-				req.getRequest('/api/content/list',{code:code,page:1,limit:2},res=>{
-					r(res?res:[])
+			},
+			// 获取热门活动
+			getHotActivity() {
+				req.getRequest('/api/banner', {
+					code: 'index_hot_activity'
+				}, res => {
+					this.hotActivityList = res
 				})
-			})
-		},
-		
-		// 获取发现文章列表
-		getFxContenteList(code){
-			return new Promise((r,j)=>{
-				req.getRequest('/api/content/list',{code:code,page:1,limit:10},res=>{
-					this.fxContentList = res?res:[]
-					r(res?res:[])
+			},
+			// 获取更多活动
+			getMatchList() {
+				req.getRequest('/api/match/list', {
+					page: 1,
+					limit: 10
+				}, res => {
+					this.matchList = res
 				})
-			})
-		},
-		// 投保案例tab切换
-		async changeTbalTab(index){
-			if(this.tbalIndex==index) return false;
-			this.tbalIndex = index
-			this.tbalList[this.tbalIndex].contentList = await this.getContentPageList(this.tbalList[this.tbalIndex].code)
-		},
-		// 发现tab切换
-		changeFxTab(index){
-			if(this.fxIndex==index) return false;
-			this.fxIndex = index
-			this.getFxContenteList(this.fxList[this.fxIndex].code)
-		},
-		
-		async getRqeDatas() {
-			console.log('getRqeDatas');
-			let that = this; //多门店
-			
-			// 金刚区
-			let district = that.homeTemplate.filter(it => it.module == that.templateType.module_king_kong_district);
-			if (district && district.length > 0 && district[0].state == 0) {
-				let data = district[0];
-				data.content = JSON.parse(district[0].content);
-				that.districtTemplate = data;
-				if (data.contentId == 2) {
-					that.districtShow = true;
-				}
-				console.log(that.districtTemplate, '=============');
-			}
-			//顶部banner
-			let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
-			if (ad && ad.length > 0 && ad[0].state == 0) {
-				if (that.freshen) {
-					await that.getBannerList(ad[0].module, ad[0].contentId);
-				}
-			} 
-			that.logo = true;
-		},
+			},
+			// 获取投保案例
+			async getTbal() {
+				this.tbalList = await this.getContentList(req.public.tbalCode)
+				this.tbalList[this.tbalIndex].contentList = await this.getContentPageList(this.tbalList[this.tbalIndex]
+					.code)
+				this.$forceUpdate()
+			},
+			// 获取理赔案例
+			async getLpal() {
+				this.lpalList = await this.getContentList(req.public.lpalCode)
+				this.lpalList.map(async item => {
+					item.contentList = await this.getContentPageList(item.code)
+					this.$forceUpdate()
+				})
+			},
+			// 获取发现
+			async getFx() {
+				this.fxList = await this.getContentList('faxian')
+				this.getFxContenteList(this.fxList[this.fxIndex].code)
+			},
 
-		getUrl2(e) {
-			// 2 普通产品详情  4社区团购产品详情   5优惠券列表  6直播列表  7社区团购列表 9分类列表 10直播间 11拼团列表  12秒杀列表 13砍价列表 14新客列表 15新客详情 16秒杀详情 17砍价详情 18 拼团详情
-			var dt = e.currentTarget.dataset;
-			var url = '';
-			var id = '';
-			var acid = '';
-
-			if (dt.content != '') {
-				let conunt = dt.content.split('_');
-				id = conunt[1];
-				acid = conunt[0];
-			}
+			// 获取文章栏目列表
+			getContentList(code) {
+				return new Promise((r, j) => {
+					req.getRequest('/api/content/category/list', {
+						parentCode: code
+					}, res => {
+						r(res ? res : [])
+					})
+				})
+			},
 
-			if (dt.type * 1 == 2 && dt.content != '') {
-				url = 'product/detail/detail?id=' + dt.content;
-			} else if (dt.type * 1 == 4) {
-				url = 'product/groupDetail/groupDetail?acid=' + acid + '&id=' + id;
-			} else if (dt.type * 1 == 5) {
-				url = 'product/coupon/coupon';
-			} else if (dt.type * 1 == 6) {
-				url = 'pages/live/live';
-			} else if (dt.type * 1 == 7) {
-				url = 'product/groupList/groupList' + dt.merchant;
-			} else if (dt.type * 1 == 9 && dt.content != '') {
-				url = 'product/list/list?id=' + dt.content;
-			} else if (dt.type * 1 == 10) {
-				url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + dt.content;
-				// console.log(
-				// 	url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
-			} else if (dt.type * 1 == 11) {
-				url = 'activity/group/index/index' + dt.merchant;
-			} else if (dt.type * 1 == 12) {
-				url = 'activity/seckill/seckill' + dt.merchant;
-			} else if (dt.type * 1 == 13) {
-				url = 'activity/bargain/index/index' + dt.merchant;
-			} else if (dt.type * 1 == 14) {
-				url = 'activity/newbornZone/newbornZone' + dt.merchant;
-			} else if (dt.type * 1 == 15 && dt.content != '') {
-				url = 'activity/newbornDetails/newbornDetails?acid=' + acid + '&id=' + id;
-			} else if (dt.type * 1 == 16 && dt.content != '') {
-				url = 'activity/seckillDetails/seckillDetails?acid=' + acid + '&id=' + id;
-			} else if (dt.type * 1 == 17 && dt.content != '') {
-				url = 'activity/bargain/detail/detail?acid=' + acid + '&id=' + id;
-			} else if (dt.type * 1 == 18 && dt.content != '') {
-				url = 'activity/group/detail/detail?acid=' + acid + '&id=' + id;
-			} else {
-				url = '';
-			}
+			// 获取文章列表
+			getContentPageList(code) {
+				return new Promise((r, j) => {
+					req.getRequest('/api/content/list', {
+						code: code,
+						page: 1,
+						limit: 2
+					}, res => {
+						r(res ? res : [])
+					})
+				})
+			},
 
-			if (dt.type * 1 == 6) app.globalData.switchTab(url);
-			else app.globalData.openPage(url);
-			this.hideAd();
-		},
+			// 获取发现文章列表
+			getFxContenteList(code) {
+				return new Promise((r, j) => {
+					req.getRequest('/api/content/list', {
+						code: code,
+						page: 1,
+						limit: 10
+					}, res => {
+						this.fxContentList = res ? res : []
+						r(res ? res : [])
+					})
+				})
+			},
+			// 投保案例tab切换
+			async changeTbalTab(index) {
+				if (this.tbalIndex == index) return false;
+				this.tbalIndex = index
+				this.tbalList[this.tbalIndex].contentList = await this.getContentPageList(this.tbalList[this.tbalIndex]
+					.code)
+			},
+			// 发现tab切换
+			changeFxTab(index) {
+				if (this.fxIndex == index) return false;
+				this.fxIndex = index
+				this.getFxContenteList(this.fxList[this.fxIndex].code)
+			},
 
-		//获取首页模板配置
-		getHomeTemplateConfig() {
-			let _ts = this;
-			let page = 'index';
-			//荣康模板配置、小店产品==门店产品
-			// if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) page = 'shopIndex'
-			req.getRequest(
-				'/api/template/getTemplate',
-				{
-					page: page
-				},
-				data => {
-					let arr = [];
-					data.forEach(it => {
-						arr.push(it.module);
-					});
-					this.setData({
-						contact: [...new Set(arr)],
-						contactShow: false
-					});
-					if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('store_options') != -1) {
-						this.top = false;
-					} else {
-						this.top = true;
+			async getRqeDatas() {
+				console.log('getRqeDatas');
+				let that = this; //多门店
+
+				// 金刚区
+				let district = that.homeTemplate.filter(it => it.module == that.templateType
+					.module_king_kong_district);
+				if (district && district.length > 0 && district[0].state == 0) {
+					let data = district[0];
+					data.content = JSON.parse(district[0].content);
+					that.districtTemplate = data;
+					if (data.contentId == 2) {
+						that.districtShow = true;
 					}
-					if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('type_district') != -1) {
-						this.top_type = false;
-					} else {
-						this.top_type = true;
+					console.log(that.districtTemplate, '=============');
+				}
+				//顶部banner
+				let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
+				if (ad && ad.length > 0 && ad[0].state == 0) {
+					if (that.freshen) {
+						await that.getBannerList(ad[0].module, ad[0].contentId);
 					}
+				}
+				that.logo = true;
+			},
 
-					console.log(this.contact.indexOf('sou') != -1, this.contact.indexOf('store_options') != -1, this.contact.indexOf('type_district') != -1, this.top);
-					console.log(this.contact);
-					this.setData({
-						homeTemplate: data
-					});
+			getUrl2(e) {
+				// 2 普通产品详情  4社区团购产品详情   5优惠券列表  6直播列表  7社区团购列表 9分类列表 10直播间 11拼团列表  12秒杀列表 13砍价列表 14新客列表 15新客详情 16秒杀详情 17砍价详情 18 拼团详情
+				var dt = e.currentTarget.dataset;
+				var url = '';
+				var id = '';
+				var acid = '';
+
+				if (dt.content != '') {
+					let conunt = dt.content.split('_');
+					id = conunt[1];
+					acid = conunt[0];
+				}
 
-					this.getRqeDatas();
+				if (dt.type * 1 == 2 && dt.content != '') {
+					url = 'product/detail/detail?id=' + dt.content;
+				} else if (dt.type * 1 == 4) {
+					url = 'product/groupDetail/groupDetail?acid=' + acid + '&id=' + id;
+				} else if (dt.type * 1 == 5) {
+					url = 'product/coupon/coupon';
+				} else if (dt.type * 1 == 6) {
+					url = 'pages/live/live';
+				} else if (dt.type * 1 == 7) {
+					url = 'product/groupList/groupList' + dt.merchant;
+				} else if (dt.type * 1 == 9 && dt.content != '') {
+					url = 'product/list/list?id=' + dt.content;
+				} else if (dt.type * 1 == 10) {
+					url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + dt.content;
+					// console.log(
+					// 	url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
+				} else if (dt.type * 1 == 11) {
+					url = 'activity/group/index/index' + dt.merchant;
+				} else if (dt.type * 1 == 12) {
+					url = 'activity/seckill/seckill' + dt.merchant;
+				} else if (dt.type * 1 == 13) {
+					url = 'activity/bargain/index/index' + dt.merchant;
+				} else if (dt.type * 1 == 14) {
+					url = 'activity/newbornZone/newbornZone' + dt.merchant;
+				} else if (dt.type * 1 == 15 && dt.content != '') {
+					url = 'activity/newbornDetails/newbornDetails?acid=' + acid + '&id=' + id;
+				} else if (dt.type * 1 == 16 && dt.content != '') {
+					url = 'activity/seckillDetails/seckillDetails?acid=' + acid + '&id=' + id;
+				} else if (dt.type * 1 == 17 && dt.content != '') {
+					url = 'activity/bargain/detail/detail?acid=' + acid + '&id=' + id;
+				} else if (dt.type * 1 == 18 && dt.content != '') {
+					url = 'activity/group/detail/detail?acid=' + acid + '&id=' + id;
+				} else {
+					url = '';
 				}
-			);
-		},
-		getConfig() {
-			var _this = this;
-			return new Promise((res, rej) => {
-				req.g(
-					'/api/other/config',
+
+				if (dt.type * 1 == 6) app.globalData.switchTab(url);
+				else app.globalData.openPage(url);
+				this.hideAd();
+			},
+
+			//获取首页模板配置
+			getHomeTemplateConfig() {
+				let _ts = this;
+				let page = 'index';
+				//荣康模板配置、小店产品==门店产品
+				// if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) page = 'shopIndex'
+				req.getRequest(
+					'/api/template/getTemplate', {
+						page: page
+					},
 					data => {
-						req.setStorage('configRes', JSON.stringify(data));
-						this.about = data;
-						if (!data.Index_Store_Confirm || data.Index_Store_Confirm == 0) {
-							_this.setData({
-								switchStoreShow: false,
-								storeShow: false
-							});
+						let arr = [];
+						data.forEach(it => {
+							arr.push(it.module);
+						});
+						this.setData({
+							contact: [...new Set(arr)],
+							contactShow: false
+						});
+						if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('store_options') != -1) {
+							this.top = false;
 						} else {
-							_this.setData({
-								switchStoreShow: true
-							});
+							this.top = true;
 						}
-						// console.log(data.Index_Store_Confirm, "====", !data.Index_Store_Confirm, typeof(res
-						// .Index_Store_Confirm))
-						uni.setNavigationBarTitle({
-							// title: res['CONFIG_PROJECT_TITLE'],
-							title: data['CONFIG_PROJECT_TITLE']
-						});
-						// console.log(data.Is_Store_Price_Stock);
-
-						if (data.Is_Store_Price_Stock) {
-							this.Is_Store_Price_Stock = data.Is_Store_Price_Stock;
+						if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('type_district') != -1) {
+							this.top_type = false;
+						} else {
+							this.top_type = true;
 						}
 
+						console.log(this.contact.indexOf('sou') != -1, this.contact.indexOf('store_options') != -1,
+							this.contact.indexOf('type_district') != -1, this.top);
+						console.log(this.contact);
 						this.setData({
-							Is_Store_Price_Stock: data.Is_Store_Price_Stock
+							homeTemplate: data
 						});
 
-						if (data.b2c_service_guarantee && data.b2c_service_guarantee != null) {
-							this.setData({
-								guarantee: data.b2c_service_guarantee.split(';').filter(it => {
-									return (it = it && it.trim());
-								})
+						this.getRqeDatas();
+					}
+				);
+			},
+			getConfig() {
+				var _this = this;
+				return new Promise((res, rej) => {
+					req.g(
+						'/api/other/config',
+						data => {
+							req.setStorage('configRes', JSON.stringify(data));
+							this.about = data;
+							if (!data.Index_Store_Confirm || data.Index_Store_Confirm == 0) {
+								_this.setData({
+									switchStoreShow: false,
+									storeShow: false
+								});
+							} else {
+								_this.setData({
+									switchStoreShow: true
+								});
+							}
+							// console.log(data.Index_Store_Confirm, "====", !data.Index_Store_Confirm, typeof(res
+							// .Index_Store_Confirm))
+							uni.setNavigationBarTitle({
+								// title: res['CONFIG_PROJECT_TITLE'],
+								title: data['CONFIG_PROJECT_TITLE']
 							});
-						}
+							// console.log(data.Is_Store_Price_Stock);
 
-						req.setStorage('appName', data['CONFIG_PROJECT_TITLE']);
-						req.setStorage('productDiy', data['Product_Foot-Diy']);
-						res(data);
-					},
-					true
-				);
-			});
-		},
+							if (data.Is_Store_Price_Stock) {
+								this.Is_Store_Price_Stock = data.Is_Store_Price_Stock;
+							}
 
-		merchantFun() {
-			app.globalData.openPage('pages/nearby/nearby');
-		},
+							this.setData({
+								Is_Store_Price_Stock: data.Is_Store_Price_Stock
+							});
 
-		saoma() {
-			var _this = this; // 允许从相机和相册扫码
+							if (data.b2c_service_guarantee && data.b2c_service_guarantee != null) {
+								this.setData({
+									guarantee: data.b2c_service_guarantee.split(';').filter(it => {
+										return (it = it && it.trim());
+									})
+								});
+							}
+
+							req.setStorage('appName', data['CONFIG_PROJECT_TITLE']);
+							req.setStorage('productDiy', data['Product_Foot-Diy']);
+							res(data);
+						},
+						true
+					);
+				});
+			},
 
-			uni.scanCode({
-				success: res => {
-					uni.navigateTo({
-						url: '/' + res.path
-					}); // this.scene = '1290926887903780865';
+			merchantFun() {
+				app.globalData.openPage('pages/nearby/nearby');
+			},
 
-					this.loadCodeParams();
-				}
-			});
-		},
+			saoma() {
+				var _this = this; // 允许从相机和相册扫码
 
-		update(content) {
-			var that = this;
-			var animation = uni.createAnimation(); // 旧消息向上平移
+				uni.scanCode({
+					success: res => {
+						uni.navigateTo({
+							url: '/' + res.path
+						}); // this.scene = '1290926887903780865';
 
-			animation.translateY(-50).step({
-				duration: 1000,
-				timingFunction: 'ease-in'
-			}); // 为了实现下一条新内容向上平移的效果,必须把内容很快平移到下方,并且不能被用户看见,这里其原理类似轮播图的思路。
-			// 实现方法:动画时间设置为1ms,过渡效果设置为’动画第一帧就跳至结束状态直到结束‘
+						this.loadCodeParams();
+					}
+				});
+			},
 
-			animation
-				.opacity(0)
-				.translateY(50)
-				.step({
-					duration: 1000,
-					timingFunction: 'step-start'
-				}); // 新消息向上平移的同时恢复透明
+			update(content) {
+				var that = this;
+				var animation = uni.createAnimation(); // 旧消息向上平移
 
-			animation
-				.opacity(1)
-				.translateY(0)
-				.step({
+				animation.translateY(-50).step({
 					duration: 1000,
-					timingFunction: 'ease-out'
-				});
-			that.setData({
-				animationData: animation.export()
-			}); // 更新内容的延时必须大于第一步动画时间
-
-			setTimeout(() => {
+					timingFunction: 'ease-in'
+				}); // 为了实现下一条新内容向上平移的效果,必须把内容很快平移到下方,并且不能被用户看见,这里其原理类似轮播图的思路。
+				// 实现方法:动画时间设置为1ms,过渡效果设置为’动画第一帧就跳至结束状态直到结束‘
+
+				animation
+					.opacity(0)
+					.translateY(50)
+					.step({
+						duration: 1000,
+						timingFunction: 'step-start'
+					}); // 新消息向上平移的同时恢复透明
+
+				animation
+					.opacity(1)
+					.translateY(0)
+					.step({
+						duration: 1000,
+						timingFunction: 'ease-out'
+					});
 				that.setData({
-					content: content
-				});
-			}, 500000);
-		},
+					animationData: animation.export()
+				}); // 更新内容的延时必须大于第一步动画时间
 
-		loadCodeParams() {
-			let _ts = this;
+				setTimeout(() => {
+					that.setData({
+						content: content
+					});
+				}, 500000);
+			},
 
-			return new Promise((resolve, reject) => {
-				if (!_ts.scene) {
-					resolve();
-					return false;
-				}
+			loadCodeParams() {
+				let _ts = this;
 
-				req.getRequest(
-					'/api/code/params',
-					{
-						scene: _ts.scene
-					},
-					data => {
-						req.setStorage('pidCode', data.userId);
+				return new Promise((resolve, reject) => {
+					if (!_ts.scene) {
 						resolve();
+						return false;
 					}
-				);
-			});
-		},
 
-		getBannerList(module, contentId) {
-			//banner图
-			let that = this;
-			return new Promise((resolve,reject)=>{
-				req.getRequest(
-					'/api/banner',
-					{
-						groupId: contentId
-					},
-					data => {
-						if (module == that.templateType.module_ad) {
-							that.setData({
-								bannerList: data,
-								bannerShow: true
-							});
-						} else {
-							that.setData({
-								popAdList: data[0]
-							});
+					req.getRequest(
+						'/api/code/params', {
+							scene: _ts.scene
+						},
+						data => {
+							req.setStorage('pidCode', data.userId);
+							resolve();
 						}
-						resolve();
-					}
-				);
-			})
-		},
-
-		
-		clearAllTimer(type) {
-			// console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
-
-			if (type == 1) {
-				this.activityGroup.products.forEach(it => clearInterval(it.timer));
-				this.activityGroup.products.forEach(it => clearInterval(it.times));
-			} else if (type == 2) {
-				this.joingroupList.products.forEach(it => clearInterval(it.timer));
-				this.joingroupList.products.forEach(it => clearInterval(it.times));
-			} else if (type == 3) {
-				this.bargainList.products.forEach(it => clearInterval(it.timer));
-				this.bargainList.products.forEach(it => clearInterval(it.times));
-			} else if (type == 4) {
-				this.customersList.products.forEach(it => clearInterval(it.timer));
-				this.customersList.products.forEach(it => clearInterval(it.times));
-			} else if (type == 5) {
-				this.seckillList.products.forEach(it => clearInterval(it.timer));
-				this.seckillList.products.forEach(it => clearInterval(it.times));
-			}
-		},
+					);
+				});
+			},
 
-		hideGuide() {
-			//关闭提示加入我的小程序
-			this.setData({
-				first: false
-			});
-			req.setStorage('first', false);
-		},
+			getBannerList(module, contentId) {
+				//banner图
+				let that = this;
+				return new Promise((resolve, reject) => {
+					req.getRequest(
+						'/api/banner', {
+							groupId: contentId
+						},
+						data => {
+							if (module == that.templateType.module_ad) {
+								that.setData({
+									bannerList: data,
+									bannerShow: true
+								});
+							} else {
+								that.setData({
+									popAdList: data[0]
+								});
+							}
+							resolve();
+						}
+					);
+				})
+			},
 
-		hideAd() {
-			//关闭广告
-			// if(this.data.first==false){
-			this.setData({
-				isLayerAd: false
-			}); // }
-			app.globalData.isLayerAd = false;
-		},
-		click(e) {
-			// console.log(e)
-			this.storeShow = e;
-		},
 
-		goUrl(event) {
-			//跳转链接
-			let url = event.currentTarget.dataset.url;
-			app.globalData.openPage(url);
-		},
-		// 拨打电话
-		callPhone(val) {
-			if(!val) return false
-		    uni.makePhoneCall({
-		        phoneNumber: val
-		    });
-		},
-		copy(val){
-			this.isShowCodePop = false
-			uni.setClipboardData({
-				data: val,
-				complete() {
-					req.msg('复制成功')
+			clearAllTimer(type) {
+				// console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
+
+				if (type == 1) {
+					this.activityGroup.products.forEach(it => clearInterval(it.timer));
+					this.activityGroup.products.forEach(it => clearInterval(it.times));
+				} else if (type == 2) {
+					this.joingroupList.products.forEach(it => clearInterval(it.timer));
+					this.joingroupList.products.forEach(it => clearInterval(it.times));
+				} else if (type == 3) {
+					this.bargainList.products.forEach(it => clearInterval(it.timer));
+					this.bargainList.products.forEach(it => clearInterval(it.times));
+				} else if (type == 4) {
+					this.customersList.products.forEach(it => clearInterval(it.timer));
+					this.customersList.products.forEach(it => clearInterval(it.times));
+				} else if (type == 5) {
+					this.seckillList.products.forEach(it => clearInterval(it.timer));
+					this.seckillList.products.forEach(it => clearInterval(it.times));
 				}
-			})
-		},
-		unitFormat(data){
-			return req.unitConverter(data).text
-		},
-		formatTime(date){
-			date = new Date(date.replace(/-/g, '/'))
-			return utils.formatTime(date).t3
+			},
+
+			hideGuide() {
+				//关闭提示加入我的小程序
+				this.setData({
+					first: false
+				});
+				req.setStorage('first', false);
+			},
+
+			hideAd() {
+				//关闭广告
+				// if(this.data.first==false){
+				this.setData({
+					isLayerAd: false
+				}); // }
+				app.globalData.isLayerAd = false;
+			},
+			click(e) {
+				// console.log(e)
+				this.storeShow = e;
+			},
+
+			goUrl(event) {
+				//跳转链接
+				let url = event.currentTarget.dataset.url;
+				app.globalData.openPage(url);
+			},
+			// 拨打电话
+			callPhone(val) {
+				if (!val) return false
+				uni.makePhoneCall({
+					phoneNumber: val
+				});
+			},
+			copy(val) {
+				this.isShowCodePop = false
+				uni.setClipboardData({
+					data: val,
+					complete() {
+						req.msg('复制成功')
+					}
+				})
+			},
+			unitFormat(data) {
+				return req.unitConverter(data).text
+			},
+			formatTime(date) {
+				date = new Date(date.replace(/-/g, '/'))
+				return utils.formatTime(date).t3
+			},
+			getAge(date) {
+				return utils.getAge(date)
+			}
 		},
-		getAge(date){
-			return utils.getAge(date)
+		mounted() {
+			const systemInfo = uni.getSystemInfoSync();
+			// px转换到rpx的比例
+			let pxToRpxScale = 750 / systemInfo.windowWidth;
+			let systems = {
+				ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
+				navigationHeight: 44 * pxToRpxScale // 导航栏的高度
+			};
+			systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
+			this.systems = systems;
 		}
-	},
-	mounted() {
-		const systemInfo = uni.getSystemInfoSync();
-		// px转换到rpx的比例
-		let pxToRpxScale = 750 / systemInfo.windowWidth;
-		let systems = {
-			ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
-			navigationHeight: 44 * pxToRpxScale // 导航栏的高度
-		};
-		systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
-		this.systems = systems;
-	}
-};
+	};
 </script>
 <style>
-@import './index.css';
-</style>
+	@import './index.css';
+</style>

+ 108 - 40
utils/request.js

@@ -42,13 +42,13 @@ const publics = {
 	'iconSrc': 'red/',
 	'titleTopBgColor': '#FFF',
 	// 小程序ID  wxe7bec198ecfe1162
-	
-	
+
+
 	// 文章栏目code
-	'fxCode':'faxian',//发现
-	'xbrmCode':'xiaobaorumen',//小白入门
-	'tbalCode':'toubaoanli',//投保案例
-	'lpalCode':'lipeianli',//理赔案例
+	'fxCode': 'faxian', //发现
+	'xbrmCode': 'xiaobaorumen', //小白入门
+	'tbalCode': 'toubaoanli', //投保案例
+	'lpalCode': 'lipeianli', //理赔案例
 
 }
 /*
@@ -113,7 +113,8 @@ const silenceLogin = (parentId, merchantId) => {
 					});
 				}
 			});
-		}else{
+		} else {
+			initIMChat();
 			resolve();
 		}
 	});
@@ -121,37 +122,62 @@ const silenceLogin = (parentId, merchantId) => {
 }
 
 
-const getIMToken = (isUpdatToken) => {
+/**
+ * 初始化 IMsdk
+ */
+const initIMChat = () => {
 	var user = getStorage('userInfo');
-	getRequest('/api/im/msg/userToken', {}, suc => {
-		setStorage('imToken', suc);
-		if (isUpdatToken) {
-			//更新token
-			
-			
+	if (user) {
+		var imToken = getStorage('imToken');
+		if (imToken) {
+			//初始化IM
 			uni.setStorage({
-			    key: "myUsername",
-			    data: 'RS_' + user.id
+				key: "myUsername",
+				data: 'RS_' + user.id
 			});
 			getApp().globalData.conn.open({
+				apiUrl: WebIM.config.apiURL,
 				user: 'RS_' + user.id,
+				pwd: getStorage('imToken'),
 				accessToken: getStorage('imToken'),
+				appKey: WebIM.config.appkey
 			});
-			getApp().globalData.onLoginSuccess(uni.getStorageSync("myUsername"));
 		} else {
-			//初始化IM
+			getRequest('/api/im/msg/userToken', {}, suc => {
+				setStorage('imToken', suc);
+				uni.setStorage({
+					key: "myUsername",
+					data: 'RS_' + user.id
+				});
+				getApp().globalData.conn.open({
+					apiUrl: WebIM.config.apiURL,
+					user: 'RS_' + user.id,
+					pwd: getStorage('imToken'),
+					accessToken: getStorage('imToken'),
+					appKey: WebIM.config.appkey
+				});
+			});
+		}
+	}
+}
+
+const getIMToken = (isUpdatToken) => {
+	var user = getStorage('userInfo');
+	getRequest('/api/im/msg/userToken', {}, suc => {
+		setStorage('imToken', suc);
+		if (isUpdatToken) {
+			//更新token
 			uni.setStorage({
-			    key: "myUsername",
-			    data: 'RS_' + user.id
+				key: "myUsername",
+				data: 'RS_' + user.id
 			});
 			getApp().globalData.conn.open({
-				apiUrl: WebIM.config.apiURL,
 				user: 'RS_' + user.id,
-				pwd: getStorage('imToken'),
 				accessToken: getStorage('imToken'),
-				//grant_type: this.data.grant_type,
-				appKey: WebIM.config.appkey
 			});
+			getApp().globalData.onLoginSuccess(uni.getStorageSync("myUsername"));
+		} else {
+			initIMChat();
 		}
 	}, true);
 }
@@ -163,9 +189,7 @@ const jumpConversation = () => {
 	if (!isLogins(true)) { //未登录
 		return;
 	}
-
 	getIMToken(true);
-
 }
 
 const getWXUserProfile = (suc) => {
@@ -1060,20 +1084,36 @@ const excludeSpecial = (s) => {
 }
 
 // 数字单位格式化
-function unitConverter (num) {
+function unitConverter(num) {
 	// text 数字+单位 number格式化后的数字 unit单位
 	console.log(num)
-  if (!num || isNaN(num)) {
-    return {text:0,number:0,unit:''}
-  }
-  num = Number(num)
-  if (Math.abs(num) > 100000000) {
-    return {text:(num / 100000000).toFixed(2) + '亿',number:(num / 100000000).toFixed(2),unit:'亿'}
-  } else if (Math.abs(num) > 10000) {
-    return {text:(num / 10000).toFixed(2) + '万',number:(num / 10000).toFixed(2),unit:'万'}
-  } else {
-    return {text:num,number:num,unit:''}
-  }
+	if (!num || isNaN(num)) {
+		return {
+			text: 0,
+			number: 0,
+			unit: ''
+		}
+	}
+	num = Number(num)
+	if (Math.abs(num) > 100000000) {
+		return {
+			text: (num / 100000000).toFixed(2) + '亿',
+			number: (num / 100000000).toFixed(2),
+			unit: '亿'
+		}
+	} else if (Math.abs(num) > 10000) {
+		return {
+			text: (num / 10000).toFixed(2) + '万',
+			number: (num / 10000).toFixed(2),
+			unit: '万'
+		}
+	} else {
+		return {
+			text: num,
+			number: num,
+			unit: ''
+		}
+	}
 }
 
 // 行为操作
@@ -1092,6 +1132,32 @@ const getBehavior = (params, success) => {
 		success.call(this, data)
 	})
 }
+
+/**
+ * 跳入聊天
+ * @param {Object} userId 对方用户ID
+ * @param {Object} avatar 对方用户头像
+ * @param {Object} realName 对方用户名称
+ */
+const jumpSingleChatRoom = function(userId, avatar, realName) {
+	var my = uni.getStorageSync("myUsername");
+	var nameList = {
+		myName: my,
+		your: 'rs_' + userId
+	};
+	uni.setStorage({
+		key: 'imUserInfo_' + nameList.your,
+		data: {
+			avatar: avatar,
+			id: userId,
+			nickName: realName
+		}
+	});
+	uni.navigateTo({
+		url: "/chat/chatroom/chatroom?username=" + JSON.stringify(nameList)
+	});
+}
+
 /**
  * text:展示导航名
  * iconPath:未点击显示图标
@@ -1201,7 +1267,9 @@ module.exports = {
 	updataWxInfos: updataWxInfos,
 	saveBehavior: saveBehavior,
 	getBehavior: getBehavior,
-	unitConverter:unitConverter,
+	unitConverter: unitConverter,
+	initIMChat: initIMChat,
 	getIMToken: getIMToken,
-	jumpConversation: jumpConversation
+	jumpConversation: jumpConversation,
+	jumpSingleChatRoom: jumpSingleChatRoom
 }