popup-transactions.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <div class="com-wrapper" ref="listWrapper" @scroll="listScroll">
  3. <!-- <div class="com-nav-bar">
  4. <img
  5. :src="require('@/assets/svg/icon-bar-arrow-left.svg')"
  6. class="icon"
  7. @click="back"
  8. />
  9. Transactions
  10. </div> -->
  11. <template v-if="!dataList.length">
  12. <img class="icon-empty" :src="require('@/assets/svg/icon-empty-list.svg')" />
  13. </template>
  14. <div class="list-wrapper" ref="listContent">
  15. <div>
  16. <div class="cell" v-for="(item, index) in dataList" :key="index">
  17. <red-dot class="red-dots"
  18. v-if="item.unReadMsgCount > 0 && isReadMsg"></red-dot>
  19. <div class="img-wrapper">
  20. <!-- 收入- 任务红包领取 -->
  21. <template v-if="item.bizType == 1 || item.bizType == 5">
  22. <img class="icon-avatar" :src="item.bizData.avatarUrl" />
  23. <img class="icon-give" :src="
  24. require('@/assets/svg/icon-get-giveaways-s.svg')
  25. " />
  26. </template>
  27. <!-- 收入- 任务红包结余退款, -->
  28. <template v-else-if="item.bizType == 2 || item.bizType == 6">
  29. <img style="margin-left:-4px" :src="
  30. require('@/assets/svg/icon-give-refund-list.svg')
  31. " />
  32. </template>
  33. <!-- 收入 - 提现 -- 失败退款 -->
  34. <template v-else-if="item.bizType == 3">
  35. <img style="margin-left:-4px" :src="
  36. require('@/assets/svg/icon-list-withdraw.svg')
  37. " />
  38. </template>
  39. <!-- 收入-充值 -->
  40. <template v-else-if="item.bizType == 4">
  41. <img style="margin-left:-4px" :src="
  42. require('@/assets/svg/icon-list-top-up.svg')
  43. " />
  44. </template>
  45. <!-- 收入 - 盲盒 -->
  46. <template v-else-if="item.bizType == 7">
  47. <img class="icon-avatar" style="margin-left:-4px" :src="require('@/assets/svg/icon-wallter-list-blind-box.svg')" />
  48. <img class="icon-give" :src="require('@/assets/svg/icon-list-withdraw-s.svg')" />
  49. </template>
  50. <!-- 收入 - 盲盒 -->
  51. <template v-else-if="item.bizType == 8">
  52. <img class="icon-avatar" style="margin-left:-4px" :src="require('@/assets/svg/icon-wallter-list-blind-box.svg')" />
  53. <img class="icon-give" :src="require('@/assets/svg/icon-get-giveaways-s.svg')" />
  54. </template>
  55. <!-- 支出 - 提现 -->
  56. <template v-else-if="item.bizType == -1">
  57. <img style="margin-left:-4px" :src="
  58. require('@/assets/svg/icon-list-withdraw.svg')
  59. " />
  60. </template>
  61. <!-- 支出-任务红包余额支付 -->
  62. <template v-else-if="item.bizType == -2">
  63. <img style="margin-left:-4px" :src="
  64. require('@/assets/svg/icon-big-give.svg')
  65. " />
  66. </template>
  67. <!-- 支出-买盲盒 -->
  68. <template v-else-if="item.bizType == -3">
  69. <img style="margin-left:-4px" :src="
  70. require('@/assets/svg/icon-wallter-list-blind-box.svg')
  71. " />
  72. </template>
  73. <template v-else-if="item.bizType == -4">
  74. <img class="icon-avatar" style="margin-left:-4px" :src="
  75. require('@/assets/svg/icon-big-give.svg')
  76. " />
  77. <img class="icon-give" :src="
  78. require('@/assets/svg/icon-list-withdraw-s.svg')
  79. " />
  80. </template>
  81. <!-- 交易链手续费 -->
  82. <template v-else-if="item.bizType == -5">
  83. <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath" v-if="item.bizData && item.bizData.imagePath" />
  84. <img class="icon-avatar" style="margin-left:-4px" :src="require('@/assets/img/icon-box2.png')" v-else />
  85. <img class="icon-give" :src="require('@/assets/svg/icon-transaction-s.svg')" />
  86. </template>
  87. </div>
  88. <div class="info-wrapper">
  89. <div class="left">
  90. <div class="nickname">
  91. <template v-if="item.bizType == 1">
  92. Giveaways ({{ item.bizData.nickName }})
  93. </template>
  94. <template v-else-if="item.bizType == 2">
  95. Giveaways Refund
  96. </template>
  97. <template v-else-if="item.bizType == 3">
  98. Withdrawal Refund
  99. </template>
  100. <template v-else-if="item.bizType == 4">
  101. Deposit
  102. </template>
  103. <template v-else-if="item.bizType == 5">
  104. Winning the lottery
  105. </template>
  106. <template v-else-if="item.bizType == 6">
  107. Lottery Refund
  108. </template>
  109. <template v-else-if="item.bizType == 7">
  110. Sell NFT Mystery box*{{(item.bizData && item.bizData.nftItemCount || '')}}
  111. </template>
  112. <template v-else-if="item.bizType == 8">
  113. NFT Refund
  114. </template>
  115. <template v-else-if="item.bizType == -1">
  116. Withdrawal
  117. </template>
  118. <template v-else-if="item.bizType == -2">
  119. Giveaways
  120. </template>
  121. <template v-else-if="item.bizType == -3">
  122. Buy NFT Mystery box*{{(item.bizData && item.bizData.nftItemCount || '')}}
  123. </template>
  124. <template v-else-if="item.bizType == -4">
  125. Lottery Giveaway
  126. </template>
  127. <template v-else-if="item.bizType == -5">
  128. Transaction Royalties
  129. </template>
  130. </div>
  131. <div class="time">{{ moment(item.createTimestamp).format('MM-DD HH:mm:ss') }}</div>
  132. </div>
  133. <div class="right">
  134. <div class="msg">
  135. <template v-if="item.bizType == -1">
  136. <!-- 提现支出-状态(0:已申请,1:支付中,2:提现成功,3:提现失败) -->
  137. <template v-if="item.bizData.withdrawStatus == 0 || item.bizData.withdrawStatus == 1">
  138. <div>
  139. <div class="balance"
  140. :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
  141. <span class="amount">
  142. <a-tooltip :title="'-'+item.trxAmountValue">
  143. -{{ getBit(item.trxAmountValue) || 0 }}
  144. </a-tooltip>
  145. </span>
  146. <div class="trx-amount-currency-info">
  147. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  148. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  149. </div>
  150. </div>
  151. <div class="desc">
  152. in progress
  153. </div>
  154. </div>
  155. </template>
  156. <template v-else-if="item.bizData.withdrawStatus == 2">
  157. <div class="balance"
  158. :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
  159. <span class="amount">
  160. <a-tooltip :title="'-'+item.trxAmountValue">
  161. -{{ getBit(item.trxAmountValue) || 0 }}
  162. </a-tooltip>
  163. </span>
  164. <div class="trx-amount-currency-info">
  165. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  166. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  167. </div>
  168. </div>
  169. </template>
  170. <template v-else-if="item.bizData.withdrawStatus == 3">
  171. <div>
  172. <div class="balance"
  173. :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
  174. <span class="amount">
  175. <a-tooltip :title="'-'+item.trxAmountValue">
  176. -{{ getBit(item.trxAmountValue) || 0 }}
  177. </a-tooltip>
  178. </span>
  179. <div class="trx-amount-currency-info">
  180. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  181. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  182. </div>
  183. </div>
  184. <div class="desc">
  185. Withdrawal failed
  186. </div>
  187. </div>
  188. </template>
  189. <template v-else>
  190. <div class="balance"
  191. :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
  192. <span class="amount">
  193. <a-tooltip :title="'-'+item.trxAmountValue">
  194. -{{ getBit(item.trxAmountValue) || 0 }}
  195. </a-tooltip>
  196. </span>
  197. <div class="trx-amount-currency-info">
  198. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  199. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  200. </div>
  201. </div>
  202. </template>
  203. </template>
  204. <template v-else>
  205. <div class="balance"
  206. :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
  207. <!--支出—— -2:零钱余额支付 、-3: NFT盲盒余额支付 -->
  208. <span class="amount" v-if="item.bizType == -2 || item.bizType == -3 || item.bizType == -4 || item.bizType == -5">
  209. <a-tooltip :title="'-' + item.trxAmountValue">
  210. -{{ getBit(item.trxAmountValue) || 0 }}
  211. </a-tooltip>
  212. </span>
  213. <!-- 收入—— bizType:1、2、3、4 -->
  214. <span class="amount" v-else>
  215. <a-tooltip :title="'+'+item.trxAmountValue">
  216. +{{ getBit(item.trxAmountValue) || 0 }}
  217. </a-tooltip>
  218. </span>
  219. <div class="trx-amount-currency-info">
  220. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  221. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  222. </div>
  223. </div>
  224. </template>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. </template>
  233. <script setup>
  234. /* eslint-disable */
  235. import { onMounted, ref, defineProps, defineEmits } from "vue";
  236. import redDot from "@/view/components/red-dot.vue";
  237. import { transactionsList } from "@/http/account";
  238. import { readAllMsgByType, getAllMessageInfo } from "@/http/messageApi"
  239. import { setBadgeInfo, hideBadge } from "@/logic/background/twitter";
  240. import { getBit } from "@/uilts/help";
  241. var moment = require('moment');
  242. let dataList = ref([]);
  243. let listWrapper = ref(null);
  244. let listContent = ref(null);
  245. let listReqParams = {
  246. params: {
  247. pageNum: 1,
  248. pageSize: 20,
  249. },
  250. loadMore: false,
  251. };
  252. let isReadMsg = ref(true);
  253. const getTransactionsList = () => {
  254. transactionsList({
  255. params: listReqParams.params,
  256. }).then((res) => {
  257. console.log(res);
  258. if (res.code == 0) {
  259. let resData = res.data;
  260. if (resData.length) {
  261. for (let i = 0; i < resData.length; i++) {
  262. resData[i]["bizData"] = JSON.parse(resData[i]["bizData"]);
  263. }
  264. if (listReqParams.params.pageNum < 2) {
  265. dataList.value = resData;
  266. } else {
  267. let data = dataList.value;
  268. data = data.concat(resData);
  269. dataList.value = data;
  270. }
  271. listReqParams.loadMore = false;
  272. }
  273. }
  274. });
  275. };
  276. onMounted(() => {
  277. chrome.runtime.connect({ name: "popup_transactions" });
  278. setTimeout(() => {
  279. isReadMsg.value = false;
  280. readAllMsgByType({
  281. params: {
  282. msgType: 2 // 1:任务红包 2:钱包明细
  283. }
  284. }).then(res => {
  285. setMessageCount();
  286. })
  287. }, 2000)
  288. getTransactionsList();
  289. });
  290. const setMessageCount = () => {
  291. getAllMessageInfo({params: {
  292. }}).then(res => {
  293. if(res.code == 0) {
  294. let {unReadCountTotal = 0 } = res.data;
  295. if(unReadCountTotal > 0) {
  296. let text = unReadCountTotal > 99 ? '99+' : unReadCountTotal+'';
  297. setBadgeInfo({data: {text}});
  298. } else {
  299. hideBadge();
  300. }
  301. }
  302. });
  303. }
  304. const emits = defineEmits(["back"]);
  305. const back = () => {
  306. emits("back", {});
  307. };
  308. const listScroll = (e) => {
  309. let wrapperHeight = listWrapper.value.offsetHeight;
  310. let listContentHeight = listContent.value.offsetHeight;
  311. let scrollTop = e.target.scrollTop || 0;
  312. if (
  313. listReqParams.loadMore === false &&
  314. wrapperHeight + scrollTop >= listContentHeight - 30
  315. ) {
  316. listReqParams.loadMore = true;
  317. listReqParams.params.pageNum++;
  318. getTransactionsList();
  319. }
  320. };
  321. </script>
  322. <style lang="scss" scoped>
  323. .com-wrapper {
  324. height: 100%;
  325. position: relative;
  326. overflow-y: auto;
  327. .icon-empty {
  328. position: absolute;
  329. left: 50%;
  330. top: 20%;
  331. transform: translateX(-50%);
  332. }
  333. .com-nav-bar {
  334. padding: 14px;
  335. box-sizing: border-box;
  336. display: flex;
  337. align-items: center;
  338. font-weight: 500;
  339. font-size: 13px;
  340. .icon {
  341. width: 16px;
  342. margin-right: 6px;
  343. cursor: pointer;
  344. }
  345. }
  346. .list-wrapper {
  347. width: 100%;
  348. // height: calc(100% - 51px);
  349. // height: 100%;
  350. .cell {
  351. display: flex;
  352. justify-content: space-between;
  353. min-height: 66px;
  354. box-sizing: border-box;
  355. padding-left: 20px;
  356. position: relative;
  357. .red-dots {
  358. position: absolute;
  359. right: 4px;
  360. top: 4px;
  361. }
  362. .img-wrapper {
  363. position: relative;
  364. margin-right: 16px;
  365. box-sizing: border-box;
  366. margin-top: 11px;
  367. .icon-avatar {
  368. width: 34px;
  369. height: 34px;
  370. border-radius: 50%;
  371. margin-right: 4px;
  372. }
  373. .icon-give {
  374. position: absolute;
  375. right: -2px;
  376. top: 19px;
  377. }
  378. }
  379. .info-wrapper {
  380. flex: 1;
  381. height: 100%;
  382. display: flex;
  383. justify-content: space-between;
  384. align-items: center;
  385. box-sizing: border-box;
  386. padding: 10px 12px 10px 0;
  387. .left {
  388. .nickname {
  389. font-weight: 500;
  390. font-size: 14px;
  391. margin-bottom: 5px;
  392. word-break: break-all;
  393. max-width: 140px;
  394. }
  395. .time {
  396. font-size: 12px;
  397. color: #B0B0B0;
  398. }
  399. }
  400. .right {
  401. display: flex;
  402. align-items: center;
  403. cursor: pointer;
  404. .msg {
  405. font-weight: 500;
  406. font-size: 14px;
  407. display: flex;
  408. align-items: center;
  409. .amount {
  410. color: #E86F00;
  411. max-width: 110px;
  412. min-width: 20px;
  413. display: inline-block;
  414. word-break: break-all;
  415. text-align: right;
  416. }
  417. .name {
  418. margin-left: 3px;
  419. max-width: 130px;
  420. line-height: 14px;
  421. font-size: 13px;
  422. word-break: break-all;
  423. }
  424. img {
  425. width: 14px;
  426. height: 14px;
  427. margin-left: 4px;
  428. }
  429. .balance {
  430. text-align: right;
  431. display: flex;
  432. align-items: center;
  433. .trx-amount-currency-info {
  434. display: flex;
  435. align-items: center;
  436. }
  437. }
  438. .balance-direction {
  439. flex-direction: column;
  440. align-items: flex-end;
  441. }
  442. .desc {
  443. text-align: right;
  444. font-weight: 400;
  445. font-size: 12px;
  446. color: #797979;
  447. margin-top: 4px;
  448. }
  449. }
  450. .icon {
  451. width: 18px;
  452. height: 24px;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. }
  459. </style>