Header2.0.vue 14 KB

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