123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- <template>
- <layout-page>
- <scroll-view class="scrollBox" style="position:relative;">
- <view class="box">
- <view v-if="loading" class="vertical80-center">{{ loadingText }}</view>
- <view v-else>
- <!-- 职位名称 + 薪资 -->
- <view class="d-flex justify-space-between">
- <h2 class="JobName ellipsis">
- {{ info.name }}
- </h2>
- <span v-if="!info.payFrom && !info.payTo" class="salary w-600">面议</span>
- <span v-else class="salary w-600">{{ info.payFrom }}-{{ info.payTo }}/{{ positionInfo.payName }}</span>
- </view>
- <!-- 职位地区 收藏职位 -->
- <view class="d-flex justify-space-between mt-5">
- <view class="bold" style="font-size: 14px;">
- <span>
- <span>{{positionInfo?.areaName }}</span>
- <span class="viewider-mx" v-if="positionInfo?.areaName && positionInfo?.eduName">|</span>
- <span>{{positionInfo?.eduName }}</span>
- <span class="viewider-mx" v-if="positionInfo?.expName">|</span>
- <span>{{positionInfo?.expName }}</span>
- </span>
- </view>
- <!-- 收藏职位 -->
- <view @click="handleCollection">
- <uni-icons
- :type="isCollection ? 'heart-filled' : 'heart'"
- color="#fc6d5e"
- class="mr"
- size="25"
- ></uni-icons>
- </view>
- </view>
- <!-- 标签 -->
- <view class="tagList mt">
- <view class="tag" v-for="(tag,i) in info?.tagList || []" :key="'tagList' + i">
- {{ tag }}
- </view>
- </view>
- <!-- 赏金 -->
- <view v-if="info.hire" class="topLine mt-5" style="display: flex; align-items: center;">
- <view class="iconfont icon-a-1_zhaopin" style="color: #e03506; font-size: 30px;"></view>
- <view class="hirePrice">{{ `赏金:${commissionCalculation(info.hirePrice, 1)}元` }}</view>
- </view>
- <!-- 岗位职责 -->
- <view class="topLine fs14 mt-5">
- <view class="fs15 w-600 my5">岗位职责</view>
- <view v-if="!info.content">暂无</view>
- <rich-text v-else class="htmlCss" :nodes="info.content"></rich-text>
- </view>
- <!-- 岗位要求 -->
- <view class="topLine mt-5">
- <view class="fs15 w-600 my5">岗位要求</view>
- <view v-if="!info.requirement">暂无</view>
- <rich-text v-else class="htmlCss" :nodes="info.requirement"></rich-text>
- </view>
- <!-- 企业信息 -->
- <view class="topLine mt-5 d-flex">
- <view class="avatarBox">
- <image class="avatar" :src="info.contact?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></image>
- </view>
- <view >
- <view class="contact-name">{{ info.contact?.name }}</view>
- <view class="contact-info">{{ info.enterprise?.name }} {{ info.contact?.postNameCn ? '· ' + info.contact?.postNameCn : '' }}</view>
- </view>
- </view>
- <!-- 工作地址 -->
- <view class="topLine mt-5">
- <view class="fs15 w-600 my5">工作地址</view>
- <view class="my10">
- <uni-icons
- type="map-pin-ellipse"
- color="#00897B"
- class="mr"
- size="25"
- ></uni-icons>
- <span style="color: var(--color-666);font-size: 15px;line-height: 26px;">{{ info.address || '暂无' }}</span>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- <!-- 分享 投递 -->
- <view class="bottom-sticky" v-if="!loading && jobId && info.status === '0'">
- <view class="bottom-content">
- <view @click="handleClickShare" class="bottom-content-tool">
- <uni-icons type="redo-filled" size="24" color="#00897B"/>
- <span style="color:#00897B;font-weight:bold;">分享</span>
- </view>
- <button class="btnStyle bgButtons" @tap="handleSend">立即沟通</button>
- <button v-if="delivery" :disabled="true" class="buttons btnStyle disable">我已投递</button>
- <button v-else class="buttons btnStyle" @click="handleDelivery">我要投递</button>
- </view>
- </view>
- <uni-popup
- ref="poster"
- type="center"
- class="f-straight"
- style="position: relative;"
- >
- <canvas
- :style="{
- width:`${appInfo.windowWidth}px;`,
- height:`${appInfo.windowHeight}px;margin-left:-9999px; margin-top:-99.5vh;`
- }" canvas-id="firstCanvas" id="firstCanvas"></canvas>
- <image
- :style="{ width:`${appInfo.windowWidth}px;`, height:`${appInfo.windowHeight*.9}px;`}"
- :src="imgSrc"
- mode="aspectFit"
- />
- <!-- <uni-icons v-if="!!imgSrc" type="clear" size="35" color="#FFF" style="position: absolute;top: 10px;right: 28px;" @click="posterClose"></uni-icons> -->
- </uni-popup>
-
- <!-- 选择简历 -->
- <uni-popup ref="popup" background-color="#fff" :mask-click="false" >
- <view class="dialogBox" style="width: 86vw;">
- <view class="dialog-title">
- <view class="title">选择简历</view>
- <uni-icons type="close" color="grey" size="26" @click="popupClose" />
- </view>
- <view style="height: 1px; margin: 0 20rpx; background-color: #dedede;"></view>
- <scroll-view class="dialog-content" scroll-y="true" style="max-height: 50vh; width: auto;">
- <uni-card
- v-for="(item, index) in resumeList"
- :key="index"
- shadow="0px 0px 3px 1px rgba(0,0,0,0.1)"
- :is-shadow="true"
- :border='false'
- background-color="red"
- :class="{'selected': selectIndex === index}"
- @click="selectIndex = index"
- >
- <view class="d-flex align-center">
- <view style="flex: 1;">
- <view style="font-weight: bold;">
- <uni-icons v-if="selectIndex === index" color="green" type="checkmarkempty" size="18"></uni-icons>
- {{ item.title }}
- </view>
- <view>上传时间:{{ timesTampChange(item.createTime, 'Y-M-D') }}</view>
- </view>
- <view class="ss-m-l-30" style="width: 60rpx;">
- <uni-icons @click="preview(item.url)" type="eye" size="24"></uni-icons>
- </view>
- </view>
- </uni-card>
- <view class="selectOnline" @click="handleUpload">选取微信聊天文件</view>
- </scroll-view>
- <view class="dialog-bottom" @click="deliverySubmit()">确认投递</view>
- </view>
- </uni-popup>
- <!-- 上传简历 -->
- <uni-popup ref="uploadPopup" type="dialog">
- <uni-popup-dialog
- type="warn"
- cancelText="取消"
- confirmText="确定"
- title="系统提示"
- content="您还未上传过简历,是否选取微信聊天文件投递?"
- @confirm="handleUpload"
- @close="uploadPopup.close()"
- ></uni-popup-dialog>
- </uni-popup>
- <!-- 职位分享 -->
- <uni-popup ref="sharePopup" type="share">
- <uni-popup-share title="分享到">
- <view class="share-pop">
- <button class="f-straight" open-type="share">
- <view class="share-round share-round-1" >
- <uni-icons
- type="weixin"
- color="#FFF"
- size="30"
- />
- </view>
- <view style="font-size:12px;">微信</view>
- </button>
- <!-- <button class="f-straight" @click="createPoster">
- <view class="share-round share-round-2" >
- <uni-icons
- type="download-filled"
- color="#FFF"
- size="30"
- />
- </view>
- <view style="font-size:12px;">生成海报</view>
- </button> -->
- </view>
- </uni-popup-share>
- </uni-popup>
- </layout-page>
- </template>
- <script setup>
- import { commissionCalculation } from '@/utils/position'
- import { timesTampChange } from '@/utils/date'
- import { preview } from '@/utils/preview'
- import { uploadFile } from '@/api/file'
- import layoutPage from '@/layout'
- import { ref } from 'vue';
- import {
- jobCvRelSend,
- getPositionDetails,
- jobCvRelCheckSend,
- getPersonJobUnfavorite, // 取消收藏
- getPersonJobFavorite, // 收藏
- getJobFavoriteCheck,
- jobCvRelHireSend
- } from '@/api/position'
- import { getPersonResumeCv, saveResume } from '@/api/user'
- import { dealDictObjData } from '@/utils/position'
- import { getAccessToken } from '@/utils/request'
- import { onLoad,onShareAppMessage,onShareTimeline } from '@dcloudio/uni-app'
- import { prologue, defaultText } from '@/hooks/useIM'
- const sharePopup = ref()
- const loading = ref(false)
- const loadingText = ref('加载中 . . . ')
- // 职位详情
- const info = ref({})
- const positionInfo = ref({})
- const isEmployment = ref(null)
- const imgSrc = ref('')
- const appInfo = ref({})
- const poster = ref()
- const getPositionDetail = async () => {
- try {
- loading.value = true
- const { data } = await getPositionDetails({ id: jobId })
- info.value = data
- positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
- loading.value = false
- } finally {
- }
- }
- let jobId = ''
- onLoad((options) => {
- // 是否是众聘
- if (options.userId) {
- isEmployment.value = options.userId
- }
- jobId = options?.id || ''
- if (jobId) {
- loading.value = true
- loadingText.value = '加载中 . . . '
- deliveryCheck()
- getCollectionStatus()
- getPositionDetail()
- } else {
- loadingText.value = '加载失败 . . . '
- }
- })
- // 效验是否有投递过简历
- const delivery = ref(false) // 是否已投递简历
- const deliveryCheck = async () => {
- try {
- if (!getAccessToken()) return delivery.value = false
- const { data } = await jobCvRelCheckSend({ jobId })
- delivery.value = Boolean(data)
- } finally {
- }
- }
- import { showAuthModal } from '@/hooks/useModal'
- const popup = ref()
- const uploadPopup = ref()
- const resumeList = ref([])
- const selectIndex = ref(null)
- const handleDelivery = async () => {
- // 未登录
- if (!getAccessToken()) {
- uni.showToast({
- title:'请先登录',
- icon: 'none'
- })
- showAuthModal()
- return
- }
- // 已投递
- if (delivery.value) {
- uni.showToast({ title: '您已投递过该职位!', icon: 'none', duration: 2000, })
- return
- }
- const { data } = await getPersonResumeCv()
- resumeList.value = data
- // 未上传简历
- if (!resumeList.value?.length) {
- return uploadPopup.value.open()
- }
- popup.value.open()
- }
- const deliverySubmit = async (uploadFile) => {
- const resume = uploadFile ? uploadFile : resumeList.value[selectIndex.value]
- if (!resume) {
- selectIndex.value = null
- uni.showToast({ title: '请选择简历', icon: 'none', duration: 2000, })
- return
- }
- if (isEmployment.value) {
- await jobCvRelHireSend({
- jobId,
- url: resume.url,
- recommendUserId: isEmployment.value
- })
- } else {
- await jobCvRelSend({
- jobId,
- title: resume.title,
- url: resume.url,
- type: info.value.hire ? 1 : 0
- })
- }
-
- uni.showToast({ title: '投递成功', icon: 'none', duration: 2000, })
- deliveryCheck()
- popup.value.close()
- }
- const popupClose = () => {
- selectIndex.value = null
- popup.value.close()
- }
- // 发起聊天
- async function handleSend () {
- const userId = info.value.contact.userId
- const enterpriseId = info.value.contact.enterpriseId
- const textObj = {
- text: defaultText,
- positionInfo: positionInfo.value
- }
- const channel = await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
- console.log('channel', channel)
- // 跳转
- const query = {
- id: userId,
- name: info.value?.contact?.name,
- postName: info.value?.contact?.postNameCn,
- enterpriseName: info.value?.enterprise?.anotherName,
- enterpriseId: info.value?.enterpriseId,
- channelId: channel.channel_id,
- avatar: info.value?.contact?.avatar,
- sex: info.value?.contact?.sex,
- }
- console.log('query', query)
- const queryStr = Object.keys(query).reduce((r, v) => {
- return r += `${v}=${encodeURIComponent(query[v])}&`
- }, '?')
- uni.navigateTo({
- url: `/pagesA/chart/index${queryStr.slice(0, -1)}`
- })
- }
- // 效验求职者是否有收藏该职位
- const isCollection = ref(false)
- const getCollectionStatus = async () => {
- if (!getAccessToken()) return isCollection.value = false
- const { data } = await getJobFavoriteCheck({ jobId })
- isCollection.value = Boolean(data)
- }
- // 操作 收藏&取消收藏职位
- const handleCollection = async () => {
- const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
- await api(isCollection.value ? jobId : { jobId })
- await getCollectionStatus()
- }
- // 选取微信聊天文件
- // 上传附件
- const handleUpload = () => {
- wx.chooseMessageFile({
- count: 1,
- type: 'file',
- success (res) {
- const title = res.tempFiles[0].name
- const path = res.tempFiles[0].path
- //效验是否为支持的文件格式
- if(/\.(pdf|docx|doc)$/.test(title)){
- uploadFile(path).then(async (res) => {
- if (!res.data) {
- uni.showToast({
- title: '上传失败',
- icon: 'none'
- })
- return
- }
- await saveResume({ title, url: res.data })
- uni.showToast({
- title: '上传成功',
- icon: 'success'
- })
- deliverySubmit({ title, url: res.data })
- })
- }else{
- uni.showToast({
- icon: 'none',
- title: '请上传pdf、word类型的文件',
- duration: 2000
- })
- return
- }
- }
- })
- }
- // 分享
- const handleClickShare = () => {
- sharePopup.value.open()
- }
- //在点击open-type="share"按钮后会触发以下函数,可以在函数中写需要的逻辑,当然函数的返回值必须是一个对象,用于设置分享卡片的展示形式
- //发送给微信好友
- onShareAppMessage((res) => {
- let path = `/pagesB/positionDetail/index?id=${info.value.id}`
- if (info.value.hire) {
- path += `&userId=${info.value.userId}`
- }
- return {
- title: '我发现了一个好职位,快来看看吧', //分享的名称
- path
- }
- })
- // 获取设备信息
- function getSystemInfo(){
- return new Promise((resolve, reject) =>{
- uni.getSystemInfo({
- success: (result) => {
- console.log(result)
- resolve(result)
- },
- fail: (err) => {
- console.log(err)
- }
- })
- })
- }
- function roundedRect(ctx, x, y, width, height, radius, color) {
- ctx.beginPath();
- ctx.moveTo(x, y + radius);
- ctx.lineTo(x, y + height - radius);
- ctx.quadraticCurveTo(x, y + height, x + radius, y + height);
- ctx.lineTo(x + width - radius, y + height);
- ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);
- ctx.lineTo(x + width, y + radius);
- ctx.quadraticCurveTo(x + width, y, x + width - radius, y);
- ctx.lineTo(x + radius, y);
- ctx.quadraticCurveTo(x, y, x, y + radius);
- // ctx.fillStyle = "#f5f5f5";
- ctx.fillStyle = color;
- ctx.fill()
- ctx.strokeStyle = color
- ctx.stroke();
- }
- //微信获取图片信息
- function getImageTempRatio (url){
- return new Promise((resolve, reject)=>{
- wx.getImageInfo({
- src:url,
- success:(res) =>{
- resolve(res)
- }
- })
- })
- }
- /**
- *
- * @param text 文本
- * @param x 起始位置x
- * @param y 起始位置y
- * @param maxWidth 最大宽度
- * @param lineHeight 行高
- * @param ctx 画布上下文
- * @param type 类型 cut 截断+省略号 wrap 自动换行
- */
- function wrapText(text, x, y, maxWidth, lineHeight, ctx, type = 'cut') {
- const words = text.split(' '); // 按空格分割成单词
- let line = ''
- words.forEach((word) => {
- const testLine = line + word + ' '; // 测试当前行加上新单词
- const metrics = ctx.measureText(testLine); // 测量文本宽度
-
- // 检查是否超过最大宽度
- if (metrics.width > maxWidth && line) {
- if (type === 'wrap') {
- ctx.fillText(line, x, y); // 在当前 y 位置绘制当前行
- line = word + ' '; // 重置行并开始新的一行
- y += lineHeight; // 更新 y 位置
- }
- if (type === 'cut') {
- line = line.slice(0, -word.length - 2) + '...'; // 截断当前行并添加省略号
- }
- } else {
- line = testLine; // 如果没有超出宽度,更新当前行
- }
- })
- // 绘制剩余的文本
- ctx.fillText(line, x, y)
- }
- // 生成海报
- async function createPoster () {
- const top = 50
- const left = 30
- console.log(info.value)
- sharePopup.value.close()
- const res = await getSystemInfo()
- const { windowWidth, windowHeight } = res
- appInfo.value = {
- windowWidth, windowHeight
- }
- var context = uni.createCanvasContext('firstCanvas')
- //底色
- context.setFillStyle('#03877a')
- context.fillRect(0,0, windowWidth, windowHeight)
- // 职位信息
- // 名称
- context.setFillStyle('#FFF')
- context.font = 'normal bold 26px Microsoft YaHei'
- context.fillText(info.value.name, left, top)
- // 薪酬
- context.fillStyle = 'yellow';
- context.font = 'normal 22px Microsoft YaHei'
- const payText = `${info.value.payFrom}-${info.value.payTo} / ${positionInfo.value.payName}`
- const payWidth = context.measureText(payText).width;
- const rightX = windowWidth - payWidth - left;
- context.fillText(payText, rightX, top);
- // 地区|年限|学历
- const areaText = `${positionInfo.value?.areaName} | ${positionInfo.value?.eduName} | ${positionInfo.value?.expName}`
- context.setFillStyle('#FFF')
- context.font = 'normal 14px Microsoft YaHei'
- const subTitleH = top + 20
- context.fillText(areaText, left, subTitleH)
- // 企业信息卡片
- roundedRect(context, left, subTitleH + 20 , windowWidth - 2 * left , 50, 10, 'rgba(255, 255, 255, 0.45)')
-
- // 企业信息
- // const headerMsg = await getImageTempRatio(info.value.contact.avatar)
- // context.drawImage(
- // headerMsg.path,
- // left + 5,
- // subTitleH + 25,
- // 40,
- // 40
- // )
- // 企业信息
- context.setFillStyle('#FFF')
- context.font = 'normal 16px Microsoft YaHei'
- const emTextH = subTitleH + 50
- context.fillText(info.value.enterprise.anotherName, left + 20, emTextH)
- // 企业地点
- const _areaText = `${info.value.areaName}`
- const areaTextW = context.measureText(_areaText).width;
- const _rightX = windowWidth - areaTextW - left - 20;
- context.fillText(_areaText, _rightX, emTextH);
- // 福利
- // context.setFillStyle('#FFF')
- context.font = 'normal 14px Microsoft YaHei'
- const welfareH = emTextH + 40
- const welfareText = info.value.tagList && info.value.tagList.join(' ') || ''
- wrapText(welfareText, left, welfareH, windowWidth - 2 * left, 20, context)
- // 卡片
- const cardTop = welfareH + 20 // 卡片顶部距离
- const cardH = windowHeight - cardTop - 100 // 卡片高度
- roundedRect(context, 10, cardTop , windowWidth - 20 , cardH, 10,'#fff')
- // 岗位
- // context.setFillStyle('#000000')
- // context.setFontSize(20)
- // context.font = 'normal bold 20px Microsoft YaHei'
- // context.fillText('111',windowWidth/10, windowHeight * 0.2)
- // 地区频率时长薪资
- // context.setFillStyle('#6c6e7b')
- // context.setFontSize(15)
- // context.font = 'normal 15px Microsoft YaHei'
- // context.fillText(' | ',windowWidth/10, windowHeight * 0.2 + 30)
- // context.setFontSize(18)
- // context.font = 'normal 18px Microsoft YaHei'
- // context.setFillStyle('#f67272')
- // context.fillText('120/天', windowWidth/10, windowHeight * 0.2 + 60)
- // 小程序码/ 二维码
- // context.drawImage(
- // // image.path,
- // windowWidth *0.5 - windowWidth/8,
- // windowHeight * 0.60,
- // windowWidth/4,
- // windowWidth/4
- // )
-
- context.setFontSize(16)
- context.fillText('长按二维码查看岗位', windowWidth/3.2, windowHeight * 0.65 + windowWidth/4)
- context.draw(false, () =>{
- uni.showLoading({
- title: '加载中……',
- icon: 'none',
- })
- setTimeout(() => {
- wx.canvasToTempFilePath({
- canvasId: 'firstCanvas',
- x:0,
- y:0,
- success:(res)=>{
- console.log('成功', res)
- imgSrc.value = res.tempFilePath
- },
- fail:(err)=>{
- console.log('canvasToTemp-fail', err)
- },
- complete:()=>{
- uni.hideLoading();
- }
- })
- }, 3000)
- // canvas生成图片
- poster.value.open()
- })
- }
- </script>
- <style scoped lang="scss">
- @import '../../static/style/position/index.scss';
- .bottom-content {
- display: flex;
- justify-content: space-evenly;
- align-items: center;
- width: 100%;
- margin: 20rpx 0;
- .btnStyle {
- flex: 1;
- margin-right: 20rpx;
- }
- .bgButtons {
- border: 2rpx solid #00897b;
- color: #00897b;
- background: #FFF;
- border-radius: 50rpx;
- }
- &-tool {
- width: 160rpx;
- display: flex;
- justify-content: center;
- flex-direction: column;
- align-items: center;
- }
- }
- .share-pop {
- width: 100%;
- // height:300rpx;
- display: flex;
- justify-content: center;
- .f-straight {
- margin: 40rpx;
- background: unset;
- &::after{
- border:none !important;
- }
- }
- .share-round {
- border-radius:50%;
- height:100rpx;
- width:100rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .share-round-1 {
- background-color:#22a039;
- }
- .share-round-2 {
- background-color:#3693cd;
- }
- }
- .preview {
- position: fixed;
- z-index: 9;
- height: 100vh;
- width: 100vw;
- left: 0;
- top: 0;
- .image {
- position: absolute;
- width: 80%;
- left: 10%;
- top: 100rpx;
- }
- }
- </style>
|