integral.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="goback-box" @click="toBack">
  6. <image class="goback" src="https://37shop.liuniu946.com/front/img/fanhui.png" mode=""></image>
  7. </view>
  8. <view class="header">我的积分</view>
  9. <image class="jifen_bg" src="https://37shop.liuniu946.com/front/img/img012.png"></image>
  10. <view class="jifen_box">
  11. <!-- <view class="text">我的积分</view> -->
  12. <view class="money">{{ userInfo.integral | parseFloatNum }}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="navbar">
  17. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  18. </view>
  19. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  20. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  21. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  22. <!-- 空白页 -->
  23. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  24. <!-- 订单列表 -->
  25. <template v-for="(item, index) in tabItem.orderList.filter(item => item.pm == !filterType)">
  26. <view class="order-item flex">
  27. <view class="title-box">
  28. <view class="title">
  29. <text>{{ item.mark }}</text>
  30. </view>
  31. <view class="time">
  32. <text>{{ item.add_time }}</text>
  33. </view>
  34. </view>
  35. <view class="money">
  36. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  37. </view>
  38. </view>
  39. </template>
  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 { integrallist } 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. export default {
  53. filters: {
  54. getMoneyStyle,
  55. // 去处小数点后的0
  56. parseFloatNum(clock) {
  57. return parseFloat(clock);
  58. }
  59. },
  60. components: {
  61. empty,
  62. uniLoadMore
  63. },
  64. onReady() {
  65. // 初始化获取页面宽度
  66. uni.createSelectorQuery()
  67. .select('.content')
  68. .fields(
  69. {
  70. size: true
  71. },
  72. data => {
  73. // 保存头部高度
  74. this.maxheight = data.height - Math.floor((data.width / 750) * 320) - 40;
  75. }
  76. )
  77. .exec();
  78. },
  79. data() {
  80. return {
  81. // 头部图高度
  82. filterType:'',
  83. maxheight: '',
  84. tabCurrentIndex: 0,
  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. this.loadData();
  108. },
  109. onShow() {
  110. },
  111. computed: {
  112. ...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
  113. },
  114. methods: {
  115. // 页面跳转
  116. navto(e) {
  117. uni.navigateTo({
  118. url: e
  119. });
  120. },
  121. //获取收入支出信息
  122. async loadData(source) {
  123. //这里是将订单挂载到tab列表下
  124. let index = this.tabCurrentIndex;
  125. let navItem = this.navList[index];
  126. let state = navItem.state;
  127. if (source === 'tabChange' && navItem.loaded === true) {
  128. //tab切换只有第一次需要加载数据
  129. return;
  130. }
  131. if (navItem.loadingType === 'noMore') {
  132. //防止重复加载
  133. return;
  134. }
  135. // 修改当前对象状态为加载中
  136. navItem.loadingType = 'loading';
  137. integrallist({
  138. page: navItem.page,
  139. limit: navItem.limit,
  140. type: state
  141. })
  142. .then(({ data }) => {
  143. console.log('---data ---',data );
  144. if (data.length > 0) {
  145. navItem.orderList = navItem.orderList.concat(data);
  146. navItem.page++;
  147. }
  148. if (navItem.limit == data.length) {
  149. //判断是否还有数据, 有改为 more, 没有改为noMore
  150. navItem.loadingType = 'more';
  151. return;
  152. } else {
  153. //判断是否还有数据, 有改为 more, 没有改为noMore
  154. navItem.loadingType = 'noMore';
  155. }
  156. uni.hideLoading();
  157. this.$set(navItem, 'loaded', true);
  158. })
  159. .catch(e => {
  160. console.log(e);
  161. });
  162. },
  163. //swiper 切换
  164. changeTab(e) {
  165. this.tabCurrentIndex = e.target.current;
  166. this.loadData('tabChange');
  167. },
  168. //顶部tab点击
  169. tabClick(index) {
  170. this.tabCurrentIndex = index;
  171. this.filterType = this.tabCurrentIndex
  172. },
  173. // 点击返回 我的页面
  174. toBack(){
  175. uni.switchTab({
  176. url:'/pages/user/user'
  177. })
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. page {
  184. background: #ffffff;
  185. height: 100%;
  186. }
  187. .content-money {
  188. padding-bottom: 20rpx;
  189. background: $page-color-base;
  190. // border: 2px solid #ffffff;
  191. .moneyTx {
  192. position: absolute;
  193. top: 120rpx;
  194. right: 0rpx;
  195. // width: 150rpx;
  196. padding: 10rpx 10rpx;
  197. border: 2px solid #ffffff;
  198. border-top-left-radius: 15rpx;
  199. border-bottom-left-radius: 15rpx;
  200. color: $motif-color;
  201. line-height: 1;
  202. font-size: $font-base;
  203. background: #FFFFFF;
  204. }
  205. .buttom-box {
  206. background-color: #ffffff;
  207. text-align: center;
  208. margin: 0 30rpx;
  209. padding: 20rpx 0;
  210. border-radius: $border-radius-sm;
  211. margin-top: -60rpx;
  212. .buttom {
  213. font-size: $font-lg;
  214. flex-grow: 1;
  215. }
  216. .interval {
  217. width: 2px;
  218. height: 60rpx;
  219. background-color: #eeeeee;
  220. }
  221. .icon {
  222. height: 36rpx;
  223. width: 36rpx;
  224. margin: 0 auto;
  225. .icon-img {
  226. width: 100%;
  227. height: 100%;
  228. }
  229. }
  230. }
  231. }
  232. .money-box {
  233. background: $base-color;
  234. // padding-top: var(--status-bar-height);
  235. height: 390rpx;
  236. color: #ffffff;
  237. text-align: center;
  238. position: relative;
  239. .header{
  240. position: absolute;
  241. left: 0;
  242. top: 0;
  243. width: 100%;
  244. height: 80rpx;
  245. font-size: 32rpx;
  246. font-weight: 700;
  247. z-index: 99;
  248. display: flex;
  249. justify-content: center;
  250. align-items: center;
  251. }
  252. .goback-box{
  253. position: absolute;
  254. left: 18rpx;
  255. top: 0;
  256. height: 80rpx;
  257. display: flex;
  258. align-items: center;
  259. }
  260. .goback{
  261. z-index: 100;
  262. width: 34rpx;
  263. height: 34rpx;
  264. }
  265. .jifen_bg {
  266. width: 100%;
  267. height: 390rpx;
  268. }
  269. .jifen_box {
  270. position: absolute;
  271. top: 0;
  272. width: 100%;
  273. padding-top: 160rpx;
  274. // left: 30rpx;
  275. // display: flex;
  276. // flex-direction: column;
  277. // align-items: flex-start;
  278. }
  279. .text {
  280. padding-top: 40rpx;
  281. font-size: $font-sm;
  282. }
  283. .money {
  284. font-size: 60rpx;
  285. font-weight: bold;
  286. // &::before {
  287. // content: '¥';
  288. // font-size: 30rpx;
  289. // }
  290. }
  291. }
  292. .navbar {
  293. display: flex;
  294. height: 40px;
  295. padding: 0 5px;
  296. background: #fff;
  297. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  298. position: relative;
  299. z-index: 10;
  300. .nav-item {
  301. flex: 1;
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. height: 100%;
  306. font-size: 15px;
  307. color: $font-color-dark;
  308. position: relative;
  309. &.current {
  310. color: #FF4E00;
  311. &:after {
  312. content: '';
  313. position: absolute;
  314. left: 50%;
  315. bottom: 0;
  316. transform: translateX(-50%);
  317. width: 44px;
  318. height: 0;
  319. border-bottom: 2px solid #FF4E00;
  320. }
  321. }
  322. }
  323. }
  324. // 列表
  325. .swiper-box {
  326. padding-top: 10rpx;
  327. .order-item {
  328. padding: 20rpx 30rpx;
  329. line-height: 1.5;
  330. .title-box {
  331. .title {
  332. font-size: $font-lg;
  333. color: $font-color-base;
  334. }
  335. .time {
  336. font-size: $font-base;
  337. color: $font-color-light;
  338. }
  339. }
  340. .money {
  341. // color: #fd5b23;
  342. color: #E80000;
  343. font-size: $font-lg;
  344. }
  345. }
  346. }
  347. .list-scroll-content {
  348. height: 100%;
  349. }
  350. .content {
  351. height: 100%;
  352. .empty-content {
  353. background-color: #ffffff;
  354. }
  355. }
  356. </style>