popup.vue 8.0 KB

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