123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <template>
- <view class="integralRecord">
- <!-- 分段器 -->
- <view class="segmented">
- <view class="tab_nav">
- <view class="navTitle" v-for="(item,index) in items" :key="index">
- <view :class="{'active':isActive == index}" @click="checked(index)">
- {{item}}
- </view>
- </view>
- </view>
- </view>
-
- <!-- 占位 -->
- <view style="width: 100%; height: 112rpx; "></view>
-
- <view class="msg-null" v-if="incomeList.length == 0 && isActive == 0 ">
- <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
- <view class="msg-null-text">
- <text>暂无数据</text>
- </view>
- </view>
- <!-- 收入 -->
- <view class="List" v-if="isActive == 0 && incomeList.length > 0 ">
- <view class="ListItem" v-for="(item,index) in incomeList" :key="index">
- <view style="display: flex; justify-content: space-between;">
- <view class="title"><text>{{item.change_integral}}积分</text> </view>
- <view class='data'><text>{{item.created_at}}</text></view>
- </view>
- <view class="content" v-if="item.type==1"><text>投票奖励获得</text></view>
- <view class="content" v-if="item.type==2"><text>抽奖奖励获得</text></view>
- </view>
- </view>
-
- <view class="msg-null" v-if="spendingList.length == 0 && isActive == 1 ">
- <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
- <view class="msg-null-text">
- <text>暂无数据</text>
- </view>
- </view>
- <!-- 支出 -->
- <view class="List" :style="{'--height':ListHeight+'rpx'}" v-if="isActive == 1 && spendingList.length > 0" >
- <view class="ListItem" v-for="(item,index) in spendingList" :key="index" >
- <view style="display: flex; justify-content: space-between;">
- <view class="title"><text>{{item.change_integral}}积分</text> </view>
- <view class='data'><text>{{item.created_at}}</text></view>
- </view>
- <view class="content" v-if="item.type==3"><text>兑换商品消耗</text></view>
- <view class="content" v-if="item.type==4"><text>后台增加/减少</text></view>
- </view>
- </view>
-
- <!-- 已经到底啦 -->
- <view class="home-bottom" style="margin-top: 88rpx;padding-bottom: 60rpx;" v-if="isActive == 0 && incomeList.length > 0 ">
- <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
- </view>
- <view class="home-bottom" style="margin-top: 88rpx;padding-bottom: 60rpx;" v-if="isActive == 1 && spendingList.length > 0 ">
- <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
- </view>
- </view>
- </template>
- <script>
- export default{
- data(){
- return{
- // 分段器
- items: ['收入', '支出',],
- isActive: 0,
- // list高度
- ListHeight: 800,
- contentText: {
- contentdown: '查看更多',
- contentrefresh: '加载中',
- contentnomore: '—— 已经到底啦 ——'
- },
- // 收入列表
- incomeList:[],
- // 支出列表
- spendingList:[],
- // 分页
- page: 1,
- pagesize: 15,
- totalElements: '',
- allListItem: '',
- // 组件uni-load-more
- status: 'noMore',
- }
- },
- onLoad() {
- // 收入
- this.getIntegralList(1)
- // 支出
- this.getIntegralList(2)
- },
-
- // 触底加载
- onReachBottom() {
- // 触底的时候请求数据,即为上拉加载更多
- var allTotal = this.page * this.pagesize
- console.log(allTotal, '----allTotal');
- //this.page为加载次数,this.pagesize为每一次加载的数据条数
- if(this.isActive + 1 == 1){
- if (allTotal < this.totalElements) {
- //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
- this.allListItem = false;
- this.page++;
- //加载次数递加
- this.status = "loading"
- this.$api.integral.getIntegralLog({ //请求更多数据列表
- page: this.page,
- type:this.isActive + 1
- }).then(res => {
- let ret = [...this.incomeList, ...res.data.data]
- this.incomeList = ret
- console.log(ret)
- })
- } else {
- this.allListItem = true;
- console.log('已加载全部数据')
- this.status = "noMore"
- }
- }else if(this.isActive + 1 == 2){
- if (allTotal < this.totalElements) {
- //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
- this.allListItem = false;
- this.page++;
- //加载次数递加
- this.status = "loading"
- this.$api.integral.getIntegralLog({ //请求更多数据列表
- page: this.page,
- type:this.isActive + 1
- }).then(res => {
- let ret = [...this.spendingList, ...res.data.data]
- this.spendingList = ret
- console.log(ret)
- })
- } else {
- this.allListItem = true;
- console.log('已加载全部数据')
- this.status = "noMore"
- }
- }
- },
-
- methods:{
- //菜单index切换
- checked(index) {
- this.isActive = index
- this.page = 1
- this.getIntegralList(this.isActive + 1)
- },
- // 获取积分日志
- getIntegralList(type){
- if(type==1){
- this.$api.integral.getIntegralLog({
- page:1,
- type:1
- }).then(res=>{
- console.log(res,'收入积分日志')
- if(res.code==0){
- this.incomeList=res.data.data
- this.totalElements = res.data.total
- this.pagesize = res.data.per_page
- }
- })
- } else if (type==2){
- this.$api.integral.getIntegralLog({
- page:1,
- type:2
- }).then(res=>{
- console.log(res,'支出积分日志')
- if(res.code==0){
- this.spendingList=res.data.data
- this.totalElements = res.data.total
- this.pagesize = res.data.per_page
- }
- })
- }else{
- uni.showToast({
- title:'请传入正确type值!',
- icon:'none'
- })
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- $pageColor:#F9F9F9;
- $bgColor:#FFFFFF;
- // flex布局居中对齐
- @mixin flexlayout {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .integralRecord{
- height: 100%;
- background: $pageColor;
- }
-
- .msg-null{
- padding-top: 60rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .msg-null-text{
- margin-top: 40rpx;
- font-size: 28rpx;
- color: #333;
- }
- }
-
-
- .segmented{
- position: fixed;
- top: 0;
- z-index: 99;
- height: 112rpx;
- width: 100%;
- background: $bgColor;
- box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
- border-radius: 0px 0px 16rpx 16rpx;
- //菜单切换
- .tab_nav {
- width: 690rpx;
- margin-left: 30rpx;
- padding:0 80rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- margin-top: 14rpx;
- }
- .tab_nav .navTitle {
- @include flexlayout()
- margin-top: 20rpx;
- width: 128rpx;
- flex: none;
- height: 28rpx;
- font-size: 32rpx;
- color: #666;
- position: relative;
- }
- .active {
- color: #D9A94D;
- font-weight: bold;
-
- &::after {
- display: inline-block;
- content: '';
- width: 48rpx;
- height: 12rpx;
- background: linear-gradient(90deg, #F3D69F 0%, #D9A94D 100%);
- border-radius: 6px;
- position: absolute;
- bottom: -24rpx;
- left: 40rpx;
- }
- }
- }
- ::v-deep .segmented-control__text {
- font-size: 32rpx !important;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- color: #666666 !important;
- }
-
- ::v-deep .segmented-control__item--text {
- font-size: 32rpx;
- font-family: PingFang-SC-Heavy, PingFang-SC;
- font-weight: 800 !important;
- padding: 10rpx 0 !important;
- border-radius: 4rpx !important;
- color: #D9A94D !important;
- }
- .List {
- width: 750rpx;
- background: $bgColor;
- box-shadow: 0px 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
- border-radius: 12rpx;
- margin-top: 24rpx;
- padding: 0rpx 28rpx 0 32rpx;
- box-sizing: border-box;
-
- .ListItem {
- width: 690rpx;
- border-bottom: #F0F0F0 solid 0.5rpx;
- position: relative;
- padding-top: 40rpx;
- padding-bottom: 40rpx;
- box-sizing: border-box;
- &:first-child{
- padding-top: 48rpx;
- }
- &:last-child{
- border-bottom: none;
- }
- .title {
- margin-bottom: 10rpx;
- text {
- font-size: 32rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: bold;
- color: #333333;
- }
- }
-
- .data {
- text {
- font-size: 26rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- color: #999999;
- }
- }
- .content {
- text {
- font-size: 28rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- color: #333333;
- }
- }
-
- }
- // 消除最后一个下划线
- .ListItem:last-child {
- width: 690rpx;
- height: 160rpx;
- border-bottom: #F0F0F0 solid 0rpx;
- position: relative;
- padding-top: 35rpx;
- box-sizing: border-box;
-
- .title {
- margin-bottom: 10rpx;
- text {
- font-size: 32rpx;
- font-family: PingFang-SC-Bold, PingFang-SC;
- font-weight: bold;
- color: #333333;
- }
- }
-
- .data {
- text {
- font-size: 26rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- color: #999999;
- }
- }
- .content {
- text {
- font-size: 28rpx;
- font-family: PingFang-SC-Medium, PingFang-SC;
- color: #333333;
- }
- }
-
- }
- }
-
- </style>
|