| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- <template>
- <view class="layout-container">
- <!-- 顶部填充区 -->
- <view class="top-fill" :style="{height: safeArea.statusBarHeight+'px'}"></view>
- <!-- 顶部胶囊区 -->
- <view class="capsule-container" :style="{
- height: safeArea.capsuleBarHeight+'px',
- width: safeArea.capsuleBarLeft+'px',
- 'padding-top': safeArea.capsuleBarMarginTop+'px',
- 'padding-bottom': safeArea.capsuleBarMarginBottom+'px'}">
-
- <view class="user-info-container" @click="goUserInfoPage">
- <view class="user-info"
- :style="{height: safeArea.capsuleBarContentHeight+'px',width: safeArea.capsuleBarContentHeight+'px'}">
- <image v-if="userInfo" :style="{
- height: safeArea.capsuleBarContentHeight+'px',
- width: safeArea.capsuleBarContentHeight+'px',
- }" mode="aspectFill" :src="userInfo.avatar"></image>
- <uni-icons v-else type="person" :size="safeArea.capsuleBarContentHeight" color="#FFFFFF"></uni-icons>
- </view>
-
- <view class="nickname" v-if="userInfo">{{userInfo.nickname}}</view>
- <view class="nickname" v-else>登录</view>
- </view>
- </view>
- <!-- 内容区 -->
- <view class="content-container">
- <view class="settle-container">
- <view class="settle-text-container">
- <view class="settle-title">待领取奖励数</view>
- <view class="settle-num">{{reward}}</view>
- </view>
- <view class="settle-btn" @click="claimReward">领取</view>
- </view>
- <view class="task-container">
- <view class="task-header">
- <view class="task-title" v-if="punchIns.length && punchIns.length > 0">任务({{punchIns.length}}个)
- </view>
- <view class="task-title" v-else>任务</view>
- <view class="task-add-btn" @click="goPunchInDetailPage">
- <uni-icons type="plusempty" size="30" color="#406CE7"></uni-icons>
- </view>
- </view>
- <view class="task-item" v-for="punchIn in punchIns" :key="punchIn.punchInId">
- <view class="item-header">
- <view class="item-title">{{punchIn.taskName}}</view>
- <navigator :url="'/pages/detail/detail?id='+punchIn.punchInId">
- <uni-icons class="item-icon" type="settings" size="30" color="#C4C4C4"></uni-icons>
- </navigator>
- <view class="item-tag-container">
- <view class="item-tag" v-if="punchIn.fullAttendanceFlag">全勤奖励</view>
- <view class="item-tag" v-if="punchIn.weekendDoubleFlag">周末双倍</view>
- </view>
- <view class="item-btn" @click="doPunchIn(punchIn.punchInId)">完成</view>
- </view>
- <view class="item-detail-list">
- <view class="item-detail" v-for="punchInRecord in punchIn.punchInRecords"
- :key="punchInRecord.punchInDate">
- <view class="detail-text">
- <uni-dateformat :date="punchInRecord.punchInDate" format="M月d日"></uni-dateformat>
- </view>
- <view class="detail-box" style="background-color: #E5E5E5;"
- v-if="punchInRecord.punchInStatus == 'uncreated'"></view>
- <view class="detail-box" style="background-color: #A5D63F;"
- v-if="punchInRecord.punchInStatus == 'punchIn'"></view>
- <view class="detail-box" style="background-color: #D43030;"
- v-if="punchInRecord.punchInStatus == 'unPunchIn'"></view>
- <view class="detail-box"
- v-if="punchInRecord.punchInStatus == 'futureTime' || punchInRecord.punchInStatus == 'todayUnknown'">
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 弹出框 -->
- <view>
- <uni-popup ref="claimRewardDialog" type="dialog">
- <uni-popup-dialog ref="inputClose" mode="input" title="领取奖励" value="对话框预置提示内容!" placeholder="请输入领取的奖励数"
- @confirm="claimRewardConfirm"></uni-popup-dialog>
- </uni-popup>
- </view>
- <!-- 底部填充区 -->
- <view class="bottom-fill" :style="{height: safeArea.bottomHeight+'px'}"></view>
- </view>
- </template>
- <script setup>
- import {
- onMounted,
- ref
- } from 'vue';
- import {
- onLoad,
- onPullDownRefresh,
- onShow
- } from "@dcloudio/uni-app";
- import {
- rewardApi,
- punchInApi
- } from '@/service/apis.js';
- import {
- getSafeArea
- } from '@/utils/system.js';
- /**
- * 可领取奖励
- */
- const reward = ref(0);
- /**
- * 打卡任务
- */
- const punchIns = ref([]);
- /**
- * 领取奖励对话框
- */
- const claimRewardDialog = ref(null);
- /**
- * 安全区
- */
- const safeArea = ref({});
- /**
- * 用户信息
- */
- const userInfo = ref(null);
- /**
- * 领取奖励
- */
- const claimReward = () => {
- claimRewardDialog.value.open();
- }
- /**
- * 确认领取奖励
- */
- const claimRewardConfirm = async (val) => {
- await rewardApi.claimReward({
- "claimRewardNum": val
- });
- getReward();
- claimRewardDialog.value.close();
- }
- /**
- * 获取奖励
- */
- const getReward = async () => {
- let res = await rewardApi.queryReward();
- reward.value = res.unclaimedRewardNum;
- }
- /**
- * 获取打卡
- */
- const getPunchIn = async () => {
- let res = await punchInApi.queryPunchIn();
- punchIns.value = res;
- }
- /**
- * 打卡
- */
- const doPunchIn = async (id) => {
- await punchInApi.doPunchIn({
- id
- });
- getPunchIn();
- }
- /**
- * 跳转用户用心
- */
- const goUserInfoPage = () => {
- uni.navigateTo({
- url: "/pages/userInfo/userInfo"
- });
- }
- /**
- * 获取打卡编辑页面
- */
- const goPunchInDetailPage = () => {
- uni.navigateTo({
- url: "/pages/detail/detail"
- })
- };
-
- /**
- * 加载数据
- */
- const loadData = async () => {
- let token = uni.getStorageSync("token");
- // 如果还没登录就结束获取数据
- if (!token) {
- reward.value = 0;
- punchIns.value = [];
- return;
- }
-
- try {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- // 获取奖励
- getReward();
- // 获取打卡
- getPunchIn();
- } finally {
- uni.hideLoading();
- }
- };
- onLoad(() => {
- safeArea.value = getSafeArea();
- });
- onShow(() => {
- userInfo.value = uni.getStorageSync("userInfo");
- loadData();
- });
- onPullDownRefresh(() => {
- loadData();
- uni.stopPullDownRefresh();
- });
- </script>
- <style lang="scss" scoped>
- .user-info-container {
- display: flex;
- align-items: center;
-
- .user-info {
- display: flex;
- justify-content: center;
- align-items: center;
-
- border-radius: 50%;
- background: rgba(210, 239, 243, 1);
- }
-
- .nickname {
- display: flex;
- /* 水平居中 */
- justify-content: center;
- /* 垂直居中 */
- align-items: center;
- margin-left: 10rpx;
- color: rgba(0, 0, 0, 1);
- }
- }
- .content-container {
- .settle-container {
- // margin-top: 16rpx;
- height: 228rpx;
- position: relative;
- border-radius: 20rpx;
- background: rgba(64, 108, 231, 1);
- box-shadow: 1rpx 2rpx 4rpx rgba(0, 0, 0, 0.25);
- .settle-text-container {
- position: absolute;
- left: 108rpx;
- top: 20rpx;
- .settle-title {
- font-size: 24rpx;
- line-height: 34.75rpx;
- color: rgba(255, 255, 255, 1);
- }
- .settle-num {
- font-size: 100rpx;
- font-weight: 700;
- line-height: 144.8rpx;
- color: rgba(255, 255, 255, 1);
- display: flex;
- justify-content: center;
- /* 水平居中 */
- align-items: center;
- /* 垂直居中 */
- }
- }
- .settle-btn {
- position: absolute;
- left: 503rpx;
- top: 76rpx;
- width: 164rpx;
- height: 99rpx;
- border-radius: 40rpx;
- background: rgba(242, 247, 255, 1);
- font-size: 48rpx;
- font-weight: 700;
- line-height: 69.5px;
- color: rgba(64, 108, 231, 1);
- display: flex;
- justify-content: center;
- /* 水平居中 */
- align-items: center;
- /* 垂直居中 */
- }
- }
- .task-container {
- margin-top: 16rpx;
- .task-header {
- position: relative;
- height: 80rpx;
- display: flex;
- justify-content: center;
- /* 水平居中 */
- align-items: center;
- /* 垂直居中 */
- .task-title {
- position: absolute;
- left: 0rpx;
- font-size: 30rpx;
- font-weight: 400;
- line-height: 43.44rpx;
- color: rgba(0, 0, 0, 1);
- }
- .task-add-btn {
- display: inline-flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- right: 0rpx;
- width: 60rpx;
- height: 60rpx;
- border-radius: 10rpx;
- border: 3px solid rgba(64, 108, 231, 1);
- }
- }
- .task-item {
- margin-top: 16rpx;
- width: 100%;
- height: 201rpx;
- border-radius: 20px;
- background: #FFFFFF;
- box-shadow: 1px 2px 4px #000000;
- box-sizing: border-box;
- padding: 16rpx;
- .item-header {
- position: relative;
- display: flex;
- align-items: center;
- .item-title {
- display: inline-block;
- // margin-left: 20rpx;
- font-size: 36rpx;
- font-weight: 400;
- letter-spacing: 0rpx;
- line-height: 52.13rpx;
- color: rgba(0, 0, 0, 1);
- }
- .item-icon {
- margin-left: 10rpx;
- }
- .item-tag-container {
- display: inline-block;
- margin-left: 10rpx;
- .item-tag:not(:first-child) {
- margin-left: 10rpx;
- }
- .item-tag {
- display: inline-block;
- background-color: #F2F7FF;
- padding: 10rpx;
- border-radius: 40rpx;
- background: #F2F7FF;
- font-size: 16rpx;
- font-weight: 400;
- line-height: 23.17rpx;
- color: rgba(0, 0, 0, 1);
- text-align: center;
- vertical-align: top;
- }
- }
- .item-btn {
- display: inline-flex;
- position: absolute;
- right: 0rpx;
- width: 123rpx;
- height: 42rpx;
- border-radius: 30rpx;
- border: 1rpx solid #2A82E4;
- justify-content: center;
- align-items: center;
- font-size: 20rpx;
- font-weight: 400;
- line-height: 28.96px;
- color: rgba(64, 108, 231, 1);
- }
- }
- .item-detail-list {
- margin-top: 16rpx;
- display: grid;
- grid-template-columns: repeat(7, 1fr);
- .item-detail {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .detail-text {
- font-size: 20rpx;
- font-weight: 400;
- letter-spacing: 0rpx;
- line-height: 28.96rpx;
- color: rgba(0, 0, 0, 1);
- }
- .detail-box {
- // display: block;
- width: 42rpx;
- height: 42rpx;
- margin-top: 5rpx;
- border: 5rpx solid #000000;
- }
- }
- }
- }
- }
- }
- </style>
|