index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div style="background-color: #f0f2f5; padding-bottom: 20px; min-height: 100%;">
  3. <!-- 客户详情 -->
  4. <div v-if="showDetail">
  5. <div style="padding: 20px; background-color: #fff;">
  6. 客户详情
  7. </div>
  8. <!-- 用户头像 -->
  9. <div style="padding: 20px 10px 0 10px;background-image: linear-gradient(to right, #e0edff, #dfe0fe)">
  10. <div style="padding: 20px 10px 0 10px;background-image: linear-gradient(to right, #edf5ff, #ecedff);display: flex;border-radius: 8px;">
  11. <div style="padding: 10px">
  12. <el-avatar :size="50" :src="qwUserInfo.avatar"/>
  13. </div>
  14. <div style="padding: 10px;display: flex;flex-direction: column;align-items: flex-start;justify-content: center;">
  15. <div>
  16. <span style="font-size: 16px;">{{qwUserInfo.name}}</span>
  17. </div>
  18. <div>
  19. <span style="font-size: 14px;color: #8c939d">备注:{{qwUserInfo.remark}}</span>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <!-- 基本信息 -->
  25. <div>
  26. <div style="display: flex;justify-content: space-between;align-items: center;flex-direction: row;background: #FFF;padding: 10px">
  27. <div>
  28. 基本信息
  29. </div>
  30. <div>
  31. <el-button size="mini" round @click="updateQwDetail">修改用户信息</el-button>
  32. </div>
  33. </div>
  34. <div style="background: #FFF; padding: 0 10px 10px 20px;color: #8c939d">
  35. <el-row>
  36. <span style="font-size: 14px;">性别:</span>
  37. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.sex || '未知'}}</span>
  38. </el-row>
  39. <el-row style="margin-top: 10px">
  40. <span style="font-size: 14px;">年龄:</span>
  41. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.age || '未知'}}</span>
  42. </el-row>
  43. <el-row style="margin-top: 10px">
  44. <span style="font-size: 14px;">行为习惯:</span>
  45. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.habits || '无'}}</span>
  46. </el-row>
  47. <el-row style="margin-top: 10px">
  48. <span style="font-size: 14px;">患病时间:</span>
  49. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.illnessTime || '无'}}</span>
  50. </el-row>
  51. <el-row style="margin-top: 10px">
  52. <span style="font-size: 14px;">疾病:</span>
  53. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.disease || '无'}}</span>
  54. </el-row>
  55. <el-row style="margin-top: 10px">
  56. <span style="font-size: 14px;">家人的疾病:</span>
  57. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.familyDisease || '无'}}</span>
  58. </el-row>
  59. <el-row style="margin-top: 10px">
  60. <span style="font-size: 14px;">是否线下就诊:</span>
  61. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.isLine || '无'}}</span>
  62. </el-row>
  63. <el-row style="margin-top: 10px">
  64. <span style="font-size: 14px;">体质:</span>
  65. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.constitution || '无'}}</span>
  66. </el-row>
  67. <el-row style="margin-top: 10px">
  68. <span style="font-size: 14px;">使用药品:</span>
  69. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.medicine || '无'}}</span>
  70. </el-row>
  71. <el-row style="margin-top: 10px">
  72. <span style="font-size: 14px;">咨询产品:</span>
  73. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.consultProduct || '无'}}</span>
  74. </el-row>
  75. <el-row style="margin-top: 10px">
  76. <span style="font-size: 14px;">是否已经购买产品:</span>
  77. <span style="font-size: 14px;margin-left: 10px">{{qwUserDetail.isBuy || '无'}}</span>
  78. </el-row>
  79. </div>
  80. </div>
  81. <!-- 看课记录 -->
  82. <div style="background-color: #FFF">
  83. <div style="padding: 10px;">
  84. 看课记录
  85. </div>
  86. <!-- 状态 -->
  87. <div class="status-container">
  88. <div
  89. v-for="(item, index) in logTypeList"
  90. :key="index"
  91. class="status-item"
  92. >
  93. <div
  94. class="status-color-block"
  95. :style="{ backgroundColor: item.color }"
  96. ></div>
  97. <span class="status-text">{{ item.text }}</span>
  98. </div>
  99. </div>
  100. <!-- 近七天看课记录 -->
  101. <div>
  102. <div style="display: flex;justify-content: space-between;align-items: center;flex-direction: row;background: #FFF;padding: 10px 0 20px 0">
  103. <div class="section-title">
  104. 近七天看课记录
  105. </div>
  106. <el-button size="mini" round @click="courseManage">课程管理</el-button>
  107. </div>
  108. <div class="course-record-container">
  109. <div
  110. v-for="item in courseWatch7day"
  111. :key="item.id"
  112. class="course-record-item"
  113. >
  114. <span class="course-date">{{ item.date.split('-')[2] }}日</span>
  115. <div
  116. class="course-status-block"
  117. :style="{ backgroundColor: getLogTypeColor(item.logType) }"
  118. :title="getLogTypeText(item.logType)"
  119. ></div>
  120. </div>
  121. <div v-if="courseWatch7day.length === 0" class="empty-record">
  122. 暂无看课记录
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <!-- 修改用户信息 -->
  129. <user-info-edit
  130. v-if="showUpdate"
  131. :userDetail="qwUserDetail"
  132. @back="handleBack"
  133. @save-success="handleSaveSuccess"
  134. />
  135. <!-- 课程管理 -->
  136. <course-manage
  137. v-if="showCourseManage"
  138. :userId="qwUserInfo.id"
  139. @back="handleBack"
  140. />
  141. <!-- 催课管理 -->
  142. <remind-course-manage
  143. v-if="showRemindCourseManage"
  144. :user-id="qwUserDetail.id"
  145. @back="handleBack"
  146. />
  147. <!-- <div class="contentx" v-if="item.userId != null" >-->
  148. <!-- <div class="desct">-->
  149. <!-- 用户订单-->
  150. <!-- </div>-->
  151. <!-- <userStorerDetails ref="userDetails" />-->
  152. <!-- </div>-->
  153. <!-- <div class="contentx" v-if="item.userId != null" >-->
  154. <!-- <div class="desct">-->
  155. <!-- 用户看客记录-->
  156. <!-- </div>-->
  157. <!-- <userCourseWatchLog ref="userWatchLog" />-->
  158. <!-- </div>-->
  159. </div>
  160. </template>
  161. <script>
  162. import userStorerDetails from "@/views/qw/qwChat/userDetail/userStorerDetails.vue"
  163. import userCourseWatchLog from "@/views/qw/qwChat/userDetail/userCourseWatchLog.vue";
  164. import userInfoEdit from "@/views/qw/qwChat/userDetail/userInfoEdit.vue";
  165. import courseManage from "@/views/qw/qwChat/userDetail/courseManage.vue";
  166. import remindCourseManage from "@/views/qw/qwChat/userDetail/remindCourseManage.vue";
  167. import {getQwExternalContactDetails, getQwUserInfo, queryCourseWatchStatistics} from "@/api/qw/im";
  168. export default {
  169. name: "userDetail",
  170. components: {
  171. userStorerDetails,
  172. userCourseWatchLog,
  173. userInfoEdit,
  174. courseManage,
  175. remindCourseManage
  176. },
  177. data() {
  178. // 定义颜色常量
  179. const logTypeColors = {
  180. notWatched: '#909399', // 未看课
  181. watching: '#0bc6ff', // 看课中
  182. completed: '#67c23a', // 完课
  183. pending: '#f55a4f', // 待看课
  184. interrupted: '#ffd700' // 看课中断
  185. };
  186. return {
  187. extId: null,
  188. qwUserInfo: {},
  189. qwUserDetail: {},
  190. showDetail: true,
  191. showUpdate: false,
  192. courseWatch7day: [],
  193. logTypeColors,
  194. // 定义状态列表用于渲染
  195. logTypeList: [
  196. { type: 0, text: '未看课', color: logTypeColors.notWatched },
  197. { type: 1, text: '看课中', color: logTypeColors.watching },
  198. { type: 2, text: '完课', color: logTypeColors.completed },
  199. { type: 3, text: '待看课', color: logTypeColors.pending },
  200. { type: 4, text: '看课中断', color: logTypeColors.interrupted }
  201. ],
  202. showCourseManage: false,
  203. showRemindCourseManage: false
  204. }
  205. },
  206. methods: {
  207. getDetail(extId) {
  208. this.extId = extId
  209. this.getQwExternalContactDetails()
  210. this.getQwUserInfo()
  211. this.queryCourseWatchStatistics()
  212. },
  213. queryCourseWatchStatistics() {
  214. const data = {
  215. type: 0,
  216. qwExternalContactId: this.extId
  217. }
  218. queryCourseWatchStatistics(data).then(response => {
  219. this.courseWatch7day = response.data.data
  220. })
  221. },
  222. getQwExternalContactDetails() {
  223. const query = {
  224. qwExternalContactId: this.extId
  225. }
  226. getQwExternalContactDetails(query).then(response => {
  227. this.qwUserInfo = response.data
  228. })
  229. },
  230. getQwUserInfo() {
  231. const query = {
  232. qwExternalContactId: this.extId
  233. }
  234. getQwUserInfo(query).then(response => {
  235. this.qwUserDetail = response.moreInfo
  236. })
  237. },
  238. updateQwDetail() {
  239. this.showDetail = false
  240. this.showUpdate = true
  241. },
  242. handleBack() {
  243. this.getQwUserInfo()
  244. this.showDetail = true
  245. this.showUpdate = false
  246. this.showCourseManage = false
  247. this.showRemindCourseManage = false
  248. },
  249. handleSaveSuccess() {
  250. this.handleBack()
  251. },
  252. getLogTypeColor(logType) {
  253. const type = parseInt(logType);
  254. // 使用对象映射替代switch语句
  255. const colorMap = {
  256. 0: this.logTypeColors.notWatched,
  257. 1: this.logTypeColors.watching,
  258. 2: this.logTypeColors.completed,
  259. 3: this.logTypeColors.pending,
  260. 4: this.logTypeColors.interrupted
  261. };
  262. return colorMap[type] || '';
  263. },
  264. getLogTypeText(logType) {
  265. const type = parseInt(logType);
  266. // 使用对象映射替代switch语句
  267. const textMap = {
  268. 0: '未看课',
  269. 1: '看课中',
  270. 2: '完课',
  271. 3: '待看课',
  272. 4: '看课中断'
  273. };
  274. return textMap[type] || '';
  275. },
  276. courseManage() {
  277. this.showDetail = false
  278. this.showCourseManage = true
  279. },
  280. remindCourseManage() {
  281. this.showDetail = false
  282. this.showRemindCourseManage = true
  283. }
  284. }
  285. }
  286. </script>
  287. <style scoped>
  288. .status-container {
  289. display: flex;
  290. gap: 20px;
  291. padding: 10px 0 0 20px;
  292. color: #8c939d;
  293. }
  294. .status-item {
  295. display: flex;
  296. align-items: center;
  297. gap: 5px;
  298. }
  299. .status-color-block {
  300. border-radius: 4px;
  301. width: 20px;
  302. height: 20px;
  303. }
  304. .status-text {
  305. font-size: 12px;
  306. }
  307. .section-title {
  308. padding: 10px;
  309. font-size: 12px;
  310. color: #8c939d;
  311. }
  312. .course-record-container {
  313. display: flex;
  314. padding: 0 10px 15px 10px;
  315. gap: 10px;
  316. overflow-x: auto;
  317. }
  318. .course-record-item {
  319. display: flex;
  320. flex-direction: column;
  321. align-items: center;
  322. min-width: 40px;
  323. }
  324. .course-date {
  325. font-size: 12px;
  326. color: #606266;
  327. margin-bottom: 5px;
  328. }
  329. .course-status-block {
  330. width: 20px;
  331. height: 20px;
  332. border-radius: 4px;
  333. display: flex;
  334. justify-content: center;
  335. align-items: center;
  336. }
  337. .empty-record {
  338. width: 100%;
  339. text-align: center;
  340. color: #909399;
  341. font-size: 14px;
  342. }
  343. </style>