sharingPage.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>分享职位</title>
  7. </head>
  8. <style type="text/css">
  9. #app {
  10. height: 100vh; /* 占据整个视口高度 */
  11. width: 100%;
  12. padding: 0;
  13. margin: 0;
  14. overflow: hidden;
  15. font-size: 16px;
  16. background-color: #fff;
  17. }
  18. #app .loadingCss {
  19. display: flex;
  20. justify-content: center;
  21. align-items: center;
  22. height: 100%;
  23. background-color: #f0f0f0;
  24. }
  25. #app .content {
  26. padding: 10px 15px;
  27. display: flex;
  28. flex-direction: column;
  29. /* justify-content: center; */
  30. align-items: center;
  31. height: 100%;
  32. width: 100%;
  33. overflow: auto;
  34. margin-top: 50px;
  35. }
  36. body {
  37. width: 100%;
  38. margin: 0;
  39. padding: 0;
  40. }
  41. </style>
  42. <body>
  43. <div id="app" v-cloak>
  44. <div v-if="loading && !loadFail" class="loadingCss">加载中...</div>
  45. <div v-else-if="loading && loadFail" class="loadingCss">加载失败...</div>
  46. <div v-else class="content">
  47. <div class="banner-title">
  48. <h1 class="ellipsis">{{ info?.name || '数据错误' }}</h1>
  49. <span class="salary">{{ info?.payFrom || '数据错误' }}-{{ info?.payTo || '数据错误' }}/月</span>
  50. </div>
  51. <div class="banner-tags mt-4">
  52. <span v-for="k in desc" :key="k.mdi" style="margin-right: 15px;">
  53. <span class="ml-1">{{ k.value }}</span>
  54. </span>
  55. </div>
  56. <div class="banner-tools my-4">
  57. </div>
  58. <div class="">
  59. <div class="">
  60. <span style="margin-right: 15px;">立即沟通</span>
  61. <span>投递简历</span>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </body>
  67. <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  68. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  69. <script type="text/javascript">
  70. const { nextTick, createApp, ref } = Vue
  71. const loading = ref(true)
  72. const loadFail = ref(false)
  73. const app = createApp({
  74. setup() {
  75. const url = window.location.href
  76. // const urlTest = 'http://menduner.citupro.com:7878/app-api/detail?id=1802541269864042498&name=2&phone=3&file=4'
  77. const queryStr = url.split('?') && url.split('?')[1] // 提取URL的查询字符串部分
  78. const query = { id: '', name: '', phone: '', file: '' }
  79. if (queryStr) queryStr.split('&').forEach(function (pair) { // 分割查询字符串为键值对数组
  80. const parts = pair.split('=') // 分割每个键值对
  81. query[parts[0]] = parts[1] || '' // 赋值到对象上,注意处理undefined情况
  82. })
  83. // 请求分享的详情数据
  84. let info = ref(null)
  85. const fetchData = async () => {
  86. function alertFun (val) {
  87. loadFail.value = true
  88. // alert('获取详情失败,' + val)
  89. }
  90. try {
  91. const url = 'http://menduner.citupro.com:7878/app-api/menduner/system/job/advertised/get/detail'
  92. const params = { id: query.id }
  93. const res = await axios.get(url, { params })
  94. if (res && res.status !== 200) return alertFun(res.statusText)
  95. // 处理数据
  96. const { data } = res.data
  97. if (data) {
  98. info.value = data
  99. loading.value = false
  100. } else {
  101. alertFun(res.data.msg)
  102. }
  103. } catch (error) {
  104. console.error(error)
  105. }
  106. }
  107. // 设置请求头
  108. axios.defaults.headers.common['tenant-id'] = '155'
  109. fetchData()
  110. const desc = [
  111. { mdi: 'mdi-map-marker-outline', value: '越秀区' }, // areaName
  112. { mdi: 'mdi-school-outline', value: '高中' }, // eduName
  113. { mdi: 'mdi-clock-time-ten-outline', value: '经验不限' } // expName
  114. ]
  115. return {
  116. loading,
  117. loadFail,
  118. info,
  119. desc
  120. }
  121. }
  122. })
  123. app.mount('#app')
  124. </script>
  125. </html>