popup-transactions.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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"></red-dot>
  19. <div class="img-wrapper">
  20. <!-- 收入- 任务红包领取 -->
  21. <template v-if="item.bizType == 1">
  22. <img class="icon-avatar" :src="item.bizData.avatarUrl" />
  23. <img class="icon-give" :src="
  24. require('@/assets/svg/icon-giveaways.svg')
  25. " />
  26. </template>
  27. <!-- 收入- 任务红包结余退款, -->
  28. <template v-else-if="item.bizType == 2">
  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. </div>
  58. <div class="info-wrapper">
  59. <div class="left">
  60. <div class="nickname">
  61. <template v-if="item.bizType == 1">
  62. Giveaways ({{ item.bizData.nickName }})
  63. </template>
  64. <template v-else-if="item.bizType == 2">
  65. Giveaways Refund
  66. </template>
  67. <template v-else-if="item.bizType == 3">
  68. Withdrawal Refund
  69. </template>
  70. <template v-else-if="item.bizType == 4">
  71. Deposit
  72. </template>
  73. <template v-else-if="item.bizType == -1">
  74. Withdrawal
  75. </template>
  76. <template v-else-if="item.bizType == -2">
  77. Giveaways
  78. </template>
  79. </div>
  80. <div class="time">{{ moment(item.createTimestamp).format('MM-DD HH:mm:ss') }}</div>
  81. </div>
  82. <div class="right">
  83. <div class="msg">
  84. <!-- 支出--提现 -->
  85. <template v-if="item.bizType == -1">
  86. <!-- 提现状态(0:已申请,1:支付中,2:提现成功,3:提现失败) -->
  87. <template v-if="item.bizData.withdrawStatus == 0 || item.bizData.withdrawStatus == 1">
  88. <div>
  89. <div class="balance">
  90. <span class="amount">
  91. -{{ item.trxAmountValue || 0 }}
  92. </span>
  93. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  94. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  95. </div>
  96. <div class="desc">
  97. in progress
  98. </div>
  99. </div>
  100. </template>
  101. <template v-else-if="item.bizData.withdrawStatus == 2">
  102. <div class="balance">
  103. <span class="amount">-{{ item.trxAmountValue || 0 }}</span>
  104. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  105. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  106. </div>
  107. </template>
  108. <template v-else-if="item.bizData.withdrawStatus == 3">
  109. <div>
  110. <div class="balance">
  111. <span class="amount">-{{ item.trxAmountValue || 0 }}</span>
  112. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  113. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  114. </div>
  115. <div class="desc">
  116. Withdrawal failed
  117. </div>
  118. </div>
  119. </template>
  120. <template v-else>
  121. <span class="amount">-{{ item.trxAmountValue || 0 }}</span>
  122. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  123. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  124. </template>
  125. </template>
  126. <!-- 收入 -->
  127. <template v-else>
  128. <span class="amount">
  129. <template v-if="item.bizType == -2">-</template>{{ item.trxAmountValue || 0 }}
  130. </span>
  131. <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
  132. <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
  133. </template>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. </template>
  142. <script setup>
  143. /* eslint-disable */
  144. import { onMounted, ref, defineProps, defineEmits, onBeforeUnmount } from "vue";
  145. import redDot from "@/view/components/red-dot.vue";
  146. import { transactionsList } from "@/http/account";
  147. import { readAllMsgByType, getAllMessageInfo } from "@/http/messageApi"
  148. import { setBadgeInfo, hideBadge } from "@/logic/background/twitter";
  149. var moment = require('moment');
  150. let dataList = ref([]);
  151. let listWrapper = ref(null);
  152. let listContent = ref(null);
  153. let listReqParams = {
  154. params: {
  155. pageNum: 1,
  156. pageSize: 10,
  157. },
  158. loadMore: false,
  159. };
  160. const getTransactionsList = () => {
  161. transactionsList({
  162. params: listReqParams.params,
  163. }).then((res) => {
  164. console.log(res);
  165. if (res.code == 0) {
  166. let resData = res.data;
  167. if (resData.length) {
  168. for (let i = 0; i < resData.length; i++) {
  169. resData[i]["bizData"] = JSON.parse(resData[i]["bizData"]);
  170. }
  171. if (listReqParams.params.pageNum < 2) {
  172. dataList.value = resData;
  173. } else {
  174. let data = dataList.value;
  175. data = data.concat(resData);
  176. dataList.value = data;
  177. }
  178. listReqParams.loadMore = false;
  179. }
  180. }
  181. });
  182. };
  183. onMounted(() => {
  184. readAllMsgByType({
  185. params: {
  186. msgType: 1
  187. }
  188. }).then(res => {
  189. setMessageCount();
  190. });
  191. getTransactionsList();
  192. });
  193. onBeforeUnmount(() => {
  194. readAllMsgByType({
  195. params: {
  196. msgType: 1 // 1:任务红包 2:钱包明细
  197. }
  198. });
  199. readAllMsgByType({
  200. params: {
  201. msgType: 2
  202. }
  203. });
  204. })
  205. const setMessageCount = () => {
  206. getAllMessageInfo({params: {
  207. }}).then(res => {
  208. if(res.code == 0) {
  209. let {unReadCountTotal = 0 } = res.data;
  210. if(unReadCountTotal > 0) {
  211. let text = unReadCountTotal > 99 ? '99+' : text+'';
  212. setBadgeInfo({data: {text}});
  213. } else {
  214. hideBadge();
  215. }
  216. }
  217. });
  218. }
  219. const emits = defineEmits(["back"]);
  220. const back = () => {
  221. emits("back", {});
  222. };
  223. const listScroll = (e) => {
  224. let wrapperHeight = listWrapper.value.offsetHeight;
  225. let listContentHeight = listContent.value.offsetHeight;
  226. let scrollTop = e.target.scrollTop || 0;
  227. if (
  228. listReqParams.loadMore === false &&
  229. wrapperHeight + scrollTop >= listContentHeight - 30
  230. ) {
  231. listReqParams.loadMore = true;
  232. listReqParams.params.pageNum++;
  233. getTransactionsList();
  234. }
  235. };
  236. </script>
  237. <style lang="scss" scoped>
  238. .com-wrapper {
  239. height: 100%;
  240. position: relative;
  241. overflow-y: auto;
  242. .icon-empty {
  243. position: absolute;
  244. left: 50%;
  245. top: 20%;
  246. transform: translateX(-50%);
  247. }
  248. .com-nav-bar {
  249. padding: 14px;
  250. box-sizing: border-box;
  251. display: flex;
  252. align-items: center;
  253. font-weight: 500;
  254. font-size: 13px;
  255. .icon {
  256. width: 16px;
  257. margin-right: 6px;
  258. cursor: pointer;
  259. }
  260. }
  261. .list-wrapper {
  262. width: 100%;
  263. // height: calc(100% - 51px);
  264. // height: 100%;
  265. .cell {
  266. display: flex;
  267. justify-content: space-between;
  268. align-items: center;
  269. min-height: 66px;
  270. box-sizing: border-box;
  271. padding-left: 20px;
  272. position: relative;
  273. .red-dots {
  274. position: absolute;
  275. right: 4px;
  276. top: 4px;
  277. }
  278. .img-wrapper {
  279. position: relative;
  280. margin-right: 16px;
  281. box-sizing: border-box;
  282. .icon-avatar {
  283. width: 34px;
  284. height: 34px;
  285. border-radius: 50%;
  286. }
  287. .icon-give {
  288. position: absolute;
  289. right: -4px;
  290. bottom: 2px;
  291. }
  292. }
  293. .info-wrapper {
  294. flex: 1;
  295. height: 100%;
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. border-bottom: 1px solid #d1d1d1;
  300. box-sizing: border-box;
  301. padding: 10px 12px 10px 0;
  302. .left {
  303. .nickname {
  304. font-weight: 500;
  305. font-size: 14px;
  306. margin-bottom: 5px;
  307. word-break: break-all;
  308. max-width: 120px;
  309. }
  310. .time {
  311. font-size: 12px;
  312. color: #b6b6b6;
  313. }
  314. }
  315. .right {
  316. display: flex;
  317. align-items: center;
  318. cursor: pointer;
  319. .msg {
  320. font-weight: 500;
  321. font-size: 14px;
  322. display: flex;
  323. align-items: center;
  324. .amount {
  325. max-width: 110px;
  326. display: inline-block;
  327. word-break: break-all;
  328. text-align: right;
  329. }
  330. .name {
  331. margin-left: 3px;
  332. color: #E29A2E;
  333. }
  334. img {
  335. width: 14px;
  336. height: 14px;
  337. margin-left: 4px;
  338. }
  339. .balance {
  340. text-align: right;
  341. margin-bottom: 4px;
  342. display: flex;
  343. align-items: center;
  344. }
  345. .desc {
  346. text-align: right;
  347. font-weight: 400;
  348. font-size: 12px;
  349. color: #797979;
  350. }
  351. }
  352. .icon {
  353. width: 18px;
  354. height: 24px;
  355. }
  356. }
  357. }
  358. }
  359. }
  360. }
  361. </style>