From 13cb91cd927df87f3cb54d5de3e452caef3ab394 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Thu, 3 Jun 2021 14:10:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/src/layout/components/Navbar.vue | 2 +- stdiet-ui/src/utils/websocket.js | 2 ++ stdiet-ui/src/views/custom/message/messageBrowser/index.vue | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stdiet-ui/src/layout/components/Navbar.vue b/stdiet-ui/src/layout/components/Navbar.vue index ee333af6c..2eaf0ebec 100644 --- a/stdiet-ui/src/layout/components/Navbar.vue +++ b/stdiet-ui/src/layout/components/Navbar.vue @@ -28,7 +28,7 @@ trigger="click" >
- avatar +
diff --git a/stdiet-ui/src/utils/websocket.js b/stdiet-ui/src/utils/websocket.js index 7d6554c69..62dde69ec 100644 --- a/stdiet-ui/src/utils/websocket.js +++ b/stdiet-ui/src/utils/websocket.js @@ -39,6 +39,7 @@ function connect() { ws.onerror = event => { // console.log({ event }); + ws.close(); ws = undefined; window.removeEventListener("message", handleOnMessageReceive); @@ -56,6 +57,7 @@ function connect() { } catch (error) { // console.log(error); // console.log("浏览器不支持websocket"); + ws.close(); ws = undefined; websocketInit(); } diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue index 23aefbb2d..aa9041f94 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue @@ -91,9 +91,9 @@ export default { data() { return { topicTypeDict: { - 0: "建议", - 1: "食谱", - 2: "咨询", + 0: "食材", + 1: "身体", + 2: "环境", }, replyTarget: "", replyContent: "", From f682efe7589d437cf6f07e3325d15a1bf26d1b72 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Thu, 3 Jun 2021 14:26:02 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=80=80=E5=87=BA=E5=85=B3=E9=97=ADws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/src/layout/components/Navbar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdiet-ui/src/layout/components/Navbar.vue b/stdiet-ui/src/layout/components/Navbar.vue index 2eaf0ebec..e26a0168d 100644 --- a/stdiet-ui/src/layout/components/Navbar.vue +++ b/stdiet-ui/src/layout/components/Navbar.vue @@ -72,7 +72,7 @@ export default { window.addEventListener("message", this.handleOnMessage); }, unmounted() { - beforeUnmount(); + beforeUnmount(1000); window.removeEventListener("message", this.handleOnMessage); }, computed: { From d495f47304117c3ec824d8091bd38651dbb56705 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Thu, 3 Jun 2021 17:37:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/filters/local/application.yml | 2 +- stdiet-ui/src/store/modules/message.js | 49 +++++++++++++++++-- stdiet-ui/src/views/custom/message/index.vue | 4 +- .../custom/message/messageBrowser/index.vue | 28 +++++++++-- .../views/custom/message/userInfo/index.vue | 38 ++++++++++++++ 5 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 stdiet-ui/src/views/custom/message/userInfo/index.vue diff --git a/stdiet-admin/src/main/filters/local/application.yml b/stdiet-admin/src/main/filters/local/application.yml index b3bead739..6932d7b76 100644 --- a/stdiet-admin/src/main/filters/local/application.yml +++ b/stdiet-admin/src/main/filters/local/application.yml @@ -83,7 +83,7 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://47.115.23.82:3306/stdiet?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://47.115.23.82:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 password: gzDxPaZcSiXJpi2N username: root slave: diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index 20270f7d4..e4f2bcb64 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -1,3 +1,6 @@ +import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; +import { dealHealthy } from "@/utils/healthyData"; + import { fetchTopicList, postTopicReply, @@ -9,7 +12,11 @@ const oriState = { pageNum: 1, topicList: [], detailData: {}, - selTopicId: "" + selTopicId: "", + healthyData: {}, + healthDataLoading: false, + healthyDataType: 0, + avoidFoodIds: [] }; const mutations = { @@ -46,10 +53,12 @@ const actions = { }); if (result.code === 200) { if (!detailData.topicId) { + // 默认展示第一个 const [defTopic] = result.rows; dispatch("fetchTopicDetailActions", { topicId: defTopic.topicId, - id: defTopic.id + id: defTopic.id, + uid: defTopic.uid }); } if (result.rows.length) { @@ -60,9 +69,15 @@ const actions = { } } }, - async fetchTopicDetailActions({ commit }, payload) { - const { topicId, id } = payload; + async fetchTopicDetailActions({ commit, dispatch, state }, payload) { + const { topicId, id, uid } = payload; + const { healthyData } = state; commit("save", { selTopicId: topicId }); + // 客户信息 + if (healthyData.customerId !== parseInt(uid)) { + dispatch("getHealthyData", { cusId: uid }); + } + // const result = await fetchTopicDetail({ topicId, id }); if (result.code === 200) { commit("save", { detailData: result.data[0] }); @@ -89,11 +104,35 @@ const actions = { if (tarTopic) { dispatch("fetchTopicDetailActions", { topicId: tarTopic.topicId, - id: tarTopic.id + id: tarTopic.id, + uid: tarTopic.uid }); } } return result; + }, + async getHealthyData({ commit }, payload) { + commit("save", { healthDataLoading: true }); + const healthyDataResult = await getCustomerPhysicalSignsByCusId( + payload.cusId + ); + let healthyData = undefined, + healthyDataType = 0; + if (healthyDataResult.code === 200) { + if (!healthyDataResult.data.customerHealthy) { + throw new Error("客户还没填写健康评估表"); + } + healthyDataType = healthyDataResult.data.type; + healthyData = dealHealthy(healthyDataResult.data.customerHealthy); + } else { + throw new Error(healthyDataResult.msg); + } + commit("save", { + healthDataLoading: false, + healthyDataType, + healthyData, + avoidFoodIds: (healthyData.avoidFood || []).map(obj => obj.id) + }); } }; diff --git a/stdiet-ui/src/views/custom/message/index.vue b/stdiet-ui/src/views/custom/message/index.vue index a2239526f..e6650663f 100644 --- a/stdiet-ui/src/views/custom/message/index.vue +++ b/stdiet-ui/src/views/custom/message/index.vue @@ -1,17 +1,19 @@