popup.vue 7.6 KB

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