|
|
@@ -15,18 +15,21 @@
|
|
|
</scroll-view>
|
|
|
</div>
|
|
|
<template v-if="tidx===1">
|
|
|
- <div class="list">
|
|
|
+ <div class="list" v-if="list.length">
|
|
|
<up-list @scrolltolower="scrolltolower" style="height: 100%;">
|
|
|
<up-list-item v-for="(item, index) in list" :key="index">
|
|
|
- <practice-box></practice-box>
|
|
|
+ <practice-box :item="item" @itemCheck="handleCheck"></practice-box>
|
|
|
</up-list-item>
|
|
|
</up-list>
|
|
|
</div>
|
|
|
- <div class="btn">申领社会实践记录</div>
|
|
|
+ <div class="dataEmpty" v-else>
|
|
|
+ <page-empty text="暂无已申领记录"></page-empty>
|
|
|
+ </div>
|
|
|
+ <div class="btn" @click="handleApply">申领社会实践记录</div>
|
|
|
</template>
|
|
|
<template v-else-if="tidx===2">
|
|
|
- <div class="list">
|
|
|
- <up-list @scrolltolower="scrolltolower2" style="height: 100%;">
|
|
|
+ <div class="list" v-if="yslList.length">
|
|
|
+ <up-list @scrolltolower="scrolltolower" style="height: 100%;">
|
|
|
<up-list-item v-for="(item, index) in yslList" :key="index">
|
|
|
<div class="ysl-box">
|
|
|
<div class="ysl-box-title">{{'感恩有你 温暖前行'}}</div>
|
|
|
@@ -37,34 +40,58 @@
|
|
|
</up-list-item>
|
|
|
</up-list>
|
|
|
</div>
|
|
|
+ <div class="dataEmpty" v-else>
|
|
|
+ <page-empty text="暂无已申领记录"></page-empty>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="">
|
|
|
import CusHeader from '@/components/CusHeader/index.vue'
|
|
|
+ import PageEmpty from '@/components/pageEmpty/index.vue'
|
|
|
import PracticeBox from '@/components/pages/practiceBox/index.vue'
|
|
|
- import { ref } from 'vue'
|
|
|
+ import { ref, getCurrentInstance, onMounted } from 'vue'
|
|
|
+ const { proxy } = getCurrentInstance()
|
|
|
|
|
|
const pb = ref(184)
|
|
|
const tidx = ref(1)
|
|
|
const midx = ref(0)
|
|
|
const scrollLeft = ref(0)
|
|
|
- const memberList = ref([
|
|
|
- {id:1,name:'张三'},
|
|
|
- {id:2,name:'李四'},
|
|
|
- {id:3,name:'龙傲天'}
|
|
|
- ])
|
|
|
- const list = ref([1,1,1,1,1])
|
|
|
- const yslList = ref([1,1,1])
|
|
|
+ const queryParams = ref({
|
|
|
+ page:1,
|
|
|
+ limit:10,
|
|
|
+ userId:'',
|
|
|
+ memberId:''
|
|
|
+ })
|
|
|
+ const isOver = ref(false)
|
|
|
+ const memberList = ref([])
|
|
|
+ const list = ref([])
|
|
|
+ const yslList = ref([])
|
|
|
|
|
|
const changeTab = index => {
|
|
|
tidx.value = index;
|
|
|
pb.value = index===1?184:40;
|
|
|
+ getDataByTab()
|
|
|
}
|
|
|
|
|
|
const changeMember = (item,index) => {
|
|
|
midx.value = index;
|
|
|
+ queryParams.value.memberId = item.id;
|
|
|
+ getDataByTab()
|
|
|
+ }
|
|
|
+
|
|
|
+ const getDataByTab = () => {
|
|
|
+ queryParams.value.page = 1;
|
|
|
+ isOver.value = false;
|
|
|
+ list.value = [];
|
|
|
+ yslList.value = [1];
|
|
|
+ if(!queryParams.value.memberId) queryParams.value.memberId = memberList.value[0]?.id;
|
|
|
+ if(tidx.value===1){
|
|
|
+ getKslList()
|
|
|
+ }else if(tidx.value===2){
|
|
|
+ getYslList()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const handleDetail = item => {
|
|
|
@@ -72,6 +99,87 @@
|
|
|
url:'/pagesMy/practiceRecord'
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ const scrolltolower = () => {
|
|
|
+ if(isOver.value) return
|
|
|
+ getDataByTab()
|
|
|
+ }
|
|
|
+
|
|
|
+ const getKslList = () => {
|
|
|
+ proxy.$api.get('/core/social/practice/record/claimPage',queryParams.value).then(({data:res})=>{
|
|
|
+ if(res.code!==0) return proxy.$showToast(res.msg)
|
|
|
+ list.value = [...list.value,...res.data.list]
|
|
|
+ list.value.forEach(l=>{
|
|
|
+ l.activityStartTime = new Date(l.activityStartTime).Format('yyyy-MM-dd');
|
|
|
+ l.activityEndTime = new Date(l.activityEndTime).Format('yyyy-MM-dd');
|
|
|
+ l.check = false;
|
|
|
+ l.age = getAge(l.idCard);
|
|
|
+ })
|
|
|
+ queryParams.value.page++;
|
|
|
+ if(res.data.list.length===0) isOver.value = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const getYslList = () => {
|
|
|
+ proxy.$api.get('/core/social/practice/record/claimedPage',queryParams.value).then(({data:res})=>{
|
|
|
+ if(res.code!==0) return proxy.$showToast(res.msg)
|
|
|
+ // yslList.value = [...yslList.value,...res.data.list]
|
|
|
+ // queryParams.value.page++;
|
|
|
+ // if(res.data.list.length===0) isOver.value = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const getMemberList = () => {
|
|
|
+ proxy.$api.get('/core/family/member/page',{page:1,limit:-1}).then(({data:res})=>{
|
|
|
+ if(res.code!==0) return proxy.$showToast(res.msg)
|
|
|
+ memberList.value = res.data.list;
|
|
|
+ getDataByTab()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const isValid = (idCard) => {
|
|
|
+ // 正则表达式校验18位身份证号码(最后一位可以是数字或X/x)
|
|
|
+ const regex = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
|
|
|
+ return typeof idCard === 'string' && regex.test(idCard);
|
|
|
+ }
|
|
|
+
|
|
|
+ const getAge = (idCard) => {
|
|
|
+ if (!isValid(idCard)) return 0
|
|
|
+
|
|
|
+ // 从身份证的第7位开始,截取8位作为出生日期字符串 (YYYYMMDD)
|
|
|
+ const birthDateStr = idCard.substring(6, 14);
|
|
|
+ const birthYear = parseInt(birthDateStr.substring(0, 4), 10);
|
|
|
+ const birthMonth = parseInt(birthDateStr.substring(4, 6), 10);
|
|
|
+ const birthDay = parseInt(birthDateStr.substring(6, 8), 10);
|
|
|
+
|
|
|
+ const today = new Date();
|
|
|
+ const currentYear = today.getFullYear();
|
|
|
+ const currentMonth = today.getMonth() + 1; // getMonth() 返回 0-11
|
|
|
+ const currentDay = today.getDate();
|
|
|
+
|
|
|
+ // 计算周岁
|
|
|
+ let age = currentYear - birthYear;
|
|
|
+
|
|
|
+ // 如果当前月份小于出生月份,或者月份相同但日期小于出生日期,说明今年的生日还没过
|
|
|
+ if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay)) {
|
|
|
+ age--;
|
|
|
+ }
|
|
|
+
|
|
|
+ return age < 0 ? 0 : age;
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleCheck = (item) => {
|
|
|
+ item.check = !item.check;
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleApply = () => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(()=>{
|
|
|
+ queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
|
|
|
+ getMemberList();
|
|
|
+ })
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|