Header2.0.vue 14 KB

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