video-briefing.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="page">
  3. <!-- 自定义导航栏(可留空避免遮挡) -->
  4. <!-- <view class="nav-bar"></view> -->
  5. <!-- 右上角固定关闭/跳过按钮 -->
  6. <view class="skip-fixed" :style="{ top: 20 + 'px' }" @click="handleSkip">
  7. <text class="skip-text">关闭</text>
  8. </view>
  9. <!-- 视频区域 -->
  10. <view class="video-wrap" :style="{ height: videoHeight + 'px' }">
  11. <video
  12. :id="'briefingVideo'"
  13. :src="videoSrc"
  14. autoplay
  15. :controls="false"
  16. :enable-progress-gesture="false"
  17. :show-center-play-btn="false"
  18. :show-fullscreen-btn="false"
  19. :show-play-btn="false"
  20. :enable-play-gesture="false"
  21. object-fit="contain"
  22. @ended="handleEnded"
  23. @error="handleError"
  24. class="video"
  25. />
  26. </view>
  27. <!-- 说明文案(可选) -->
  28. <view class="tips">请完整观看宣讲视频。如需跳过,可点击右上角“跳过”。</view>
  29. </view>
  30. </template>
  31. <script>
  32. import { apiBaseUrl } from '@/common/config.js';
  33. export default {
  34. data() {
  35. return {
  36. videoSrc: 'https://data.qicai321.com/minlong/latentsync/9791ad45-dd30-4f84-a1c6-0c07c4d08707_result.mp4',
  37. nextPath: '/pages/index/index',
  38. statusBarHeight: 0,
  39. navBarHeight: 44,
  40. videoHeight: 0,
  41. tenant_id: '', // 租户ID
  42. }
  43. },
  44. onLoad(options) {
  45. // 从参数获取视频地址与下一个页面路径,避免硬编码- this.navBarHeight
  46. this.videoSrc = (options && options.src) ? decodeURIComponent(options.src) : '';
  47. this.nextPath = (options && options.next) ? decodeURIComponent(options.next) : '/pages/index/index';
  48. const sysInfo = uni.getSystemInfoSync();
  49. this.statusBarHeight = sysInfo.statusBarHeight || 0;
  50. // 计算视频高度(去掉自定义导航)
  51. this.videoHeight = (sysInfo.windowHeight || 0) - this.statusBarHeight;
  52. // 获取本地存储的tenant_id
  53. this.getTenantId();
  54. },
  55. methods: {
  56. // 获取本地存储的tenant_id
  57. getTenantId() {
  58. const tenantId = uni.getStorageSync('tenant_id');
  59. if (tenantId) {
  60. this.tenant_id = tenantId;
  61. return tenantId;
  62. }
  63. return null;
  64. },
  65. handleSkip() {
  66. this.navigateToNext();
  67. },
  68. handleEnded() {
  69. this.navigateToNext();
  70. },
  71. handleError(e) {
  72. uni.showToast({ title: '视频加载失败', icon: 'none' });
  73. },
  74. /* navigateToNext() {
  75. console.log(uni.getStorageSync('configData'));
  76. // 若 nextPath 是 tabBar 页面,需要使用 switchTab;否则使用 navigateTo
  77. try {
  78. const tabBarPages = [
  79. '/pages/index/index',
  80. '/pages/my/my'
  81. ];
  82. if (tabBarPages.includes(this.nextPath)) {
  83. uni.switchTab({ url: this.nextPath });
  84. } else {
  85. uni.navigateTo({ url: this.nextPath });
  86. }
  87. } catch (err) {
  88. // 兜底跳首页
  89. uni.switchTab({ url: '/pages/index/index' });
  90. }
  91. }, */
  92. navigateToNext() {
  93. try {
  94. // 获取配置数据
  95. const configStr = uni.getStorageSync('configData');
  96. let configData = null;
  97. if (configStr) {
  98. try {
  99. configData = JSON.parse(configStr);
  100. console.log('解析到的配置数据:', configData);
  101. } catch (parseError) {
  102. console.error('解析configData失败:', parseError);
  103. }
  104. }
  105. this.handleUserInfoAndNavigation(configData.require_resume_upload);
  106. } catch (error) {
  107. console.error('跳转处理失败:', error);
  108. }
  109. },
  110. // 处理用户信息获取和页面跳转逻辑
  111. handleUserInfoAndNavigation(require_resume_upload) {
  112. // 调用获取用户完整信息的接口
  113. const openid = JSON.parse(uni.getStorageSync('userInfo')).openid;
  114. uni.request({
  115. url: `${apiBaseUrl}/api/wechat/user/get_full_info?tenant_id=${this.tenant_id||JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1}&openid=${openid}`,
  116. method: 'GET',
  117. success: (infoRes) => {
  118. if (infoRes.statusCode === 200 && infoRes.data && infoRes.data.data && infoRes.data.data.profile) {
  119. const resumeUrl = infoRes.data.data.profile.resume_url || '';
  120. if (!resumeUrl && require_resume_upload) {
  121. // resume_url 为空,跳转到其他页面
  122. uni.navigateTo({
  123. url: '/pages/uploadResume/uploadResume', // 假设跳转到上传简历页面
  124. fail: (err) => {
  125. console.error('页面跳转失败:', err);
  126. uni.showToast({
  127. title: '页面跳转失败',
  128. icon: 'none'
  129. });
  130. }
  131. });
  132. } else {
  133. // resume_url 不为空,跳转到 Personal 页面
  134. uni.navigateTo({
  135. url: '/pages/Personal/Personal',
  136. fail: (err) => {
  137. console.error('页面跳转失败:', err);
  138. uni.showToast({
  139. title: '页面跳转失败',
  140. icon: 'none'
  141. });
  142. }
  143. });
  144. }
  145. } else {
  146. // 获取用户信息失败,直接跳转到 Personal 页面
  147. uni.navigateTo({
  148. url: '/pages/Personal/Personal',
  149. fail: (err) => {
  150. console.error('页面跳转失败:', err);
  151. uni.showToast({
  152. title: '页面跳转失败',
  153. icon: 'none'
  154. });
  155. }
  156. });
  157. }
  158. },
  159. fail: (err) => {
  160. console.error('获取用户信息失败:', err);
  161. uni.navigateTo({
  162. url: '/pages/Personal/Personal',
  163. fail: (err) => {
  164. console.error('页面跳转失败:', err);
  165. uni.showToast({
  166. title: '页面跳转失败',
  167. icon: 'none'
  168. });
  169. }
  170. });
  171. }
  172. });
  173. },
  174. }
  175. }
  176. </script>
  177. <style>
  178. .page {
  179. background: #000;
  180. min-height: 100vh;
  181. }
  182. .nav-bar {
  183. position: relative;
  184. display: flex;
  185. align-items: center;
  186. justify-content: space-between;
  187. /* height: 44px; */
  188. padding: 0 16px;
  189. background: #000;
  190. color: #fff;
  191. box-sizing: border-box;
  192. z-index: 1;
  193. }
  194. .nav-title {
  195. font-size: 16px;
  196. font-weight: 600;
  197. }
  198. .skip-btn {
  199. font-size: 14px;
  200. color: #ffffff;
  201. opacity: 0.9;
  202. }
  203. .video-wrap {
  204. width: 100%;
  205. background: #000;
  206. }
  207. .video {
  208. width: 100%;
  209. height: 100%;
  210. }
  211. .tips {
  212. padding: 5px 16px;
  213. text-align: center;
  214. font-size: 12px;
  215. color: #bbb;
  216. background: #000;
  217. }
  218. /* 右上角固定关闭按钮样式 */
  219. .skip-fixed {
  220. position: fixed;
  221. right: 12px;
  222. /* top 动态由内联样式结合状态栏高度控制 */
  223. background: rgba(0, 0, 0, 0.35);
  224. color: #fff;
  225. border-radius: 18px;
  226. padding: 6px 12px;
  227. border: 0.5px solid rgba(255, 255, 255, 0.35);
  228. backdrop-filter: blur(6px);
  229. -webkit-backdrop-filter: blur(6px);
  230. line-height: 12px;
  231. z-index: 999;
  232. }
  233. .skip-text {
  234. font-size: 12px;
  235. }
  236. </style>