index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. const props = defineProps({
  47. project: Object,
  48. showAdjust: Boolean,
  49. })
  50. const emits = defineEmits(['update'])
  51. const user = ref(null)
  52. const points = ref({ p1: null, p2: null })
  53. const showLogin = ref(false)
  54. const onSetP1 = () => {
  55. points.value.p1 = { id: 0, position: { x: 1, y: 1, z: 1 } }
  56. emits('update','p1')
  57. }
  58. const onSetP2 = () => {
  59. points.value.p2 = { id: 0, position: { x: 1, y: 1, z: 1 } }
  60. emits('update','p2')
  61. }
  62. const getUserInfo = () => {
  63. http.post(`smart-site/getUserInfo`)
  64. .then(response => {
  65. if (response.success) {
  66. user.value = {
  67. head: response.data.head,
  68. nickName: response.data.nickName,
  69. }
  70. } else {
  71. if (response.code == 4008) {
  72. // 未登录
  73. }
  74. }
  75. })
  76. .catch(() => {})
  77. }
  78. const onLogout = () => [
  79. http
  80. .post(`smart-site/fdLogout`)
  81. .then(response => {
  82. if (response.success) {
  83. localStorage.removeItem('token')
  84. localStorage.removeItem('remember')
  85. localStorage.removeItem('username')
  86. localStorage.removeItem('password')
  87. user.value = null
  88. }
  89. })
  90. .catch(() => {}),
  91. ]
  92. const onCancel = () => {
  93. window.location.href = window.location.href.replace('&adjust', '')
  94. }
  95. const onSubmit = () => {
  96. http.post(`smart-site/project/updatePanos`, {
  97. projet_id: props.project.projectId,
  98. panos: JSON.stringify(points.value),
  99. })
  100. .then(response => {
  101. if (response.success) {
  102. window.location.href = window.location.href.replace('&adjust', '&split')
  103. }
  104. })
  105. .catch(() => {})
  106. }
  107. onMounted(() => {
  108. if (localStorage.getItem('token')) {
  109. getUserInfo()
  110. }
  111. })
  112. </script>
  113. <style lang="scss" scoped>
  114. ul,
  115. li {
  116. margin: 0;
  117. padding: 0;
  118. list-style: none;
  119. }
  120. header {
  121. position: relative;
  122. height: 60px;
  123. background-color: #1a1b1d;
  124. display: flex;
  125. justify-content: center;
  126. align-items: center;
  127. font-size: 16px;
  128. }
  129. footer {
  130. position: absolute;
  131. left: 0;
  132. bottom: 0;
  133. width: 100%;
  134. height: 90px;
  135. color: rgba(255, 255, 255, 0.8);
  136. backdrop-filter: blur(4px);
  137. background: rgba(27, 27, 28, 0.8);
  138. z-index: 99999;
  139. padding: 20px 24px;
  140. h4 {
  141. font-size: 20px;
  142. margin: 0;
  143. padding: 0;
  144. color: #fff;
  145. margin-bottom: 14px;
  146. }
  147. .points {
  148. position: absolute;
  149. top: 20px;
  150. right: 0;
  151. bottom: 20px;
  152. display: flex;
  153. align-items: center;
  154. button {
  155. cursor: pointer;
  156. outline: none;
  157. color: #0076f6;
  158. margin-right: 24px;
  159. width: 160px;
  160. height: 36px;
  161. background: transparent;
  162. border: 1px solid #0076f6;
  163. border-radius: 4px;
  164. &.active {
  165. background: #0076f6;
  166. color: #fff;
  167. }
  168. }
  169. }
  170. }
  171. .user {
  172. position: absolute;
  173. top: 0;
  174. right: 20px;
  175. bottom: 0;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. font-size: 14px;
  180. ul {
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. }
  185. i {
  186. font-size: 18px;
  187. }
  188. em {
  189. margin: 0 20px;
  190. display: inline-block;
  191. width: 1px;
  192. height: 16px;
  193. vertical-align: -2px;
  194. background-color: rgba(255, 255, 255, 0.16);
  195. }
  196. .login {
  197. cursor: pointer;
  198. color: rgba(0, 118, 246, 1);
  199. }
  200. .uinfo {
  201. position: relative;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. width: 40px;
  206. height: 40px;
  207. font-size: 14px;
  208. &::after {
  209. content: '';
  210. position: absolute;
  211. right: 3px;
  212. bottom: 4px;
  213. width: 0;
  214. height: 0;
  215. border-color: rgba(255, 255, 255, 0.6) transparent;
  216. border-width: 0 0 5px 5px;
  217. border-style: solid;
  218. }
  219. &:hover {
  220. .menu {
  221. display: block;
  222. }
  223. }
  224. img {
  225. width: 32px;
  226. height: 32px;
  227. border-radius: 50%;
  228. background-size: cover;
  229. border: none;
  230. outline: none;
  231. overflow: hidden;
  232. cursor: pointer;
  233. }
  234. .menu {
  235. display: none;
  236. position: absolute;
  237. top: 40px;
  238. right: 0;
  239. z-index: 2000;
  240. a {
  241. color: #fff;
  242. text-decoration: none;
  243. }
  244. ul {
  245. background-color: #343535;
  246. width: 128px;
  247. flex-direction: column;
  248. border-radius: 4px;
  249. box-shadow: 0 0 4px #333;
  250. padding: 0 15px;
  251. margin-top: 15px;
  252. }
  253. li {
  254. height: 45px;
  255. line-height: 45px;
  256. text-align: center;
  257. &.split {
  258. width: 100%;
  259. height: 1px;
  260. background-color: rgba(255, 255, 255, 0.16);
  261. }
  262. }
  263. }
  264. }
  265. }
  266. .sync {
  267. position: absolute;
  268. right: 0;
  269. top: 0;
  270. height: 100%;
  271. display: flex;
  272. align-items: center;
  273. button {
  274. cursor: pointer;
  275. width: 90px;
  276. height: 35px;
  277. background: #313131;
  278. color: #fff;
  279. border: none;
  280. outline: none;
  281. border-radius: 4px;
  282. margin-right: 10px;
  283. &[type='submit'] {
  284. background: #0076f6;
  285. opacity: 0.5;
  286. pointer-events: none;
  287. }
  288. &[type='submit'].active {
  289. opacity: 1;
  290. pointer-events: all;
  291. }
  292. }
  293. }
  294. </style>