jifen.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view class="content">
  3. <!-- <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view> -->
  6. <view class="header">
  7. <image src="../../static/user/shopping.png" mode=""></image>
  8. <view class="integral">
  9. {{ integral || 0 }}
  10. </view>
  11. <!-- <navigator url="/pages/money/conversionIntegral"><view class="right">转换USDT</view></navigator> -->
  12. </view>
  13. <view class="navbar ">
  14. <view class="nav-item" v-for="(item,index) in navList" :key="index"
  15. :class="{current:tabCurrentIndex===index}" @click="tabClick(index)">{{item.text}}</view>
  16. </view>
  17. <swiper class="swiper-box" duration="300" :style="{ height: maxheight }" :current="tabCurrentIndex"
  18. @change="changeTab">
  19. <swiper-item class="tab-content" v-for="(item,index) in navList">
  20. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  21. <!-- 空白页 -->
  22. <!-- <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty> -->
  23. <empty v-if="item.loaded ===true && item.orderList.length===0"></empty>
  24. <!-- 订单列表 -->
  25. <view v-else class="order-item flex " v-for="orderItem in item.orderList">
  26. <view class="title-box ">
  27. <view class="title">
  28. <text>{{orderItem.mark}}</text>
  29. </view>
  30. <view class="time">
  31. <text>{{orderItem.add_time}}</text>
  32. </view>
  33. </view>
  34. <view class="money">
  35. <text>{{(orderItem.pm == 0?'-':'+')+orderItem.number}}</text>
  36. </view>
  37. </view>
  38. <!-- <uni-load-more :status="tabItem.loadingType"></uni-load-more> -->
  39. <uni-load-more :status="item.loadingType"></uni-load-more>
  40. </scroll-view>
  41. </swiper-item>
  42. </swiper>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. moneyLog,
  48. wallet
  49. } from '@/api/finance.js';
  50. import { integral } from '@/api/wallet.js';
  51. //下拉加载
  52. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  53. import empty from '@/components/u-empty/u-empty.vue';
  54. export default {
  55. components: {
  56. uniLoadMore,
  57. empty
  58. },
  59. computed: {
  60. //积分
  61. // integral() {
  62. // return this.$store.state.user.userInfo.integral
  63. // }
  64. // ...mapState('user',['userInfo'])
  65. },
  66. onReady(res) {
  67. var _this = this;
  68. uni.getSystemInfo({
  69. success: resu => {
  70. const query = uni.createSelectorQuery();
  71. query.select('.swiper-box').boundingClientRect();
  72. query.exec(function(res) {
  73. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  74. console.log('打印页面的剩余高度', _this.height);
  75. });
  76. },
  77. fail: res => {}
  78. });
  79. },
  80. onLoad() {
  81. wallet({}).then(({
  82. data
  83. }) => {
  84. const obj = this
  85. const arr = Object.keys(data.back)
  86. console.log(data.back, '000');
  87. arr.forEach(e => {
  88. if (e == 'USDT') {
  89. obj.integral = (data.back[e].money.money * 1)
  90. console.log(obj.integral, '666');
  91. }
  92. })
  93. })
  94. this.loadData();
  95. },
  96. data() {
  97. return {
  98. tabCurrentIndex: 0, //判断亮不亮
  99. integral: 0, //我的积分
  100. maxheight: '',
  101. navList: [{
  102. state: 1,
  103. text: '收入',
  104. orderList: [], //里面的数据
  105. loadingType: 'More', //是否还有更多数据
  106. limit: 10, //一页10条
  107. page: 1
  108. },
  109. {
  110. text: '支出',
  111. state: 0,
  112. orderList: [],
  113. limit: 10,
  114. page: 1,
  115. loadingType: 'More'
  116. }
  117. ]
  118. };
  119. },
  120. onShow() {
  121. this.loadData()
  122. },
  123. methods: {
  124. // 下拉刷新
  125. async loadData(source) {
  126. console.log(source, "222");
  127. // 将订单挂载到tab列表下
  128. let index = this.tabCurrentIndex
  129. let item = this.navList[index];
  130. console.log(item);
  131. let state = item.state
  132. if (source === 'tabChange' && item.loaded === true) {
  133. return
  134. }
  135. if (item.loadingType === 'loading') {
  136. //防止重复加载
  137. return
  138. }
  139. //修改当前数据为加载中
  140. item.loadingType = 'loading'
  141. console.log(item.limit, '123456789987654321')
  142. integral({
  143. page: item.page,
  144. limit: item.limit,
  145. pm: item.state
  146. }).then(({
  147. data
  148. }) => {
  149. console.log(data, '123456');
  150. item.orderList = item.orderList.concat(data)
  151. item.page++
  152. //判断是否还有数据,没有就把提示语改成nomore,有就为more
  153. if (item.limit == data.length) {
  154. item.loadingType = 'more'
  155. return
  156. } else {
  157. item.loadingType = 'noMore'
  158. }
  159. this.$set(item, 'loaded', true)
  160. }).catch(e => {
  161. console.log(e)
  162. })
  163. },
  164. //tab点击
  165. tabClick(index) {
  166. this.tabCurrentIndex = index
  167. this.loadData('tabChange')
  168. console.log(this.tabCurrentIndex)
  169. },
  170. changeTab(e) {
  171. this.tabCurrentIndex = e.target.current
  172. console.log(this.tabCurrentIndex, '21')
  173. this.loadData('tabChange')
  174. }
  175. },
  176. };
  177. </script>
  178. <style lang="scss">
  179. page {
  180. background: #ffffff;
  181. height: 100%;
  182. }
  183. .header {
  184. image {
  185. width: 100%;
  186. height: 400rpx;
  187. }
  188. .integral {
  189. width: 100%;
  190. text-align: center;
  191. position: absolute;
  192. top: 160rpx;
  193. color: #fff;
  194. font-size: 80rpx;
  195. font-weight: bold;
  196. }
  197. .right {
  198. position: absolute;
  199. top: 120rpx;
  200. right: 0;
  201. background-color: #fff;
  202. border-radius: 10rpx 0 0 10rpx;
  203. color: #438BED;
  204. padding: 5rpx 15rpx;
  205. font-size: 28rpx;
  206. }
  207. }
  208. .navbar {
  209. display: flex;
  210. height: 40px;
  211. padding: 0 5px;
  212. background: #fff;
  213. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  214. position: relative;
  215. z-index: 10;
  216. .nav-item {
  217. flex: 1;
  218. display: flex;
  219. justify-content: center;
  220. align-items: center;
  221. height: 100%;
  222. font-size: 15px;
  223. color: $font-color-dark;
  224. position: relative;
  225. &.current {
  226. color: #438BED;
  227. &:after {
  228. content: '';
  229. position: absolute;
  230. left: 50%;
  231. bottom: 0;
  232. transform: translateX(-50%);
  233. width: 44px;
  234. height: 0;
  235. border-bottom: 2px solid #438BED;
  236. }
  237. }
  238. }
  239. }
  240. // 列表
  241. .swiper-box {
  242. height: calc(100% - 180rpx - 400rpx);
  243. padding-top: 10rpx;
  244. .order-item {
  245. padding: 20rpx 30rpx;
  246. line-height: 1.5;
  247. .title-box {
  248. .title {
  249. font-size: $font-lg;
  250. color: $font-color-base;
  251. }
  252. .time {
  253. font-size: $font-base;
  254. color: $font-color-light;
  255. }
  256. }
  257. .money {
  258. color: #EF3A55;
  259. font-size: $font-lg;
  260. }
  261. }
  262. }
  263. .list-scroll-content {
  264. height: 100%;
  265. }
  266. .content {
  267. height: 100%;
  268. .empty-content {
  269. background-color: #ffffff;
  270. }
  271. }
  272. .button {
  273. height: 180rpx;
  274. width: 100%;
  275. display: flex;
  276. position: absolute;
  277. padding: 40rpx 30rpx 60rpx 30rpx;
  278. bottom: 0;
  279. text-align: center;
  280. .b-left,
  281. .b-right {
  282. flex: 1;
  283. height: 80rpx;
  284. line-height: 80rpx;
  285. margin: 0 30rpx;
  286. border-radius: 50rpx;
  287. }
  288. .b-left {
  289. color: #438BED;
  290. border: solid 1rpx #438BED;
  291. }
  292. .b-right {
  293. background: linear-gradient(90deg, #438BED 0%, #44BFEC 100%);
  294. color: #fff;
  295. }
  296. }
  297. </style>