yue.vue 7.6 KB

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