Header2.0.vue 14 KB

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