Header2.0.vue 13 KB

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