index.vue 8.2 KB

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