BaseInfoView.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <script setup lang="ts">
  2. import HeaderCard from '@/components/dataAnalysis/HeaderCard.vue'
  3. import { reactive, onMounted, ref } from 'vue'
  4. import { initLoadResouce } from '@/utils/resource'
  5. import { copyText } from '@/utils/common'
  6. interface AppInfo {
  7. name: string
  8. pf: string
  9. appType: string
  10. createDate: string
  11. AppletsID: string
  12. AppID: string
  13. img: string
  14. }
  15. // 返回的APP信息
  16. const appInfo = reactive<AppInfo>({
  17. img: '/img/default/defaultGameImg.svg',
  18. name: '消消乐',
  19. pf: '微信',
  20. appType: '游戏娱乐',
  21. createDate: '2024-1-1',
  22. AppletsID: 'ASJDFJAHSJDF',
  23. AppID: 'A12312312412JAHSJDF'
  24. })
  25. // 信息对应的字段
  26. const fieldsInfo = {
  27. name: '应用名称',
  28. pf: '应用平台',
  29. appType: '游戏平台',
  30. createDate: '创建日期',
  31. AppletsID: '小程序ID',
  32. AppID: 'App ID'
  33. }
  34. // 资源的加载路径
  35. const resourceInfo: Record<string, string> = {
  36. defaultHead: `/img/default/defaultHead.png`
  37. }
  38. // 使用blob的资源路径信息
  39. const blobUrlInfo = reactive<Record<string, string>>({})
  40. const AppID = ref<Array<HTMLSpanElement> | null>(null)
  41. const copyAppID = () => {
  42. copyText(appInfo.AppID).then(() => {
  43. if (AppID.value) {
  44. const range = document.createRange()
  45. range.selectNodeContents(AppID.value[0])
  46. const selection = window.getSelection()
  47. if (selection) {
  48. selection.removeAllRanges()
  49. selection.addRange(range)
  50. }
  51. }
  52. })
  53. }
  54. onMounted(() => {
  55. // 去加载所有需要的资源
  56. initLoadResouce(resourceInfo).then((data) => {
  57. Object.assign(blobUrlInfo, data)
  58. })
  59. })
  60. </script>
  61. <template>
  62. <div class="baseInfo">
  63. <HeaderCard :title="'基本信息'"></HeaderCard>
  64. <div class="body">
  65. <div class="info">
  66. <div class="infoItem" v-for="[key, val] in Object.entries(fieldsInfo)">
  67. <span class="itmeTitle">{{ val }}</span>
  68. <span class="text" :ref="key">{{ appInfo[key as keyof AppInfo] }}</span>
  69. <span class="copy" v-if="key === 'AppID'" @click="copyAppID">复制</span>
  70. </div>
  71. </div>
  72. <div class="photo">
  73. <el-image :src="appInfo.img">
  74. <template #error>
  75. <el-image class="headPortrait" :src="blobUrlInfo.defaultHead"></el-image>
  76. </template>
  77. </el-image>
  78. </div>
  79. </div>
  80. </div>
  81. </template>
  82. <style scoped>
  83. .baseInfo {
  84. width: 98%;
  85. margin: 1% auto;
  86. box-sizing: border-box;
  87. }
  88. .body {
  89. box-sizing: border-box;
  90. margin-top: 15px;
  91. /* padding: 0 24px; */
  92. display: flex;
  93. align-items: center;
  94. width: 100%;
  95. position: relative;
  96. }
  97. .info {
  98. width: 100%;
  99. box-sizing: border-box;
  100. padding: 40px 40px 40px 144px;
  101. background: #fff;
  102. box-shadow:
  103. 0 4px 8px 0 rgba(0, 0, 0, 0.02),
  104. 0 1px 3px 0 rgba(0, 0, 0, 0.02);
  105. border-radius: 4px;
  106. position: relative;
  107. }
  108. .photo {
  109. position: absolute;
  110. left: 40px;
  111. top: 40px;
  112. border-radius: 16px;
  113. width: 64px;
  114. height: 64px;
  115. }
  116. .infoItem {
  117. margin-bottom: 15px;
  118. }
  119. .itmeTitle {
  120. display: inline-block;
  121. width: 80px;
  122. text-align: left;
  123. padding-right: 0;
  124. font-size: 14px;
  125. color: #808695;
  126. line-height: 2px;
  127. }
  128. .text {
  129. font-weight: 600;
  130. color: #1c2438;
  131. font-size: 14px;
  132. margin-left: 106px;
  133. line-height: 20px;
  134. }
  135. .copy {
  136. margin-left: 8px;
  137. font-size: 14px;
  138. font-weight: 600;
  139. color: #2285f0;
  140. cursor: pointer;
  141. }
  142. </style>