clubDetail.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. showAuthCard: false,
  18. authId: '',
  19. clubInfo: {},
  20. }
  21. },
  22. computed: {
  23. ...mapGetters(['routePrefix', 'supplierInfo']),
  24. address() {
  25. let resultAddress = this.clubInfo.area
  26. ? this.clubInfo.area + this.clubInfo.address
  27. : this.clubInfo.address
  28. return resultAddress || '暂无'
  29. },
  30. isEmpty() {
  31. return this.clubInfo.productList
  32. ? this.clubInfo.productList.length === 0
  33. : true
  34. },
  35. // 授权牌
  36. authCardImage() {
  37. if (!this.clubInfo) return ''
  38. return this.clubInfo.authImage
  39. },
  40. },
  41. mounted() {
  42. this.initData()
  43. },
  44. beforeDestroy() {
  45. this.$removeStorage(this.routePrefix, 'clubInfo')
  46. },
  47. methods: {
  48. callMobile,
  49. // 显示授权牌
  50. onShowAuthCard() {
  51. this.showAuthCard = true
  52. },
  53. // 隐藏授权牌
  54. onHideAuthCard() {
  55. this.showAuthCard = false
  56. },
  57. // 设备详情
  58. toDetail(item) {
  59. const url = `${this.routePrefix}/approve/device/detail?id=${item.productId}`
  60. this.$router.push(url)
  61. },
  62. // 初始化
  63. initData() {
  64. this.authId = parseInt(this.$route.query.id)
  65. const clubInfo = this.$getStorage(this.routePrefix, 'clubInfo')
  66. if (clubInfo) {
  67. this.clubInfo = clubInfo
  68. }
  69. this.fetchDetail()
  70. },
  71. // 获取机构详细信息
  72. async fetchDetail() {
  73. try {
  74. const res = await this.$http.api.getAuthClubDetail({
  75. authId: this.authId,
  76. })
  77. this.clubInfo = { ...this.clubInfo, ...res.data } // 合并
  78. } catch (error) {
  79. console.log(error)
  80. }
  81. // 默认轮播图
  82. if (this.clubInfo.bannerList.length <= 0) {
  83. this.clubInfo.bannerList.push('/placeholder.png')
  84. }
  85. // 默认logo
  86. if (!this.clubInfo.logo) {
  87. this.clubInfo.logo = drawLogo(this.clubInfo.authParty)
  88. }
  89. },
  90. // 地图导航
  91. onMapNav() {
  92. this.$refs.mapNav.open()
  93. },
  94. // 导航
  95. navigation(type) {
  96. const point = this.clubInfo.lngAndLat.split(',')
  97. let lng = point[0]
  98. let lat = point[1]
  99. mapNavigate(
  100. { lat, lng, title: this.clubInfo.authParty, address: this.address },
  101. type
  102. )
  103. this.$refs.mapNav.close()
  104. },
  105. },
  106. }