myPledge.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <view class="all">
  3. <view class="top">
  4. <view class="zhiya"> 質押數 </view>
  5. <view class="zhiyashu">
  6. <p class="shu">241,142,574.25</p>
  7. <p class="wen">USDT</p>
  8. </view>
  9. </view>
  10. <view class="navbar">
  11. <view
  12. v-for="(item, index) in navList"
  13. :key="index"
  14. class="nav-item"
  15. :class="{ current: tabCurrentIndex === index }"
  16. @click="tabClick(index)"
  17. >{{ item.text }}</view
  18. >
  19. </view>
  20. <swiper
  21. :current="tabCurrentIndex"
  22. :style="{ height: height }"
  23. class="swiper-box"
  24. duration="300"
  25. @change="changeTab">
  26. <swiper-item
  27. class="tab-content"
  28. v-for="(tabItem, tabIndex) in navList"
  29. :key="tabIndex">
  30. <scroll-view
  31. scroll-y="true"
  32. class="list-scroll-content"
  33. @scrolltolower="loadData">
  34. <!-- 空白页 -->
  35. <!-- <empty
  36. v-if="
  37. tabItem.loaded === true &&
  38. tabItem.orderList.length === 0
  39. "></empty> -->
  40. <!-- 订单列表 -->
  41. <view>
  42. <!-- <view class="order-item flex" > -->
  43. <view class="order-item">
  44. <view class="title-box">
  45. <view class="title">
  46. <text>質押金額</text>
  47. </view>
  48. <view class="title">
  49. <text>累計收益</text>
  50. </view>
  51. <view class="title">
  52. <text>質押期限</text>
  53. </view>
  54. <view class="title">
  55. <text>購買時間</text>
  56. </view>
  57. <view class="title">
  58. <text>到期時間</text>
  59. </view>
  60. </view>
  61. <view class="heng"></view>
  62. <view
  63. class="all-list"
  64. v-for="item in 10"
  65. :key="item">
  66. <view class="list">
  67. <view class="list-item">
  68. <view class="item"> 100 </view>
  69. <view class="item"> USDT </view>
  70. </view>
  71. <view class="list-item">
  72. <view class="item"> 100 </view>
  73. <view class="item"> USDT </view>
  74. </view>
  75. <view class="list-item">
  76. <view
  77. class="item"
  78. style="margin-top: 18rpx">
  79. 7天
  80. </view>
  81. </view>
  82. <view class="list-item">
  83. <view class="l-item"> 2023.12.02 </view>
  84. <view
  85. class="l-item"
  86. style="margin-top: 20rpx">
  87. 12:00:00
  88. </view>
  89. </view>
  90. <view class="list-item">
  91. <view class="l-item"> 2023.12.02 </view>
  92. <view
  93. class="l-item"
  94. style="margin-top: 20rpx">
  95. 12:00:00
  96. </view>
  97. </view>
  98. </view>
  99. <view class="heng"></view>
  100. </view>
  101. <!-- <view class="money">
  102. <view>{{ (item.pm == 0 ? '-' : '+') + item.number * 1 }}</view>
  103. </view> -->
  104. </view>
  105. </view>
  106. <!-- 上拉显示更多 -->
  107. <!-- <uni-load-more :status="tabItem.loadingType"
  108. v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more> -->
  109. </scroll-view>
  110. </swiper-item>
  111. </swiper>
  112. </view>
  113. </template>
  114. <script>
  115. import { mapState, mapMutations } from "vuex";
  116. import { getCommissionInfo, getUserInfo } from "@/api/user.js";
  117. import { getMoneyStyle } from "@/utils/rocessor.js";
  118. import { mapGetters } from "vuex";
  119. import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
  120. import empty from "@/components/empty";
  121. import {
  122. spreadCommission,
  123. userBalance,
  124. extractBank,
  125. } from "@/api/wallet.js";
  126. export default {
  127. filters: {
  128. getMoneyStyle,
  129. },
  130. components: {
  131. empty,
  132. uniLoadMore,
  133. },
  134. onReady(res) {
  135. var _this = this;
  136. uni.getSystemInfo({
  137. success: resu => {
  138. const query = uni.createSelectorQuery();
  139. query.select(".swiper-box").boundingClientRect();
  140. query.exec(function (res) {
  141. _this.height = resu.windowHeight - res[0].top + "px";
  142. console.log("打印页面的剩余高度", _this.height);
  143. });
  144. },
  145. fail: res => {},
  146. });
  147. },
  148. data() {
  149. return {
  150. userInfo: {},
  151. yj: "",
  152. height: "",
  153. // 头部图高度
  154. maxheight: "",
  155. tabCurrentIndex: 0,
  156. orderStatusSum: 0,
  157. recharge: 0,
  158. navList: [
  159. // {
  160. // state: 0,
  161. // text: '全部',
  162. // loadingType: 'more',
  163. // orderList: [],
  164. // page: 1, //当前页数
  165. // limit: 10 //每次信息条数
  166. // },
  167. {
  168. state: 4,
  169. text: "进行中",
  170. loadingType: "more",
  171. orderList: [],
  172. page: 1, //当前页数
  173. limit: 10, //每次信息条数
  174. },
  175. {
  176. state: 3,
  177. text: "已结束",
  178. loadingType: "more",
  179. orderList: [],
  180. page: 1, //当前页数
  181. limit: 10, //每次信息条数
  182. },
  183. ],
  184. money: "",
  185. };
  186. },
  187. onLoad(options) {},
  188. onShow() {
  189. this.extractBank();
  190. this.getUserInfo();
  191. this.loadData();
  192. },
  193. methods: {
  194. getUserInfo() {
  195. getUserInfo({}).then(({ data }) => {
  196. this.userInfo = data;
  197. });
  198. },
  199. extractBank() {
  200. extractBank().then(res => {
  201. console.log(res);
  202. this.yj = res.data.brokerage_price;
  203. });
  204. },
  205. toBack() {
  206. uni.switchTab({
  207. url: "/pages/pledge/pledge",
  208. });
  209. },
  210. // 页面跳转
  211. navto(e) {
  212. uni.navigateTo({
  213. url: e,
  214. });
  215. },
  216. //获取收入支出信息
  217. async loadData(source) {
  218. let obj = this;
  219. //这里是将订单挂载到tab列表下
  220. let index = this.tabCurrentIndex;
  221. let navItem = this.navList[index];
  222. let state = navItem.state;
  223. if (source === "tabChange" && navItem.loaded === true) {
  224. //tab切换只有第一次需要加载数据
  225. return;
  226. }
  227. if (navItem.loadingType === "loading") {
  228. //防止重复加载
  229. return;
  230. }
  231. // 修改当前对象状态为加载中
  232. // navItem.loadingType = 'loading';
  233. spreadCommission(
  234. {
  235. page: navItem.page,
  236. limit: navItem.limit,
  237. },
  238. state
  239. )
  240. .then(({ data }) => {
  241. if (data.length > 0) {
  242. data.forEach(e => {
  243. navItem.orderList = navItem.orderList.concat(
  244. e.list
  245. );
  246. });
  247. console.log(navItem.orderList);
  248. navItem.page++;
  249. }
  250. //判断是否还有数据, 有改为more, 没有改为noMore
  251. if (navItem.limit == data.length) {
  252. navItem.loadingType = "more";
  253. return;
  254. } else {
  255. navItem.loadingType = "noMore";
  256. }
  257. uni.hideLoading();
  258. this.$set(navItem, "loaded", true);
  259. })
  260. .catch(e => {
  261. console.log(e);
  262. });
  263. },
  264. //swiper 切换
  265. changeTab(e) {
  266. this.tabCurrentIndex = e.target.current;
  267. this.loadData("tabChange");
  268. },
  269. //顶部tab点击
  270. tabClick(index) {
  271. this.tabCurrentIndex = index;
  272. },
  273. },
  274. };
  275. </script>
  276. <style lang="scss">
  277. .all {
  278. width: 750rpx;
  279. height: 1660rpx;
  280. background-color: #000000;
  281. }
  282. .top {
  283. margin-left: 30rpx;
  284. width: 690rpx;
  285. height: 137rpx;
  286. background-color: #191a1f;
  287. }
  288. .zhiya {
  289. margin-left: 28rpx;
  290. // margin-top: 31rpx;
  291. padding-top: 31rpx;
  292. height: 21rpx;
  293. font-size: 21rpx;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. color: #757c8f;
  297. }
  298. .zhiyashu {
  299. display: flex;
  300. justify-content: start;
  301. }
  302. .shu {
  303. margin-left: 29rpx;
  304. margin-top: 30rpx;
  305. font-size: 32rpx;
  306. height: 30rpx;
  307. color: #ffffff;
  308. font-family: PingFang SC;
  309. font-weight: bold;
  310. }
  311. .wen {
  312. margin-left: 20rpx;
  313. margin-top: 36rpx;
  314. height: 26rpx;
  315. font-size: 26rpx;
  316. font-family: PingFang SC;
  317. font-weight: bold;
  318. color: #ffffff;
  319. }
  320. .body {
  321. background-color: #191a1f;
  322. margin-left: 30rpx;
  323. margin-top: 20rpx;
  324. width: 690rpx;
  325. height: 137rpx;
  326. }
  327. // !!!!
  328. .navbar {
  329. margin-top: 20rpx;
  330. display: flex;
  331. height: 88rpx;
  332. padding: 0 5px;
  333. background: #191a1f;
  334. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  335. position: relative;
  336. z-index: 10;
  337. .nav-item {
  338. flex: 1;
  339. display: flex;
  340. justify-content: center;
  341. align-items: center;
  342. height: 100%;
  343. font-size: 15px;
  344. color: #999999;
  345. position: relative;
  346. &.current {
  347. color: #fff;
  348. &:after {
  349. content: "";
  350. position: absolute;
  351. left: 50%;
  352. bottom: 0;
  353. transform: translateX(-50%);
  354. width: 44px;
  355. height: 0;
  356. border-bottom: 2px solid #fe5b38;
  357. }
  358. }
  359. }
  360. }
  361. // 列表样式
  362. .order-item {
  363. // margin-top: 30rpx;
  364. // width: 690rpx;
  365. background: #191a1f;
  366. }
  367. .title-box {
  368. // margin-top: 30rpx;
  369. // margin-top: 30rpx;
  370. margin-left: 38rpx;
  371. display: flex;
  372. justify-content: space-between;
  373. width: 690rpx;
  374. }
  375. .title {
  376. flex: 1;
  377. margin-top: 30rpx;
  378. // text-align: center;
  379. // white-space: normal;
  380. // word-wrap: break-word;
  381. width: 43rpx;
  382. height: 50rpx;
  383. font-size: 22rpx;
  384. font-family: PingFang SC;
  385. font-weight: 500;
  386. color: #ffffff;
  387. line-height: 28rpx;
  388. opacity: 0.53;
  389. }
  390. .list {
  391. margin-top: 40rpx;
  392. margin-left: 38rpx;
  393. display: flex;
  394. justify-content: space-between;
  395. width: 690rpx;
  396. // background-color: #000000;
  397. }
  398. .item {
  399. height: 40rpx;
  400. font-size: 22rpx;
  401. font-family: PingFang SC;
  402. font-weight: bold;
  403. color: #ffffff;
  404. line-height: 23rpx;
  405. }
  406. .l-item {
  407. height: 15rpx;
  408. font-size: 18rpx;
  409. font-family: PingFang SC;
  410. font-weight: 500;
  411. color: #ffffff;
  412. }
  413. .heng {
  414. margin-top: 30rpx;
  415. width: 750rpx;
  416. height: 2rpx;
  417. background: #e9e9e9;
  418. }
  419. // .list-scroll-content {
  420. // background: #000;
  421. // height: 100%;
  422. // // height: 1600rpx;
  423. // }
  424. // .content {
  425. // height: 100%;
  426. // // height: 1600rpx;
  427. // .empty-content {
  428. // background-color: #000;
  429. // }
  430. // }
  431. .btn-box {
  432. width: 674rpx;
  433. height: 88rpx;
  434. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  435. border-radius: 44rpx;
  436. font-size: 36rpx;
  437. font-family: PingFang SC;
  438. font-weight: 500;
  439. color: #ffffff;
  440. text-align: center;
  441. line-height: 88rpx;
  442. position: fixed;
  443. bottom: 48rpx;
  444. left: 0;
  445. right: 0;
  446. margin: 0 auto;
  447. }
  448. </style>