lifanagju_citu 10 miesięcy temu
rodzic
commit
323c8af421

+ 2 - 0
src/locales/en.js

@@ -142,6 +142,8 @@ export default {
     currentOnline: 'Currently online',
     jobResponsibilities: 'Job responsibilities',
     jobRequirements: 'Job requirements',
+    sharePosition: 'Share Position',
+    rewardsShared: 'Rewards shared',
     cancelFavorite: 'Cancel Favorite',
     collection: 'Collection',
     recruitmentPosition: 'Recruitment positions',

+ 2 - 0
src/locales/zh-CN.js

@@ -142,6 +142,8 @@ export default {
     currentOnline: '当前在线',
     jobResponsibilities: '岗位职责',
     jobRequirements: '岗位要求',
+    sharePosition: '分享职位',
+    rewardsShared: '分享有礼',
     cancelFavorite: '取消收藏',
     collection: '收藏',
     recruitmentPosition: '在招职位',

+ 65 - 4
src/views/recruit/personal/position/components/details.vue

@@ -31,7 +31,7 @@
             prepend-icon="mdi-share-outline"
             style="height: 36px;"
             @click="handleShare"
-          >分享有礼</v-btn>
+          >{{ $t('position.rewardsShared') }}</v-btn>
           <v-btn
             class="button-item radius"
             color="warning" 
@@ -107,13 +107,37 @@
         <v-radio v-for="val in resumeList" :key="val.id" :value="val.id" :label="val.title" color="primary"></v-radio>
       </v-radio-group>
     </Dialog>
+
+    <!-- 复制分享链接 -->
+    <Dialog
+      :visible="shareDialog" :widthType="2" :footer="false" titleClass="text-h6"
+      :title="$t('position.rewardsShared')"
+      @close="shareDialog = false"
+    >
+      <div>
+        <div class="pa-4" style="background-color: #f0f0f0; border-radius: 8px;">{{ shareUrl }}</div>
+        <v-btn class="mt-4 ml-3" color="success" @click="copyText">复制分享链接</v-btn>
+        <v-btn class="mt-4 ml-3" color="primary" variant="outlined" @click="openShareLink">打开分享链接</v-btn>
+      </div>
+      <template #footer>
+        <v-divider></v-divider>
+        <div>
+          <v-btn
+            class="float-right ma-2"
+            color="primary"
+            variant="text"
+            @click="shareDialog = false"
+          >{{ $t('common.close') }}</v-btn>
+        </div>
+      </template>
+    </Dialog>
   </div>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
 </template>
 
 <script setup>
 defineOptions({ name: 'position-details' })
 import { ref } from 'vue'
-import { useRouter } from 'vue-router'
+import { useRoute, useRouter } from 'vue-router'
 import { timesTampChange } from '@/utils/date'
 import { getPersonResumeCv } from '@/api/resume'
 import { useI18n } from '@/hooks/web/useI18n'
@@ -127,6 +151,7 @@ import { getToken } from '@/utils/auth'
 
 const { t } = useI18n()
 const router = useRouter()
+const route = useRoute()
 const { id } = router.currentRoute.value.params
 const delivery = ref(false) // 是否已投递简历
 
@@ -172,16 +197,52 @@ const getCollectionStatus = async () => {
 getCollectionStatus()
 
 // 分享有礼
+const shareDialog = ref(false)
+const shareUrl = ref('')
 const handleShare = async () => {
+  if (!getToken()) {
+    router.push(`/login?redirect=${route.fullPath}`)
+    return
+  }
   // 分享链接携带参数: 1.用户id。2.手机号。3.附件简历。4.姓名。5.职位id
-  const url = '/shareJob?' + new URLSearchParams({
+  shareUrl.value = '/shareJob?' + new URLSearchParams({
     jobId: id,
     sharedById: 'userId',
     sharedByName: 'name',
     sharedByPhone: 'phone',
     file: 'file',
   }).toString()
-  window.open(url, '_blank')
+  shareDialog.value = true
+  // window.open(shareUrl.value)
+}
+const openShareLink = () => { window.open(shareUrl.value) }
+const copyText = async () => {
+  try {
+    if (navigator.clipboard && navigator.clipboard.writeText) {
+      await navigator.clipboard.writeText(shareUrl.value)
+      Snackbar.success('复制成功')
+    } else {
+      const textArea = document.createElement("textarea")
+      textArea.value = shareUrl.value
+      textArea.style.position = "fixed" // 避免在页面上滚动  
+      textArea.style.top = 0
+      textArea.style.left = 0
+      textArea.style.width = "2em"
+      textArea.style.height = "2em"
+      textArea.style.padding = 0
+      textArea.style.border = "none"
+      textArea.style.outline = "none"
+      textArea.style.boxShadow = "none"
+      textArea.style.background = "transparent"
+      document.body.appendChild(textArea)
+      textArea.focus()
+      textArea.select()
+      const successful = document.execCommand('copy')
+      Snackbar.success(successful ? '复制成功' : '复制失败,请手动复制。')
+    }
+  } catch (err) {
+    Snackbar.error('复制失败,请手动复制。')
+  }
 }
 
 // 收藏&取消收藏职位