index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="phone-ycms-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">远程面试</text>
  6. </view>
  7. <view class="ycms-body-box">
  8. <view class="ycms-card-box">
  9. <view class="card-title-row">
  10. <text>远程面试</text>
  11. <view @click="handleClose" class="colse-btn" v-if="data.room">关闭房间</view>
  12. </view>
  13. <view class="room-box">
  14. <view class="room-info-box" v-if="data.room">
  15. <view class="room-num">{{ data.room }}</view>
  16. <view class="room-text">房间号</view>
  17. </view>
  18. <view class="room-info-box flex-info" v-else>
  19. <view class="room-wcj">未创建</view>
  20. <view class="room-text">房间号</view>
  21. </view>
  22. <button @click="openUrl(1)" type="default" class="phone-white-btn jr-btn"
  23. v-if="data.room">进入房间</button>
  24. <!-- <button @click="openUrl2">进入房间2</button> -->
  25. </view>
  26. <view class="btn-tip" v-if="data.room">每个邀请链接仅限一人使用,请勿重复分享</view>
  27. <!-- phone-white-btn -->
  28. <button @click="yqBtn(3)" type="default" class="phone-green-btn yqkh-btn" v-if="data.room">邀请阿姨</button>
  29. <button @click="yqBtn(2)" type="default" class="phone-green-btn yqkh-btn"
  30. v-if="data.room">邀请客户1</button>
  31. <button @click="yqBtn(4)" type="default" class="phone-green-btn yqkh-btn"
  32. v-if="data.room">邀请客户2</button>
  33. <button @click="handleCreate" type="default" class="phone-green-btn" v-else>创建面试房间</button>
  34. <view class="ycms-tip-box">
  35. <view class="tip-title"><text>小贴士</text>
  36. <icon></icon>
  37. </view>
  38. <view class="tip-text">1.创建房间后会生成房间号,生成房间号后,可进入房间,也可以直接分享给客户进入房间。</view>
  39. <view class="tip-text">2. 关闭房间后,面试人员将无法再进入房间,需要重新创建房间。</view>
  40. </view>
  41. </view>
  42. <share-popup
  43. ref="sharePopupRef"
  44. :image="roomImageUrl"
  45. title="远程面试邀请"
  46. desc="请点击链接参加面试"
  47. :link=roomUrl
  48. type="0"
  49. @success="onShareSuccess"
  50. />
  51. </view>
  52. </view>
  53. </template>
  54. <script setup>
  55. import * as httpApi from '@/api/mianshi.js'
  56. import {
  57. ref,
  58. reactive
  59. } from "vue"
  60. import {
  61. onLoad
  62. } from "@dcloudio/uni-app";
  63. import config from "../../../config"
  64. import SharePopup from '@/components/sharePopUp/index.vue'
  65. import userDefaultImg from '@/static/images/share/mianshi-img.jpg'
  66. const roomImageUrl = ref(userDefaultImg)
  67. const data = reactive({
  68. room: '',
  69. })
  70. const roomUrl = ref('')
  71. const sharePopupRef = ref(null)
  72. function onShareSuccess(e){
  73. console.log('分享成功', e.scene)
  74. }
  75. function goUpPage() {
  76. uni.redirectTo({
  77. url: `/pages/admin/ShouYe/shouye`
  78. })
  79. }
  80. function handleMianshiInfo() {
  81. httpApi.getMianshiInfo().then(res => {
  82. data.room = res.data.room;
  83. })
  84. }
  85. function handleCreate() {
  86. httpApi.getMianshiCreate().then(res => {
  87. data.room = res.data.room;
  88. uni.showToast({
  89. title: '创建成功',
  90. icon: 'none'
  91. });
  92. })
  93. .catch(err => {
  94. console.error('创建失败:', err);
  95. uni.showToast({
  96. title: '创建失败,请重试',
  97. icon: 'none'
  98. });
  99. });
  100. }
  101. function yqBtn(code) {
  102. roomUrl.value = `${config.mianshiUrl}?roomId=${data.room}&index=${code}`
  103. sharePopupRef.value.open()
  104. // 分享地址
  105. //const url = `${config.mianshiUrl}?roomId=900803&index=${code}`
  106. }
  107. function handleClose() {
  108. httpApi.getMianshiClose().then(res => {
  109. if (res.data) {
  110. data.room = null;
  111. uni.showToast({
  112. title: '房间已关闭',
  113. icon: 'none'
  114. });
  115. }
  116. })
  117. }
  118. function openUrl(code) {
  119. const url = `${config.mianshiUrl}?roomId=${data.room}&index=${code}`
  120. plus.runtime.openURL(url, (err) => {
  121. if (err) {
  122. console.error('打开浏览器失败: ', err);
  123. uni.showToast({
  124. title: '打开链接失败',
  125. icon: 'none'
  126. });
  127. }
  128. });
  129. }
  130. onLoad(() => {
  131. handleMianshiInfo()
  132. })
  133. </script>