detail.vue 4.7 KB

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