Header2.0.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. console.log(res);
  128. this.city = res.city
  129. console.log(this.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.user = res
  161. this.rolesPermissions = getRolesPermissions(res.roleList)
  162. storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  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. this.hideLoading();
  171. })
  172. } else {
  173. this.user = storageGet('user')
  174. // this.fullScreenLoading = false
  175. this.isLogin = true
  176. }
  177. this.hideLoading();
  178. },
  179. getCurrentUserSuccess (res) {
  180. // console.log(res)
  181. storageSave('user', res)
  182. this.user = res
  183. this.rolesPermissions = getRolesPermissions(res.roleList)
  184. storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  185. console.log('用户信息加载成功')
  186. this.isLogin = true
  187. this.fullScreenLoading = false
  188. },
  189. getCurrentUserFail (error) {
  190. console.log('用户信息加载失败')
  191. this.fullScreenLoading = false
  192. },
  193. userLogout () {
  194. this.isLogin = false
  195. logout().then((res) => {
  196. // location.reload();
  197. console.log(this.$route.fullPath);
  198. if(this.$route.fullPath.includes("/home")){
  199. location.reload();
  200. }else{
  201. this.$router.push('/home')
  202. }
  203. })
  204. },
  205. // showLoading () {
  206. // this.fullScreenLoading = true
  207. // },
  208. // hideLoading () {
  209. // this.fullScreenLoading = false
  210. // },
  211. handleClickAuthReject () {
  212. if (this.user.userVO.authType == 'agency') {
  213. this.$router.push({
  214. name: 'AgencyAuthentication',
  215. params: {userId: this.user.userVO.id}
  216. })
  217. }
  218. if (this.user.userVO.authType == 'enterprise') {
  219. this.$router.push({
  220. name: 'EnterpriseAuthentication',
  221. params: {userId: this.user.userVO.id}
  222. })
  223. }
  224. if (this.user.userVO.authType == 'personal') {
  225. this.$router.push({
  226. name: 'IndividualAuthentication',
  227. params: {userId: this.user.userVO.id}
  228. })
  229. }
  230. //this.getAuthInfo()
  231. },
  232. handleClickAuthPass () {
  233. if (this.user.personalAuthVO) {
  234. this.$router.push({
  235. name: 'IndividualAuthentication',
  236. params: {userId: this.user.userVO.id}
  237. })
  238. }else if (this.user.agencyVO) {
  239. this.$router.push({
  240. name: 'AgencyAuthentication',
  241. params: {userId: this.user.userVO.id}
  242. })
  243. }
  244. else if (this.user.enterpriseAuthVO) {
  245. this.$router.push({
  246. name: 'EnterpriseAuthentication',
  247. params: {userId: this.user.userVO.id}
  248. })
  249. }
  250. //this.getAuthInfo()
  251. },
  252. handleClickAuthChecking () {
  253. //this.getAuthInfo()
  254. if (this.user.userVO.authType == 'agency') {
  255. this.$router.push({
  256. name: 'AgencyAuthentication',
  257. params: {userId: this.user.userVO.id}
  258. })
  259. }
  260. if (this.user.userVO.authType == 'enterprise') {
  261. this.$router.push({
  262. name: 'EnterpriseAuthentication',
  263. params: {userId: this.user.userVO.id}
  264. })
  265. }
  266. if (this.user.userVO.authType == 'personal') {
  267. this.$router.push({
  268. name: 'IndividualAuthentication',
  269. params: {userId: this.user.userVO.id}
  270. })
  271. }
  272. },
  273. showAuthRejectDialog () {
  274. this.isShowAuthRejectDialog = true
  275. },
  276. showAuthPassDialog () {
  277. this.isShowAuthPassDialog = true
  278. },
  279. showAuthCheckingDialog () {
  280. this.isShowAuthCheckingDialog = true
  281. },
  282. hideAuthRejectDialog () {
  283. this.isShowAuthRejectDialog = false
  284. },
  285. hideAuthPassDialog () {
  286. this.isShowAuthPassDialog = false
  287. },
  288. hideAuthCheckingDialog () {
  289. this.isShowAuthCheckingDialog = false
  290. },
  291. deleteOldAuthInfo () {
  292. this.hideAuthCheckingDialog()
  293. this.hideAuthRejectDialog()
  294. this.hideAuthPassDialog()
  295. this.showLoading()
  296. deleteAuthInfo().then((res) => {
  297. this.hideLoading()
  298. notify('success', '成功删除认证信息')
  299. }).catch((error) => {
  300. this.hideLoading()
  301. notify('error', '删除认证信息失败:' + error.data)
  302. })
  303. },
  304. getAuthInfo () {
  305. this.showLoading()
  306. if (this.user.userVO.authType == 'agency') {
  307. getCurrentAgencyAuthInfo(this.user.userVO.id, this.getCurrentAgencyAuthInfoSuccess, this.getCurrentAgencyAuthInfoFail)
  308. }
  309. if (this.user.userVO.authType == 'personal') {
  310. getCurrentIndividualAuthenInfo(this.user.userVO.id, this.getCurrentIndividualAuthenInfoSuccess, this.getCurrentIndividualAuthenInfoFail)
  311. }
  312. if (this.user.userVO.authType == 'enterprise') {
  313. getCurrentEnterpriseAuthInfo(this.user.userVO.id, this.getCurrentEnterpriseAuthInfoSuccess, this.getCurrentEnterpriseAuthInfoFail)
  314. }
  315. },
  316. getCurrentAgencyAuthInfoSuccess () {
  317. this.hideLoading()
  318. },
  319. getCurrentAgencyAuthInfoFail () {
  320. this.hideLoading()
  321. },
  322. getCurrentIndividualAuthenInfoSuccess () {
  323. this.hideLoading()
  324. },
  325. getCurrentIndividualAuthenInfoFail () {
  326. this.hideLoading()
  327. },
  328. getCurrentEnterpriseAuthInfoSuccess () {
  329. this.hideLoading()
  330. },
  331. getCurrentEnterpriseAuthInfoFail () {
  332. this.hideLoading()
  333. },
  334. handleUpdateAuthInfo () {
  335. this.hideAuthPassDialog()
  336. this.hideAuthRejectDialog()
  337. this.hideAuthCheckingDialog()
  338. if (this.user.userVO.authType == 'personal') {
  339. this.$router.push({
  340. name: 'IndividualAuthentication',
  341. params: {
  342. userId: this.authInfo.userId
  343. }
  344. })
  345. }
  346. if (this.authInfo.type == 'enterprise') {
  347. this.$router.push({
  348. name: 'EnterpriseAuthentication',
  349. params: {
  350. userId: this.authInfo.userId
  351. }
  352. })
  353. }
  354. if (this.authInfo.type == 'agency') {
  355. this.$router.push({
  356. name: 'AgencyAuthentication',
  357. params: {
  358. userId: this.authInfo.userId
  359. }
  360. })
  361. }
  362. }
  363. },
  364. created () {
  365. var self = this
  366. this.$root.$on('user', function (val) {
  367. self.user = val
  368. })
  369. },
  370. beforeMount () {
  371. this.getAddress();
  372. this.setUserInfo()
  373. // if (storageGet('user' != null)){
  374. // this.isLogin = true
  375. // }
  376. }
  377. }
  378. </script>
  379. <style scoped>
  380. .header-nav {
  381. padding: 5px 0;
  382. text-align: center;
  383. display: flex;
  384. font-size: 16px;
  385. color: rgba(153, 153, 153, 1);
  386. /*height:58px;*/
  387. background:rgba(243,244,247,1);
  388. }
  389. .header-nav ul{
  390. margin-bottom: 0;
  391. padding: 0;
  392. list-style: none;
  393. }
  394. .header-nav ul li {
  395. display: inline-block;
  396. }
  397. .header-nav ul li a{
  398. color: inherit;
  399. padding: 5px;
  400. font-weight: 500;
  401. text-transform: uppercase;
  402. border-radius: 3px;
  403. position: relative;
  404. display: block;
  405. }
  406. .header-nav .copyright {
  407. padding: 5px 0;
  408. color:#333;
  409. }
  410. .copyright a{
  411. color:#666;
  412. }
  413. </style>