签到记录列表的实现

pull/1/MERGE
YunaiV 2023-08-21 21:57:32 +08:00
parent 09496a038b
commit a7f96df500
1 changed files with 55 additions and 69 deletions

View File

@ -3,14 +3,14 @@
<view class='sign-record'> <view class='sign-record'>
<view class='list pad30' v-for="(item,index) in signList" :key="index"> <view class='list pad30' v-for="(item,index) in signList" :key="index">
<view class='item'> <view class='item'>
<view class='data'>{{item.month}}</view> <view class='data'>{{ formatMonth(item.createTime) }}</view>
<view class='listn borRadius14'> <view class='listn borRadius14'>
<view class='itemn acea-row row-between-wrapper' v-for="(itemn,indexn) in item.list" :key="indexn"> <view class='itemn acea-row row-between-wrapper'>
<view> <view>
<view class='name line1'>{{itemn.title}}</view> <view class='name line1'> {{item.day}} 天签到积分奖励</view>
<view>{{itemn.createDay}}</view> <view>{{ formatDate(item.createTime) }}</view>
</view> </view>
<view class='num font-color'>+{{itemn.number}}</view> <view class='num font-color'>+{{ item.point }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -19,41 +19,29 @@
<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadtitle}} <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadtitle}}
</view> </view>
</view> </view>
<!-- #ifdef MP -->
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
<!-- #endif -->
</view> </view>
</template> </template>
<script> <script>
import { getSignMonthList } from '@/api/user.js';
import { toLogin } from '@/libs/login.js'; import { toLogin } from '@/libs/login.js';
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
// #ifdef MP import * as SignInApi from '@/api/member/signin';
import authorize from '@/components/Authorize'; import dayjs from "@/plugin/dayjs/dayjs.min.js";
// #endif
export default { export default {
components: {
// #ifdef MP
authorize
// #endif
},
data() { data() {
return { return {
loading:false, loading: false,
loadend:false, loadend: false,
loadtitle:'加载更多', loadtitle: '加载更多',
page:1, page:1,
limit:8, limit:8,
signList:[], signList:[],
isAuto: false, //
isShowAuth: false //
}; };
}, },
computed: mapGetters(['isLogin']), computed: mapGetters(['isLogin']),
watch:{ watch:{
isLogin:{ isLogin: {
handler:function(newV,oldV){ handler:function(newV,oldV) {
if(newV){ if(newV){
this.getSignMoneList(); this.getSignMoneList();
} }
@ -62,49 +50,47 @@
} }
}, },
onLoad(){ onLoad(){
if(this.isLogin){ if (!this.isLogin) {
this.getSignMoneList();
}else{
toLogin(); toLogin();
return;
} }
this.getSignMoneList();
}, },
onReachBottom: function () { onReachBottom: function () {
this.getSignMoneList(); this.getSignMoneList();
}, },
methods: { methods: {
/**
*
* 授权回调
*/
onLoadFun:function(){
this.getSignMoneList();
},
//
authColse:function(e){
this.isShowAuth = e
},
/** /**
* 获取签到记录列表 * 获取签到记录列表
*/ */
getSignMoneList:function(){ getSignMoneList:function(){
let that=this; if (this.loading || this.loadend) {
if(that.loading) return; return;
if(that.loadend) return; }
that.loading = true; this.loading = true;
that.loadtitle = ""; this.loadtitle = "";
getSignMonthList({ page: that.page, limit: that.limit }).then(res=>{ SignInApi.getSignRecordPage({
let list = res.data.list; pageNo: this.page,
let loadend = list.length < that.limit; pageSize: this.limit
that.signList = that.$util.SplitArray(list, that.signList); }).then(res=>{
that.$set(that,'signList',that.signList); const list = res.data.list;
that.loadend = loadend; const loadend = list.length < this.limit;
that.loading = false; this.signList = this.$util.SplitArray(list, this.signList);
that.loadtitle = loadend ? "哼😕~我也是有底线的~" : "加载更多" this.$set(this,'signList',this.signList);
this.loadend = loadend;
this.loading = false;
this.loadtitle = loadend ? "哼😕~我也是有底线的~" : "加载更多"
}).catch(err=>{ }).catch(err=>{
that.loading = false; this.loading = false;
that.loadtitle = '加载更多'; this.loadtitle = '加载更多';
}); });
}, },
formatDate: function(date) {
return dayjs(date).format("YYYY-MM-DD");
},
formatMonth: function(date) {
return dayjs(date).format("YYYY-MM");
}
} }
} }
</script> </script>