deviceDetail.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { mapGetters } from 'vuex'
  2. import { chunk } from 'lodash'
  3. export default {
  4. filters: {
  5. snCodeRender(code) {
  6. return code.replace(/^(\w{2})\w+(\w{4})$/, '$1******$2')
  7. },
  8. },
  9. data() {
  10. return {
  11. showAuthCard: false,
  12. bannerList: [],
  13. productInfo: null,
  14. }
  15. },
  16. watch: {
  17. isPc() {
  18. this.$nextTick(() => {
  19. window.location.reload()
  20. })
  21. },
  22. },
  23. computed: {
  24. ...mapGetters(['isPc']),
  25. // 参数列表
  26. paramListRender() {
  27. if (!this.productInfo) return []
  28. return this.isPc
  29. ? chunk(this.productInfo.paramList, 2)
  30. : chunk(this.productInfo.paramList, 1)
  31. },
  32. // 机构logo
  33. brandLogoImage() {
  34. if (!this.productInfo) return ''
  35. return this.productInfo.brandLogo
  36. },
  37. // 授权牌
  38. authCardImage() {
  39. if (!this.productInfo) return ''
  40. return this.productInfo.appletsCertificateImage
  41. },
  42. // 机构logo列表
  43. clubLogo() {
  44. if (!this.productInfo) return []
  45. return this.productInfo.clubList.map((item) => item.logo)
  46. },
  47. },
  48. created() {
  49. this.fetchProductDetails()
  50. },
  51. methods: {
  52. // 显示授权牌
  53. onShowAuthCard() {
  54. this.showAuthCard = true
  55. },
  56. // 隐藏授权牌
  57. onHideAuthCard() {
  58. this.showAuthCard = false
  59. },
  60. // 获取设备详情
  61. async fetchProductDetails() {
  62. const productId = this.$route.query.id
  63. try {
  64. const { data } = await this.$http.api.fetchProductDetails({
  65. productId: productId,
  66. })
  67. this.productInfo = data
  68. } catch (error) {
  69. console.log(error)
  70. }
  71. },
  72. },
  73. }