index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <header v-if="props.showAdjust">
  3. <div v-if="project">{{ project.projectName }}</div>
  4. <div class="sync">
  5. <button @click="onCancel">取消</button>
  6. <button type="submit" @click="onSubmit" :class="{ active: points.p1 && points.p2 }">同步</button>
  7. </div>
  8. </header>
  9. <header v-else>
  10. <div v-if="project">{{ project.projectName }}</div>
  11. <div class="user">
  12. <ul>
  13. <li>
  14. <i class="iconfont icon-share"></i>
  15. </li>
  16. <li><em></em></li>
  17. <li v-if="user" class="uinfo" @click="showDrop = true">
  18. <img :src="user.head + '&x-oss-process=image/resize,m_fill,w_64,h_64/quality,q_70'" alt="" />
  19. <div class="menu">
  20. <ul>
  21. <li><a href="/">个人信息</a></li>
  22. <li class="split"></li>
  23. <li><a href="javascript:;" @click="onLogout">退出登录</a></li>
  24. </ul>
  25. </div>
  26. </li>
  27. <li v-else class="login" @click="showLogin = true"><span>登录</span></li>
  28. </ul>
  29. </div>
  30. <Login v-if="showLogin" @close="showLogin = false" @user="info => (user = info)" />
  31. </header>
  32. <footer v-if="props.showAdjust">
  33. <h4>为场景设置关联位置</h4>
  34. <div>请选择位置,确认左右视图中的场景在同一位置后,单击右侧按钮将其设为关联位置。</div>
  35. <div class="points">
  36. <button @click="onSetP1" :class="{ active: points.p1 }">设为P1</button>
  37. <button @click="onSetP2" :class="{ active: points.p2 }">设为P2</button>
  38. </div>
  39. </footer>
  40. </template>
  41. <script setup>
  42. import { ref, defineProps, onMounted } from 'vue'
  43. import { http } from '@/utils/request'
  44. import browser from '@/utils/browser'
  45. import Login from './Login'
  46. import sync from '@/utils/sync'
  47. const props = defineProps({
  48. project: Object,
  49. showAdjust: Boolean,
  50. })
  51. const emits = defineEmits(['update'])
  52. const user = ref(null)
  53. const points = ref({ p1: null, p2: null })
  54. const showLogin = ref(false)
  55. const getCurPosInfo = ()=>{
  56. let app = sync.sourceInst
  57. let id
  58. if(app.sceneType == 'laser'){
  59. id = app.viewer.images360.currentPano.id
  60. }else{
  61. id = app.app.core.get('Player').currentPano.id
  62. }
  63. let info = sync.targetInst.viewer.getCameraStatus()
  64. let position = info.position
  65. return {id, position}
  66. }
  67. const onSetP1 = () => {
  68. points.value.p1 = getCurPosInfo()
  69. console.log(points.value.p1)
  70. emits('update','p1')
  71. }
  72. const onSetP2 = () => {
  73. points.value.p2 = getCurPosInfo()
  74. console.log(points.value.p2)
  75. emits('update','p2')
  76. }
  77. const getUserInfo = () => {
  78. http.post(`smart-site/getUserInfo`)
  79. .then(response => {
  80. if (response.success) {
  81. user.value = {
  82. head: response.data.head,
  83. nickName: response.data.nickName,
  84. }
  85. } else {
  86. if (response.code == 4008) {
  87. // 未登录
  88. }
  89. }
  90. })
  91. .catch(() => {})
  92. }
  93. const onLogout = () => [
  94. http
  95. .post(`smart-site/fdLogout`)
  96. .then(response => {
  97. if (response.success) {
  98. localStorage.removeItem('token')
  99. localStorage.removeItem('remember')
  100. localStorage.removeItem('username')
  101. localStorage.removeItem('password')
  102. user.value = null
  103. }
  104. })
  105. .catch(() => {}),
  106. ]
  107. const onCancel = () => {
  108. window.location.href = window.location.href.replace('&adjust', '')
  109. }
  110. const onSubmit = () => {
  111. http.post(`smart-site/project/updatePanos`, {
  112. projectId: props.project.projectId,
  113. panos: JSON.stringify(points.value),
  114. })
  115. .then(response => {
  116. if (response.success) {
  117. window.location.href = window.location.href.replace('&adjust', '&split')
  118. }else {
  119. alert(response.message)
  120. }
  121. })
  122. .catch(() => {})
  123. }
  124. onMounted(() => {
  125. if (localStorage.getItem('token')) {
  126. getUserInfo()
  127. }
  128. })
  129. </script>
  130. <style lang="scss" scoped>
  131. ul,
  132. li {
  133. margin: 0;
  134. padding: 0;
  135. list-style: none;
  136. }
  137. header {
  138. position: relative;
  139. height: 60px;
  140. background-color: #1a1b1d;
  141. display: flex;
  142. justify-content: center;
  143. align-items: center;
  144. font-size: 16px;
  145. }
  146. footer {
  147. position: absolute;
  148. left: 0;
  149. bottom: 0;
  150. width: 100%;
  151. height: 90px;
  152. color: rgba(255, 255, 255, 0.8);
  153. backdrop-filter: blur(4px);
  154. background: rgba(27, 27, 28, 0.8);
  155. z-index: 99999;
  156. padding: 20px 24px;
  157. h4 {
  158. font-size: 20px;
  159. margin: 0;
  160. padding: 0;
  161. color: #fff;
  162. margin-bottom: 14px;
  163. }
  164. .points {
  165. position: absolute;
  166. top: 20px;
  167. right: 0;
  168. bottom: 20px;
  169. display: flex;
  170. align-items: center;
  171. button {
  172. cursor: pointer;
  173. outline: none;
  174. color: #0076f6;
  175. margin-right: 24px;
  176. width: 160px;
  177. height: 36px;
  178. background: transparent;
  179. border: 1px solid #0076f6;
  180. border-radius: 4px;
  181. &.active {
  182. background: #0076f6;
  183. color: #fff;
  184. }
  185. }
  186. }
  187. }
  188. .user {
  189. position: absolute;
  190. top: 0;
  191. right: 20px;
  192. bottom: 0;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. font-size: 14px;
  197. ul {
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. }
  202. i {
  203. font-size: 18px;
  204. }
  205. em {
  206. margin: 0 20px;
  207. display: inline-block;
  208. width: 1px;
  209. height: 16px;
  210. vertical-align: -2px;
  211. background-color: rgba(255, 255, 255, 0.16);
  212. }
  213. .login {
  214. cursor: pointer;
  215. color: rgba(0, 118, 246, 1);
  216. }
  217. .uinfo {
  218. position: relative;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. width: 40px;
  223. height: 40px;
  224. font-size: 14px;
  225. &::after {
  226. content: '';
  227. position: absolute;
  228. right: 3px;
  229. bottom: 4px;
  230. width: 0;
  231. height: 0;
  232. border-color: rgba(255, 255, 255, 0.6) transparent;
  233. border-width: 0 0 5px 5px;
  234. border-style: solid;
  235. }
  236. &:hover {
  237. .menu {
  238. display: block;
  239. }
  240. }
  241. img {
  242. width: 32px;
  243. height: 32px;
  244. border-radius: 50%;
  245. background-size: cover;
  246. border: none;
  247. outline: none;
  248. overflow: hidden;
  249. cursor: pointer;
  250. }
  251. .menu {
  252. display: none;
  253. position: absolute;
  254. top: 40px;
  255. right: 0;
  256. z-index: 2000;
  257. a {
  258. color: #fff;
  259. text-decoration: none;
  260. }
  261. ul {
  262. background-color: #343535;
  263. width: 128px;
  264. flex-direction: column;
  265. border-radius: 4px;
  266. box-shadow: 0 0 4px #333;
  267. padding: 0 15px;
  268. margin-top: 15px;
  269. }
  270. li {
  271. height: 45px;
  272. line-height: 45px;
  273. text-align: center;
  274. &.split {
  275. width: 100%;
  276. height: 1px;
  277. background-color: rgba(255, 255, 255, 0.16);
  278. }
  279. }
  280. }
  281. }
  282. }
  283. .sync {
  284. position: absolute;
  285. right: 0;
  286. top: 0;
  287. height: 100%;
  288. display: flex;
  289. align-items: center;
  290. button {
  291. cursor: pointer;
  292. width: 90px;
  293. height: 35px;
  294. background: #313131;
  295. color: #fff;
  296. border: none;
  297. outline: none;
  298. border-radius: 4px;
  299. margin-right: 10px;
  300. &[type='submit'] {
  301. background: #0076f6;
  302. opacity: 0.5;
  303. pointer-events: none;
  304. }
  305. &[type='submit'].active {
  306. opacity: 1;
  307. pointer-events: all;
  308. }
  309. }
  310. }
  311. </style>