Sidebar.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="sidebarShow"
  3. :class="pageShow ? 'open' : ''">
  4. <div class="user"
  5. v-show="pageShow">
  6. <div class="invitation">
  7. <div>
  8. <img src="@/assets/img/invitations.png"
  9. class="invitation_img" />
  10. <span>邀请</span>
  11. </div>
  12. <div class="more"
  13. @click="toNav('Invitation')">
  14. <span>{{$t('lang.swap156')}}</span>
  15. </div>
  16. </div>
  17. <div class="address">
  18. <div class="invitation_address">
  19. <span>{{ invited || '请先添加邀请人' }}</span>
  20. </div>
  21. <div class="copys"
  22. @click="copy"
  23. :data-clipboard-text="this.invite_link">
  24. <span>复制</span>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="mobile_phone">
  29. <div class="navigation_list"
  30. v-show="!pageShow"
  31. @click="toNav('Invitation')">
  32. <div class="li">
  33. <img src="@/assets/img/invitationa.png"
  34. class="li_img" />
  35. <span>邀请</span>
  36. </div>
  37. <span>></span>
  38. </div>
  39. <div class="navigation_list"
  40. v-for="(item, index) of navigationList"
  41. :key="index"
  42. @click="toNav(item.name)">
  43. <div class="li">
  44. <img :src="item.bright"
  45. class="li_img" />
  46. <span>{{ $t(item.text) }}</span>
  47. </div>
  48. <span>></span>
  49. </div>
  50. </div>
  51. <div class="submenu">
  52. <div class="submenu_list"
  53. v-for="(item, index) of submenuList"
  54. :key="index"
  55. @click="toNav(item.name)">
  56. <div class="li">
  57. <img :src="item.img"
  58. class="submenu_img" />
  59. <span>{{ $t(item.text) }}</span>
  60. </div>
  61. <span>></span>
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import Clipboard from 'clipboard';
  68. import { mapState } from 'vuex';
  69. export default {
  70. props: ['pageShow'],
  71. data () {
  72. return {
  73. navigationList: [
  74. // { img: require('@/assets/img/home_pagesash.png'), bright: require('@/assets/img/home_pagesashbright.png'), text: 'lang.swap85', name: 'Index' },
  75. // // { img: require('@/assets/img/transactions.png'), bright: require('@/assets/img/transactionsbright.png'), text: 'lang.swap88', name: 'Swap' },
  76. // // { img: require('@/assets/img/wallets.png'), bright: require('@/assets/img/walletsbright.png'), text: 'lang.swap197', name: 'Mining' },
  77. // { img: require('@/assets/img/communitys.png'), bright: require('@/assets/img/communitysbright.png'), text: 'lang.swap198', name: '' },
  78. ],
  79. submenuList: [
  80. // {
  81. // img: require('@/assets/img/rightsAndInterests.png'),
  82. // text: 'lang.swap60',
  83. // name: '',
  84. // },
  85. // {
  86. // img: require('@/assets/img/rechange.png'),
  87. // text: 'lang.swap1',
  88. // name: 'FlashExchange',
  89. // },
  90. {
  91. img: require('@/assets/img/rightsAndInterests.png'),
  92. text: '',
  93. name: 'StakePool',
  94. },
  95. {
  96. img: require('@/assets/img/crowdFunding.png'),
  97. text: '',
  98. name: 'StartingCenter',
  99. },
  100. {
  101. img: require('@/assets/img/government.png'),
  102. text: '',
  103. name: 'govern',
  104. },
  105. {
  106. img: require('@/assets/img/notices.png'),
  107. text: '',
  108. name: 'NoticeIndex',
  109. },
  110. {
  111. img: require('@/assets/img/feedback.png'),
  112. text: '',
  113. name: 'Feedback',
  114. },
  115. {
  116. img: require('@/assets/img/understand.png'),
  117. text: '',
  118. name: 'Understand',
  119. },
  120. {
  121. img: require('@/assets/img/gameFi.png'),
  122. text: '',
  123. name: 'GameFi',
  124. },
  125. ],
  126. invite_link: '',
  127. };
  128. },
  129. methods: {
  130. handleScroll () {
  131. // this.pageShow = !this.pageShow
  132. this.$emit('handleScroll');
  133. },
  134. // 获取邀请地址
  135. init () {
  136. if (this.account) {
  137. }
  138. },
  139. // 复制
  140. copy () {
  141. if (this.invite_link) {
  142. var clipboard = new Clipboard('.copys');
  143. clipboard.on('success', e => {
  144. this.$toast(this.$t('lang.swap222'));
  145. clipboard.destroy(); // 释放内存
  146. });
  147. clipboard.on('error', e => {
  148. this.$toast(this.$t('lang.swap223'));
  149. clipboard.destroy(); // 释放内存
  150. });
  151. }
  152. },
  153. toNav (router, title) {
  154. if (this.$route.name == router) return
  155. if (router != '') {
  156. this.$router.push({ name: router });
  157. } else {
  158. this.$toast(this.$t('lang2'));
  159. }
  160. },
  161. },
  162. watch: {
  163. account () {
  164. this.init();
  165. },
  166. },
  167. created () {
  168. this.init();
  169. },
  170. computed: {
  171. ...mapState(['account']),
  172. invited () {
  173. if (this.account && this.invite_link) {
  174. return this.account.substring(0, 7) + '*****' + this.account.substring(this.account.length - 6, this.account.length);
  175. } else {
  176. return '';
  177. }
  178. },
  179. },
  180. };
  181. </script>
  182. <style lang="less" scoped>
  183. span {
  184. white-space: nowrap;
  185. }
  186. .user {
  187. font-size: 18px;
  188. font-family: Source Han Sans CN-Medium, Source Han Sans CN;
  189. font-weight: 500;
  190. color: #ffffff;
  191. background: linear-gradient(180deg, #f39714 0%, #fff1c4 100%);
  192. border-radius: 16px;
  193. padding: 10px 14px;
  194. margin: 20px 0;
  195. .invitation {
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. font-size: 14px;
  200. div {
  201. display: flex;
  202. justify-content: space-between;
  203. align-items: center;
  204. }
  205. .invitation_img {
  206. width: 26px;
  207. height: 26px;
  208. }
  209. .more {
  210. font-size: 12px;
  211. border-radius: 16px;
  212. border: 1px solid #ffffff;
  213. padding: 2px 12px;
  214. }
  215. }
  216. .address {
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: center;
  220. font-size: 12px;
  221. color: #333333;
  222. font-family: Source Han Sans CN-Medium, Source Han Sans CN;
  223. font-weight: 500;
  224. margin-top: 20px;
  225. .invitation_address {
  226. background: #fff;
  227. border-radius: 16px;
  228. padding: 4px 16px;
  229. overflow: hidden; //超出的文本隐藏
  230. text-overflow: ellipsis; //溢出用省略号显示
  231. white-space: nowrap; //溢出不换行
  232. }
  233. .copys {
  234. background: #fff;
  235. border-radius: 16px;
  236. white-space: nowrap;
  237. padding: 4px 16px;
  238. margin-left: 10px;
  239. }
  240. }
  241. }
  242. .sidebarShow {
  243. position: fixed;
  244. left: 0;
  245. top: 50px;
  246. height: calc(100% - 50px);
  247. width: 60px;
  248. background: #ffffff;
  249. box-shadow: 2px 3px 6px 1px rgba(0, 0, 0, 0.16);
  250. border-radius: 0px 10px 10px 0px;
  251. transition: width 0.5s;
  252. padding: 0 20px;
  253. overflow: auto;
  254. scrollbar-width: none; /* Firefox */
  255. -ms-overflow-style: none; /* IE10+ */
  256. &::-webkit-scrollbar {
  257. display: none; /* ChromeSafari */
  258. }
  259. .put_away {
  260. }
  261. .mobile_phone {
  262. display: flex;
  263. flex-direction: column;
  264. width: 100%;
  265. // height: 50px;
  266. background: #fff;
  267. padding: 4px 0;
  268. .navigation_list {
  269. display: flex;
  270. align-items: center;
  271. justify-content: space-between;
  272. padding: 18px 0;
  273. // border-bottom: 1px solid #999999;
  274. cursor: pointer;
  275. .li {
  276. display: flex;
  277. align-items: center;
  278. span {
  279. font-size: 14px;
  280. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  281. font-weight: bold;
  282. color: #1b2333;
  283. transform: scale(0.9, 0.9);
  284. }
  285. .li_img {
  286. width: 30px;
  287. height: 30px;
  288. margin-right: 10px;
  289. }
  290. }
  291. }
  292. .last {
  293. border-bottom: 0;
  294. }
  295. }
  296. .submenu {
  297. width: 100%;
  298. // margin-top: 50px;
  299. .submenu_list {
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. font-size: 12px;
  304. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  305. font-weight: bold;
  306. color: #333333;
  307. // padding: 10px 8px;
  308. margin: 20px 8px;
  309. cursor: pointer;
  310. .li {
  311. display: flex;
  312. align-items: center;
  313. .submenu_img {
  314. width: 22px;
  315. height: 22px;
  316. margin-right: 10px;
  317. }
  318. }
  319. }
  320. }
  321. }
  322. .open {
  323. width: 240px !important;
  324. .navigation_list {
  325. }
  326. }
  327. @media screen and (max-width: 700px) {
  328. .sidebarShow {
  329. display: none;
  330. }
  331. }
  332. </style>