接入客户信息

This commit is contained in:
huangdeliang 2021-06-03 17:37:59 +08:00
parent f682efe758
commit d495f47304
5 changed files with 110 additions and 11 deletions

View File

@ -83,7 +83,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: 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 password: gzDxPaZcSiXJpi2N
username: root username: root
slave: slave:

View File

@ -1,3 +1,6 @@
import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
import { dealHealthy } from "@/utils/healthyData";
import { import {
fetchTopicList, fetchTopicList,
postTopicReply, postTopicReply,
@ -9,7 +12,11 @@ const oriState = {
pageNum: 1, pageNum: 1,
topicList: [], topicList: [],
detailData: {}, detailData: {},
selTopicId: "" selTopicId: "",
healthyData: {},
healthDataLoading: false,
healthyDataType: 0,
avoidFoodIds: []
}; };
const mutations = { const mutations = {
@ -46,10 +53,12 @@ const actions = {
}); });
if (result.code === 200) { if (result.code === 200) {
if (!detailData.topicId) { if (!detailData.topicId) {
// 默认展示第一个
const [defTopic] = result.rows; const [defTopic] = result.rows;
dispatch("fetchTopicDetailActions", { dispatch("fetchTopicDetailActions", {
topicId: defTopic.topicId, topicId: defTopic.topicId,
id: defTopic.id id: defTopic.id,
uid: defTopic.uid
}); });
} }
if (result.rows.length) { if (result.rows.length) {
@ -60,9 +69,15 @@ const actions = {
} }
} }
}, },
async fetchTopicDetailActions({ commit }, payload) { async fetchTopicDetailActions({ commit, dispatch, state }, payload) {
const { topicId, id } = payload; const { topicId, id, uid } = payload;
const { healthyData } = state;
commit("save", { selTopicId: topicId }); commit("save", { selTopicId: topicId });
// 客户信息
if (healthyData.customerId !== parseInt(uid)) {
dispatch("getHealthyData", { cusId: uid });
}
//
const result = await fetchTopicDetail({ topicId, id }); const result = await fetchTopicDetail({ topicId, id });
if (result.code === 200) { if (result.code === 200) {
commit("save", { detailData: result.data[0] }); commit("save", { detailData: result.data[0] });
@ -89,11 +104,35 @@ const actions = {
if (tarTopic) { if (tarTopic) {
dispatch("fetchTopicDetailActions", { dispatch("fetchTopicDetailActions", {
topicId: tarTopic.topicId, topicId: tarTopic.topicId,
id: tarTopic.id id: tarTopic.id,
uid: tarTopic.uid
}); });
} }
} }
return result; 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)
});
} }
}; };

View File

@ -1,17 +1,19 @@
<template> <template>
<div class="user_message_wrapper"> <div class="user_message_wrapper">
<MessageBrowser /> <MessageBrowser />
<div class="info_zone"></div> <UserInfo />
</div> </div>
</template> </template>
<script> <script>
import MessageBrowser from "./messageBrowser/index"; import MessageBrowser from "./messageBrowser/index";
import UserInfo from "./userInfo/index";
export default { export default {
data() { data() {
return {}; return {};
}, },
components: { components: {
MessageBrowser, MessageBrowser,
UserInfo,
}, },
created() {}, created() {},
computed: {}, computed: {},

View File

@ -16,7 +16,9 @@
}`" }`"
/> />
<div class="topic_item_content"> <div class="topic_item_content">
<div class="topic_content">{{ topic.content }}</div> <div class="topic_content" :style="{ width: `${itemWidth}px` }">
{{ topic.content }}
</div>
<div class="topic_user_name">by {{ topic.name }}</div> <div class="topic_user_name">by {{ topic.name }}</div>
</div> </div>
<div class="topic_info"> <div class="topic_info">
@ -98,6 +100,7 @@ export default {
replyTarget: "", replyTarget: "",
replyContent: "", replyContent: "",
replyObj: {}, replyObj: {},
itemWidth: 160,
}; };
}, },
components: { Comment }, components: { Comment },
@ -106,6 +109,14 @@ export default {
}, },
mounted() { mounted() {
window.addEventListener("message", this.handleOnMessage); window.addEventListener("message", this.handleOnMessage);
setTimeout(() => {
const itemElm = document.querySelector(".topic_item");
if (itemElm) {
console.log(itemElm);
this.itemWidth = itemElm.clientWidth - 32 - 20 - 80;
}
}, 100);
}, },
unmounted() { unmounted() {
window.removeEventListener("message", this.handleOnMessage); window.removeEventListener("message", this.handleOnMessage);
@ -154,7 +165,12 @@ export default {
(obj) => obj.topicId === topicId (obj) => obj.topicId === topicId
); );
if (tarTopic) { if (tarTopic) {
this.fetchTopicDetailActions({ topicId, id: tarTopic.id }); console.log({ tarTopic });
this.fetchTopicDetailActions({
topicId,
id: tarTopic.id,
uid: tarTopic.uid,
});
} }
} }
} }
@ -166,7 +182,11 @@ export default {
this.replyTarget = ""; this.replyTarget = "";
this.replyContent = ""; this.replyContent = "";
this.replyObj = {}; this.replyObj = {};
this.fetchTopicDetailActions({ topicId: data.topicId, id: data.id }); this.fetchTopicDetailActions({
topicId: data.topicId,
id: data.id,
uid: data.uid,
});
}, },
handleOnReplyTopic(data) { handleOnReplyTopic(data) {
this.replyTarget = "主题"; this.replyTarget = "主题";
@ -265,7 +285,7 @@ export default {
flex: 1 0 0; flex: 1 0 0;
.topic_content { .topic_content {
width: 260px; width: 100px;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;

View File

@ -0,0 +1,38 @@
<template>
<div v-loading="healthDataLoading">
<HealthyView
dev
:data="healthyDataType === 0 ? healthyData : {}"
v-show="healthyDataType === 0"
/>
<BodySignView
dev
:data="healthyDataType === 1 ? healthyData : {}"
v-show="healthyDataType === 1"
/>
</div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
import HealthyView from "@/components/HealthyView";
import BodySignView from "@/components/BodySignView";
const {
mapActions,
mapState,
mapMutations,
mapGetters,
} = createNamespacedHelpers("message");
export default {
name: "SignUserInfo",
components: {
HealthyView,
BodySignView,
},
data() {
return {};
},
computed: {
...mapState(["healthyData", "healthyDataType", "healthDataLoading"]),
},
};
</script>