index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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. v-model="inputValue"
  151. auto-height
  152. confirm-type="send"
  153. @confirm="handleSend"
  154. />
  155. </view>
  156. <uni-popup ref="popup" background-color="#fff">
  157. <view class="popup-title">
  158. <text>请选择简历</text>
  159. <uni-icons type="closeempty" size="20" @tap="handleClose"></uni-icons>
  160. </view>
  161. <view v-for="resume in resumeList" :key="resume.id" class="popup-content" @tap="resumeCheck = resume">
  162. <view class="iconBox">
  163. <uni-icons
  164. v-show="resumeCheck.id === resume.id"
  165. type="checkmarkempty"
  166. size="20"
  167. :color="resumeCheck.id === resume.id ? '#43AC57' : '#999'"></uni-icons>
  168. </view>
  169. <text class="text" :class="resumeCheck.id === resume.id ? 'active' : ''">{{ resume.title }}</text>
  170. </view>
  171. <view class="popup-actions">
  172. <button class="default" type="default" @click="handleSendResume">发送简历</button>
  173. </view>
  174. </uni-popup>
  175. </view>
  176. </template>
  177. <script setup>
  178. import { ref, nextTick, watch, computed } from 'vue'
  179. import { useIMStore } from '@/store/im'
  180. import { userStore } from '@/store/user'
  181. import { timesTampChange } from '@/utils/date'
  182. import { getUserAvatar } from '@/utils/avatar'
  183. import { initConnect, send, initChart, getMoreMessages, checkConversation } from '@/hooks/useIM'
  184. import { onLoad } from '@dcloudio/uni-app'
  185. import { getPersonResumeCv } from '@/api/user'
  186. import { getInterviewInviteListByInviteUserId } from '@/api/common'
  187. import { getDict } from '@/hooks/useDictionaries'
  188. const useUserStore = userStore()
  189. const IM = useIMStore()
  190. const info = ref({})
  191. const chatRef = ref()
  192. const items = ref([])
  193. const channelItem = ref(null)
  194. const hasMore = ref(false)
  195. const popup = ref()
  196. const resumeCheck = ref({})
  197. const resumeList = ref([]) // 简历列表
  198. const pageSize = ref(1)
  199. // 求职者面试列表
  200. const interview = ref([])
  201. // 求职端-获取求职者与当前邀请人的面试记录
  202. const statusList = ref([])
  203. const inputValue = ref('')
  204. const {
  205. conversationList,
  206. updateConversation,
  207. updateUnreadCount,
  208. deleteConversations,
  209. resetUnread
  210. } = initConnect(async (successful) => {
  211. if (!successful) {
  212. uni.showToast({
  213. title: '发送失败',
  214. icon: 'none',
  215. mask: true,
  216. })
  217. return
  218. }
  219. inputValue.value = ''
  220. // chatRef.value.reset()
  221. // // 发送成功
  222. const { list } = await getMoreMessages(1, channelItem.value)
  223. // updateConversation()
  224. items.value = list.value
  225. // chatRef.value.scrollBottom()
  226. })
  227. watch(
  228. () => conversationList.value,
  229. async (val) => {
  230. if (!channelItem.value) {
  231. return
  232. }
  233. const { list } = await getMoreMessages(1, channelItem.value)
  234. items.value = list.value
  235. // if (Object.keys(info.value).length) updateUnreadMessageCount(val)
  236. },
  237. {
  238. deep: true,
  239. immediate: true
  240. }
  241. )
  242. async function init(userId, enterpriseId) {
  243. const { channel, list, more } = await initChart(userId, enterpriseId)
  244. hasMore.value = more
  245. channelItem.value = channel.value
  246. items.value = list.value
  247. }
  248. function showStatus (status) {
  249. return statusList.value.find(e => e.value === status)?.label
  250. }
  251. async function getInterviewInviteList () {
  252. if (!info.value.id) return
  253. const { data } = await getInterviewInviteListByInviteUserId(info.value.id)
  254. interview.value = data.slice(0, 1)
  255. }
  256. const getStatusList = () => {
  257. getDict('menduner_interview_invite_status').then(({data}) => {
  258. if (data.length) statusList.value = data
  259. })
  260. }
  261. function handleSend () {
  262. send(inputValue.value, channelItem.value)
  263. }
  264. const getFileType = (url) => {
  265. const extension = url.split('.').pop().toLowerCase();
  266. switch (extension) {
  267. case 'pdf':
  268. return 'pdf';
  269. case 'doc':
  270. case 'docx':
  271. return 'doc';
  272. case 'xls':
  273. case 'xlsx':
  274. return 'xls';
  275. case 'ppt':
  276. case 'pptx':
  277. return 'ppt';
  278. case 'txt':
  279. return 'txt';
  280. default:
  281. return ''; // 不支持的文件类型
  282. }
  283. }
  284. // 预览简历
  285. function handlePreview (payload) {
  286. // 使用 wx.downloadFile 下载文档
  287. wx.downloadFile({
  288. url: payload.content.query.src,
  289. success: function (res) {
  290. // 下载成功后,打开文档
  291. if (res.statusCode === 200) {
  292. const fileType = getFileType(payload.content.query.src); // 动态获取文件类型
  293. if (fileType) {
  294. wx.openDocument({
  295. filePath: res.tempFilePath,
  296. fileType: fileType,
  297. success: function () {
  298. console.log('打开文档成功');
  299. },
  300. fail: function (error) {
  301. console.error('打开文档失败', error);
  302. }
  303. });
  304. } else {
  305. console.error('不支持的文件类型');
  306. }
  307. }
  308. },
  309. fail: function (error) {
  310. console.error('下载文件失败', error);
  311. }
  312. })
  313. }
  314. // 获取简历
  315. async function handleFindResume () {
  316. uni.showLoading({
  317. title: '真正查找简历'
  318. })
  319. try {
  320. // 获取简历列表
  321. const { data } = await getPersonResumeCv()
  322. if (data.length === 0) {
  323. uni.showToast({
  324. title: '您还未上传过简历,请先上传简历后再投递',
  325. icon: 'none',
  326. mask: true,
  327. })
  328. return
  329. }
  330. resumeList.value = data
  331. resumeCheck.value = data[0]
  332. popup.value.open('center')
  333. } finally {
  334. uni.hideLoading()
  335. }
  336. }
  337. function handleClose () {
  338. popup.value.close()
  339. }
  340. function handleSendResume () {}
  341. async function handleMore () {
  342. try {
  343. uni.showLoading({
  344. title: '加载中...'
  345. })
  346. pageSize.value++
  347. const { list, more } = await getMoreMessages(pageSize.value, channelItem.value)
  348. items.value.unshift(...list.value)
  349. hasMore.value = more
  350. } finally {
  351. uni.hideLoading()
  352. }
  353. }
  354. onLoad(async (options) => {
  355. info.value = Object.keys(options).reduce((r, k) => {
  356. r[k] = decodeURIComponent(options[k])
  357. return r
  358. }, {})
  359. getStatusList()
  360. getInterviewInviteList()
  361. init(options.id, options.enterpriseId)
  362. })
  363. </script>
  364. <style lang="scss" scoped>
  365. .white {
  366. color: #FFF !important;
  367. }
  368. .text-left {
  369. text-align: left !important;
  370. }
  371. .text-right {
  372. text-align: right !important;
  373. }
  374. .box {
  375. width: 100%;
  376. height: 100vh;
  377. display: flex;
  378. flex-direction: column;
  379. &-top {
  380. &-title {
  381. padding: 0 60rpx;
  382. box-sizing: border-box;
  383. width: 100%;
  384. height: 80rpx;
  385. line-height: 80rpx;
  386. // text-align: center;
  387. border-bottom: 2rpx solid #EEE;
  388. overflow: hidden;
  389. white-space: nowrap;
  390. text-overflow: ellipsis;
  391. .subText {
  392. font-size: .85em;
  393. color: #999;
  394. .gun {
  395. padding: 0 10rpx;
  396. }
  397. }
  398. }
  399. &-content {
  400. padding: 20rpx 50rpx;
  401. padding-bottom: 20rpx;
  402. border-bottom: 2rpx solid #eee;
  403. .color-666 {
  404. color: #666;
  405. }
  406. .font-weight-bold {
  407. font-weight: bold;
  408. }
  409. .color-primary {
  410. color: #009688;
  411. }
  412. .ml-3 {
  413. margin-left: 40rpx;
  414. }
  415. .mt-1 {
  416. margin-top: 12rpx;
  417. }
  418. .font-size-14 {
  419. font-size: 24rpx;
  420. }
  421. .py-1 {
  422. padding: 4rpx 0;
  423. }
  424. .tipsText {
  425. font-size: .75em;
  426. color: #999;
  427. }
  428. &-t {
  429. display: flex;
  430. justify-content: space-between;
  431. }
  432. }
  433. }
  434. &-main {
  435. flex: 1;
  436. height: 0;
  437. padding: 40rpx;
  438. overflow-y: auto;
  439. &-more {
  440. display: flex;
  441. justify-content: center;
  442. align-items: center;
  443. color: #24bc3e;
  444. font-size: .9em;
  445. padding: 20rpx 0;
  446. }
  447. &-time {
  448. user-select: none;
  449. position: relative;
  450. top: 16rpx;
  451. margin: 40rpx 0;
  452. text-align: center;
  453. max-height: 40rpx;
  454. text-align: center;
  455. font-weight: 400;
  456. font-size: .85em;
  457. color: #999;
  458. }
  459. .jobCard {
  460. padding: 30rpx;
  461. background: #E2F2F0;
  462. color: #009688 ;
  463. margin-top: 20rpx;
  464. max-width: unset;
  465. margin-right: 0;
  466. &-title {
  467. font-size: 1.2em;
  468. }
  469. &-subtitle {
  470. padding: 10rpx 0;
  471. // font-size: .5em;
  472. }
  473. &-divider {
  474. width: 100%;
  475. height: 2rpx;
  476. margin: 20rpx 0;
  477. background: #ddd;
  478. }
  479. &-tag {
  480. display: flex;
  481. flex-wrap: wrap;
  482. }
  483. }
  484. .message-view_item {
  485. display: flex;
  486. flex-direction: row;
  487. align-items: flex-start;
  488. margin: 16rpx 0;
  489. position: relative;
  490. .image {
  491. width: 60rpx;
  492. height: 60rpx;
  493. border-radius: 180rpx;
  494. // flex-grow: 1;
  495. // flex-shrink: 0;
  496. overflow: hidden;
  497. .header {
  498. width: 60rpx;
  499. height: 60rpx;
  500. }
  501. }
  502. .text-end {
  503. text-align: right !important;
  504. width: 400rpx;
  505. margin-right: 20rpx;
  506. }
  507. .message-text {
  508. overflow-wrap: break-word;
  509. background-color: #f0f2f5;
  510. border-radius: 12rpx;
  511. max-width: 75%;
  512. padding: 20rpx;
  513. &.active {
  514. background: #d5e6e8;
  515. }
  516. &.card {
  517. background: #E2F2F0;
  518. color: #009688 ;
  519. margin-top: 20rpx;
  520. max-width: unset;
  521. margin-right: 0;
  522. .btn-actions {
  523. margin: 40rpx auto 20rpx auto ;
  524. text-align: center;
  525. .btn {
  526. padding: 10rpx 30rpx;
  527. background: #C8E7D8;
  528. color: #43AC57;
  529. font-size: .75em;
  530. border-radius: 10rpx;
  531. }
  532. }
  533. }
  534. &.none {
  535. padding: 10rpx 0;
  536. background-color: unset;
  537. }
  538. &.active {
  539. background: #d5e6e8;
  540. }
  541. }
  542. }
  543. .is-self {
  544. flex-direction: row-reverse;
  545. display: flex;
  546. .message-text {
  547. margin-right: 20rpx;
  548. }
  549. }
  550. .is-other {
  551. .message-text {
  552. margin-left: 20rpx;
  553. }
  554. }
  555. }
  556. &-bottom {
  557. max-height: 300rpx;
  558. border-top: 2rpx solid #EEE;
  559. background: rgba(230, 230, 230, 0.5);
  560. padding: 20rpx 40rpx;
  561. box-sizing: border-box;
  562. &-tool {
  563. margin-bottom: 40rpx;
  564. }
  565. textarea {
  566. border-radius: 10rpx;
  567. width: 100%;
  568. min-height: 80rpx;
  569. max-height: 180rpx;
  570. padding: 20rpx;
  571. box-sizing: border-box;
  572. background: #FFF;
  573. }
  574. }
  575. .popup-title {
  576. padding: 30rpx 20rpx;
  577. display: flex;
  578. justify-content: space-between;
  579. border-bottom: 2rpx solid #DDD;
  580. }
  581. .popup-content {
  582. padding: 20rpx 40rpx;
  583. color: #999;
  584. display: flex;
  585. align-content: center;
  586. justify-items: center;
  587. .iconBox {
  588. width: 40rpx;
  589. }
  590. .text {
  591. margin-left: 20rpx;
  592. &.active {
  593. color: #43AC57;
  594. }
  595. }
  596. }
  597. .popup-actions {
  598. padding: 60rpx;
  599. .default {
  600. background: #43AC57;
  601. color: #DDD;
  602. font-size: .9em;
  603. }
  604. }
  605. }
  606. </style>