diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue
index de250eca..2c741004 100644
--- a/resources/assets/js/pages/manage/components/DialogWrapper.vue
+++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue
@@ -65,20 +65,12 @@ export default {
}
},
- mounted() {
- this.$store.state.dialogShow = true;
- },
-
destroyed() {
- this.$store.state.dialogShow = false;
- },
-
- activated() {
- this.$store.state.dialogShow = true;
+ this.$store.state.dialogId = 0;
},
deactivated() {
- this.$store.state.dialogShow = false;
+ this.$store.state.dialogId = 0;
},
computed: {
@@ -132,10 +124,7 @@ export default {
content: msg
});
}
- this.$store.commit('spliceDialogMsg', {
- id: tempId,
- data: ret === 1 ? data : null
- });
+ this.$store.commit('spliceDialogMsg', {id: tempId, data: ret === 1 ? data : null});
}
});
//
diff --git a/resources/assets/js/pages/manage/components/ProjectDialog.vue b/resources/assets/js/pages/manage/components/ProjectDialog.vue
index f528f2d4..fe893329 100644
--- a/resources/assets/js/pages/manage/components/ProjectDialog.vue
+++ b/resources/assets/js/pages/manage/components/ProjectDialog.vue
@@ -92,6 +92,10 @@ export default {
}
},
+ mounted() {
+ this.getMsg();
+ },
+
computed: {
...mapState(['projectDetail', 'projectChatShow']),
},
diff --git a/resources/assets/js/pages/manage/components/ProjectList.vue b/resources/assets/js/pages/manage/components/ProjectList.vue
index 7e78a238..8a5e76d7 100644
--- a/resources/assets/js/pages/manage/components/ProjectList.vue
+++ b/resources/assets/js/pages/manage/components/ProjectList.vue
@@ -26,7 +26,7 @@
-
+
@@ -836,6 +836,8 @@ export default {
data() {
return {
nowTime: Math.round(new Date().getTime() / 1000),
+ nowInterval: null,
+
searchText: '',
addShow: false,
@@ -863,17 +865,25 @@ export default {
transferLoad: 0,
}
},
+
mounted() {
- setInterval(() => {
+ this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000);
}, 1000)
},
+
+ destroyed() {
+ clearInterval(this.nowInterval)
+ },
+
computed: {
...mapState([
'userId',
+ 'dialogList',
+
'projectDetail',
'projectLoad',
- 'projectMsgUnread',
+
'projectChatShow',
'projectListPanel',
'taskMyShow',
@@ -881,6 +891,12 @@ export default {
'taskCompletedShow'
]),
+ msgUnread() {
+ const {dialogList, projectDetail} = this;
+ const dialog = dialogList.find(({id}) => id === projectDetail.dialog_id);
+ return dialog ? dialog.unread : 0;
+ },
+
panelTask() {
const {searchText} = this;
return function (project_task) {
@@ -963,6 +979,7 @@ export default {
}
},
},
+
methods: {
addOpen(column_id) {
this.$set(this.addData, 'owner', this.userId);
diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue
index b342ad9d..3b7a425a 100644
--- a/resources/assets/js/pages/manage/messenger.vue
+++ b/resources/assets/js/pages/manage/messenger.vue
@@ -72,7 +72,12 @@ export default {
this.dialogLoad++;
this.$store.commit("getDialogList", () => {
this.dialogLoad--;
- })
+ this.openDialogStorage();
+ });
+ },
+
+ activated() {
+ this.openDialogStorage();
},
computed: {
@@ -97,9 +102,18 @@ export default {
methods: {
openDialog(dialog) {
+ this.$store.state.method.setStorage('messengerDialogId', dialog.id)
this.$store.commit('getDialogMsgList', dialog.id);
},
+ openDialogStorage() {
+ let tmpId = this.$store.state.method.getStorageInt('messengerDialogId')
+ if (tmpId > 0) {
+ const dialog = this.dialogList.find(({id}) => id === tmpId);
+ dialog && this.openDialog(dialog);
+ }
+ },
+
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
string = '';
diff --git a/resources/assets/js/store/mutations.js b/resources/assets/js/store/mutations.js
index e18a0c8a..eaf72325 100644
--- a/resources/assets/js/store/mutations.js
+++ b/resources/assets/js/store/mutations.js
@@ -82,18 +82,18 @@ export default {
/**
* 获取项目列表
* @param state
- * @param completeCallback
+ * @param afterCallback
*/
- getProjectList(state, completeCallback) {
+ getProjectList(state, afterCallback) {
if (state.userId === 0) {
state.projectList = [];
- typeof completeCallback === "function" && completeCallback();
+ typeof afterCallback === "function" && afterCallback();
return;
}
$A.apiAjax({
url: 'project/lists',
- complete: () => {
- typeof completeCallback === "function" && completeCallback();
+ after: () => {
+ typeof afterCallback === "function" && afterCallback();
},
success: ({ret, data, msg}) => {
if (ret === 1) {
@@ -212,13 +212,13 @@ export default {
/**
* 获取对话列表
* @param state
- * @param completeCallback
+ * @param afterCallback
*/
- getDialogList(state, completeCallback) {
+ getDialogList(state, afterCallback) {
$A.apiAjax({
url: 'dialog/lists',
- complete: () => {
- typeof completeCallback === "function" && completeCallback();
+ after: () => {
+ typeof afterCallback === "function" && afterCallback();
},
success: ({ret, data, msg}) => {
if (ret === 1) {
@@ -241,6 +241,7 @@ export default {
},
success: ({ret, data, msg}) => {
if (ret === 1) {
+ if (state.dialogId === data.id) data.unread = 0;
let index = state.dialogList.findIndex(({id}) => id == data.id);
if (index > -1) {
state.dialogList.splice(index, 1, data);
@@ -250,18 +251,6 @@ export default {
}
}
});
-
- $A.apiAjax({
- url: 'dialog/lists',
- complete: () => {
- typeof completeCallback === "function" && completeCallback();
- },
- success: ({ret, data, msg}) => {
- if (ret === 1) {
- state.dialogList = data.data;
- }
- }
- });
},
/**
@@ -374,6 +363,12 @@ export default {
if (index > -1) {
if (data) {
state.dialogMsgList.splice(index, 1, state.method.cloneJSON(data));
+ // 是最后一条消息时更新对话 last_msg
+ console.log(data);
+ if (state.dialogMsgList.length - 1 == index) {
+ const dialog = state.dialogList.find(({id}) => id == data.dialog_id);
+ if (dialog) dialog.last_msg = data;
+ }
} else {
state.dialogMsgList.splice(index, 1);
}
@@ -489,7 +484,7 @@ export default {
} else {
that.commit('getDialogOne', dialog_id);
}
- if (!state.dialogShow || state.dialogId !== dialog_id) state.dialogMsgUnread++;
+ if (state.dialogId !== dialog_id) state.dialogMsgUnread++;
}
})(msgDetail, this);
}
diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js
index 940a4b1c..bb5ffbdc 100644
--- a/resources/assets/js/store/state.js
+++ b/resources/assets/js/store/state.js
@@ -13,7 +13,7 @@ const method = {
return typeof value === "string" || typeof value === "number" ? value : def;
},
- getStorageNumber(key, def = 0) {
+ getStorageInt(key, def = 0) {
let value = this.storage(key);
return typeof value === "number" ? value : def;
},
@@ -182,11 +182,9 @@ state.projectDetail = {
project_column: [],
project_user: []
};
-state.projectMsgUnread = 0;
// 会话消息
state.dialogId = 0;
-state.dialogShow = false;
state.dialogList = [];
state.dialogDetail = {};
state.dialogMsgLoad = 0;