popup.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div class="page-wrapper" ref="pageWrapperDom">
  3. <div class="content">
  4. <div class="balance">
  5. <div class="wallet">
  6. <font>Balance Valuation</font>
  7. </div>
  8. </div>
  9. <div class="amount-wrapper">
  10. <div class="amount">
  11. <a-tooltip :title="'$'+canWithdrawBalance">
  12. ${{ getBit(canWithdrawBalance) }}
  13. </a-tooltip>
  14. </div>
  15. <div class="right">
  16. <div class="bill" @click="showTransactions">
  17. <red-dot class="red-dot" v-if="unReadCountWallet > 0"></red-dot>
  18. <img :src="require('@/assets/svg/icon-home-list.svg')" />
  19. </div>
  20. <img :src="require('@/assets/svg/icon-home-refresh.svg')"
  21. class="icon"
  22. :class="{ transform_rotate: iconRotate }"
  23. @click="refreshList" />
  24. </div>
  25. </div>
  26. </div>
  27. <currency-list
  28. v-if="userInfo.accessToken"
  29. style="height: calc(100% - 118px);"
  30. ref="currencyListDom"
  31. :showRefresh="false"
  32. :page="'top-up'"
  33. @selectCurrency="selectCurrency"></currency-list>
  34. </div>
  35. </template>
  36. <script setup>
  37. import { ref, onMounted, inject } from "vue";
  38. import redDot from "@/view/components/red-dot.vue";
  39. import CurrencyList from "@/view/components/currency-list.vue";
  40. import {
  41. getChromeStorage,
  42. } from "@/uilts/chromeExtension";
  43. import { getBalance } from "@/http/account";
  44. import { getAllMessageInfo } from "@/http/messageApi"
  45. import { setBadgeInfo, hideBadge } from "@/logic/background/twitter";
  46. import Report from "@/log-center/log";
  47. import router from "@/router/popup.js";
  48. import { getBit } from "@/uilts/help";
  49. let withdraw_info = inject('withdraw_info')
  50. withdraw_info.paypal = {}
  51. var moment = require("moment");
  52. let userInfo = ref({});
  53. let canWithdrawBalance = ref(0);
  54. withdraw_info.paypal.amount_value = canWithdrawBalance
  55. withdraw_info.balance = 0
  56. let isRequestWithdrawBalance = ref(false);
  57. let currencyListDom = ref('');
  58. let iconRotate = ref(false)
  59. // 钱包未读数
  60. let unReadCountWallet = ref(0);
  61. let walletWithdrawConfig = ref({
  62. withdrawUSDPaypalFee: 0,
  63. withdrawUSDPreMinAmount: 100,
  64. withdrawUSDSwitch: "",
  65. withdrawUSDPaypalFeeDesc: ''
  66. });
  67. withdraw_info.paypal.wallet_withdraw_config = walletWithdrawConfig
  68. function selectCurrency(_params) {
  69. router.push({
  70. path: 'currencyDetail',
  71. query: {
  72. params: JSON.stringify(_params)
  73. }
  74. });
  75. }
  76. onMounted(() => {
  77. checkLoginState((res) => {
  78. if (res) {
  79. getAccountBalance();
  80. Report.reportLog({
  81. pageSource: Report.pageSource.denetHomePage,
  82. businessType: Report.businessType.pageView,
  83. },{
  84. type: window.location.href.indexOf('home.html') > -1 ? 'web' : 'extensions'
  85. });
  86. setMessageCount();
  87. } else {
  88. Report.reportLog({
  89. pageSource: Report.pageSource.denetLogin,
  90. businessType: Report.businessType.pageView,
  91. });
  92. }
  93. });
  94. });
  95. const setMessageCount = () => {
  96. getAllMessageInfo({params: {
  97. }}).then(res => {
  98. if(res.code == 0) {
  99. let {unReadCountTotal = 0, unReadCountWalletDetail = 0, unReadCountTaskLuckdrop = 0} = res.data;
  100. unReadCountWallet.value = unReadCountWalletDetail;
  101. if(unReadCountTotal > 0) {
  102. let text = unReadCountTotal > 99 ? '99+' : unReadCountTotal+'';
  103. setBadgeInfo({data: {text}});
  104. } else {
  105. hideBadge();
  106. }
  107. }
  108. });
  109. }
  110. /**
  111. * 获取账户余额
  112. */
  113. const getAccountBalance = () => {
  114. isRequestWithdrawBalance.value = false;
  115. getBalance({}).then((res) => {
  116. isRequestWithdrawBalance.value = true;
  117. if (res.code == 0) {
  118. if (res.data) {
  119. canWithdrawBalance.value = res.data.allAssetValuationUSD;
  120. withdraw_info.balance = res.data.allAssetValuationUSD || 0
  121. }
  122. }
  123. });
  124. };
  125. const getUserInfo = (cb) => {
  126. getChromeStorage("userInfo", (res) => {
  127. cb && cb(res);
  128. });
  129. };
  130. /**
  131. * 检查登录状态
  132. */
  133. const checkLoginState = (cb) => {
  134. getUserInfo((res) => {
  135. if (res && res.accessToken) {
  136. userInfo.value = res;
  137. } else {
  138. userInfo.value = {};
  139. }
  140. cb && cb(res);
  141. });
  142. };
  143. const showTransactions = () => {
  144. router.push('/transactions')
  145. };
  146. // 点击提现
  147. const clickWithdraw = () => {
  148. Report.reportLog({
  149. pageSource: Report.pageSource.denetHomePage,
  150. businessType: Report.businessType.buttonClick,
  151. objectType: Report.objectType.withdrawButton
  152. });
  153. router.push('/withdraw/home');
  154. }
  155. const clickTopUp = () => {
  156. Report.reportLog({
  157. pageSource: Report.pageSource.denetHomePage,
  158. businessType: Report.businessType.buttonClick,
  159. objectType: Report.objectType.topupButton
  160. });
  161. router.push('/top-up/home');
  162. }
  163. const refreshList = () => {
  164. if (iconRotate.value) {
  165. return
  166. }
  167. iconRotate.value = true
  168. setTimeout(() => {
  169. iconRotate.value = false
  170. }, 1000)
  171. getAccountBalance();
  172. if(currencyListDom.value) {
  173. currencyListDom.value.getCurrencyInfoList && currencyListDom.value.getCurrencyInfoList();
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. html,
  179. body {
  180. padding: 0 !important;
  181. margin: 0 !important;
  182. }
  183. .page-wrapper {
  184. width: 375px;
  185. height: 100%;
  186. box-sizing: border-box;
  187. overflow-y: auto;
  188. .nav-bar {
  189. padding: 14px;
  190. box-sizing: border-box;
  191. display: flex;
  192. align-items: center;
  193. justify-content: space-between;
  194. .item {
  195. display: flex;
  196. align-items: center;
  197. font-size: 13px;
  198. cursor: pointer;
  199. img {
  200. width: 16px;
  201. height: 16px;
  202. margin-right: 4px;
  203. }
  204. }
  205. .left {
  206. font-weight: 500;
  207. }
  208. .right {
  209. color: #b6b6b6;
  210. }
  211. }
  212. .content {
  213. padding: 12px 16px 10px 16px;
  214. background: #1D9BF0;
  215. box-sizing: border-box;
  216. .icon-money {
  217. width: 70px;
  218. height: 70px;
  219. }
  220. .balance {
  221. display: flex;
  222. justify-content: space-between;
  223. .wallet {
  224. font {
  225. font-size: 13px;
  226. color: #fff;
  227. opacity: 0.7;
  228. }
  229. }
  230. }
  231. .amount-wrapper {
  232. margin-top: 2px;
  233. font-weight: 700;
  234. font-size: 36px;
  235. color: #fff;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. .amount {
  240. display: inline-block;
  241. }
  242. .right {
  243. display: flex;
  244. align-items: center;
  245. .bill {
  246. height: 24px;
  247. width: 24px;
  248. position: relative;
  249. img {
  250. width: 24px;
  251. height: 24px;
  252. cursor: pointer;
  253. position: absolute;
  254. left: 0;
  255. top: 0;
  256. }
  257. .red-dot {
  258. position: absolute;
  259. right: 0px;
  260. top: -1px;
  261. z-index: 100;
  262. }
  263. }
  264. .icon {
  265. margin-left: 22px;
  266. cursor: pointer;
  267. }
  268. .transform_rotate {
  269. transform: rotate(360deg);
  270. transition-duration: 1s;
  271. }
  272. }
  273. }
  274. .msg {
  275. margin-top: 10px;
  276. font-size: 13px;
  277. color: #b6b6b6;
  278. }
  279. }
  280. }
  281. .page-wrapper::-webkit-scrollbar {
  282. display: none;
  283. }
  284. </style>