main.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div :class="[mode, myClass]">
  3. <nt-loading style="flex: 1;" v-if="!data" :type="'05'"/>
  4. <div v-else v-for="(item, index) in options" :key="index" :class="item.class" :style="item.style">
  5. <div v-for="(node, nodeIndex) in item.list" :key="nodeIndex" v-if="!(isNotShow && node.isNotShow)">
  6. <div v-if="node.type === 1" :style="node.style" :class="node.class">
  7. <img :src="node.key ? data[node.key] : node.value" alt="">
  8. </div>
  9. <div v-else-if="node.type === 2" class="text-space-nowrap" :style="node.style" :class="node.class" v-html="node.key ? (data[node.key] || node.value) : node.value"></div>
  10. <div v-else-if="node.type === 3" class="text-space-nowrap" :style="node.style" :class="node.class">{{node.curr}}{{ node.key ? (data[node.key] || node.value) : node.value }}</div>
  11. <div v-else-if="node.type === 4" class="text-space-nowrap" :style="node.style" :class="[node.class, rateBGColor(node)]">{{ rateValue(node) }}</div>
  12. <div v-else-if="node.type === 5" class="text-space-nowrap" :style="node.style" :class="node.class">
  13. <img :src="node.icon" class="icon-image" alt="">{{ node.key ? (data[node.key] || node.value) : node.value }}
  14. </div>
  15. <div v-else :style="node.style" class="text-space-nowrap" :class="node.class">{{ node.key ? (data[node.key] || node.value) : node.value }}</div>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import NtLoading from 'submodule/dx-element-ui/packages/loading'
  22. export default {
  23. name: 'NtCard',
  24. components: { NtLoading },
  25. data: function () {
  26. return {}
  27. },
  28. watch: {},
  29. props: {
  30. data: {
  31. required: true,
  32. type: Object | null | undefined,
  33. default: () => {}
  34. },
  35. options: {
  36. required: true,
  37. type: Array,
  38. default: () => []
  39. },
  40. mode: {
  41. type: String,
  42. default: 'horizontal'
  43. },
  44. myClass: {
  45. type: String,
  46. default: ''
  47. },
  48. isNotShow: {
  49. type: Boolean,
  50. default: false
  51. }
  52. },
  53. methods: {
  54. rateBGColor(node) {
  55. const val = node.key ? parseFloat(this.$props.data[node.key]) : parseFloat(node.value)
  56. if (val > 0) {
  57. return 'up'
  58. } else if (val < 0) {
  59. return 'down'
  60. }
  61. },
  62. rateValue(node) {
  63. let sign = ''
  64. const val = node.key ? parseFloat(this.$props.data[node.key]) : parseFloat(node.value)
  65. if (val > 0) {
  66. sign = '↗'
  67. } else if (val < 0) {
  68. sign = '↘'
  69. } else {
  70. return 0
  71. }
  72. return sign + Math.abs(val) + (node.sign || '')
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .horizontal {
  79. display: flex;
  80. flex-direction: row;
  81. }
  82. .title__size {
  83. font-size: 1.6rem;
  84. }
  85. .big__size {
  86. font-size: 4.2rem;
  87. }
  88. .small__size {
  89. font-size: 1.4rem;
  90. }
  91. .text__color {
  92. color: #14121F;
  93. }
  94. .text__size {
  95. font-size: 3.4rem;
  96. }
  97. .font-weight__bold {
  98. font-weight: bold;
  99. }
  100. .font-family__fb {
  101. font-family: AGENCYFB;
  102. }
  103. .font-family__fbo {
  104. font-family: AGENCYFB_0;
  105. }
  106. .vertical {
  107. display: flex;
  108. flex-direction: column;
  109. }
  110. .align-items__center {
  111. align-items: center;
  112. }
  113. .align-items__end {
  114. align-items: flex-end;
  115. }
  116. .justify-content__center {
  117. justify-content: center;
  118. }
  119. .justify-content__between {
  120. justify-content: space-between;
  121. }
  122. .card-line {
  123. display: flex;
  124. }
  125. .card-images {
  126. display: flex;
  127. justify-content: center;
  128. align-items: center;
  129. margin-right: 1.3rem;
  130. width: 6rem;
  131. height: 6rem;
  132. border-radius: 50%;
  133. background: #5b8ff9;
  134. img {
  135. width: 3.4rem;
  136. }
  137. }
  138. .history-info__text-8 {
  139. color: rgba(20, 18, 31, .8)
  140. }
  141. .history-info__text {
  142. color: rgba(20, 18, 31, .5)
  143. }
  144. .icon-image {
  145. height: 3rem;
  146. margin-right: 10px;
  147. }
  148. .order__info {
  149. display: flex;
  150. flex-direction: column;
  151. justify-content: center;
  152. align-items: center;
  153. }
  154. .rate {
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. background: #C2C4D1;
  159. padding: 0 5px;
  160. height: 1.8rem;
  161. width: fit-content;
  162. font-size: 1.4rem;
  163. color: #fff;
  164. &.up {
  165. background-color: #E86452;
  166. }
  167. &.down {
  168. background-color: #41CC7C;
  169. }
  170. }
  171. .text-space-nowrap {
  172. white-space: nowrap;
  173. }
  174. </style>