index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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: ${val.statusColor}`" >
  21. {{ val.statusText }}
  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. console.log(val.value)
  231. if (!channelItem.value) {
  232. return
  233. }
  234. const { list } = await getMoreMessages(1, channelItem.value)
  235. items.value = list.value
  236. // if (Object.keys(info.value).length) updateUnreadMessageCount(val)
  237. },
  238. {
  239. deep: true,
  240. immediate: true
  241. }
  242. )
  243. async function init(userId, enterpriseId) {
  244. const { channel, list, more } = await initChart(userId, enterpriseId)
  245. hasMore.value = more
  246. channelItem.value = channel.value
  247. items.value = list.value
  248. }
  249. function showStatus (status) {
  250. return statusList.value.find(e => e.value === status)?.label
  251. }
  252. async function getInterviewInviteList () {
  253. if (!info.value.id) return
  254. const { data } = await getInterviewInviteListByInviteUserId(info.value.id)
  255. interview.value = data.slice(0, 1).map(e => {
  256. const statusItem = statusList.value.find(_e => _e.value === e.status)
  257. const statusText = statusItem?.label || ''
  258. const statusColor = ['5', '98', '99'].includes(e.status)
  259. return {
  260. ...e,
  261. statusColor: statusColor ? '#FE574A' : '#0E8E80',
  262. statusText
  263. }
  264. })
  265. }
  266. const getStatusList = () => {
  267. getDict('menduner_interview_invite_status').then(({data}) => {
  268. if (data.length) statusList.value = data
  269. })
  270. }
  271. function handleSend () {
  272. send(inputValue.value, channelItem.value)
  273. }
  274. const getFileType = (url) => {
  275. const extension = url.split('.').pop().toLowerCase();
  276. switch (extension) {
  277. case 'pdf':
  278. return 'pdf';
  279. case 'doc':
  280. case 'docx':
  281. return 'doc';
  282. case 'xls':
  283. case 'xlsx':
  284. return 'xls';
  285. case 'ppt':
  286. case 'pptx':
  287. return 'ppt';
  288. case 'txt':
  289. return 'txt';
  290. default:
  291. return ''; // 不支持的文件类型
  292. }
  293. }
  294. // 预览简历
  295. function handlePreview (payload) {
  296. // 使用 wx.downloadFile 下载文档
  297. wx.downloadFile({
  298. url: payload.content.query.src,
  299. success: function (res) {
  300. // 下载成功后,打开文档
  301. if (res.statusCode === 200) {
  302. const fileType = getFileType(payload.content.query.src); // 动态获取文件类型
  303. if (fileType) {
  304. wx.openDocument({
  305. filePath: res.tempFilePath,
  306. fileType: fileType,
  307. success: function () {
  308. console.log('打开文档成功');
  309. },
  310. fail: function (error) {
  311. console.error('打开文档失败', error);
  312. }
  313. });
  314. } else {
  315. console.error('不支持的文件类型');
  316. }
  317. }
  318. },
  319. fail: function (error) {
  320. console.error('下载文件失败', error);
  321. }
  322. })
  323. }
  324. // 获取简历
  325. async function handleFindResume () {
  326. uni.showLoading({
  327. title: '真正查找简历'
  328. })
  329. try {
  330. // 获取简历列表
  331. const { data } = await getPersonResumeCv()
  332. if (data.length === 0) {
  333. uni.showToast({
  334. title: '您还未上传过简历,请先上传简历后再投递',
  335. icon: 'none',
  336. mask: true,
  337. })
  338. return
  339. }
  340. resumeList.value = data
  341. resumeCheck.value = data[0]
  342. popup.value.open('center')
  343. } finally {
  344. uni.hideLoading()
  345. }
  346. }
  347. function handleClose () {
  348. popup.value.close()
  349. }
  350. function handleSendResume () {}
  351. async function handleMore () {
  352. try {
  353. uni.showLoading({
  354. title: '加载中...'
  355. })
  356. pageSize.value++
  357. const { list, more } = await getMoreMessages(pageSize.value, channelItem.value)
  358. items.value.unshift(...list.value)
  359. hasMore.value = more
  360. } finally {
  361. uni.hideLoading()
  362. }
  363. }
  364. onLoad(async (options) => {
  365. info.value = Object.keys(options).reduce((r, k) => {
  366. r[k] = decodeURIComponent(options[k])
  367. return r
  368. }, {})
  369. getStatusList()
  370. getInterviewInviteList()
  371. init(options.id, options.enterpriseId)
  372. })
  373. </script>
  374. <style lang="scss" scoped>
  375. .white {
  376. color: #FFF !important;
  377. }
  378. .text-left {
  379. text-align: left !important;
  380. }
  381. .text-right {
  382. text-align: right !important;
  383. }
  384. .box {
  385. width: 100%;
  386. height: 100vh;
  387. display: flex;
  388. flex-direction: column;
  389. &-top {
  390. &-title {
  391. padding: 0 60rpx;
  392. box-sizing: border-box;
  393. width: 100%;
  394. height: 80rpx;
  395. line-height: 80rpx;
  396. // text-align: center;
  397. border-bottom: 2rpx solid #EEE;
  398. overflow: hidden;
  399. white-space: nowrap;
  400. text-overflow: ellipsis;
  401. .subText {
  402. font-size: .85em;
  403. color: #999;
  404. .gun {
  405. padding: 0 10rpx;
  406. }
  407. }
  408. }
  409. &-content {
  410. padding: 20rpx 50rpx;
  411. padding-bottom: 20rpx;
  412. border-bottom: 2rpx solid #eee;
  413. .color-666 {
  414. color: #666;
  415. }
  416. .font-weight-bold {
  417. font-weight: bold;
  418. }
  419. .color-primary {
  420. color: #009688;
  421. }
  422. .ml-3 {
  423. margin-left: 40rpx;
  424. }
  425. .mt-1 {
  426. margin-top: 12rpx;
  427. }
  428. .font-size-14 {
  429. font-size: 24rpx;
  430. }
  431. .py-1 {
  432. padding: 4rpx 0;
  433. }
  434. .tipsText {
  435. font-size: .75em;
  436. color: #999;
  437. }
  438. &-t {
  439. display: flex;
  440. justify-content: space-between;
  441. }
  442. }
  443. }
  444. &-main {
  445. flex: 1;
  446. height: 0;
  447. padding: 40rpx;
  448. overflow-y: auto;
  449. &-more {
  450. display: flex;
  451. justify-content: center;
  452. align-items: center;
  453. color: #24bc3e;
  454. font-size: .9em;
  455. padding: 20rpx 0;
  456. }
  457. &-time {
  458. user-select: none;
  459. position: relative;
  460. top: 16rpx;
  461. margin: 40rpx 0;
  462. text-align: center;
  463. max-height: 40rpx;
  464. text-align: center;
  465. font-weight: 400;
  466. font-size: .85em;
  467. color: #999;
  468. }
  469. .jobCard {
  470. padding: 30rpx;
  471. background: #E2F2F0;
  472. color: #009688 ;
  473. margin-top: 20rpx;
  474. max-width: unset;
  475. margin-right: 0;
  476. &-title {
  477. font-size: 1.2em;
  478. }
  479. &-subtitle {
  480. padding: 10rpx 0;
  481. // font-size: .5em;
  482. }
  483. &-divider {
  484. width: 100%;
  485. height: 2rpx;
  486. margin: 20rpx 0;
  487. background: #ddd;
  488. }
  489. &-tag {
  490. display: flex;
  491. flex-wrap: wrap;
  492. }
  493. }
  494. .message-view_item {
  495. display: flex;
  496. flex-direction: row;
  497. align-items: flex-start;
  498. margin: 16rpx 0;
  499. position: relative;
  500. .image {
  501. width: 60rpx;
  502. height: 60rpx;
  503. border-radius: 180rpx;
  504. // flex-grow: 1;
  505. // flex-shrink: 0;
  506. overflow: hidden;
  507. .header {
  508. width: 60rpx;
  509. height: 60rpx;
  510. }
  511. }
  512. .text-end {
  513. text-align: right !important;
  514. width: 400rpx;
  515. margin-right: 20rpx;
  516. }
  517. .message-text {
  518. overflow-wrap: break-word;
  519. background-color: #f0f2f5;
  520. border-radius: 12rpx;
  521. max-width: 75%;
  522. padding: 20rpx;
  523. &.active {
  524. background: #d5e6e8;
  525. }
  526. &.card {
  527. background: #E2F2F0;
  528. color: #009688 ;
  529. margin-top: 20rpx;
  530. max-width: unset;
  531. margin-right: 0;
  532. .btn-actions {
  533. margin: 40rpx auto 20rpx auto ;
  534. text-align: center;
  535. .btn {
  536. padding: 10rpx 30rpx;
  537. background: #C8E7D8;
  538. color: #43AC57;
  539. font-size: .75em;
  540. border-radius: 10rpx;
  541. }
  542. }
  543. }
  544. &.none {
  545. padding: 10rpx 0;
  546. background-color: unset;
  547. }
  548. &.active {
  549. background: #d5e6e8;
  550. }
  551. }
  552. }
  553. .is-self {
  554. flex-direction: row-reverse;
  555. display: flex;
  556. .message-text {
  557. margin-right: 20rpx;
  558. }
  559. }
  560. .is-other {
  561. .message-text {
  562. margin-left: 20rpx;
  563. }
  564. }
  565. }
  566. &-bottom {
  567. max-height: 300rpx;
  568. border-top: 2rpx solid #EEE;
  569. background: rgba(230, 230, 230, 0.5);
  570. padding: 20rpx 40rpx;
  571. box-sizing: border-box;
  572. &-tool {
  573. margin-bottom: 40rpx;
  574. }
  575. textarea {
  576. border-radius: 10rpx;
  577. width: 100%;
  578. min-height: 80rpx;
  579. max-height: 180rpx;
  580. padding: 20rpx;
  581. box-sizing: border-box;
  582. background: #FFF;
  583. }
  584. }
  585. .popup-title {
  586. padding: 30rpx 20rpx;
  587. display: flex;
  588. justify-content: space-between;
  589. border-bottom: 2rpx solid #DDD;
  590. }
  591. .popup-content {
  592. padding: 20rpx 40rpx;
  593. color: #999;
  594. display: flex;
  595. align-content: center;
  596. justify-items: center;
  597. .iconBox {
  598. width: 40rpx;
  599. }
  600. .text {
  601. margin-left: 20rpx;
  602. &.active {
  603. color: #43AC57;
  604. }
  605. }
  606. }
  607. .popup-actions {
  608. padding: 60rpx;
  609. .default {
  610. background: #43AC57;
  611. color: #DDD;
  612. font-size: .9em;
  613. }
  614. }
  615. }
  616. </style>