yj.vue 6.6 KB

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