jhz.vue 8.5 KB

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