index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <main-layout>
  3. <template>
  4. <!-- 用户信息区 -->
  5. <view class="user-info">
  6. <view class="user-icon">
  7. <uni-icons type="person" size="30"></uni-icons>
  8. </view>
  9. <span class="nickname">登录</span>
  10. <span class="user-btn">用户中心</span>
  11. </view>
  12. <!-- 结算 -->
  13. <view class="settle-container">
  14. <!-- 刮刮乐、奖励数相关区域 -->
  15. <view class="left-box">
  16. <view class="split-box">
  17. <view class="line-box">
  18. <span>投入</span>
  19. <span class="number-box">50</span>
  20. </view>
  21. <view class="under-line-box">
  22. <span>中奖</span>
  23. <span class="number-box">100</span>
  24. </view>
  25. </view>
  26. <view class="split-box">
  27. <view class="line-box">
  28. <span>已领取</span>
  29. <span class="number-box">68</span>
  30. </view>
  31. <view class="under-line-box">
  32. <span>总奖励</span>
  33. <span class="number-box">100</span>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 待领取奖励区 -->
  38. <view class="right-box">
  39. <view class="reward-title">待领取奖励数</view>
  40. <view class="reward-num">24</view>
  41. <view class="reward-btn-group">
  42. <view class="reward-btn-left">全部领取</view>
  43. <view class="reward-btn-right">部分领取</view>
  44. </view>
  45. </view>
  46. <!-- 刷新按钮 -->
  47. <view class="refresh-btn">
  48. <uni-icons type="refreshempty" color="#406CE7"></uni-icons>
  49. </view>
  50. </view>
  51. <!-- 打卡任务 -->
  52. <view class="task-container">
  53. <view class="task-header">
  54. <view class="task-title" v-if="punchIns.length && punchIns.length > 0">任务({{punchIns.length}}个)
  55. </view>
  56. <view class="task-title" v-else>任务</view>
  57. <view class="task-add-btn" @click="goPunchInDetailPage">
  58. <uni-icons type="plusempty" size="30" color="#406CE7"></uni-icons>
  59. </view>
  60. </view>
  61. <view class="task-item" v-for="punchIn in punchIns" :key="punchIn.punchInId">
  62. <view class="main-box">
  63. <view class="item-header">
  64. <span class="item-title">{{punchIn.taskName}}</span>
  65. <span class="item-reward">x88</span>
  66. <view class="item-tag" v-if="punchIn.fullAttendanceFlag">全勤奖励</view>
  67. <view class="item-tag" v-if="punchIn.weekendDoubleFlag">周末双倍</view>
  68. </view>
  69. <view class="item-desc">
  70. 规则:最少做金刚功两次,四次八部金刚功+一次长寿宫
  71. </view>
  72. <view class="item-detail-list">
  73. <view class="item-detail" v-for="punchInRecord in punchIn.punchInRecords"
  74. :key="punchInRecord.punchInDate">
  75. <view class="detail-text">
  76. <uni-dateformat :date="punchInRecord.punchInDate" format="M/d"></uni-dateformat>
  77. </view>
  78. <view class="detail-box" style="background-color: #E5E5E5;"
  79. v-if="punchInRecord.punchInStatus == 'uncreated'"></view>
  80. <view class="detail-box" style="background-color: #A5D63F;"
  81. v-if="punchInRecord.punchInStatus == 'punchIn'"></view>
  82. <view class="detail-box" style="background-color: #D43030;"
  83. v-if="punchInRecord.punchInStatus == 'unPunchIn'"></view>
  84. <view class="detail-box"
  85. v-if="punchInRecord.punchInStatus == 'futureTime' || punchInRecord.punchInStatus == 'todayUnknown'">
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="func-box">
  91. <span>06:30:00</span>
  92. <span>已完成</span>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 弹出框 -->
  97. <view>
  98. <uni-popup ref="claimRewardDialog" type="dialog">
  99. <uni-popup-dialog ref="inputClose" mode="input" title="领取奖励" value="对话框预置提示内容!" placeholder="请输入领取的奖励数"
  100. @confirm="claimRewardConfirm"></uni-popup-dialog>
  101. </uni-popup>
  102. </view>
  103. </template>
  104. </main-layout>
  105. </template>
  106. <script setup>
  107. import { onMounted, ref } from 'vue';
  108. import { onLoad, onPullDownRefresh, onShow } from "@dcloudio/uni-app";
  109. import { rewardApi, punchInApi } from '@/service/apis.js';
  110. /**
  111. * 可领取奖励
  112. */
  113. const reward = ref(0);
  114. /**
  115. * 打卡任务
  116. */
  117. const punchIns = ref([]);
  118. /**
  119. * 领取奖励对话框
  120. */
  121. const claimRewardDialog = ref(null);
  122. /**
  123. * 用户信息
  124. */
  125. const userInfo = ref(null);
  126. /**
  127. * 领取奖励
  128. */
  129. const claimReward = () => {
  130. claimRewardDialog.value.open();
  131. }
  132. /**
  133. * 确认领取奖励
  134. */
  135. const claimRewardConfirm = async (val) => {
  136. await rewardApi.claimReward({
  137. "claimRewardNum": val
  138. });
  139. getReward();
  140. claimRewardDialog.value.close();
  141. }
  142. /**
  143. * 获取奖励
  144. */
  145. const getReward = async () => {
  146. let res = await rewardApi.queryReward();
  147. reward.value = res.unclaimedRewardNum;
  148. }
  149. /**
  150. * 获取打卡
  151. */
  152. const getPunchIn = async () => {
  153. let res = await punchInApi.queryPunchIn();
  154. punchIns.value = res;
  155. }
  156. /**
  157. * 打卡
  158. */
  159. const doPunchIn = async (id) => {
  160. await punchInApi.doPunchIn({
  161. id
  162. });
  163. getPunchIn();
  164. }
  165. /**
  166. * 跳转用户用心
  167. */
  168. const goUserInfoPage = () => {
  169. uni.navigateTo({
  170. url: "/pages/userInfo/userInfo"
  171. });
  172. }
  173. /**
  174. * 获取打卡编辑页面
  175. */
  176. const goPunchInDetailPage = () => {
  177. uni.navigateTo({
  178. url: "/pages/detail/detail"
  179. })
  180. };
  181. /**
  182. * 加载数据
  183. */
  184. const loadData = async () => {
  185. let token = uni.getStorageSync("token");
  186. // 如果还没登录就结束获取数据
  187. if (!token) {
  188. reward.value = 0;
  189. punchIns.value = [];
  190. return;
  191. }
  192. try {
  193. uni.showLoading({
  194. title: '加载中',
  195. mask: true
  196. });
  197. // 获取奖励
  198. getReward();
  199. // 获取打卡
  200. getPunchIn();
  201. } finally {
  202. uni.hideLoading();
  203. }
  204. };
  205. onShow(() => {
  206. userInfo.value = uni.getStorageSync("userInfo");
  207. loadData();
  208. });
  209. onPullDownRefresh(() => {
  210. loadData();
  211. uni.stopPullDownRefresh();
  212. });
  213. </script>
  214. <style lang="scss" scoped>
  215. .user-info {
  216. display: flex;
  217. align-items: center;
  218. position: relative;
  219. .user-icon {
  220. display: inline-block !important;
  221. width: 72rpx;
  222. height: 72rpx;
  223. background: #FFFFFF;
  224. border-radius: 50%;
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. }
  229. .nickname {
  230. margin-left: 16rpx;
  231. font-size: 24rpx;
  232. font-weight: 400;
  233. letter-spacing: 0rpx;
  234. line-height: 34.75rpx;
  235. color: #000000;
  236. }
  237. .user-btn {
  238. position: absolute;
  239. right: 0px;
  240. width: 122rpx;
  241. height: 40rpx;
  242. opacity: 1;
  243. border-radius: 24rpx;
  244. background: #FFFFFF;
  245. border: 1px solid #406CE7;
  246. /** 文本1 */
  247. font-size: 18rpx;
  248. font-weight: 400;
  249. letter-spacing: 0rpx;
  250. line-height: 26.06rpx;
  251. color: #406CE7;
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. }
  256. }
  257. .settle-container {
  258. margin-top: 16rpx;
  259. display: flex;
  260. padding: 16rpx 24rpx;
  261. height: 266rpx;
  262. opacity: 1;
  263. background: #406CE7;
  264. border-radius: 21.35rpx;
  265. border: 0.5px solid #E4E4E4;
  266. box-shadow: 0px 1px 6px #D8D8D8;
  267. position: relative;
  268. .left-box {
  269. flex: 1;
  270. display: flex;
  271. flex-direction: column;
  272. border-right: 1px solid #FFFFFF;
  273. padding-right: 24rpx;
  274. font-size: 22rpx;
  275. font-weight: 400;
  276. letter-spacing: 0rpx;
  277. line-height: 31.86rpx;
  278. color: #FFFFFF;
  279. .line-box {
  280. padding-bottom: 16rpx;
  281. border-bottom: 1px solid #FFFFFF;
  282. position: relative;
  283. }
  284. .under-line-box {
  285. padding-top: 16rpx;
  286. position: relative;
  287. }
  288. .number-box {
  289. position: absolute;
  290. right: 0px;
  291. text-align: right;
  292. }
  293. .split-box {
  294. flex: 1;
  295. display: flex;
  296. justify-content: center;
  297. align-content: center;
  298. flex-direction: column;
  299. }
  300. }
  301. .right-box {
  302. flex: 2;
  303. display: flex;
  304. flex-direction: column;
  305. align-items: center;
  306. .reward-title {
  307. font-size: 26rpx;
  308. font-weight: 400;
  309. letter-spacing: 0rpx;
  310. line-height: 37.65rpx;
  311. color: #FFFFFF;
  312. }
  313. .reward-num {
  314. flex-grow: 1;
  315. font-size: 120rpx;
  316. font-weight: 700;
  317. letter-spacing: 0rpx;
  318. color: #FFFFFF;
  319. }
  320. .reward-btn-group {
  321. width: 100%;
  322. height: 36rpx;
  323. display: flex;
  324. align-items: center;
  325. justify-content: center;
  326. .reward-btn-left {
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. width: 108rpx;
  331. height: 36rpx;
  332. opacity: 1;
  333. border-radius: 24rpx 0rpx 0rpx 24rpx;
  334. background: #FFFFFF;
  335. font-size: 20rpx;
  336. font-weight: 700;
  337. letter-spacing: 0rpx;
  338. line-height: 28.96rpx;
  339. color: #406CE7;
  340. }
  341. .reward-btn-right {
  342. margin-left: 5rpx;
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. width: 108rpx;
  347. height: 36rpx;
  348. opacity: 1;
  349. border-radius: 0rpx 24rpx 24rpx 0rpx;
  350. background: #FFFFFF;
  351. font-size: 20rpx;
  352. font-weight: 700;
  353. letter-spacing: 0rpx;
  354. line-height: 28.96rpx;
  355. color: #406CE7;
  356. }
  357. }
  358. }
  359. .refresh-btn {
  360. position: absolute;
  361. top: 16rpx;
  362. right: 24rpx;
  363. border-radius: 50%;
  364. width: 36rpx;
  365. height: 36rpx;
  366. opacity: 1;
  367. background: #F7F7F7;
  368. display: flex;
  369. justify-content: center;
  370. align-items: center;
  371. }
  372. }
  373. .task-container {
  374. margin-top: 16rpx;
  375. .task-header {
  376. position: relative;
  377. height: 80rpx;
  378. display: flex;
  379. justify-content: center;
  380. /* 水平居中 */
  381. align-items: center;
  382. /* 垂直居中 */
  383. .task-title {
  384. position: absolute;
  385. left: 0rpx;
  386. font-size: 30rpx;
  387. font-weight: 400;
  388. line-height: 43.44rpx;
  389. color: rgba(0, 0, 0, 1);
  390. }
  391. .task-add-btn {
  392. display: inline-flex;
  393. justify-content: center;
  394. align-items: center;
  395. position: absolute;
  396. right: 0rpx;
  397. width: 60rpx;
  398. height: 60rpx;
  399. border-radius: 10rpx;
  400. border: 3px solid rgba(64, 108, 231, 1);
  401. }
  402. }
  403. .task-item {
  404. margin-top: 16rpx;
  405. width: 100%;
  406. // height: 239rpx;
  407. border-radius: 24rpx;
  408. background: #FFFFFF;
  409. border: 0.5px solid #E4E4E4;
  410. box-shadow: 0px 1px 6px #D8D8D8;
  411. display: flex;
  412. .main-box {
  413. flex-grow: 1;
  414. padding: 16rpx 16rpx 16rpx 24rpx;
  415. .item-header {
  416. // position: relative;
  417. display: flex;
  418. align-items: center;
  419. .item-title {
  420. font-size: 30rpx;
  421. font-weight: 400;
  422. letter-spacing: 0rpx;
  423. line-height: 43.44rpx;
  424. color: #000000;
  425. }
  426. .item-reward {
  427. margin-left: 8rpx;
  428. font-size: 24rpx;
  429. font-weight: 400;
  430. letter-spacing: 0rpx;
  431. line-height: 34.75rpx;
  432. color: #000000;
  433. }
  434. .item-tag:first-child {
  435. margin-left: 24rpx;
  436. }
  437. .item-tag {
  438. margin-left: 16rpx;
  439. width: 94rpx;
  440. height: 38rpx;
  441. opacity: 1;
  442. border-radius: 24rpx;
  443. background: #FFFFFF;
  444. border: 1px solid #406CE7;
  445. display: inline-flex;
  446. justify-content: center;
  447. align-content: center;
  448. font-size: 18rpx;
  449. font-weight: 400;
  450. letter-spacing: 0rpx;
  451. // line-height: 26.06rpx;
  452. color: #406CE7;
  453. }
  454. .item-btn {
  455. display: inline-flex;
  456. position: absolute;
  457. right: 0rpx;
  458. width: 123rpx;
  459. height: 42rpx;
  460. border-radius: 30rpx;
  461. border: 1rpx solid #2A82E4;
  462. justify-content: center;
  463. align-items: center;
  464. font-size: 20rpx;
  465. font-weight: 400;
  466. line-height: 28.96px;
  467. color: rgba(64, 108, 231, 1);
  468. }
  469. }
  470. .item-desc {
  471. margin-top: 16rpx;
  472. font-size: 24rpx;
  473. font-weight: 400;
  474. letter-spacing: 0rpx;
  475. line-height: 34.75rpx;
  476. color: #000000;
  477. }
  478. .item-detail-list {
  479. margin-top: 16rpx;
  480. display: grid;
  481. grid-template-columns: repeat(7, 1fr);
  482. .item-detail {
  483. display: flex;
  484. flex-direction: column;
  485. justify-content: center;
  486. align-items: center;
  487. .detail-text {
  488. font-size: 20rpx;
  489. font-weight: 400;
  490. letter-spacing: 0rpx;
  491. line-height: 28.96rpx;
  492. color: rgba(0, 0, 0, 1);
  493. }
  494. .detail-box {
  495. // display: block;
  496. width: 42rpx;
  497. height: 42rpx;
  498. margin-top: 5rpx;
  499. border: 5rpx solid #000000;
  500. }
  501. }
  502. }
  503. }
  504. .func-box {
  505. width: 160rpx;
  506. border-radius: 0rpx 24rpx 24rpx 0rpx;
  507. background: #406CE7;
  508. font-size: 36rpx;
  509. font-weight: 400;
  510. letter-spacing: 0rpx;
  511. line-height: 52.13rpx;
  512. color: #FFFFFF;
  513. display: flex;
  514. justify-content: center;
  515. align-items: center;
  516. flex-direction: column;
  517. }
  518. }
  519. }
  520. </style>