detail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 safeArea from '@/utils/system.js';
  55. /**
  56. * 打卡任务
  57. */
  58. const punchIn = ref({
  59. "rewardNum": 1,
  60. "weekendDoubleFlag": false,
  61. "fullAttendanceFlag": false
  62. });
  63. onLoad(async (e) => {
  64. if (e.id) {
  65. const res = await punchInApi.queryPunchInById({"id": e.id});
  66. punchIn.value = res;
  67. }
  68. })
  69. const weekendDoubleSwitchChange = (e) => {
  70. punchIn.value.weekendDoubleFlag = e.detail.value;
  71. }
  72. const fullAttendanceSwitchChange = (e) => {
  73. punchIn.value.fullAttendanceFlag = e.detail.value;
  74. }
  75. /**
  76. * 保存打卡任务
  77. */
  78. const savePunchIn = () => {
  79. punchInApi.addPunchIn(punchIn.value).then(() => {
  80. uni.showToast({
  81. title: '保存成功',
  82. icon: 'success',
  83. duration: 2000
  84. });
  85. setTimeout(() => {
  86. uni.navigateBack();
  87. }, 2000);
  88. });
  89. }
  90. /**
  91. * 后退
  92. */
  93. const cancel = () => {
  94. uni.navigateBack();
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .back-container {
  99. border-radius: 50%;
  100. background-color: rgba(0, 0, 0, 0.1);
  101. display: flex;
  102. justify-content: center;
  103. align-items: center;
  104. }
  105. .edit-container {
  106. margin-top: 32rpx;
  107. width: 100%;
  108. .input-item {
  109. margin-top: 30rpx;
  110. width: 100%;
  111. .input-title {
  112. font-size: 36rpx;
  113. font-weight: 400;
  114. letter-spacing: 0rpx;
  115. line-height: 52.13rpx;
  116. color: rgba(0, 0, 0, 1);
  117. }
  118. .input-box {
  119. box-sizing: border-box;
  120. margin-top: 10rpx;
  121. width: 100%;
  122. height: 65rpx;
  123. padding: 10rpx 10rpx;
  124. border-radius: 5rpx;
  125. background: #FFFFFF;
  126. }
  127. }
  128. .switch-item {
  129. margin-top: 30rpx;
  130. display: flex;
  131. align-items: center;
  132. .input-title {
  133. font-size: 36rpx;
  134. font-weight: 400;
  135. letter-spacing: 0rpx;
  136. line-height: 52.13rpx;
  137. color: rgba(0, 0, 0, 1);
  138. }
  139. .input-switch {
  140. position: absolute;
  141. right: 0rpx;
  142. }
  143. }
  144. }
  145. .btn-container {
  146. position: absolute;
  147. bottom: 44rpx;
  148. left: 0rpx;
  149. width: 100%;
  150. display: grid;
  151. grid-template-columns: 1fr 1fr;
  152. place-items: center;
  153. .cancel-btn {
  154. width: 298rpx;
  155. height: 67rpx;
  156. border-radius: 30rpx;
  157. background: #E5E5E5;
  158. display: flex;
  159. justify-content: center;
  160. align-items: center;
  161. font-size: 36rpx;
  162. font-weight: 400;
  163. letter-spacing: 0rpx;
  164. line-height: 52.13rpx;
  165. color: #FFFFFF;
  166. }
  167. .save-btn {
  168. width: 298rpx;
  169. height: 67rpx;
  170. border-radius: 30rpx;
  171. background: #2A82E4;
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. font-size: 36rpx;
  176. font-weight: 400;
  177. letter-spacing: 0rpx;
  178. line-height: 52.13rpx;
  179. color: #FFFFFF;
  180. }
  181. }
  182. </style>