myPledge.vue 8.3 KB

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