yue.vue 7.4 KB

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