index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view class="box">
  3. <view class="box-top">
  4. <view class="box-top-title">
  5. {{ info.name }}
  6. <text class="subText">
  7. {{ info.postName }}
  8. <text v-if="info.postName && info.enterpriseName" class="gun">|</text>
  9. {{ info.enterpriseName }}
  10. </text>
  11. </view>
  12. <view class="box-top-content" v-if="interview.length">
  13. <view v-for="val in interview" :key="val.id" class="color-666">
  14. <view class="box-top-content-t">
  15. <view class="font-weight-bold color-primary">
  16. <text>{{ val.job.name }}</text>
  17. <text v-if="!val.job.payFrom && !val.job.payTo" class="ml-3">面议</text>
  18. <text v-else class="ml-3">{{ val.job.payFrom ? val.job.payFrom + '-' : '' }}{{ val.job.payTo }}</text>
  19. </view>
  20. <view :style="{'color': ['5', '98', '99'].includes(val.status) ? '#FE574A' : '#0E8E80'}">
  21. {{ showStatus(val.status) }}
  22. </view>
  23. </view>
  24. <view class="mt-1 font-size-14 ellipsis" style="max-width: 100%;">
  25. <view class="py-1">面试时间:{{ timesTampChange(val.time, 'Y-M-D h:m') }}</view>
  26. <view class="py-1">面试地点:{{ val.address }}</view>
  27. <view class="py-1">联系电话:{{ val.invitePhone }}</view>
  28. </view>
  29. <view class="bottom">
  30. <view class="tipsText" @click="handleToCenter">在“个人中心-面试”中管理我的面试</view>
  31. <view v-if="val.status === '0'">
  32. <v-btn class="mr-3" variant="outlined" color="error" size="small" @click="handleRefuse(val)">拒绝邀请</v-btn>
  33. <v-btn variant="outlined" color="primary" size="small" @click="handleAgree(val)">接受邀请</v-btn>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="box-main" ref="chatRef">
  40. <view class="box-main-more" v-if="hasMore">
  41. <text @click="handleMore">查看更多</text>
  42. </view>
  43. <view v-for="val in items" :key="val.id">
  44. <view class="box-main-time">{{ timesTampChange(+(val.timestamp.padEnd(13, '0'))) }}</view>
  45. <template v-if="val.payload?.type === 102">
  46. <view class="jobCard">
  47. <view class="jobCard-title"> {{ val.payload?.content?.positionInfo?.name }}</view>
  48. <view
  49. v-if="!val.payload?.content?.positionInfo?.payFrom && !val.payload?.content?.positionInfo?.payTo"
  50. class="jobCard-subtitle">
  51. 薪酬待遇: 面议
  52. </view>
  53. <view
  54. v-else
  55. class="jobCard-subtitle"
  56. >
  57. 薪酬待遇:
  58. {{ val.payload?.content?.positionInfo?.payFrom ? val.payload?.content?.positionInfo?.payFrom + ' - ' : '' }}
  59. {{ val.payload?.content?.positionInfo?.payTo }}
  60. </view>
  61. <view class="jobCard-tag">
  62. <view
  63. v-for="(v, i) in (val.payload?.content?.positionInfo?.enterprise?.welfareList || [])"
  64. :key="val.message_id + v + i"
  65. style="margin: 10rpx"
  66. >
  67. <uni-tag
  68. :text="v"
  69. type="success"
  70. />
  71. </view>
  72. </view>
  73. <view class="jobCard-divider"></view>
  74. <view class="jobCard-subtitle text-right">
  75. <v-avatar size="24">
  76. <v-img :src="val.payload?.content?.positionInfo?.contact?.avatar"></v-img>
  77. </v-avatar>
  78. {{ val.payload?.content?.positionInfo?.contact?.name }}
  79. {{ val.payload?.content?.positionInfo?.contact?.postNameCn }}
  80. {{ val.payload?.content?.positionInfo?.enterprise?.name }}
  81. </view>
  82. <div class="jobCard-subtitle text-right">
  83. 地址:{{ val.payload?.content?.positionInfo?.address }}
  84. </div>
  85. </view>
  86. </template>
  87. <view :class="['message-view_item', val.from_uid === IM.uid ? 'is-self' : 'is-other']">
  88. <view class="image">
  89. <image
  90. :data-target="getUserAvatar(info.avatar, info.sex)"
  91. class="header"
  92. :src="(
  93. val.from_uid === IM.uid ?
  94. getUserAvatar(useUserStore.baseInfo?.avatar, useUserStore.baseInfo?.sex) :
  95. getUserAvatar(info.avatar, info.sex)
  96. )"
  97. ></image>
  98. </view>
  99. <!-- 显示沟通职位 -->
  100. <template v-if="val.payload?.type === 102">
  101. <view class="message-text" :class="val.from_uid === IM.uid ? 'active' : ''">
  102. {{ val.payload?.content.text }}
  103. </view>
  104. </template>
  105. <!-- 发起面试邀请 -->
  106. <view class="message-text none" v-else-if="val.payload?.type === 101">
  107. <uni-tag text="发起了面试邀请" type="primary" />
  108. </view>
  109. <view class="message-text none" v-else-if="val.payload?.type === 103">
  110. <uni-tag text="拒绝了面试邀请" type="error" />
  111. </view>
  112. <view class="message-text none" v-else-if="val.payload?.type === 104">
  113. <uni-tag text="接受了面试邀请" type="success" />
  114. </view>
  115. <view v-else-if="val.payload.type === 105" class="text-end">
  116. <uni-tag
  117. v-if="val.from_uid === IM.uid"
  118. :text="val.payload.content?.type === 1 ? '附件简历已发送' : '简历请求已发送'"
  119. type="success"
  120. />
  121. <view
  122. v-if="val.payload.content?.type !== 2 || val.from_uid !== IM.uid"
  123. class="message-text card"
  124. >
  125. <view class="text-left">
  126. <text v-if="val.payload.content?.type === 1">{{
  127. val.payload.content?.query?.title || '附件简历' }}
  128. </text>
  129. <text v-if="val.payload.content?.type === 2">
  130. 我想要一份您的简历,您是否同意
  131. </text>
  132. </view>
  133. <view class="btn-actions">
  134. <text class="btn" v-if="val.payload.content?.type === 1" @tap="handlePreview(val.payload)">点击预览附件简历</text>
  135. <text class="btn" v-if="val.payload.content?.type === 2" @tap="handleFindResume">点击发送附件简历</text>
  136. </view>
  137. </view>
  138. </view>
  139. <view v-else class="message-text" :class="{ active: val.from_uid === IM.uid}">
  140. {{ val.payload?.content }}
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. <view class="box-bottom">
  146. <view class="box-bottom-tool">
  147. <uni-tag text="发送简历" type="success" @tap="handleFindResume"/>
  148. </view>
  149. <textarea
  150. auto-height
  151. confirm-type="send"
  152. @confirm="handleSend"
  153. />
  154. </view>
  155. <uni-popup ref="popup" background-color="#fff">
  156. <view class="popup-title">
  157. <text>请选择简历</text>
  158. <uni-icons type="closeempty" size="20" @tap="handleClose"></uni-icons>
  159. </view>
  160. <view v-for="resume in resumeList" :key="resume.id" class="popup-content" @tap="resumeCheck = resume">
  161. <view class="iconBox">
  162. <uni-icons
  163. v-show="resumeCheck.id === resume.id"
  164. type="checkmarkempty"
  165. size="20"
  166. :color="resumeCheck.id === resume.id ? '#43AC57' : '#999'"></uni-icons>
  167. </view>
  168. <text class="text" :class="resumeCheck.id === resume.id ? 'active' : ''">{{ resume.title }}</text>
  169. </view>
  170. <view class="popup-actions">
  171. <button class="default" type="default" @click="handleSendResume">发送简历</button>
  172. </view>
  173. </uni-popup>
  174. </view>
  175. </template>
  176. <script setup>
  177. import { ref, nextTick, watch, computed } from 'vue'
  178. import { useIMStore } from '@/store/im'
  179. import { userStore } from '@/store/user'
  180. import { timesTampChange } from '@/utils/date'
  181. import { getUserAvatar } from '@/utils/avatar'
  182. import { initConnect, send, initChart, getMoreMessages, checkConversation } from '@/hooks/useIM'
  183. import { onLoad } from '@dcloudio/uni-app'
  184. import { getPersonResumeCv } from '@/api/user'
  185. import { getInterviewInviteListByInviteUserId } from '@/api/common'
  186. import { getDict } from '@/hooks/useDictionaries'
  187. const useUserStore = userStore()
  188. const IM = useIMStore()
  189. const info = ref({})
  190. const chatRef = ref()
  191. const items = ref([])
  192. const channelItem = ref(null)
  193. const hasMore = ref(false)
  194. const popup = ref()
  195. const resumeCheck = ref({})
  196. const resumeList = ref([]) // 简历列表
  197. const pageSize = ref(1)
  198. // 求职者面试列表
  199. const interview = ref([])
  200. // 求职端-获取求职者与当前邀请人的面试记录
  201. const statusList = ref([])
  202. const {
  203. conversationList,
  204. updateConversation,
  205. updateUnreadCount,
  206. deleteConversations,
  207. resetUnread
  208. } = initConnect(async (successful) => {
  209. if (!successful) {
  210. Snackbar.error('发送失败')
  211. return
  212. }
  213. // chatRef.value.reset()
  214. // // 发送成功
  215. const { list } = await getMoreMessages(1, channelItem.value)
  216. // updateConversation()
  217. items.value = list.value
  218. // chatRef.value.scrollBottom()
  219. })
  220. watch(
  221. () => conversationList.value,
  222. async (val) => {
  223. if (!channelItem.value) {
  224. return
  225. }
  226. const { list } = await getMoreMessages(1, channelItem.value)
  227. items.value = list.value
  228. // if (Object.keys(info.value).length) updateUnreadMessageCount(val)
  229. },
  230. {
  231. deep: true,
  232. immediate: true
  233. }
  234. )
  235. async function init(userId, enterpriseId) {
  236. const { channel, list, more } = await initChart(userId, enterpriseId)
  237. hasMore.value = more
  238. channelItem.value = channel.value
  239. items.value = list.value
  240. }
  241. function showStatus (status) {
  242. return statusList.value.find(e => e.value === status)?.label
  243. }
  244. async function getInterviewInviteList () {
  245. if (!info.value.id) return
  246. const { data } = await getInterviewInviteListByInviteUserId(info.value.id)
  247. interview.value = data.slice(0, 1)
  248. }
  249. const getStatusList = () => {
  250. getDict('menduner_interview_invite_status').then(({data}) => {
  251. if (data.length) statusList.value = data
  252. })
  253. }
  254. function handleSend () {
  255. console.log('发送')
  256. }
  257. const getFileType = (url) => {
  258. const extension = url.split('.').pop().toLowerCase();
  259. switch (extension) {
  260. case 'pdf':
  261. return 'pdf';
  262. case 'doc':
  263. case 'docx':
  264. return 'doc';
  265. case 'xls':
  266. case 'xlsx':
  267. return 'xls';
  268. case 'ppt':
  269. case 'pptx':
  270. return 'ppt';
  271. case 'txt':
  272. return 'txt';
  273. default:
  274. return ''; // 不支持的文件类型
  275. }
  276. }
  277. // 预览简历
  278. function handlePreview (payload) {
  279. // 使用 wx.downloadFile 下载文档
  280. wx.downloadFile({
  281. url: payload.content.query.src,
  282. success: function (res) {
  283. // 下载成功后,打开文档
  284. if (res.statusCode === 200) {
  285. const fileType = getFileType(payload.content.query.src); // 动态获取文件类型
  286. if (fileType) {
  287. wx.openDocument({
  288. filePath: res.tempFilePath,
  289. fileType: fileType,
  290. success: function () {
  291. console.log('打开文档成功');
  292. },
  293. fail: function (error) {
  294. console.error('打开文档失败', error);
  295. }
  296. });
  297. } else {
  298. console.error('不支持的文件类型');
  299. }
  300. }
  301. },
  302. fail: function (error) {
  303. console.error('下载文件失败', error);
  304. }
  305. })
  306. }
  307. // 获取简历
  308. async function handleFindResume () {
  309. uni.showLoading({
  310. title: '真正查找简历'
  311. })
  312. try {
  313. // 获取简历列表
  314. const { data } = await getPersonResumeCv()
  315. if (data.length === 0) {
  316. Snackbar.error('您还未上传过简历,请先上传简历后再投递')
  317. return
  318. }
  319. resumeList.value = data
  320. resumeCheck.value = data[0]
  321. popup.value.open('center')
  322. } finally {
  323. uni.hideLoading()
  324. }
  325. }
  326. function handleClose () {
  327. popup.value.close()
  328. }
  329. function handleSendResume () {}
  330. async function handleMore () {
  331. try {
  332. uni.showLoading({
  333. title: '加载中...'
  334. })
  335. pageSize.value++
  336. const { list, more } = await getMoreMessages(pageSize.value, channelItem.value)
  337. items.value.unshift(...list.value)
  338. hasMore.value = more
  339. } finally {
  340. uni.hideLoading()
  341. }
  342. }
  343. onLoad(async (options) => {
  344. info.value = Object.keys(options).reduce((r, k) => {
  345. r[k] = decodeURIComponent(options[k])
  346. return r
  347. }, {})
  348. getStatusList()
  349. getInterviewInviteList()
  350. init(options.id, options.enterpriseId)
  351. })
  352. </script>
  353. <style lang="scss" scoped>
  354. .white {
  355. color: #FFF !important;
  356. }
  357. .text-left {
  358. text-align: left !important;
  359. }
  360. .text-right {
  361. text-align: right !important;
  362. }
  363. .box {
  364. width: 100%;
  365. height: 100vh;
  366. display: flex;
  367. flex-direction: column;
  368. &-top {
  369. &-title {
  370. padding: 0 60rpx;
  371. box-sizing: border-box;
  372. width: 100%;
  373. height: 80rpx;
  374. line-height: 80rpx;
  375. // text-align: center;
  376. border-bottom: 2rpx solid #EEE;
  377. overflow: hidden;
  378. white-space: nowrap;
  379. text-overflow: ellipsis;
  380. .subText {
  381. font-size: .85em;
  382. color: #999;
  383. .gun {
  384. padding: 0 10rpx;
  385. }
  386. }
  387. }
  388. &-content {
  389. padding: 20rpx 50rpx;
  390. padding-bottom: 20rpx;
  391. border-bottom: 2rpx solid #eee;
  392. .color-666 {
  393. color: #666;
  394. }
  395. .font-weight-bold {
  396. font-weight: bold;
  397. }
  398. .color-primary {
  399. color: #009688;
  400. }
  401. .ml-3 {
  402. margin-left: 40rpx;
  403. }
  404. .mt-1 {
  405. margin-top: 12rpx;
  406. }
  407. .font-size-14 {
  408. font-size: 24rpx;
  409. }
  410. .py-1 {
  411. padding: 4rpx 0;
  412. }
  413. .tipsText {
  414. font-size: .75em;
  415. color: #999;
  416. }
  417. &-t {
  418. display: flex;
  419. justify-content: space-between;
  420. }
  421. }
  422. }
  423. &-main {
  424. flex: 1;
  425. height: 0;
  426. padding: 40rpx;
  427. overflow-y: auto;
  428. &-more {
  429. display: flex;
  430. justify-content: center;
  431. align-items: center;
  432. color: #24bc3e;
  433. font-size: .9em;
  434. padding: 20rpx 0;
  435. }
  436. &-time {
  437. user-select: none;
  438. position: relative;
  439. top: 16rpx;
  440. margin: 40rpx 0;
  441. text-align: center;
  442. max-height: 40rpx;
  443. text-align: center;
  444. font-weight: 400;
  445. font-size: .85em;
  446. color: #999;
  447. }
  448. .jobCard {
  449. padding: 30rpx;
  450. background: #E2F2F0;
  451. color: #009688 ;
  452. margin-top: 20rpx;
  453. max-width: unset;
  454. margin-right: 0;
  455. &-title {
  456. font-size: 1.2em;
  457. }
  458. &-subtitle {
  459. padding: 10rpx 0;
  460. // font-size: .5em;
  461. }
  462. &-divider {
  463. width: 100%;
  464. height: 2rpx;
  465. margin: 20rpx 0;
  466. background: #ddd;
  467. }
  468. &-tag {
  469. display: flex;
  470. flex-wrap: wrap;
  471. }
  472. }
  473. .message-view_item {
  474. display: flex;
  475. flex-direction: row;
  476. align-items: flex-start;
  477. margin: 16rpx 0;
  478. position: relative;
  479. .image {
  480. width: 60rpx;
  481. height: 60rpx;
  482. border-radius: 180rpx;
  483. // flex-grow: 1;
  484. // flex-shrink: 0;
  485. overflow: hidden;
  486. .header {
  487. width: 60rpx;
  488. height: 60rpx;
  489. }
  490. }
  491. .text-end {
  492. text-align: right !important;
  493. width: 400rpx;
  494. margin-right: 20rpx;
  495. }
  496. .message-text {
  497. overflow-wrap: break-word;
  498. background-color: #f0f2f5;
  499. border-radius: 12rpx;
  500. max-width: 75%;
  501. padding: 20rpx;
  502. &.active {
  503. background: #d5e6e8;
  504. }
  505. &.card {
  506. background: #E2F2F0;
  507. color: #009688 ;
  508. margin-top: 20rpx;
  509. max-width: unset;
  510. margin-right: 0;
  511. .btn-actions {
  512. margin: 40rpx auto 20rpx auto ;
  513. text-align: center;
  514. .btn {
  515. padding: 10rpx 30rpx;
  516. background: #C8E7D8;
  517. color: #43AC57;
  518. font-size: .75em;
  519. border-radius: 10rpx;
  520. }
  521. }
  522. }
  523. &.none {
  524. padding: 10rpx 0;
  525. background-color: unset;
  526. }
  527. &.active {
  528. background: #d5e6e8;
  529. }
  530. }
  531. }
  532. .is-self {
  533. flex-direction: row-reverse;
  534. display: flex;
  535. .message-text {
  536. margin-right: 20rpx;
  537. }
  538. }
  539. .is-other {
  540. .message-text {
  541. margin-left: 20rpx;
  542. }
  543. }
  544. }
  545. &-bottom {
  546. max-height: 300rpx;
  547. border-top: 2rpx solid #EEE;
  548. background: rgba(230, 230, 230, 0.5);
  549. padding: 20rpx 40rpx;
  550. box-sizing: border-box;
  551. &-tool {
  552. margin-bottom: 40rpx;
  553. }
  554. textarea {
  555. border-radius: 10rpx;
  556. width: 100%;
  557. min-height: 80rpx;
  558. max-height: 180rpx;
  559. padding: 20rpx;
  560. box-sizing: border-box;
  561. background: #FFF;
  562. }
  563. }
  564. .popup-title {
  565. padding: 30rpx 20rpx;
  566. display: flex;
  567. justify-content: space-between;
  568. border-bottom: 2rpx solid #DDD;
  569. }
  570. .popup-content {
  571. padding: 20rpx 40rpx;
  572. color: #999;
  573. display: flex;
  574. align-content: center;
  575. justify-items: center;
  576. .iconBox {
  577. width: 40rpx;
  578. }
  579. .text {
  580. margin-left: 20rpx;
  581. &.active {
  582. color: #43AC57;
  583. }
  584. }
  585. }
  586. .popup-actions {
  587. padding: 60rpx;
  588. .default {
  589. background: #43AC57;
  590. color: #DDD;
  591. font-size: .9em;
  592. }
  593. }
  594. }
  595. </style>