popup-transactions.vue 20 KB

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