deviceDetail.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. return chunk(this.productInfo.paramList, 1)
  32. },
  33. // 机构logo
  34. brandLogoImage() {
  35. if (!this.productInfo) return ''
  36. return this.productInfo.brandLogo
  37. },
  38. // 授权牌
  39. authCardImage() {
  40. if (!this.productInfo) return ''
  41. return this.productInfo.appletsCertificateImage
  42. },
  43. // 机构logo列表
  44. clubLogo() {
  45. if (!this.productInfo) return []
  46. return this.productInfo.clubList.map((item) => item.logo)
  47. },
  48. },
  49. created() {
  50. this.fetchProductDetails()
  51. },
  52. methods: {
  53. // 显示授权牌
  54. onShowAuthCard() {
  55. this.showAuthCard = true
  56. },
  57. // 隐藏授权牌
  58. onHideAuthCard() {
  59. this.showAuthCard = false
  60. },
  61. // 获取设备详情
  62. async fetchProductDetails() {
  63. const productId = this.$route.query.id
  64. try {
  65. const { data } = await this.$http.api.fetchProductDetails({
  66. productId: productId,
  67. })
  68. this.productInfo = data
  69. } catch (error) {
  70. console.log(error)
  71. }
  72. },
  73. },
  74. }