Header2.0.vue 14 KB

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