mine.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <v-page>
  3. <view class="flex-col" style="padding-bottom:60px">
  4. <v-header :title="$t('base.d2')" :left-arrow="false"></v-header>
  5. <!-- <view style="height: var(--status-bar-height)"></view> -->
  6. <view
  7. class="head bg-panel-3 h-66 p-x-md m-x-md d-flex justify-between align-center bgb4 rounded-md color-plain p-y-xl">
  8. <view>
  9. <view class="d-flex">
  10. <text class="fn-sm d-block m-t-md">{{ $t("base.d6") }}(BTC)</text>
  11. <view class="fn-20 m-t-md m-l-md" @click="setHide(!hideMoney)">
  12. <van-icon v-if="!hideMoney" name="eye-o" />
  13. <van-icon v-else name="closed-eye" />
  14. </view>
  15. </view>
  16. <view class="m-t-md">
  17. <text class="fn-28">{{
  18. filterMoney(account.total_assets_btc)
  19. }}</text>
  20. <text class="fn-sm m-l-md">≈{{ filterMoney(account.total_assets_usd) }}USD</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="layout-main">
  25. <!-- 头部 -->
  26. <view class="top p-t-md">
  27. <van-tabs :active="tabActive" @change="changtTab" :border="false" v-if="show" :line-width="30"
  28. swipeable animated class="tabs-main d-flex justify-between align-center flex-col">
  29. <van-tab :title="$t('base.d7')" :name="0">
  30. <view class="m-x-md">
  31. <view class="m-y-lg">
  32. <view class="bg-panel-3 p-xs p-x-md rounded-lg bgb3"
  33. :class="theme == 'light' ? 'bgb3-white' : ''" style="position: relative">
  34. <text class="fn-sm d-block color-gray-6 m-t-xs">{{ $t("base.d6") }}(BTC)</text>
  35. <text
  36. class="fn-20 d-block color-light m-t-md">{{ filterMoney(account.funds_account_btc) }}
  37. BTC</text>
  38. <text
  39. class="fn-sm d-block m-t-xs color-gray-6">{{ filterMoney(account.funds_account_usd) }}
  40. USD</text>
  41. <view class="p-x-md p-t-xs" style="margin-top: 10px">
  42. <view class="d-flex justify-between align-center rounded-lg">
  43. <v-link tag="view" to="/pages/assets/recharge" class="d-flex">
  44. <view class="m-r-xs align-center">
  45. <img :src="$localImgUrl('fill3.png')" alt="" class="h-18" />
  46. </view>
  47. <text class="color-light fn-middle">{{
  48. $t("base.b5")
  49. }}</text>
  50. </v-link>
  51. <v-link tag="view" to="/pages/assets/draw" class="d-flex">
  52. <view class="m-r-xs align-center">
  53. <img :src="$localImgUrl('fill5.png')" alt="" class="h-18" />
  54. </view>
  55. <text class="color-light fn-middle">{{
  56. $t("base.b6")
  57. }}</text>
  58. </v-link>
  59. <v-link tag="view" to="/pages/transfer/index" class="d-flex">
  60. <view class="m-r-xs align-center">
  61. <img :src="$localImgUrl('fill4.png')" alt="" class="h-18" />
  62. </view>
  63. <text class="color-light fn-middle">{{
  64. $t("base.d8")
  65. }}</text>
  66. </v-link>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="h-60 d-flex justify-between align-center">
  72. <van-field :value="searchText" @input="searchText = $event.detail"
  73. left-icon="search" :placeholder="$t('base.d9')" input-class="fn-12 "
  74. class="flex-fill color-gray-6 bg-form-panel-4 rounded-md pos fn-12 m-r-md"
  75. style="padding-left: 0" />
  76. <text class="color-gray-6 p-r-xs">{{ $t("base.e0") }} 0 {{ $t("base.e1") }}</text>
  77. <van-checkbox :value="hide" @change="hide = !hide" icon-size="16"></van-checkbox>
  78. </view>
  79. <v-link tag="div" :to="{
  80. path: '/pages/assets/bill',
  81. query: { coin_name: item.coin_name },
  82. }" v-show="ifShow(item)" class="p-t-xs d-block bg-panel-3 rounded-md box-shadow"
  83. style="margin: 10px 0" v-for="(item, index) in list" :key="index">
  84. <view class="m-x-md d-flex justify-between align-center p-b-sm">
  85. <view>
  86. <img :src="item.image" class="w-20 h-20 rounded-max fn-middle" />
  87. <text class="fn-16 color-light fn-middle p-l-sm">{{
  88. item.coin_name
  89. }}</text>
  90. </view>
  91. <view>
  92. <text class="fn-lg color-light fn-middle">{{
  93. add(
  94. item.usable_balance,
  95. item.freeze_balance,
  96. item.priceDecimals
  97. )
  98. }}</text>
  99. <!-- <van-icon
  100. class="p-l-xs fn-middle"
  101. name="arrow"
  102. size="16"
  103. color="#646566"
  104. /> -->
  105. </view>
  106. </view>
  107. <view class="p-x-md d-flex justify-between align-center">
  108. <view class="w-4/12">
  109. <p class="color-gray-6" style="padding: 5px 0">
  110. {{ $t("base.b9") }}
  111. </p>
  112. <p class="fn-xs color-light">{{ item.usable_balance }}</p>
  113. </view>
  114. <view class="w-4/12">
  115. <p class="color-gray-6" style="padding: 5px 0">
  116. {{ $t("base.e2") }}
  117. </p>
  118. <p class="fn-xs color-light">{{ item.freeze_balance }}</p>
  119. </view>
  120. <view class="w-4/12 fn-right">
  121. <p class="color-gray-6" style="padding: 5px 0">
  122. {{ $t("base.e3") }}(USD)
  123. </p>
  124. <p class="fn-xs color-light">
  125. {{ omitTo(item.usd_estimate, item.priceDecimals) }}
  126. </p>
  127. </view>
  128. </view>
  129. <view class="h-4 m-t-xs"></view>
  130. </v-link>
  131. </view>
  132. </van-tab>
  133. <van-tab :title="$t('base.e4')" :name="1" class="p-t-md">
  134. <view class="m-x-md">
  135. <view class="bgb3 p-x-md p-y-lg rounded-lg" :class="theme == 'light' ? 'bgb3-white' : ''"
  136. style="position: relative">
  137. <view class="fn-sm d-flex justify-between color-gray-6 m-t-xs">
  138. <span> USDT </span>
  139. <v-link class="color-buy" to="/pages/assets/account-bill">{{ $t("base.e4") }}
  140. <van-icon class="fn-middle" name="arrow" size="16" />
  141. </v-link>
  142. </view>
  143. <span class="fn-20 d-block color-light m-t-md">{{ filterMoney(account.contract_account_usd)
  144. }}{{ account.symbol }}</span>
  145. <view class="d-flex justify-between m-t-xs">
  146. <v-link to="/pages/transfer/index" class="d-flex">
  147. <view class="m-r-xs align-center">
  148. <img :src="$localImgUrl('fill4.png')" alt="" class="h-18" />
  149. </view>
  150. <!-- <van-icon class="color-theme-1 fn-26 fn-middle m-r-xs" name="exchange" /> -->
  151. <text class="color-light fn-middle">{{
  152. $t("base.d8")
  153. }}</text>
  154. </v-link>
  155. </view>
  156. </view>
  157. </view>
  158. </van-tab>
  159. <!-- <van-tab :title="$t('otc.d5')" :name="1" class="p-t-md">
  160. <view class="m-x-md">
  161. <view
  162. class="bgb3 p-x-md p-y-lg rounded-lg"
  163. :class="theme == 'light' ? 'bgb3-white' : ''"
  164. style="position: relative"
  165. >
  166. <view
  167. class="fn-sm d-flex justify-between color-gray-6 m-t-xs"
  168. >
  169. <span> USDT </span>
  170. <v-link class="color-buy" to="/pages/otc/bill"
  171. >{{ $t("otc.d5") }}
  172. <van-icon class="fn-middle" name="arrow" size="16"
  173. /></v-link>
  174. </view>
  175. <span class="fn-20 d-block color-light m-t-md"
  176. >{{ filterMoney(account.contract_account_usd)
  177. }}{{ account.symbol }}</span
  178. >
  179. <view class="d-flex justify-between m-t-xs">
  180. <v-link to="/pages/transfer/index" class="d-flex">
  181. <view class="m-r-xs align-center">
  182. <img
  183. :src="$localImgUrl('fill4.png')"
  184. alt=""
  185. class="h-18"
  186. />
  187. </view>
  188. <van-icon class="color-theme-1 fn-26 fn-middle m-r-xs" name="exchange" />
  189. <text class="color-light fn-middle">{{
  190. $t("base.d8")
  191. }}</text>
  192. </v-link>
  193. </view>
  194. </view>
  195. </view>
  196. </van-tab> -->
  197. </van-tabs>
  198. </view>
  199. </view>
  200. </view>
  201. <ComFooter tab="mine"></ComFooter>
  202. </v-page>
  203. </template>
  204. <script>
  205. import {
  206. mapState,
  207. mapActions
  208. } from "vuex";
  209. import Wallet from "@/api/wallet";
  210. import math from "@/utils/class/math.js";
  211. import Contract from "@/api/contract.js";
  212. import ComFooter from "./components/footer.vue";
  213. export default {
  214. name: "mine",
  215. data() {
  216. return {
  217. account: {},
  218. list: [],
  219. tabActive: 0, // 切换选择
  220. searchText: "",
  221. hide: false,
  222. show: false,
  223. accountDetail: {},
  224. isShow: false,
  225. };
  226. },
  227. components: {
  228. ComFooter,
  229. },
  230. computed: {
  231. ...mapState({
  232. hideMoney: "hideMoney",
  233. theme: "theme",
  234. }),
  235. },
  236. onShow() {
  237. this.isShow = true;
  238. },
  239. onHide() {
  240. this.isShow = false;
  241. },
  242. props: {
  243. // isShow: {
  244. // default: true,
  245. // type: Boolean,
  246. // required: false,
  247. // },
  248. },
  249. watch: {
  250. isShow(n, o) {
  251. if (n) {
  252. this.upDateData();
  253. }
  254. },
  255. },
  256. methods: {
  257. omitTo: math.omitTo,
  258. // 计算和
  259. add: math.add,
  260. ...mapActions({
  261. setHide: "hideMoney",
  262. }),
  263. filterMoney(val) {
  264. if (this.hideMoney) return "******";
  265. return this.omitTo(val, 4);
  266. },
  267. ifShow(item) {
  268. // 搜索过滤
  269. let show =
  270. item.coin_name
  271. .toLocaleLowerCase()
  272. .indexOf(this.searchText.toLocaleLowerCase()) != -1;
  273. if (!this.hide) return true && show;
  274. // 0余额资金过滤
  275. let hasMoney =
  276. this.add(item.usable_balance, item.freeze_balance, item.priceDecimals) *
  277. 1 !=
  278. 0;
  279. return hasMoney && show;
  280. },
  281. fundAccount() {
  282. Wallet.fundAccount().then((res) => {
  283. this.list = res.data.list;
  284. });
  285. },
  286. personalAssets() {
  287. Wallet.personalAssets().then((res) => {
  288. this.account = res.data;
  289. });
  290. },
  291. // 获取合约列表
  292. accounts() {
  293. Contract.contractAccount().then((res) => {
  294. this.accountDetail = res.data;
  295. });
  296. },
  297. changtTab($ev) {
  298. this.tabActive = $ev.detail.name;
  299. this.upDateData();
  300. },
  301. // 刷新数据
  302. upDateData() {
  303. if (this.tabActive == 1) {
  304. this.accounts();
  305. } else {
  306. this.personalAssets();
  307. this.fundAccount();
  308. }
  309. },
  310. },
  311. mounted() {
  312. this.show = true;
  313. },
  314. created() {
  315. this.upDateData();
  316. },
  317. };
  318. </script>
  319. <style lang="scss" scoped>
  320. .tabs-main {
  321. ::v-deep.van-tabs {
  322. width: 100%;
  323. }
  324. ::v-deep.van-tabs__wrap,
  325. ::v-deep.van-tabs__content {
  326. // width: 100%;
  327. }
  328. ::v-deep.van-tabs__content {
  329. flex: 1;
  330. overflow: hidden;
  331. }
  332. ::v-deep.van-pull-refresh {
  333. height: calc(100vh - 200px);
  334. overflow-y: auto;
  335. }
  336. ::v-deep.van-cell {
  337. background: transparent;
  338. &::after {
  339. border-width: 0;
  340. }
  341. }
  342. ::v-deep .van-cell__left-icon {
  343. color: $white;
  344. }
  345. }
  346. .bgb3 {
  347. background: url(../../static/img/bgb3.png) no-repeat;
  348. background-size: 140% auto;
  349. background-position: right bottom;
  350. &.bgb3-white {
  351. background-image: url(../../static/img/light/bgb3.png);
  352. }
  353. }
  354. .bgb4 {
  355. background: url(../../static/img/bgb4.png) no-repeat;
  356. background-size: 100% auto;
  357. background-position: right bottom;
  358. }
  359. .pos {
  360. position: relative;
  361. }
  362. .posa {
  363. position: absolute;
  364. }
  365. </style>