wallet.vue 7.1 KB

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