sadjv3_user/my/hongbao/xinrenhongbao.vue

330 lines
6.4 KiB
Vue

<template>
<view class="hb-view">
<t-refresh ref="refresh" v-if="hongbao.length>0" @refresh="refresh" @loadMore="loadMore"
:loadingType="loadingType" :tPadding="0">
<template slot="content">
<checkbox-group @change="checkboxChange">
<view>
<view class="youhui-weiyong youhui-list" v-for="(item,index) in hongbao" :key="index">
<view class="youhui-view-left">
<view class="youhui-view-left-yuan">
<span class="youhui-view-left-num">{{item.money}}</span>
<span class="youhui-view-left-text"></span>
</view>
<view class="youhui-view-left-bottom">
{{item.minMoney}}元可用
</view>
</view>
<view class="youhui-view-right">
<view class="youhui-view-right-top">
<view class="youhui-view-right-title">{{item.couponName}}</view>
</view>
</view>
</view>
</view>
</checkbox-group>
</template>
</t-refresh>
<view class="push-button" @tap="shiYong()" v-if="isCoupon==null">
<span class="que-btn">立即领取</span>
</view>
<view class="push-button" v-else>
<span class="que-btn2">已经领取</span>
</view>
<empty v-if="hongbao.length==0"></empty>
</view>
</template>
<script>
import tRefresh from "@/components/t-refresh/t-refresh.vue"
import empty from '@/components/empty.vue'
export default {
components: {
empty,
tRefresh
},
data() {
return {
hongbao: [],
page: 1,
size: 10,
loadingType: 0,
scrollTop: false,
contentText: {
contentdown: '上拉显示更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了'
},
isCoupon: 0
}
},
onLoad() {
this.getMyList();
this.getUserInfo();
},
methods: {
shiYong() {
var that = this;
that.$Request.get('/app/coupon/insertNewUserCoupon').then(res => {
if (res.code == 0) {
uni.showToast({
// title:'领取成功!'
icon: 'success',
title: "领取成功"
})
setTimeout(() => {
this.goHome()
}, 1500)
} else {
uni.showToast({
icon: 'error',
title: res.msg
})
}
})
},
goHome() {
uni.switchTab({
url: '/pages/index/index'
})
},
// 加载更多
loadMore: async function() {
//loadingType: 0.数据未加载完 1.数据全部加载完了 2.数据加载中
if (this.loadingType == 0) {
this.loadingType = 2
//模拟数据请求
setTimeout(() => {
this.page++;
this.loadingType = 0;
this.getData()
}, 1000)
}
},
getUserInfo() {
this.$Request.getT('/app/user/selectUserById').then(res => {
if (res.code == 0) {
this.isCoupon = res.data.isCoupon;
console.log(this.isCoupon);
}
})
},
getMyList() {
this.loadingType = 1;
uni.showLoading({
title: '加载中...'
});
this.$Request.getT('/app/coupon/selectNewUserCoupon?page=' + this.page + '&limit=' + this.size).then(
res => {
if (res.code == 0) {
if (this.page == 1) this.hongbao = []; //如果是第一页需手动制空列表
this.hongbao = [...this.hongbao, ...res.data.list]; //追加新数据
}
uni.hideLoading();
});
},
},
onPageScroll: function(e) {
this.scrollTop = e.scrollTop > 200;
},
onReachBottom: function() {
this.page = this.page + 1;
this.getMyList('');
},
onPullDownRefresh: function() {
this.page = 1;
this.getMyList('Refresh');
}
}
</script>
<style scoped>
.hb-view{
width: 100%;
/* height: 100vh;
overflow: scroll; */
}
/deep/.refresh-body {
height: 870px !important;
margin-bottom: 60rpx;
}
.push-button {
width: 100%;
height: 48px;
position: fixed;
bottom: 0px;
display: flex;
flex-direction: column;
align-items: center;
margin: 0 auto;
}
.que-btn {
display: inline-block;
width: 90%;
text-align: center;
background: linear-gradient(90deg, #019C88, #28BA92, #35C495);
height: 40px;
border-radius: 28px;
color: #ffffff;
line-height: 40px;
margin-top: 4px;
font-size: 34rpx;
}
.que-btn2 {
display: inline-block;
width: 90%;
text-align: center;
background: linear-gradient(90deg, #949494, #b4b4b4, #c5c5c5);
height: 40px;
border-radius: 28px;
color: #ffffff;
line-height: 40px;
margin-top: 4px;
font-size: 34rpx;
}
/deep/.page-box {
width: 100%;
}
.youhui-img {
width: 111.81rpx;
height: 111.81rpx;
}
.youhui-view-right-time {
font-weight: 400;
font-size: 22rpx;
color: #999999;
}
.youhui-view-right-title {
width:300rpx;
font-weight: 400;
font-size: 28rpx;
color: #333333;
}
.youhui-view-right-top {
display: flex;
flex-direction: column;
align-items: center;
}
.youhui-view-right {
width: 502.08rpx;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.youhui-view-left-bottom {
font-weight: 400;
font-size: 22rpx;
color: #FFFFFF;
}
.youhui-view-left-yuan {
display: flex;
flex-direction: row;
align-items: baseline;
color: #FFFFFF;
}
.youhui-view-left-num {
font-weight: bold;
font-size: 89rpx;
}
.youhui-view-left-text {
font-weight: bold;
font-size: 24.31rpx;
}
.youhui-view-left {
width: 199rpx;
height: 242rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.youhui-yiyong {
background-image: url('../../static/youhuijuan/coupons7.png');
}
.youhui-weiyong {
background-image: url('../../static/youhuijuan/coupons1.png');
}
.youhui-list {
width: 95%;
display: flex;
flex-direction: row;
height: 242rpx;
border-radius: 21rpx;
background-size: 100%;
margin: 10px auto;
justify-content: space-between;
}
.you-nav {
background: #FFFFFF;
padding: 14px 25px 0px 25px;
}
page {
background: #F5F5F5;
}
.bg {
background: #FFFFFF;
}
.box {
width: 128upx;
height: 60upx;
color: #666;
text-align: center;
font-weight: 500;
font-size: 30rpx;
z-index: 1;
}
.line {
width: 48px;
height: 14rpx;
background: linear-gradient(-48deg, #019C88, #2DC48E);
border-radius: 7rpx;
opacity: 0.35;
position: relative;
top: -7px;
z-index: -1;
left: 50%;
transform: translateX(-50%);
}
.tanColor {
color: #019C88;
font-weight: bold;
}
.btn {
width: 140upx;
height: 55upx;
border: 2upx solid #FF130A;
border-radius: 30upx;
text-align: center;
line-height: 55upx;
color: #FF130A;
font-size: 24upx;
}
</style>