detail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="container page-bg">
  3. <view class="back-container">
  4. <navigator url="/pages/index/index">
  5. <uni-icons type="back" size="40" color="#FFFFFF"></uni-icons>
  6. </navigator>
  7. </view>
  8. <view class="edit-container">
  9. <view class="input-item">
  10. <view class="input-title">任务名称</view>
  11. <input class="input-box" placeholder="请输入任务名称" v-model="punchIn.taskName"/>
  12. </view>
  13. <view class="input-item">
  14. <view class="input-title">奖励倍数</view>
  15. <input class="input-box" type="number" placeholder="请输入任务倍数" v-model="punchIn.rewardNum"/>
  16. </view>
  17. <view class="switch-item">
  18. <view class="input-title">周末双倍</view>
  19. <switch class="input-switch" :checked="punchIn.weekendDoubleFlag" @change="weekendDoubleSwitchChange"/>
  20. </view>
  21. <view class="switch-item">
  22. <view class="input-title">全勤奖励</view>
  23. <switch class="input-switch" :checked="punchIn.fullAttendanceFlag" @change="fullAttendanceSwitchChange"/>
  24. </view>
  25. <view class="btn-container">
  26. <view class="cancel-btn" @click="cancel">取消</view>
  27. <view class="save-btn" @click="savePunchIn">保存</view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script setup>
  33. import { ref } from 'vue';
  34. import { onLoad } from '@dcloudio/uni-app';
  35. import { punchInApi } from '@/service/apis';
  36. /**
  37. * 打卡任务
  38. */
  39. const punchIn = ref({
  40. "rewardNum": 1,
  41. "weekendDoubleFlag": false,
  42. "fullAttendanceFlag": false
  43. });
  44. onLoad(async (e) => {
  45. if (e.id) {
  46. const res = await punchInApi.queryPunchInById({"id": e.id});
  47. punchIn.value = res;
  48. }
  49. })
  50. const weekendDoubleSwitchChange = (e) => {
  51. punchIn.value.weekendDoubleFlag = e.detail.value;
  52. }
  53. const fullAttendanceSwitchChange = (e) => {
  54. punchIn.value.fullAttendanceFlag = e.detail.value;
  55. }
  56. /**
  57. * 保存打卡任务
  58. */
  59. const savePunchIn = () => {
  60. punchInApi.addPunchIn(punchIn.value).then(() => {
  61. uni.showToast({
  62. title: '保存成功',
  63. icon: 'success',
  64. duration: 2000
  65. });
  66. setTimeout(() => {
  67. uni.navigateBack();
  68. }, 2000);
  69. });
  70. }
  71. /**
  72. * 后退
  73. */
  74. const cancel = () => {
  75. uni.navigateBack();
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .container {
  80. width: 100vw;
  81. height: 100vh;
  82. padding: 16rpx;
  83. .back-container {
  84. left: 16rpx;
  85. top: 39px;
  86. width: 90rpx;
  87. height: 90rpx;
  88. border-radius: 50%;
  89. background-color: rgba(0, 0, 0, 0.1);
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. }
  94. .edit-container {
  95. margin-top: 32rpx;
  96. width: 100%;
  97. .input-item {
  98. margin-top: 30rpx;
  99. width: 100%;
  100. .input-title {
  101. font-size: 36rpx;
  102. font-weight: 400;
  103. letter-spacing: 0rpx;
  104. line-height: 52.13rpx;
  105. color: rgba(0, 0, 0, 1);
  106. }
  107. .input-box {
  108. box-sizing: border-box;
  109. margin-top: 10rpx;
  110. width: 100%;
  111. height: 65rpx;
  112. padding: 10rpx 10rpx;
  113. border-radius: 5rpx;
  114. background: #FFFFFF;
  115. }
  116. }
  117. .switch-item {
  118. margin-top: 30rpx;
  119. display: flex;
  120. align-items: center;
  121. .input-title {
  122. font-size: 36rpx;
  123. font-weight: 400;
  124. letter-spacing: 0rpx;
  125. line-height: 52.13rpx;
  126. color: rgba(0, 0, 0, 1);
  127. }
  128. .input-switch {
  129. position: absolute;
  130. right: 0rpx;
  131. }
  132. }
  133. }
  134. .btn-container {
  135. position: absolute;
  136. bottom: 44rpx;
  137. left: 0rpx;
  138. width: 100%;
  139. display: grid;
  140. grid-template-columns: 1fr 1fr;
  141. place-items: center;
  142. .cancel-btn {
  143. width: 298rpx;
  144. height: 67rpx;
  145. border-radius: 30rpx;
  146. background: #E5E5E5;
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. font-size: 36rpx;
  151. font-weight: 400;
  152. letter-spacing: 0rpx;
  153. line-height: 52.13rpx;
  154. color: #FFFFFF;
  155. }
  156. .save-btn {
  157. width: 298rpx;
  158. height: 67rpx;
  159. border-radius: 30rpx;
  160. background: #2A82E4;
  161. display: flex;
  162. justify-content: center;
  163. align-items: center;
  164. font-size: 36rpx;
  165. font-weight: 400;
  166. letter-spacing: 0rpx;
  167. line-height: 52.13rpx;
  168. color: #FFFFFF;
  169. }
  170. }
  171. }
  172. </style>