myPledge.vue 7.6 KB

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