接入客户信息

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:
# 主库数据源
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:

View File

@ -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)
});
}
};

View File

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

View File

@ -16,7 +16,9 @@
}`"
/>
<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>
<div class="topic_info">
@ -98,6 +100,7 @@ export default {
replyTarget: "",
replyContent: "",
replyObj: {},
itemWidth: 160,
};
},
components: { Comment },
@ -106,6 +109,14 @@ export default {
},
mounted() {
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() {
window.removeEventListener("message", this.handleOnMessage);
@ -154,7 +165,12 @@ export default {
(obj) => obj.topicId === topicId
);
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.replyContent = "";
this.replyObj = {};
this.fetchTopicDetailActions({ topicId: data.topicId, id: data.id });
this.fetchTopicDetailActions({
topicId: data.topicId,
id: data.id,
uid: data.uid,
});
},
handleOnReplyTopic(data) {
this.replyTarget = "主题";
@ -265,7 +285,7 @@ export default {
flex: 1 0 0;
.topic_content {
width: 260px;
width: 100px;
overflow: hidden;
white-space: nowrap;
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>