Browse Source

创建房间

zs 2 years ago
parent
commit
9e00400da0
3 changed files with 28 additions and 32 deletions
  1. 4 9
      pagesHome/order/detail.vue
  2. 17 12
      pagesMessage/message/info.vue
  3. 7 11
      pagesMy/order/index.vue

+ 4 - 9
pagesHome/order/detail.vue

@@ -657,18 +657,13 @@
 						if (arr.errcode == '0' && arr.total > 0) { //有直接进入
 							if (arr.data) {
 								uni.navigateTo({
-									url: `/pagesMessage/message/info?id=${arr.data._id}`
+									url: `/pagesMessage/message/info?id=${arr.data[0]._id}`
 								})
 							}
 						} else { //没有创建进入
-							let res = await that.$api(`/room`, `POST`, form, 'chat');
-							if (res.errcode == '0') {
-								if (res.data) {
-									uni.navigateTo({
-										url: `/pagesMessage/message/info?id=${res.data._id}`
-									})
-								}
-							}
+							uni.navigateTo({
+								url: `/pagesMessage/message/info?shop=${form.shop}`
+							})
 						}
 					} else {
 						uni.showToast({

+ 17 - 12
pagesMessage/message/info.vue

@@ -64,6 +64,7 @@
 				id: '',
 				// 店铺信息
 				shop: {},
+				shop_id: "",
 				// 历史记录
 				msgList: [],
 				total: 0,
@@ -91,6 +92,7 @@
 		onLoad: async function(e) {
 			const that = this;
 			that.$set(that, `id`, e.id);
+			that.$set(that, `shop_id`, e.shop);
 			that.watchlogin();
 		},
 		beforeDestroy() {
@@ -161,17 +163,19 @@
 				let ids = id.map(i => {
 					return i._id
 				})
-				// 信息已读
-				res = await that.$api(`/chatRecord/read`, `POST`, {
-					ids
-				}, 'chat')
-				if (res.errcode == '0') {
-					console.log(res);
-				} else {
-					uni.showToast({
-						title: res.errmsg,
-						icon: 'none'
-					})
+				if (ids.length > 0) {
+					// 信息已读
+					res = await that.$api(`/chatRecord/read`, `POST`, {
+						ids
+					}, 'chat')
+					if (res.errcode == '0') {
+						console.log(res);
+					} else {
+						uni.showToast({
+							title: res.errmsg,
+							icon: 'none'
+						})
+					}
 				}
 				// 跳转到最后一条数据 与前面的:id进行对照
 				// 如果是下拉刷新聊天记录不跳到最后一条
@@ -283,6 +287,7 @@
 					};
 					// 发送给服务器消息
 					// if (that.isSocketOpen) { //socket连接正常
+					if (!that.id) data.shop = that.shop_id
 					let res = await that.$api(`/chatRecord`, `POST`, data, 'chat');
 					if (res.errcode == '0') {
 						that.msgList.push(res.data);
@@ -398,7 +403,7 @@
 			.scroll-view {
 
 				.chat-ls {
-					padding: 0 2vw;
+					padding: 2vw 2vw 0 2vw;
 
 					.chat-time {
 						font-size: 24rpx;

+ 7 - 11
pagesMy/order/index.vue

@@ -329,28 +329,24 @@
 			},
 			// 联系客服
 			async toNotice(e) {
+				console.log(e);
 				const that = this;
 				let form = {
 					"customer": e.customer && e.customer._id,
-					"shop": e.shop && e.shop._id
+					"shop": e.shop && e.shop._id || e.goods && e.goods[0].shop
 				}
 				// 查询该用户与该店铺是否有房间
 				let arr = await that.$api(`/room`, `GET`, form, 'chat');
 				if (arr.errcode == '0' && arr.total > 0) { //有直接进入
-					if (arr.data && e.shop) {
+					if (arr.data) {
 						uni.navigateTo({
-							url: `/pagesMessage/message/info?id=${arr.data._id}`
+							url: `/pagesMessage/message/info?id=${arr.data[0]._id}`
 						})
 					}
 				} else { //没有创建进入
-					let res = await that.$api(`/room`, `POST`, form, 'chat');
-					if (res.errcode == '0') {
-						if (res.data && e.shop) {
-							uni.navigateTo({
-								url: `/pagesMessage/message/info?id=${res.data._id}`
-							})
-						}
-					}
+					uni.navigateTo({
+						url: `/pagesMessage/message/info?shop=${form.shop}`
+					})
 				}
 			},
 			// 输入框