myPledge.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. },
  151. onShow() {
  152. this.getUserInfo();
  153. this.loadData();
  154. },
  155. methods: {
  156. getTime,
  157. getUserInfo() {
  158. getUserInfo({}).then(({
  159. data
  160. }) => {
  161. this.userInfo = data;
  162. });
  163. },
  164. toBack() {
  165. uni.switchTab({
  166. url: "/pages/pledge/pledge",
  167. });
  168. },
  169. // 页面跳转
  170. navto(e) {
  171. uni.navigateTo({
  172. url: e,
  173. });
  174. },
  175. //获取收入支出信息
  176. async loadData(source) {
  177. const that = this;
  178. //这里是将订单挂载到tab列表下
  179. let index = that.tabCurrentIndex;
  180. let navItem = that.navList[index];
  181. let state = navItem.state;
  182. if (source === 'tabChange' && navItem.loaded === true) {
  183. //tab切换只有第一次需要加载数据
  184. return;
  185. }
  186. if (navItem.loadingType === 'loading') {
  187. //防止重复加载
  188. return;
  189. }
  190. if (navItem.loadingType === 'noMore') {
  191. //防止重复加载
  192. return;
  193. }
  194. // 修改当前对象状态为加载中
  195. navItem.loadingType = 'loading';
  196. getLock({
  197. status: state,
  198. page: navItem.page,
  199. limit: navItem.limit
  200. })
  201. .then(({
  202. data
  203. }) => {
  204. // 保存我的总金额
  205. that.money = data.sum;
  206. let arr = data.list.map(e => {
  207. return e;
  208. });
  209. navItem.orderList = navItem.orderList.concat(arr);
  210. if (navItem.limit == data.length) {
  211. navItem.page++;
  212. //判断是否还有数据, 有改为 more, 没有改为noMore
  213. navItem.loadingType = 'more';
  214. return;
  215. } else {
  216. //判断是否还有数据, 有改为 more, 没有改为noMore
  217. navItem.loadingType = 'noMore';
  218. }
  219. uni.hideLoading();
  220. that.$set(navItem, 'loaded', true);
  221. })
  222. .catch(e => {
  223. console.log(e);
  224. });
  225. },
  226. //swiper 切换
  227. changeTab(e) {
  228. this.tabCurrentIndex = e.target.current;
  229. this.loadData("tabChange");
  230. },
  231. //顶部tab点击
  232. tabClick(index) {
  233. this.tabCurrentIndex = index;
  234. },
  235. },
  236. };
  237. </script>
  238. <style lang="scss">
  239. .all {
  240. width: 750rpx;
  241. background-color: $page-color-base;
  242. }
  243. .top {
  244. margin: 0 30rpx;
  245. height: 138rpx;
  246. background-color: #191a1f;
  247. font-weight: bold;
  248. color: #ffffff;
  249. border-radius:20rpx ;
  250. .zhiya {
  251. font-size: $font-sm;
  252. color: #757c8f;
  253. }
  254. .zhiyashu {
  255. .shu {
  256. font-size: $font-lg;
  257. }
  258. .wen {
  259. font-size: $font-base;
  260. }
  261. }
  262. }
  263. .body {
  264. background-color: #191a1f;
  265. margin-left: 30rpx;
  266. margin-top: 20rpx;
  267. width: 690rpx;
  268. height: 137rpx;
  269. }
  270. .navbar {
  271. margin-top: 20rpx;
  272. display: flex;
  273. height: 88rpx;
  274. padding: 0 5px;
  275. background: #191a1f;
  276. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  277. position: relative;
  278. z-index: 10;
  279. .nav-item {
  280. flex: 1;
  281. display: flex;
  282. justify-content: center;
  283. align-items: center;
  284. height: 100%;
  285. font-size: 15px;
  286. color: #999999;
  287. position: relative;
  288. &.current {
  289. color: #fff;
  290. &:after {
  291. content: "";
  292. position: absolute;
  293. left: 50%;
  294. bottom: 0;
  295. transform: translateX(-50%);
  296. width: 44px;
  297. height: 0;
  298. border-bottom: 2px solid #fe5b38;
  299. }
  300. }
  301. }
  302. }
  303. // 列表样式
  304. .order-item {
  305. background: #191a1f;
  306. }
  307. .title-box {
  308. margin-left: 38rpx;
  309. display: flex;
  310. justify-content: space-between;
  311. width: 690rpx;
  312. }
  313. .title {
  314. flex: 1;
  315. margin-top: 30rpx;
  316. width: 43rpx;
  317. height: 50rpx;
  318. font-size: 22rpx;
  319. font-family: PingFang SC;
  320. font-weight: 500;
  321. color: #ffffff;
  322. line-height: 28rpx;
  323. opacity: 0.53;
  324. }
  325. .list {
  326. margin-top: 40rpx;
  327. margin-left: 38rpx;
  328. display: flex;
  329. justify-content: space-between;
  330. width: 690rpx;
  331. }
  332. .item {
  333. height: 40rpx;
  334. font-size: 22rpx;
  335. font-family: PingFang SC;
  336. font-weight: bold;
  337. color: #ffffff;
  338. line-height: 23rpx;
  339. }
  340. .l-item {
  341. height: 15rpx;
  342. font-size: 18rpx;
  343. font-family: PingFang SC;
  344. font-weight: 500;
  345. color: #ffffff;
  346. }
  347. .heng {
  348. margin-top: 30rpx;
  349. width: 750rpx;
  350. height: 2rpx;
  351. background: #e9e9e9;
  352. }
  353. .btn-box {
  354. width: 674rpx;
  355. height: 88rpx;
  356. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  357. border-radius: 44rpx;
  358. font-size: 36rpx;
  359. font-family: PingFang SC;
  360. font-weight: 500;
  361. color: #ffffff;
  362. text-align: center;
  363. line-height: 88rpx;
  364. position: fixed;
  365. bottom: 48rpx;
  366. left: 0;
  367. right: 0;
  368. margin: 0 auto;
  369. }
  370. </style>