jindou.vue 7.0 KB

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