Header2.0.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div class="header-nav" v-loading="loading">
  3. <div class="container">
  4. <div class="nav-location pull-left">
  5. <i class="el-icon-location-outline" style="margin-right: 5px"></i>
  6. <span style="line-height: 34px" v-if="!city || city == ''">暂无</span>
  7. <span style="line-height: 34px" v-else>{{ city }}</span>
  8. </div>
  9. <div class="nav-list pull-right">
  10. <ul>
  11. <li>
  12. <a @click="gotoHome" style="cursor: pointer">首页</a>
  13. </li>
  14. &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
  15. <li>
  16. <li v-if="isLogin">
  17. <el-dropdown>
  18. <span class="el-dropdown-link" style="color:rgb(153,153,153)">
  19. {{ user.userVO.name }}<i class="el-icon-arrow-down el-icon--right"></i>
  20. </span>
  21. <el-dropdown-menu slot="dropdown">
  22. <el-dropdown-item>
  23. <router-link :to="{ path:'/personal/mine'}">
  24. <el-link icon="el-icon-user" :underline="false">
  25. 个人中心
  26. </el-link>
  27. </router-link>
  28. </el-dropdown-item>
  29. <el-dropdown-item>
  30. <router-link :to="{ path:'/bookkeeptest'}">
  31. <el-link icon="el-icon-user" :underline="false">
  32. 个人账单
  33. </el-link>
  34. </router-link>
  35. </el-dropdown-item>
  36. <el-dropdown-item v-if="rolesPermissions.isSystemAdministrator || rolesPermissions.isRegionalAdmin">
  37. <router-link :to="{ name: 'AuthenticationManage'}">
  38. <el-link icon="el-icon-view" :underline="false">
  39. 审核认证信息
  40. </el-link>
  41. </router-link>
  42. </el-dropdown-item>
  43. <el-dropdown-item divided @click.native="userLogout()">登出</el-dropdown-item>
  44. </el-dropdown-menu>
  45. </el-dropdown>
  46. </li>
  47. <li v-if="!isLogin">
  48. <a :href="loginUrl">请登录</a>
  49. </li>
  50. &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
  51. <li v-if="!isLogin">
  52. <a :href="registerUrl">免费注册</a>
  53. </li>
  54. <li v-if="isLogin">
  55. <span v-if="!isLogin">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span>
  56. <router-link v-if="isLogin" to="/mine">
  57. <a class="dropdown-toggle nav-link" data-toggle="dropdown">
  58. <!-- <img class="icon" src="@/assets/img/mine_icon.svg">-->
  59. <span>我的众测</span>
  60. </a>
  61. </router-link>
  62. </li>
  63. <!-- <span v-if="isLogin&&rolesPermissions.isSystemAdministrator">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span>-->
  64. <!-- <li v-if="isLogin&&rolesPermissions.isSystemAdministrator">-->
  65. <!-- <router-link v-if="isLogin" to="/statistics">-->
  66. <!-- <span>机构统计</span>-->
  67. <!-- </router-link>-->
  68. <!-- </li>-->
  69. <span v-if="isLogin && (rolesPermissions.isSystemAdministrator || rolesPermissions.isRegionalAdmin)">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span>
  70. <li v-if="isLogin && (rolesPermissions.isSystemAdministrator || rolesPermissions.isRegionalAdmin)">
  71. <router-link v-if="isLogin" to="/companys">
  72. <span>服务企业</span>
  73. </router-link>
  74. </li>
  75. <!-- <span v-if="isLogin&&(rolesPermissions.isSystemAdministrator || rolesPermissions.isRegionManager)">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span>-->
  76. <!-- <li v-if="isLogin&&(rolesPermissions.isSystemAdministrator || rolesPermissions.isRegionManager)">-->
  77. <!-- <a :href="manage_url" v-if="manage_url">后台管理</a>-->
  78. <!-- </li>-->
  79. </ul>
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import {
  86. defaultValue,
  87. deleteAuthInfo,
  88. getCurrentAgencyAuthInfo,
  89. getCurrentEnterpriseAuthInfo,
  90. getCurrentIndividualAuthenInfo,
  91. getCurrentUser,
  92. getRolesPermissions,
  93. logout,
  94. storageGet,
  95. storageSave,
  96. storageRemove
  97. } from '@/js/index'
  98. import Http from '@/js/http.js'
  99. import Apis from '@/js/api.js'
  100. import {mapActions} from 'vuex'
  101. import {login_url, register_url, CONFIG} from '../../config/index'
  102. export default {
  103. name: 'Header2.0',
  104. data () {
  105. return {
  106. user: {},
  107. loading: false,
  108. fullScreenLoading: true,
  109. loginUrl: login_url,
  110. registerUrl: register_url,
  111. manage_url: CONFIG.manage_url,
  112. authInfo: {},
  113. isShowAuthCheckingDialog: false,
  114. isShowAuthRejectDialog: false,
  115. isShowAuthPassDialog: false,
  116. //loading: true,
  117. openNavBar: false,
  118. defaultValue: defaultValue,
  119. userIdentity: '',
  120. isLogin: false,
  121. rolesPermissions: {},
  122. city: ''
  123. }
  124. },
  125. watch: {
  126. 'user.authStatus' (val) {
  127. this.user.authStatus = val
  128. // console.log('changed')
  129. // console.log(this.user.authStatus)
  130. },
  131. deep: true
  132. },
  133. methods: {
  134. ...mapActions(['setUser']),
  135. gotoHome () {
  136. this.$router.push('/home')
  137. },
  138. openNavBarFunc () {
  139. this.openNavBar = !this.openNavBar
  140. },
  141. getAddress () {
  142. Http.get(Apis.USER.GET_ADDRESS).then((res) => {
  143. this.city = res.city
  144. }).catch((error) => {
  145. this.hideLoading()
  146. notify('error', '获取定位失败:' + error.data)
  147. })
  148. },
  149. showLoading () {
  150. this.loading = true
  151. },
  152. hideLoading () {
  153. this.loading = false
  154. },
  155. setUserInfo () {
  156. this.showLoading()
  157. getCurrentUser().then((res) => {
  158. storageSave('user', res)
  159. this.setUser(res)
  160. this.user = res
  161. storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  162. this.rolesPermissions = storageGet('rolesPermissions')
  163. console.log('用户信息加载成功')
  164. this.isLogin = true
  165. // this.fullScreenLoading = false
  166. this.hideLoading()
  167. }).catch((error) => {
  168. console.log('用户信息加载失败')
  169. // this.fullScreenLoading = false
  170. storageRemove('user')
  171. this.hideLoading()
  172. })
  173. // if (storageGet('user') == null) {
  174. // storageSave('rolesPermissions', {
  175. // 'isRegionManager': false,
  176. // 'isIndividualUser': false,
  177. // 'isEnterpriseUser': false,
  178. // 'isAgency': false,
  179. // 'isSystemAdministrator': false
  180. // })
  181. // // console.log('本地没有用户信息,开始加载用户信息')
  182. // //暂时注释
  183. // // this.user = storageGet('user')
  184. // // this.rolesPermissions = getRolesPermissions(storageGet('user')&&storageGet('user').roleList)
  185. // // storageSave('rolesPermissions', getRolesPermissions(torageGet('user')&&storageGet('user').roleList))
  186. // // this.isLogin = true
  187. // // this.fullScreenLoading = false
  188. //
  189. // } else {
  190. // this.user = storageGet('user')
  191. // this.rolesPermissions = storageGet('rolesPermissions')
  192. // // this.fullScreenLoading = false
  193. // this.isLogin = true
  194. // }
  195. this.hideLoading()
  196. },
  197. getCurrentUserSuccess (res) {
  198. storageSave('user', res)
  199. this.user = res
  200. storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  201. this.rolesPermissions = storageGet('rolesPermissions')
  202. console.log('用户信息加载成功')
  203. this.isLogin = true
  204. this.fullScreenLoading = false
  205. },
  206. getCurrentUserFail (error) {
  207. console.log('用户信息加载失败')
  208. this.fullScreenLoading = false
  209. },
  210. userLogout () {
  211. this.isLogin = false
  212. storageRemove('user')
  213. logout().then((res) => {
  214. // location.reload();
  215. if (this.$route.fullPath.includes('/home')) {
  216. location.reload()
  217. } else {
  218. this.$router.push('/home')
  219. }
  220. })
  221. },
  222. // showLoading () {
  223. // this.fullScreenLoading = true
  224. // },
  225. // hideLoading () {
  226. // this.fullScreenLoading = false
  227. // },
  228. handleClickAuthReject () {
  229. if (this.user.userVO.authType == 'agency') {
  230. this.$router.push({
  231. name: 'AgencyAuthentication',
  232. params: {userId: this.user.userVO.id}
  233. })
  234. }
  235. if (this.user.userVO.authType == 'enterprise') {
  236. this.$router.push({
  237. name: 'EnterpriseAuthentication',
  238. params: {userId: this.user.userVO.id}
  239. })
  240. }
  241. if (this.user.userVO.authType == 'personal') {
  242. this.$router.push({
  243. name: 'IndividualAuthentication',
  244. params: {userId: this.user.userVO.id}
  245. })
  246. }
  247. //this.getAuthInfo()
  248. },
  249. handleClickAuthPass () {
  250. if (this.user.personalAuthVO) {
  251. this.$router.push({
  252. name: 'IndividualAuthentication',
  253. params: {userId: this.user.userVO.id}
  254. })
  255. } else if (this.user.agencyVO) {
  256. this.$router.push({
  257. name: 'AgencyAuthentication',
  258. params: {userId: this.user.userVO.id}
  259. })
  260. } else if (this.user.enterpriseAuthVO) {
  261. this.$router.push({
  262. name: 'EnterpriseAuthentication',
  263. params: {userId: this.user.userVO.id}
  264. })
  265. }
  266. //this.getAuthInfo()
  267. },
  268. handleClickAuthChecking () {
  269. //this.getAuthInfo()
  270. if (this.user.userVO.authType == 'agency') {
  271. this.$router.push({
  272. name: 'AgencyAuthentication',
  273. params: {userId: this.user.userVO.id}
  274. })
  275. }
  276. if (this.user.userVO.authType == 'enterprise') {
  277. this.$router.push({
  278. name: 'EnterpriseAuthentication',
  279. params: {userId: this.user.userVO.id}
  280. })
  281. }
  282. if (this.user.userVO.authType == 'personal') {
  283. this.$router.push({
  284. name: 'IndividualAuthentication',
  285. params: {userId: this.user.userVO.id}
  286. })
  287. }
  288. },
  289. showAuthRejectDialog () {
  290. this.isShowAuthRejectDialog = true
  291. },
  292. showAuthPassDialog () {
  293. this.isShowAuthPassDialog = true
  294. },
  295. showAuthCheckingDialog () {
  296. this.isShowAuthCheckingDialog = true
  297. },
  298. hideAuthRejectDialog () {
  299. this.isShowAuthRejectDialog = false
  300. },
  301. hideAuthPassDialog () {
  302. this.isShowAuthPassDialog = false
  303. },
  304. hideAuthCheckingDialog () {
  305. this.isShowAuthCheckingDialog = false
  306. },
  307. deleteOldAuthInfo () {
  308. this.hideAuthCheckingDialog()
  309. this.hideAuthRejectDialog()
  310. this.hideAuthPassDialog()
  311. this.showLoading()
  312. deleteAuthInfo().then((res) => {
  313. this.hideLoading()
  314. notify('success', '成功删除认证信息')
  315. }).catch((error) => {
  316. this.hideLoading()
  317. notify('error', '删除认证信息失败:' + error.data)
  318. })
  319. },
  320. getAuthInfo () {
  321. this.showLoading()
  322. if (this.user.userVO.authType == 'agency') {
  323. getCurrentAgencyAuthInfo(this.user.userVO.id, this.getCurrentAgencyAuthInfoSuccess, this.getCurrentAgencyAuthInfoFail)
  324. }
  325. if (this.user.userVO.authType == 'personal') {
  326. getCurrentIndividualAuthenInfo(this.user.userVO.id, this.getCurrentIndividualAuthenInfoSuccess, this.getCurrentIndividualAuthenInfoFail)
  327. }
  328. if (this.user.userVO.authType == 'enterprise') {
  329. getCurrentEnterpriseAuthInfo(this.user.userVO.id, this.getCurrentEnterpriseAuthInfoSuccess, this.getCurrentEnterpriseAuthInfoFail)
  330. }
  331. },
  332. getCurrentAgencyAuthInfoSuccess () {
  333. this.hideLoading()
  334. },
  335. getCurrentAgencyAuthInfoFail () {
  336. this.hideLoading()
  337. },
  338. getCurrentIndividualAuthenInfoSuccess () {
  339. this.hideLoading()
  340. },
  341. getCurrentIndividualAuthenInfoFail () {
  342. this.hideLoading()
  343. },
  344. getCurrentEnterpriseAuthInfoSuccess () {
  345. this.hideLoading()
  346. },
  347. getCurrentEnterpriseAuthInfoFail () {
  348. this.hideLoading()
  349. },
  350. handleUpdateAuthInfo () {
  351. this.hideAuthPassDialog()
  352. this.hideAuthRejectDialog()
  353. this.hideAuthCheckingDialog()
  354. if (this.user.userVO.authType == 'personal') {
  355. this.$router.push({
  356. name: 'IndividualAuthentication',
  357. params: {
  358. userId: this.authInfo.userId
  359. }
  360. })
  361. }
  362. if (this.authInfo.type == 'enterprise') {
  363. this.$router.push({
  364. name: 'EnterpriseAuthentication',
  365. params: {
  366. userId: this.authInfo.userId
  367. }
  368. })
  369. }
  370. if (this.authInfo.type == 'agency') {
  371. this.$router.push({
  372. name: 'AgencyAuthentication',
  373. params: {
  374. userId: this.authInfo.userId
  375. }
  376. })
  377. }
  378. }
  379. },
  380. created () {
  381. var self = this
  382. this.$root.$on('user', function (val) {
  383. self.user = val
  384. })
  385. },
  386. beforeMount () {
  387. this.getAddress()
  388. this.setUserInfo()
  389. // if (storageGet('user' != null)){
  390. // this.isLogin = true
  391. // }
  392. },
  393. }
  394. </script>
  395. <style scoped>
  396. .header-nav {
  397. padding: 5px 0;
  398. text-align: center;
  399. display: flex;
  400. font-size: 16px;
  401. color: rgba(153, 153, 153, 1);
  402. /*height:58px;*/
  403. background: rgba(243, 244, 247, 1);
  404. }
  405. .header-nav ul {
  406. margin-bottom: 0;
  407. padding: 0;
  408. list-style: none;
  409. }
  410. .header-nav ul li {
  411. display: inline-block;
  412. }
  413. .header-nav ul li a {
  414. color: inherit;
  415. padding: 5px;
  416. font-weight: 500;
  417. text-transform: uppercase;
  418. border-radius: 3px;
  419. position: relative;
  420. display: block;
  421. }
  422. .header-nav .copyright {
  423. padding: 5px 0;
  424. color: #333;
  425. }
  426. .copyright a {
  427. color: #666;
  428. }
  429. </style>