226 lines
6.0 KiB
Vue
226 lines
6.0 KiB
Vue
<template>
|
||
<view
|
||
style="background: url('https://hnyea.0rui.cn/uploads/1/20240722/7f5a72050b9cbc409fb60fa8d32db76a.png');background-repeat: no-repeat;background-size: 100% 555rpx;">
|
||
<!-- 顶部自定义导航 -->
|
||
<tn-nav-bar :isBack="false" :bottomShadow="false" backgroundColor="transparent">
|
||
<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
|
||
<view style="padding-left: 15rpx;" @click="goBack()">
|
||
<text class="tn-icon-left" style="font-size: 40rpx;color: #000000;"></text>
|
||
</view>
|
||
<view
|
||
style="letter-spacing: 1px;font-size: 34rpx;text-align: center;width: 83%;font-weight: bold;color: #000000;">
|
||
<text>每日签到</text>
|
||
</view>
|
||
</view>
|
||
</tn-nav-bar>
|
||
<view :style="{paddingTop: vuex_custom_bar_height + 'px'}">
|
||
<view style="padding:30rpx 30rpx 0rpx 30rpx;">
|
||
<view style="border-radius: 20rpx;overflow: hidden;box-shadow: 0rpx 6rpx 20rpx 0rpx rgba(0,0,0,0.1);">
|
||
<view>
|
||
<uni-calendar :startDate="startDate" :endDate="startDate" class="uni-calendar--hook"
|
||
:selected="selected" :showMonth="true" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- <view style="text-align: center;">
|
||
<tn-button @click="signIn" backgroundColor="#01BEFF" fontColor="#ffffff">签到</tn-button>
|
||
</view> -->
|
||
</view>
|
||
<view style="padding: 30rpx;">
|
||
<view class="tn-flex tn-flex-center tn-flex-col-center">
|
||
<view style="font-size: 34rpx;font-weight: bold;">我的积分</view>
|
||
<view style="height: 30rpx;width: 1px;background-color:#6FBEFF;margin: 0rpx 10rpx;"></view>
|
||
<view style="margin-right: 10rpx;">
|
||
<image src="/static/ji.png" style="width: 30rpx;height: 30rpx;"></image>
|
||
</view>
|
||
<view style="font-size: 34rpx;font-weight: bold;color: #3056D3;">{{myNumber}}</view>
|
||
</view>
|
||
</view>
|
||
<view style="padding-bottom: 80rpx;">
|
||
<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding" v-for="(item,index) in integral"
|
||
:key="index">
|
||
<view class="justify-content-item">
|
||
<view class="tn-text-lg" style="color:#3056D3;">
|
||
日常签到
|
||
</view>
|
||
<view class="tn-color-gray tn-padding-top-xs">
|
||
{{item.sign_date}}
|
||
</view>
|
||
</view>
|
||
<view class="justify-content-item tn-text-xl tn-padding-top">
|
||
<view style="color: #3056D3;">+{{item.number}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view
|
||
style="position: fixed;bottom:0px;width: 100%;background-color: #FFFFFF;box-shadow: 0rpx -2rpx 4rpx 0rpx rgba(186,189,199,0.2);padding:30rpx 30rpx 40rpx 30rpx;">
|
||
<view class="tn-flex tn-flex-center tn-flex-col-center tn-flex-row-center">
|
||
<view @click="signIn"
|
||
style="line-height: 80rpx;height: 80rpx;font-size: 32rpx;font-weight: bold;text-align: center;width: 80%;color: #ffffff;;background: #3056D3;border: 1rpx solid #3056D3;border-radius:90rpx;">
|
||
<text>签到</text>
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
<tn-toast ref="toast"></tn-toast>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
pointsSignIn,
|
||
pointsSignMonth,
|
||
findPointsNumber,
|
||
signInRecords
|
||
} from "@/util/api";
|
||
import store from "@/store";
|
||
export default {
|
||
data() {
|
||
return {
|
||
selected: [],
|
||
startDate: '',
|
||
integral: [],
|
||
myNumber: 0,
|
||
}
|
||
},
|
||
onLoad() {
|
||
this.startDate = this.getDate().fullDate;
|
||
this.getSignInList();
|
||
this.getSignInRecords();
|
||
this.getUserNumber();
|
||
},
|
||
methods: {
|
||
getUserNumber() {
|
||
findPointsNumber()
|
||
.then(res => {
|
||
if(res.code==1){
|
||
this.myNumber = res.data;
|
||
}else{
|
||
this.myNumber = 0;
|
||
}
|
||
|
||
console.log(res);
|
||
})
|
||
.catch(error => {
|
||
uni.showToast({
|
||
title: error,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
})
|
||
},
|
||
getSignInRecords() {
|
||
var uid = uni.getStorageSync('uid');
|
||
signInRecords({
|
||
member_id: uid
|
||
})
|
||
.then(res => {
|
||
console.log(res);
|
||
this.integral = res.data;
|
||
})
|
||
.catch(error => {
|
||
uni.showToast({
|
||
title: error,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
})
|
||
},
|
||
getSignInList() {
|
||
var uid = uni.getStorageSync('uid');
|
||
pointsSignMonth({
|
||
member_id: uid
|
||
})
|
||
.then(res => {
|
||
console.log(res);
|
||
var attendanceData = res.data;
|
||
const formattedAttendance = Object.keys(attendanceData).map(date => ({
|
||
date: date,
|
||
info: attendanceData[date] ? '已签到' : '未签到',
|
||
is: attendanceData[date] ? '1' : '0',
|
||
}));
|
||
this.selected = formattedAttendance;
|
||
})
|
||
.catch(error => {
|
||
uni.showToast({
|
||
title: error,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
})
|
||
},
|
||
signIn() {
|
||
var uid = uni.getStorageSync('uid');
|
||
pointsSignIn({
|
||
member_id: uid
|
||
})
|
||
.then(res => {
|
||
console.log(res);
|
||
if (res.status == 'error') {
|
||
this.$refs.toast.show({
|
||
content: res.message,
|
||
duration: 2000
|
||
})
|
||
} else {
|
||
this.$refs.toast.show({
|
||
content: res.msg,
|
||
duration: 2000
|
||
})
|
||
}
|
||
this.getSignInList();
|
||
this.getSignInRecords();
|
||
this.getUserNumber();
|
||
})
|
||
.catch(error => {
|
||
uni.showToast({
|
||
title: error,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
})
|
||
},
|
||
getDate(date, AddDayCount = 0) {
|
||
if (!date) {
|
||
date = new Date()
|
||
}
|
||
if (typeof date !== 'object') {
|
||
date = date.replace(/-/g, '/')
|
||
}
|
||
const dd = new Date(date)
|
||
|
||
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
|
||
|
||
const y = dd.getFullYear()
|
||
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
|
||
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
|
||
return {
|
||
fullDate: y + '-' + m + '-' + d,
|
||
year: y,
|
||
month: m,
|
||
date: d,
|
||
day: dd.getDay()
|
||
}
|
||
},
|
||
// 跳转
|
||
tn(e) {
|
||
uni.navigateTo({
|
||
url: e,
|
||
});
|
||
},
|
||
goBack() {
|
||
if (getCurrentPages().length > 1) {
|
||
uni.navigateBack()
|
||
} else {
|
||
uni.redirectTo({
|
||
url: '/pages/index/index'
|
||
})
|
||
|
||
}
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
|
||
</style> |