wallet.vue 7.6 KB

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