clubDetail.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import { drawLogo } from '@/utils'
  2. import { mapNavigate } from '@/utils/map-utils'
  3. import { callMobile } from '@/utils'
  4. import { mapGetters } from 'vuex'
  5. export default {
  6. filters: {
  7. formatEmpty(val) {
  8. return val || '暂无'
  9. },
  10. formatSnCode(code) {
  11. if (!code) return ''
  12. return code.replace(/^(\w{2})\w+(\w{4})$/, '$1******$2')
  13. },
  14. },
  15. data() {
  16. return {
  17. authId: '',
  18. clubInfo: {},
  19. }
  20. },
  21. computed: {
  22. ...mapGetters(['routePrefix']),
  23. address() {
  24. let resultAddress = this.clubInfo.area
  25. ? this.clubInfo.area + this.clubInfo.address
  26. : this.clubInfo.address
  27. return resultAddress || '暂无'
  28. },
  29. isEmpty() {
  30. return this.clubInfo.productList
  31. ? this.clubInfo.productList.length === 0
  32. : true
  33. },
  34. },
  35. mounted() {
  36. this.initData()
  37. },
  38. beforeDestroy() {
  39. this.$removeStorage(this.routePrefix, 'clubInfo')
  40. },
  41. methods: {
  42. callMobile,
  43. // 设备详情
  44. toDetail(item) {
  45. const url = `${this.routePrefix}/approve/device/detail?id=${item.productId}`
  46. this.$router.push(url)
  47. },
  48. // 初始化
  49. initData() {
  50. this.authId = parseInt(this.$route.query.id)
  51. const clubInfo = this.$getStorage(this.routePrefix, 'clubInfo')
  52. if (clubInfo) {
  53. this.clubInfo = clubInfo
  54. }
  55. this.fetchDetail()
  56. },
  57. // 获取机构详细信息
  58. async fetchDetail() {
  59. try {
  60. const res = await this.$http.api.getAuthClubDetail({
  61. authId: this.authId,
  62. })
  63. this.clubInfo = { ...this.clubInfo, ...res.data } // 合并
  64. } catch (error) {
  65. console.log(error)
  66. }
  67. // 默认轮播图
  68. if (this.clubInfo.bannerList.length <= 0) {
  69. this.clubInfo.bannerList.push('/placeholder.png')
  70. }
  71. // 默认logo
  72. if (!this.clubInfo.logo) {
  73. this.clubInfo.logo = drawLogo(this.clubInfo.authParty)
  74. }
  75. },
  76. // 地图导航
  77. onMapNav() {
  78. this.$refs.mapNav.open()
  79. },
  80. // 导航
  81. navigation(type) {
  82. const point = this.clubInfo.lngAndLat.split(',')
  83. let lng = point[0]
  84. let lat = point[1]
  85. mapNavigate(
  86. { lat, lng, title: this.clubInfo.authParty, address: this.address },
  87. type
  88. )
  89. this.$refs.mapNav.close()
  90. },
  91. },
  92. }