index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="nav-wrap">
  3. <div class="top">
  4. <div class="top_png">
  5. <p>智慧社区管理平台</p>
  6. </div>
  7. <div class="lfet-right">
  8. <div class="logo"></div>
  9. <div style="display: flex">
  10. <div class="tenantName" @click="toggleTenant">{{ tenantName }}</div>
  11. <div class="logout" @click="logout"></div>
  12. </div>
  13. </div>
  14. </div>
  15. <select-tenant :selectDta="selectDta" v-show="isSelectTenant"></select-tenant>
  16. <div class="bottom_png"><span></span></div>
  17. <div class="bg-earth" v-show="!isSelectTenant">
  18. <div class="nav-content">
  19. <template v-for="(item, index) in navList">
  20. <div
  21. :key="index"
  22. @click="goPage(item.linkPath, item.isOwner, item.id, item.appId)"
  23. :class="[item.isOwner ? '' : 'unOwner', 'item']"
  24. >
  25. <span class="left-label"></span>
  26. <div class="item-cenText">
  27. <img class="img" :src="envConfig.baseImgApi + item.menuImage" :onerror="defaultImgSrc" />
  28. <img class="imghover" :src="envConfig.baseImgApi + item.menuDynamicImage" :onerror="defaultImgSrc" />
  29. <div class="contents">
  30. <div class="title">{{ item.name }}</div>
  31. <div class="subtitle">{{ item.englishName }}</div>
  32. </div>
  33. </div>
  34. <div class="right-img"></div>
  35. </div>
  36. </template>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import envConfig from '@/config';
  43. import SelectTenant from '@/components/ToggleTenant';
  44. export default {
  45. components: {
  46. SelectTenant
  47. },
  48. data() {
  49. return {
  50. envConfig: envConfig,
  51. navList: [],
  52. logo: '',
  53. menuImage: '',
  54. defaultImgSrc: 'this.src="' + require('@/assets/img/nav/bengzhanguanli1.png') + '"',
  55. selectDta: [],
  56. tenantName: null,
  57. isSelectTenant: false
  58. };
  59. },
  60. methods: {
  61. logout() {
  62. var access_token = localStorage.getItem('SC_token');
  63. this.$http.postForm('/user/logout', { access_token: access_token }).then(({ status, data, msg }) => {
  64. if (0 === status) {
  65. this.$message({
  66. type: 'success',
  67. message: '您已退出登录'
  68. });
  69. localStorage.removeItem('SC_token');
  70. localStorage.removeItem('menupath');
  71. localStorage.removeItem('ms_username');
  72. this.$store.commit('setloginInfo', '');
  73. // sessionStorage.removeItem('tabs');
  74. sessionStorage.clear();
  75. this.$router.push({
  76. path: '/login'
  77. });
  78. } else {
  79. this.$message.error(msg);
  80. }
  81. });
  82. },
  83. //页面跳转用,根据appid跳转到不同的界面,appid后端提供
  84. goPage(url, isOwner, id, appId) {
  85. if (!isOwner) {
  86. return;
  87. }
  88. if (url.indexOf('/IOT') != '-1') {
  89. this.$http.get('/user/getRangeCode', { appId: '1001' }).then(({ status, data, msg }) => {
  90. if (0 === status) {
  91. window.open(`${url}?code=${data}`);
  92. } else {
  93. this.$message.error(msg);
  94. }
  95. });
  96. } else if (appId == 1007) {
  97. this.$http.get('/sc-community/assets/community/getLoginParkUrl').then(({ status, data, msg }) => {
  98. if (0 === status) {
  99. window.open(`${data}`);
  100. } else {
  101. this.$message.error(msg);
  102. }
  103. });
  104. } else if (Number(appId) < 0) {
  105. window.open(url);
  106. } else {
  107. window.open(url);
  108. }
  109. },
  110. getNavList() {
  111. this.$http.get('/sc-user-center/user/findUserFirstMenu').then(({ status, data, msg }) => {
  112. if (0 === status) {
  113. if (data && data.length > 10) {
  114. let newdata = data.slice(0, 10);
  115. this.navList = newdata;
  116. } else {
  117. this.navList = data;
  118. }
  119. }
  120. });
  121. },
  122. toggleTenant() {
  123. if (this.selectDta.length > 1) {
  124. this.isSelectTenant = !this.isSelectTenant;
  125. }
  126. },
  127. selectTenant(item) {
  128. if (this.$route.query.tenantId == item.tenantId) {
  129. this.toggleTenant();
  130. return;
  131. }
  132. window.sessionStorage.setItem('loginJson', JSON.stringify(this.selectDta));
  133. window.sessionStorage.setItem('loginJsonActive', JSON.stringify(item));
  134. this.getlogin();
  135. },
  136. getlogin() {
  137. this.isSelectTenant = false;
  138. this.selectDta = JSON.parse(window.sessionStorage.getItem('loginJson'));
  139. let { phone, tenantId } = JSON.parse(window.sessionStorage.getItem('loginJsonActive'));
  140. this.selectDta.map((item, index) => {
  141. if (item.tenantId == tenantId) {
  142. this.tenantName = item.tenantName;
  143. return;
  144. }
  145. });
  146. this.$http
  147. .postForm('/user/login', { mobile: phone, tenatId: tenantId, token: localStorage.getItem('SC_token') })
  148. .then(({ status, data, msg }) => {
  149. localStorage.setItem('customerID', data.customerId);
  150. if (data.enableState === '0') {
  151. if (this.tenantName.length > 1) {
  152. this.$alert('该租户已被停用,请选择其他租户节点', '', {
  153. confirmButtonText: '确定',
  154. showClose: false
  155. })
  156. .then(() => {
  157. this.toggleTenant();
  158. })
  159. .catch(() => {});
  160. return;
  161. } else {
  162. this.$alert('你的账号已被停用,如有问题请联系管理员', '', {
  163. confirmButtonText: '确定',
  164. showClose: false
  165. })
  166. .then(() => {
  167. window.open('/login/', '_self');
  168. window.relogin = false;
  169. })
  170. .catch(() => {});
  171. return;
  172. }
  173. }
  174. this.logo = data.logo;
  175. this.getNavList();
  176. });
  177. }
  178. },
  179. created() {
  180. this.getlogin();
  181. }
  182. };
  183. </script>
  184. <style lang="scss" scoped>
  185. @import './style.scss';
  186. // .nav-wrap {
  187. // width: 100%;
  188. // height: 100%;
  189. // // min-width: 1500px;
  190. // background: linear-gradient(0deg, #000000 0%, #132037 100%);
  191. // overflow: hidden;
  192. // position: relative;
  193. // .top {
  194. // position: relative;
  195. // z-index: 101;
  196. // padding-top: 67px;
  197. // .lfet-right {
  198. // padding: 0 100px 0 100px;
  199. // display: flex;
  200. // justify-content: space-between;
  201. // text-align: center;
  202. // position: relative;
  203. // top: -25px;
  204. // .tenantName {
  205. // color: RGBA(254, 254, 254, 1);
  206. // padding: 0 20px;
  207. // height: 49px;
  208. // line-height: 49px;
  209. // font-size: 20px;
  210. // box-sizing: border-box;
  211. // border: 1px solid RGBA(71, 81, 98, 1);
  212. // border-radius: 10px;
  213. // margin-right: 20px;
  214. // cursor: pointer;
  215. // }
  216. // }
  217. // }
  218. // .logo {
  219. // width: 120px;
  220. // height: 36px;
  221. // background: url(../../assets/img/nav/logo.png);
  222. // background-size: 100% 100%;
  223. // z-index: 11;
  224. // }
  225. // .logout {
  226. // width: 49px;
  227. // height: 49px;
  228. // background: url(../../assets/img/btn_switch.png);
  229. // background-size: 100% 100%;
  230. // z-index: 11;
  231. // }
  232. // .top_png {
  233. // // position: absolute;
  234. // // z-index: 100;
  235. // // top: 67px;
  236. // // left: 50%;
  237. // width: 100%;
  238. // width: 1458px;
  239. // margin: auto;
  240. // height: 58px;
  241. // // transform: translateX(-50%);
  242. // animation-name: opacityAni;
  243. // background: url(../../assets/img/nav/img_toubu.png);
  244. // background-size: cover;
  245. // opacity: 0;
  246. // animation-delay: 0.668s;
  247. // animation-duration: 0.834s;
  248. // animation-fill-mode: forwards;
  249. // p {
  250. // font-size: 24px;
  251. // font-family: PingFang SC;
  252. // font-weight: 600;
  253. // color: #ffffff;
  254. // background: linear-gradient(1deg, #a8c4f5 0%, #ffffff 100%);
  255. // -webkit-background-clip: text;
  256. // -webkit-text-fill-color: transparent;
  257. // position: relative;
  258. // top: -10px;
  259. // text-align: center;
  260. // }
  261. // }
  262. // .bottom_png {
  263. // position: absolute;
  264. // z-index: 100;
  265. // bottom: 0;
  266. // width: 100%;
  267. // height: 83px;
  268. // height: 4.3vw;
  269. // background: #010305;
  270. // & > span {
  271. // display: block;
  272. // width: 100%;
  273. // height: 83px;
  274. // height: 4.3vw;
  275. // animation-name: opacityAni;
  276. // background: url(../../assets/img/nav/img_dibu.png);
  277. // background-size: cover;
  278. // opacity: 0;
  279. // animation-delay: 0.668s;
  280. // animation-duration: 0.834s;
  281. // animation-fill-mode: forwards;
  282. // }
  283. // }
  284. // .bg-earth {
  285. // position: absolute;
  286. // width: 1500px;
  287. // width: 1920 / 1500;
  288. // height: 600px;
  289. // top: 50%;
  290. // left: 50%;
  291. // transform: translate(-50%, -50%);
  292. // overflow-y: auto;
  293. // &::-webkit-scrollbar {
  294. // // width: 5px;
  295. // display: none;
  296. // }
  297. // // &::-webkit-scrollbar-track {
  298. // // background-color: white;
  299. // // border-radius: 10px;
  300. // // }
  301. // // &::-webkit-scrollbar-thumb {
  302. // // border-radius: 10px;
  303. // // background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.6, RGBA(9, 14, 25, 1)));
  304. // // }
  305. // }
  306. // .nav-title {
  307. // position: absolute;
  308. // display: flex;
  309. // justify-content: center;
  310. // align-items: center;
  311. // flex-direction: column;
  312. // width: 381px;
  313. // height: 153px;
  314. // img {
  315. // width: 150px;
  316. // height: 40px;
  317. // }
  318. // .dot_icon {
  319. // display: flex;
  320. // justify-content: center;
  321. // align-items: center;
  322. // flex-direction: row;
  323. // margin-top: 10px;
  324. // p {
  325. // font-size: 36px;
  326. // font-weight: 600;
  327. // font-family: PingFang SC;
  328. // color: #ffffff;
  329. // // margin-top: 10px;
  330. // text-align: center;
  331. // }
  332. // .icon-blue-rect {
  333. // display: inline-block;
  334. // margin: 0 10px;
  335. // width: 6px;
  336. // height: 6px;
  337. // background: linear-gradient(-80deg, #2a68e6 0%, #2887f2 100%);
  338. // border-radius: 3px;
  339. // vertical-align: super;
  340. // }
  341. // }
  342. // }
  343. // .nav-content {
  344. // display: grid;
  345. // // 左右距离30 一列3等分
  346. // row-gap: 30px;
  347. // column-gap: 30px;
  348. // grid-template-columns: repeat(3, minmax(0, 1fr));
  349. // .item {
  350. // width: 480px;
  351. // height: 180px;
  352. // background: RGBA(32, 40, 57, 1);
  353. // border-radius: 10px;
  354. // border: 1px solid transparent;
  355. // position: relative;
  356. // cursor: pointer;
  357. // display: flex;
  358. // justify-content: space-between;
  359. // &:hover {
  360. // border-color: #ffffff;
  361. // .left-label {
  362. // opacity: 1;
  363. // }
  364. // .item-cenText .contents {
  365. // opacity: 1;
  366. // .subtitle {
  367. // color: #0eaeff;
  368. // }
  369. // }
  370. // .right-img {
  371. // opacity: 0.7;
  372. // }
  373. // .img {
  374. // display: none;
  375. // }
  376. // .imghover {
  377. // display: block;
  378. // }
  379. // }
  380. // .imghover {
  381. // display: none;
  382. // }
  383. // .item-cenText {
  384. // margin: 43px 0 0 56px;
  385. // display: flex;
  386. // .img,
  387. // .imghover {
  388. // width: 82px;
  389. // height: 92px;
  390. // }
  391. // .contents {
  392. // margin-left: 48px;
  393. // font-size: 24px;
  394. // font-family: Microsoft YaHei;
  395. // font-weight: bold;
  396. // color: #ffffff;
  397. // opacity: 0.8;
  398. // .subtitle {
  399. // font-size: 12px;
  400. // margin-top: 10px;
  401. // color: #748ba8;
  402. // white-space: nowrap;
  403. // }
  404. // }
  405. // }
  406. // .right-img {
  407. // background: url('../../assets/img/nav/img6.png') no-repeat;
  408. // background-size: cover;
  409. // width: 90px;
  410. // height: 180px;
  411. // opacity: 0.2;
  412. // }
  413. // .left-label {
  414. // width: 6px;
  415. // height: 50px;
  416. // background: #ffffff;
  417. // opacity: 0.3;
  418. // border-radius: 0px 4px 4px 0px;
  419. // position: absolute;
  420. // left: 0;
  421. // top: 50%;
  422. // transform: translateY(-50%);
  423. // }
  424. // }
  425. // .item.unOwner {
  426. // opacity: 0.3;
  427. // cursor: no-drop;
  428. // animation-name: opacityAni2;
  429. // &:hover {
  430. // border-color: transparent;
  431. // .left-label {
  432. // opacity: 0.3;
  433. // }
  434. // .item-cenText .contents {
  435. // opacity: 0.8;
  436. // .subtitle {
  437. // color: #748ba8;
  438. // }
  439. // }
  440. // .right-img {
  441. // opacity: 0.2;
  442. // }
  443. // .img {
  444. // display: block;
  445. // }
  446. // .imghover {
  447. // display: none;
  448. // }
  449. // }
  450. // }
  451. // }
  452. // }
  453. // @keyframes opacityAni {
  454. // 0% {
  455. // opacity: 0;
  456. // }
  457. // 100% {
  458. // opacity: 1;
  459. // }
  460. // }
  461. // @keyframes opacityAni2 {
  462. // 0% {
  463. // opacity: 0;
  464. // }
  465. // 100% {
  466. // opacity: 0.3;
  467. // }
  468. // }
  469. </style>