2024-11-22 16:37:49 +08:00
< template >
2025-03-21 16:50:18 +08:00
< view
style = "background: url('https://hnyea.0rui.cn/uploads/1/20240722/7f5a72050b9cbc409fb60fa8d32db76a.png');background-repeat: no-repeat;background-size: 100% 555rpx;" >
2024-11-22 16:37:49 +08:00
<!-- 顶部自定义导航 -- >
2025-03-21 16:50:18 +08:00
< tn-nav-bar :isBack = "false" :bottomShadow = "false" backgroundColor = "transparent" >
2024-11-22 16:37:49 +08:00
< view class = "custom-nav tn-flex tn-flex-col-center tn-flex-row-left" >
< view style = "padding-left: 15rpx;" @click ="goBack()" >
2025-03-21 16:50:18 +08:00
< text class = "tn-icon-left" style = "font-size: 40rpx;color: #000000;" > < / text >
2024-11-22 16:37:49 +08:00
< / view >
2025-03-21 16:50:18 +08:00
< view
style = "letter-spacing: 1px;font-size: 34rpx;text-align: center;width: 83%;font-weight: bold;color: #000000;" >
< text > 每日签到 < / text >
2024-11-22 16:37:49 +08:00
< / view >
< / view >
< / tn-nav-bar >
2025-03-21 16:50:18 +08:00
< 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 >
2024-11-22 16:37:49 +08:00
< / view >
< / view >
2025-03-21 16:50:18 +08:00
<!-- < view style = "text-align: center;" >
2024-11-22 16:37:49 +08:00
< tn-button @click ="signIn" backgroundColor = "#01BEFF" fontColor = "#ffffff" > 签到 < / tn-button >
2025-03-21 16:50:18 +08:00
< / 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 >
2024-11-22 16:37:49 +08:00
< / view >
< / view >
2025-03-21 16:50:18 +08:00
< view style = "padding-bottom: 80rpx;" >
2024-11-22 16:37:49 +08:00
< 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" >
2025-03-21 16:50:18 +08:00
< view class = "tn-text-lg" style = "color:#3056D3;" >
2024-11-22 16:37:49 +08:00
日常签到
< / 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" >
2025-03-21 16:50:18 +08:00
< view style = "color: #3056D3;" > + { { item . number } } < / view >
2024-11-22 16:37:49 +08:00
< / view >
< / view >
2025-03-21 16:50:18 +08:00
< / 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 >
2024-11-22 16:37:49 +08:00
2025-03-21 16:50:18 +08:00
< / view >
2024-11-22 16:37:49 +08:00
< / view >
< tn-toast ref = "toast" > < / tn-toast >
< / view >
< / template >
< script >
import {
pointsSignIn ,
pointsSignMonth ,
2025-03-21 16:50:18 +08:00
findPointsNumber ,
2024-11-22 16:37:49 +08:00
signInRecords
} from "@/util/api" ;
import store from "@/store" ;
export default {
data ( ) {
return {
selected : [ ] ,
startDate : '' ,
integral : [ ] ,
2025-03-21 16:50:18 +08:00
myNumber : 0 ,
2024-11-22 16:37:49 +08:00
}
} ,
onLoad ( ) {
this . startDate = this . getDate ( ) . fullDate ;
this . getSignInList ( ) ;
this . getSignInRecords ( ) ;
2025-03-21 16:50:18 +08:00
this . getUserNumber ( ) ;
2024-11-22 16:37:49 +08:00
} ,
methods : {
2025-03-21 16:50:18 +08:00
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
} ) ;
} )
} ,
2024-11-22 16:37:49 +08:00
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 ,
2025-03-21 16:50:18 +08:00
info : attendanceData [ date ] ? '已签到' : '未签到' ,
2024-11-22 16:37:49 +08:00
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 ( ) ;
2025-03-21 16:50:18 +08:00
this . getUserNumber ( ) ;
2024-11-22 16:37:49 +08:00
} )
. 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 >