Header2.0.vue 14 KB

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