index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <view class="container page-bg">
  3. <view class="header-container">
  4. <navigator url="/pages/login/login">
  5. <view class="user-info">
  6. <uni-icons type="person" size="30" color="#FFFFFF"></uni-icons>
  7. </view>
  8. </navigator>
  9. </view>
  10. <view class="settle-container">
  11. <view class="settle-text-container">
  12. <view class="settle-title">待领取奖励数</view>
  13. <view class="settle-num">{{reward}}</view>
  14. </view>
  15. <view class="settle-btn" @click="claimReward">领取</view>
  16. </view>
  17. <view class="task-container">
  18. <view class="task-header">
  19. <view class="task-title">任务(3个)</view>
  20. <view class="task-add-btn">
  21. <navigator url="/pages/detail/detail">
  22. <uni-icons type="plusempty" size="30" color="#406CE7"></uni-icons>
  23. </navigator>
  24. </view>
  25. </view>
  26. <view class="task-item" v-for="punchIn in punchIns" :key="punchIn.punchInId">
  27. <view class="item-header">
  28. <view class="item-title">{{punchIn.taskName}}</view>
  29. <navigator :url="'/pages/detail/detail?id='+punchIn.punchInId">
  30. <uni-icons class="item-icon" type="settings" size="30" color="#C4C4C4"></uni-icons>
  31. </navigator>
  32. <view class="item-tag-container">
  33. <view class="item-tag" v-if="punchIn.fullAttendanceFlag">全勤奖励</view>
  34. <view class="item-tag" v-if="punchIn.weekendDoubleFlag">周末双倍</view>
  35. </view>
  36. <view class="item-btn" @click="doPunchIn(punchIn.punchInId)">完成</view>
  37. </view>
  38. <view class="item-detail-list">
  39. <view class="item-detail" v-for="punchInRecord in punchIn.punchInRecords">
  40. <view class="detail-text">
  41. <uni-dateformat :date="punchInRecord.punchInDate" format="M月d日"></uni-dateformat>
  42. </view>
  43. <view class="detail-box" style="background-color: #E5E5E5;" v-if="punchInRecord.punchInStatus == 'uncreated'"></view>
  44. <view class="detail-box" style="background-color: #A5D63F;" v-if="punchInRecord.punchInStatus == 'punchIn'"></view>
  45. <view class="detail-box" style="background-color: #D43030;" v-if="punchInRecord.punchInStatus == 'unPunchIn'"></view>
  46. <view class="detail-box" v-if="punchInRecord.punchInStatus == 'futureTime' || punchInRecord.punchInStatus == 'todayUnknown'"></view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view>
  52. <uni-popup ref="claimRewardDialog" type="dialog">
  53. <uni-popup-dialog ref="inputClose" mode="input" title="领取奖励" value="对话框预置提示内容!"
  54. placeholder="请输入领取的奖励数" @confirm="claimRewardConfirm"></uni-popup-dialog>
  55. </uni-popup>
  56. </view>
  57. </view>
  58. </template>
  59. <script setup>
  60. import { onMounted, ref } from 'vue';
  61. import { rewardApi, punchInApi } from '@/service/apis.js';
  62. /**
  63. * 可领取奖励
  64. */
  65. const reward = ref(0);
  66. /**
  67. * 打卡任务
  68. */
  69. const punchIns = ref([]);
  70. /**
  71. * 领取奖励对话框
  72. */
  73. const claimRewardDialog = ref(null);
  74. /**
  75. * 领取奖励
  76. */
  77. const claimReward = () => {
  78. claimRewardDialog.value.open();
  79. }
  80. /**
  81. * 确认领取奖励
  82. */
  83. const claimRewardConfirm = async (val) => {
  84. await rewardApi.claimReward({"claimRewardNum": val});
  85. getReward();
  86. claimRewardDialog.value.close();
  87. }
  88. /**
  89. * 获取奖励
  90. */
  91. const getReward = async () => {
  92. let res = await rewardApi.queryReward();
  93. reward.value = res.unclaimedRewardNum;
  94. }
  95. /**
  96. * 获取打卡
  97. */
  98. const getPunchIn = async () => {
  99. let res = await punchInApi.queryPunchIn();
  100. punchIns.value = res;
  101. }
  102. /**
  103. * 打卡
  104. */
  105. const doPunchIn = async (id) => {
  106. await punchInApi.doPunchIn({id});
  107. getPunchIn();
  108. }
  109. onMounted(() => {
  110. // 获取奖励
  111. getReward();
  112. // 获取打卡
  113. getPunchIn();
  114. })
  115. </script>
  116. <style lang="scss" scoped>
  117. .container {
  118. width: 100vw;
  119. height: 100vh;
  120. padding: 16rpx;
  121. .header-container {
  122. position: relative;
  123. height: 83rpx;
  124. .user-info {
  125. width: 83rpx;
  126. height: 83rpx;
  127. display: flex;
  128. justify-content: center;
  129. /* 水平居中 */
  130. align-items: center;
  131. /* 垂直居中 */
  132. position: absolute;
  133. right: 0rpx;
  134. top: 0rpx;
  135. border-radius: 50%;
  136. background: rgba(210, 239, 243, 1);
  137. }
  138. }
  139. .settle-container {
  140. margin-top: 16rpx;
  141. height: 228rpx;
  142. position: relative;
  143. border-radius: 20rpx;
  144. background: rgba(64, 108, 231, 1);
  145. box-shadow: 1rpx 2rpx 4rpx rgba(0, 0, 0, 0.25);
  146. .settle-text-container {
  147. position: absolute;
  148. left: 108rpx;
  149. top: 20rpx;
  150. .settle-title {
  151. font-size: 24rpx;
  152. line-height: 34.75rpx;
  153. color: rgba(255, 255, 255, 1);
  154. }
  155. .settle-num {
  156. font-size: 100rpx;
  157. font-weight: 700;
  158. line-height: 144.8rpx;
  159. color: rgba(255, 255, 255, 1);
  160. display: flex;
  161. justify-content: center;
  162. /* 水平居中 */
  163. align-items: center;
  164. /* 垂直居中 */
  165. }
  166. }
  167. .settle-btn {
  168. position: absolute;
  169. left: 503rpx;
  170. top: 76rpx;
  171. width: 164rpx;
  172. height: 99rpx;
  173. border-radius: 40rpx;
  174. background: rgba(242, 247, 255, 1);
  175. font-size: 48rpx;
  176. font-weight: 700;
  177. line-height: 69.5px;
  178. color: rgba(64, 108, 231, 1);
  179. display: flex;
  180. justify-content: center;
  181. /* 水平居中 */
  182. align-items: center;
  183. /* 垂直居中 */
  184. }
  185. }
  186. .task-container {
  187. margin-top: 16rpx;
  188. .task-header {
  189. position: relative;
  190. height: 80rpx;
  191. display: flex;
  192. justify-content: center;
  193. /* 水平居中 */
  194. align-items: center;
  195. /* 垂直居中 */
  196. .task-title {
  197. position: absolute;
  198. left: 0rpx;
  199. font-size: 30rpx;
  200. font-weight: 400;
  201. line-height: 43.44rpx;
  202. color: rgba(0, 0, 0, 1);
  203. }
  204. .task-add-btn {
  205. display: inline-flex;
  206. justify-content: center;
  207. align-items: center;
  208. position: absolute;
  209. right: 0rpx;
  210. width: 60rpx;
  211. height: 60rpx;
  212. border-radius: 10rpx;
  213. border: 3px solid rgba(64, 108, 231, 1);
  214. }
  215. }
  216. .task-item {
  217. margin-top: 16rpx;
  218. width: 100%;
  219. height: 201rpx;
  220. border-radius: 20px;
  221. background: #FFFFFF;
  222. box-shadow: 1px 2px 4px #000000;
  223. box-sizing: border-box;
  224. padding: 16rpx;
  225. .item-header {
  226. position: relative;
  227. display: flex;
  228. align-items: center;
  229. .item-title {
  230. display: inline-block;
  231. // margin-left: 20rpx;
  232. font-size: 36rpx;
  233. font-weight: 400;
  234. letter-spacing: 0rpx;
  235. line-height: 52.13rpx;
  236. color: rgba(0, 0, 0, 1);
  237. }
  238. .item-icon {
  239. margin-left: 10rpx;
  240. }
  241. .item-tag-container {
  242. display: inline-block;
  243. margin-left: 10rpx;
  244. .item-tag:not(:first-child) {
  245. margin-left: 10rpx;
  246. }
  247. .item-tag {
  248. display: inline-block;
  249. background-color: #F2F7FF;
  250. padding: 10rpx;
  251. border-radius: 40rpx;
  252. background: #F2F7FF;
  253. font-size: 16rpx;
  254. font-weight: 400;
  255. line-height: 23.17rpx;
  256. color: rgba(0, 0, 0, 1);
  257. text-align: center;
  258. vertical-align: top;
  259. }
  260. }
  261. .item-btn {
  262. display: inline-flex;
  263. position: absolute;
  264. right: 0rpx;
  265. width: 123rpx;
  266. height: 42rpx;
  267. border-radius: 30rpx;
  268. border: 1rpx solid #2A82E4;
  269. justify-content: center;
  270. align-items: center;
  271. font-size: 20rpx;
  272. font-weight: 400;
  273. line-height: 28.96px;
  274. color: rgba(64, 108, 231, 1);
  275. }
  276. }
  277. .item-detail-list {
  278. margin-top: 16rpx;
  279. display: grid;
  280. grid-template-columns: repeat(7, 1fr);
  281. .item-detail {
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: center;
  285. align-items: center;
  286. .detail-text {
  287. font-size: 20rpx;
  288. font-weight: 400;
  289. letter-spacing: 0rpx;
  290. line-height: 28.96rpx;
  291. color: rgba(0, 0, 0, 1);
  292. }
  293. .detail-box {
  294. // display: block;
  295. width: 42rpx;
  296. height: 42rpx;
  297. margin-top: 5rpx;
  298. border: 5rpx solid #000000;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. </style>