| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <view class="container page-bg">
- <view class="back-container">
- <navigator url="/pages/index/index">
- <uni-icons type="back" size="40" color="#FFFFFF"></uni-icons>
- </navigator>
- </view>
- <view class="edit-container">
- <view class="input-item">
- <view class="input-title">任务名称</view>
- <input class="input-box" placeholder="请输入任务名称" v-model="punchIn.taskName"/>
- </view>
- <view class="input-item">
- <view class="input-title">奖励倍数</view>
- <input class="input-box" type="number" placeholder="请输入任务倍数" v-model="punchIn.rewardNum"/>
- </view>
- <view class="switch-item">
- <view class="input-title">周末双倍</view>
- <switch class="input-switch" :checked="punchIn.weekendDoubleFlag" @change="weekendDoubleSwitchChange"/>
- </view>
- <view class="switch-item">
- <view class="input-title">全勤奖励</view>
- <switch class="input-switch" :checked="punchIn.fullAttendanceFlag" @change="fullAttendanceSwitchChange"/>
- </view>
- <view class="btn-container">
- <view class="cancel-btn" @click="cancel">取消</view>
- <view class="save-btn" @click="savePunchIn">保存</view>
- </view>
- </view>
-
- </view>
- </template>
- <script setup>
- import { ref } from 'vue';
- import { onLoad } from '@dcloudio/uni-app';
- import { punchInApi } from '@/service/apis';
-
- /**
- * 打卡任务
- */
- const punchIn = ref({
- "rewardNum": 1,
- "weekendDoubleFlag": false,
- "fullAttendanceFlag": false
- });
-
- onLoad(async (e) => {
- if (e.id) {
- const res = await punchInApi.queryPunchInById({"id": e.id});
- punchIn.value = res;
- }
- })
- const weekendDoubleSwitchChange = (e) => {
- punchIn.value.weekendDoubleFlag = e.detail.value;
- }
-
- const fullAttendanceSwitchChange = (e) => {
- punchIn.value.fullAttendanceFlag = e.detail.value;
- }
-
- /**
- * 保存打卡任务
- */
- const savePunchIn = () => {
- punchInApi.addPunchIn(punchIn.value).then(() => {
- uni.showToast({
- title: '保存成功',
- icon: 'success',
- duration: 2000
- });
- setTimeout(() => {
- uni.navigateBack();
- }, 2000);
- });
- }
-
- /**
- * 后退
- */
- const cancel = () => {
- uni.navigateBack();
- }
- </script>
- <style lang="scss" scoped>
- .container {
- width: 100vw;
- height: 100vh;
- padding: 16rpx;
-
- .back-container {
- left: 16rpx;
- top: 39px;
- width: 90rpx;
- height: 90rpx;
- border-radius: 50%;
- background-color: rgba(0, 0, 0, 0.1);
-
- display: flex;
- justify-content: center;
- align-items: center;
- }
-
- .edit-container {
- margin-top: 32rpx;
- width: 100%;
-
- .input-item {
- margin-top: 30rpx;
- width: 100%;
-
- .input-title {
- font-size: 36rpx;
- font-weight: 400;
- letter-spacing: 0rpx;
- line-height: 52.13rpx;
- color: rgba(0, 0, 0, 1);
- }
-
- .input-box {
- box-sizing: border-box;
- margin-top: 10rpx;
- width: 100%;
- height: 65rpx;
- padding: 10rpx 10rpx;
- border-radius: 5rpx;
- background: #FFFFFF;
- }
- }
-
- .switch-item {
- margin-top: 30rpx;
- display: flex;
- align-items: center;
-
- .input-title {
- font-size: 36rpx;
- font-weight: 400;
- letter-spacing: 0rpx;
- line-height: 52.13rpx;
- color: rgba(0, 0, 0, 1);
- }
-
- .input-switch {
- position: absolute;
- right: 0rpx;
- }
- }
- }
-
- .btn-container {
- position: absolute;
- bottom: 44rpx;
- left: 0rpx;
- width: 100%;
- display: grid;
- grid-template-columns: 1fr 1fr;
- place-items: center;
-
- .cancel-btn {
- width: 298rpx;
- height: 67rpx;
- border-radius: 30rpx;
- background: #E5E5E5;
-
- display: flex;
- justify-content: center;
- align-items: center;
-
- font-size: 36rpx;
- font-weight: 400;
- letter-spacing: 0rpx;
- line-height: 52.13rpx;
- color: #FFFFFF;
- }
-
- .save-btn {
- width: 298rpx;
- height: 67rpx;
- border-radius: 30rpx;
- background: #2A82E4;
-
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 36rpx;
- font-weight: 400;
- letter-spacing: 0rpx;
- line-height: 52.13rpx;
- color: #FFFFFF;
- }
- }
- }
- </style>
|