head.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="head" :class="{ 'border': show_state != 'home', 'home': show_state == 'home' }">
  3. <template v-if="show_state == 'home'">
  4. <div class="desc">
  5. <img class="img" :src="user_info.avatarUrl" />
  6. <font class="name">{{user_info.nickName}}</font>
  7. </div>
  8. <div class="logo">
  9. <img :src="require('@/assets/svg/icon-denet-logo.svg')" />
  10. </div>
  11. </template>
  12. <template v-else>
  13. <img :src="require('@/assets/svg/icon-back.svg')" alt="" class="back" @click="clickBack">
  14. <div class="title">{{ props.title }}</div>
  15. <img :src="require('@/assets/svg/icon-back-head-list.svg')"
  16. v-if="show_list"
  17. class="list"
  18. @click="clickList" />
  19. <img :src="require('@/assets/svg/icon-refresh.svg')" alt="" class="refresh" v-if="show_refresh"
  20. @click="clickRefresh" :class="{ transform_rotate: state.rotate }">
  21. <img :src="require('@/assets/svg/icon-head-help.svg')" alt="" class="help" v-if="props.show_help"
  22. @click="clickHelp">
  23. <img :src="require('@/assets/svg/icon-more-l.svg')" alt="" class="more" v-if="props.show_more"
  24. @click="state.show_option = true">
  25. <div class="area-option" v-if="state.show_option" @click="state.show_option = false">
  26. <div class="option">
  27. <div class="item" @click="clickItem('/transactions')">
  28. <img :src="require('@/assets/svg/icon-menu.svg')" alt="">
  29. <span>Transactions History</span>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. </div>
  35. </template>
  36. <script setup>
  37. import { getChromeStorage } from "@/uilts/chromeExtension";
  38. import { defineProps, defineEmits, reactive, ref, onMounted } from "vue";
  39. import router from "@/router/popup.js";
  40. import { boolean } from "mathjs";
  41. let props = defineProps({
  42. title: String,
  43. show_state: String,
  44. show_refresh: Boolean,
  45. show_option: Boolean,
  46. show_more: Boolean,
  47. show_help: Boolean,
  48. back_url: String,
  49. user_info: Object,
  50. show_list: Boolean,
  51. transactionsRouterParams: Object,
  52. })
  53. let state = reactive({
  54. show_option: ref(props.show_option),
  55. rotate: false
  56. })
  57. const emit = defineEmits(['on-refresh'])
  58. function clickBack() {
  59. if (props.back_url) {
  60. router.replace(props.back_url)
  61. } else {
  62. router.back()
  63. }
  64. }
  65. function clickRefresh() {
  66. if (state.rotate) {
  67. return
  68. }
  69. state.rotate = true
  70. emit('on-refresh')
  71. setTimeout(() => {
  72. state.rotate = false
  73. }, 1000)
  74. }
  75. function clickItem(path) {
  76. let params = props.transactionsRouterParams || {};
  77. router.push({
  78. path: path,
  79. query: {
  80. params: JSON.stringify(params)
  81. }
  82. })
  83. }
  84. function clickHelp() {
  85. window.open(`https://aboard-cattle-610.notion.site/How-to-withdraw-assets-from-DeNet-to-MetaMask-01c679bb9ff441429e31e8f7c1f67411`)
  86. }
  87. function clickList() {
  88. let params = props.transactionsRouterParams || {};
  89. console.log('transactionsRouterParams',params);
  90. router.push({
  91. path: '/transactions',
  92. query: {
  93. params: JSON.stringify(params)
  94. }
  95. })
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .border {
  100. border-bottom: 1px solid #DBDBDB;
  101. }
  102. .head {
  103. height: 48px;
  104. display: flex;
  105. flex-wrap: nowrap;
  106. justify-content: space-between;
  107. align-items: center;
  108. padding: 0 12px;
  109. overflow: hidden;
  110. &.home {
  111. height: 64px;
  112. }
  113. .logo {
  114. display: flex;
  115. align-items: center;
  116. img {
  117. width: 26px;
  118. height: 26px;
  119. }
  120. }
  121. .desc {
  122. .img {
  123. width: 34px;
  124. height: 34px;
  125. overflow: hidden;
  126. border-radius: 50%;
  127. margin-right: 10px;
  128. }
  129. .name {
  130. display: inline-block;
  131. width: 200px;
  132. color: #000000;
  133. font-size: 16px;
  134. font-weight: bold;
  135. }
  136. }
  137. .area-option {
  138. width: 100%;
  139. height: 100%;
  140. position: absolute;
  141. top: 0;
  142. left: 0;
  143. z-index: 111;
  144. .option {
  145. position: absolute;
  146. top: 43px;
  147. right: 15px;
  148. background: #fff;
  149. filter: drop-shadow(0px 3px 20px rgba(0, 0, 0, 0.2));
  150. width: 240px;
  151. border-radius: 15px;
  152. overflow: hidden;
  153. .item {
  154. width: 100%;
  155. height: 50px;
  156. display: flex;
  157. align-items: center;
  158. cursor: pointer;
  159. border-top: 1px solid #E9E9E9;
  160. img {
  161. margin-left: 15px;
  162. width: 30px;
  163. height: 30px;
  164. margin-right: 6px;
  165. }
  166. span {
  167. font-weight: 500;
  168. font-size: 14px;
  169. }
  170. }
  171. .item:first-child {
  172. border-top: 0;
  173. }
  174. .item:hover {
  175. background: #F5F5F5;
  176. }
  177. }
  178. }
  179. .transform_rotate {
  180. transform: rotate(360deg);
  181. transition-duration: 1s;
  182. }
  183. img {
  184. cursor: pointer;
  185. width: 24px;
  186. height: 24px;
  187. }
  188. .list {
  189. margin-right: 12px;
  190. }
  191. .refresh {
  192. }
  193. .help {
  194. margin-left: 20px;
  195. margin-right: 12px;
  196. }
  197. .title {
  198. padding-left: 16px;
  199. flex: 1;
  200. color: #000000;
  201. font-size: 16px;
  202. font-weight: 500;
  203. }
  204. }
  205. </style>