SignIn.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <div class="entry-list-container">
  6. <div class="tab-header">
  7. <span class="tab-title">每日签到</span>
  8. </div>
  9. <div class="content-body">
  10. <div class="figures">
  11. <div class="figure-card">
  12. <div class="figure">{{ signDays }}</div>
  13. <div class="attention">
  14. <span class="text">本月累计签到天数</span>
  15. </div>
  16. </div>
  17. <div class="figure-card">
  18. <div class="figure">{{ integral }}</div>
  19. <div class="attention">
  20. <span class="text">本月签到获得积分</span>
  21. </div>
  22. </div>
  23. </div>
  24. <calendar
  25. showPrepNext
  26. :markDate="markDate"
  27. @clickDate="clickDate"
  28. @changeMonth="changeMonth"
  29. />
  30. </div>
  31. </div>
  32. </div>
  33. <div class="index-aside aside" :class="{ 'sticky top': isActive }">
  34. <div class="signin-tip sidebar-block signin">
  35. <div class="first-line">
  36. <button @click="signIn" v-if="dataInfo.signStatus == 0" class="btn">
  37. 立即签到
  38. </button>
  39. <button v-else class="btn signed-btn">今日已签到</button>
  40. </div>
  41. </div>
  42. <div class="signin-tip sidebar-block">
  43. <div class="avatar">
  44. <el-avatar :size="50" :src="avatarUrl"></el-avatar>
  45. <span class="name">{{ dataInfo.userName }}</span>
  46. </div>
  47. <div class="info">
  48. <div class="info-item">
  49. <div class="item-itle">部门:</div>
  50. <div class="item-content">{{ dataInfo.deptName }}</div>
  51. </div>
  52. <div class="info-item">
  53. <div class="item-itle">积分:</div>
  54. <div class="item-content blue">
  55. {{ dataInfo.surplusIntegral }}积分
  56. </div>
  57. </div>
  58. <div class="info-item">
  59. <div class="item-itle">排行:</div>
  60. <div class="item-content blue">5名</div>
  61. </div>
  62. <div class="info-item">
  63. <div class="item-itle">勋章:</div>
  64. <div class="item-content blue">{{ dataInfo.medalCount }}枚</div>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="sidebar-block sticky-block">
  69. <div class="avatar">
  70. <el-avatar :size="50" :src="avatarUrl"></el-avatar>
  71. <span class="name">{{ dataInfo.userName }}</span>
  72. </div>
  73. <div class="info">
  74. <div class="info-item">
  75. <div class="item-itle">部门:</div>
  76. <div class="item-content">{{ dataInfo.deptName }}</div>
  77. </div>
  78. <div class="info-item">
  79. <div class="item-itle">积分:</div>
  80. <div class="item-content blue">
  81. {{ dataInfo.surplusIntegral }}积分
  82. </div>
  83. </div>
  84. <div class="info-item">
  85. <div class="item-itle">排行:</div>
  86. <div class="item-content blue">5名</div>
  87. </div>
  88. <div class="info-item">
  89. <div class="item-itle">勋章:</div>
  90. <div class="item-content blue">{{ dataInfo.medalCount }}枚</div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import { sign, signInfo,useInfo } from "@/api/allApi";
  100. import calendar from '@/components/Calendar'
  101. export default {
  102. components: {
  103. calendar,
  104. },
  105. data() {
  106. return {
  107. signDays:'20',
  108. integral:'20',
  109. markDate: ["2023/5/4"],
  110. isActive: false,
  111. dataInfo: {},
  112. avatarUrl:
  113. "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
  114. dataList: [],
  115. };
  116. },
  117. created() {
  118. this.getSignInfo();
  119. this.getUserInfo();
  120. },
  121. methods: {
  122. // 点击日期
  123. clickDate(date) {
  124. console.log(date);
  125. },
  126. // 切换月份
  127. changeMonth(date) {
  128. console.log(date);
  129. },
  130. getUserInfo() {
  131. const parmas = {
  132. userId: 13683797487,
  133. };
  134. useInfo(parmas).then((response) => {
  135. this.dataInfo = response.data.data;
  136. this.avatarUrl = this.dataInfo.httpFile + this.dataInfo.headImage;
  137. });
  138. },
  139. getSignInfo() {
  140. const parmas = {
  141. userId: 13683797487,
  142. };
  143. signInfo(parmas).then((response) => {
  144. this.markDate = response.data.data.signDays;
  145. this.integral = response.data.data.integral;
  146. this.signDays = response.data.data.signDays.length;
  147. });
  148. },
  149. signIn() {
  150. sign().then((response) => {
  151. this.$notify({
  152. title: '成功',
  153. message: '签到成功!',
  154. type: 'success'
  155. });
  156. // this.getSignInfo();
  157. });
  158. },
  159. // 保存滚动值,这是兼容的写法
  160. handleScroll() {
  161. let scrollTop =
  162. window.pageYOffset ||
  163. document.documentElement.scrollTop ||
  164. document.body.scrollTop;
  165. if (scrollTop >= 550) {
  166. this.isActive = true;
  167. } else {
  168. this.isActive = false;
  169. }
  170. },
  171. },
  172. mounted() {
  173. window.addEventListener("scroll", this.handleScroll);
  174. },
  175. destroyed() {
  176. // 离开该页面需要移除这个监听的事件,不然会报错
  177. window.removeEventListener("scroll", this.handleScroll);
  178. },
  179. };
  180. </script>
  181. <style scoped>
  182. .timeline-container {
  183. margin: 0 auto;
  184. }
  185. .timeline-entry-list {
  186. margin-right: 17.5rem;
  187. border-radius: 2px;
  188. width: 720px;
  189. position: relative;
  190. }
  191. .entry-list-container {
  192. background-color: #fff;
  193. border-radius: 4px;
  194. min-height: 500px;
  195. }
  196. .entry-list-container .tab-header {
  197. display: flex;
  198. align-items: center;
  199. justify-content: space-between;
  200. padding: 20px 20px 16px;
  201. border-bottom: 1px solid #e5e6eb;
  202. overflow: hidden;
  203. }
  204. .tab-header .tab-title {
  205. white-space: nowrap;
  206. font-size: 18px;
  207. font-weight: 600;
  208. }
  209. .content-body {
  210. padding: 10px 20px 16px;
  211. }
  212. .content-body .figures {
  213. display: flex;
  214. flex-shrink: 0;
  215. min-width: 586px;
  216. justify-content: space-around;
  217. background-color: #f7f8fa;
  218. border-radius: 2px;
  219. padding: 20px 55px;
  220. box-sizing: border-box;
  221. margin-top: 10px;
  222. }
  223. .figure-card {
  224. display: flex;
  225. flex-direction: column;
  226. justify-content: center;
  227. align-items: center;
  228. }
  229. .figure-card .figure {
  230. font-weight: 700;
  231. font-size: 32px;
  232. color: #1d2129;
  233. line-height: 36px;
  234. font-family: DIN Alternate;
  235. white-space: nowrap;
  236. margin-right: 12px;
  237. position: relative;
  238. top: 1px;
  239. }
  240. .figure-card .attention {
  241. display: flex;
  242. align-items: flex-end;
  243. margin-top: 4px;
  244. }
  245. .figure-card .attention .text {
  246. color: #86909c;
  247. font-weight: 400;
  248. font-size: 14px;
  249. white-space: nowrap;
  250. }
  251. .entry-list {
  252. width: 100%;
  253. background-color: #fff;
  254. position: relative;
  255. }
  256. .list-item:hover {
  257. background: #fafafa;
  258. }
  259. .list-item {
  260. position: relative;
  261. cursor: pointer;
  262. padding: 12px 20px 0;
  263. }
  264. .list-item .meta-container {
  265. display: flex;
  266. align-items: center;
  267. }
  268. .list-item .meta-container .user-message {
  269. max-width: 162px;
  270. font-size: 13px;
  271. line-height: 22px;
  272. color: #4e5969;
  273. white-space: nowrap;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. word-break: break-all;
  277. }
  278. .list-item .meta-container .dividing {
  279. line-height: 22px;
  280. width: 1px;
  281. height: 14px;
  282. background: #e5e6eb;
  283. margin: 0 8px;
  284. }
  285. .list-item .meta-container .date {
  286. line-height: 22px;
  287. font-size: 13px;
  288. color: #86909c;
  289. }
  290. .list-item .main {
  291. margin-top: 6px;
  292. padding-bottom: 12px;
  293. display: flex;
  294. border-bottom: 1px solid #e5e6eb;
  295. }
  296. .list-item .main .info-box {
  297. flex-grow: 1;
  298. }
  299. .list-item .main .info-box .title:visited {
  300. color: #86909c;
  301. }
  302. .list-item .main .info-box .title {
  303. font-weight: 700;
  304. font-size: 16px;
  305. line-height: 24px;
  306. color: #1d2129;
  307. margin-bottom: 8px;
  308. display: -webkit-box;
  309. overflow: hidden;
  310. text-overflow: ellipsis;
  311. -webkit-box-orient: vertical;
  312. -webkit-line-clamp: 1;
  313. }
  314. .list-item .main .info-box .description {
  315. font-weight: 400;
  316. font-size: 13px;
  317. line-height: 22px;
  318. color: #86909c;
  319. display: -webkit-box;
  320. overflow: hidden;
  321. text-overflow: ellipsis;
  322. -webkit-box-orient: vertical;
  323. -webkit-line-clamp: 2;
  324. }
  325. .list-item .thumb {
  326. flex: 0 0 auto;
  327. width: 120px;
  328. height: 80px;
  329. margin-left: 24px;
  330. border-radius: 2px;
  331. }
  332. .aside {
  333. position: absolute;
  334. top: 0;
  335. right: 0;
  336. z-index: 1;
  337. }
  338. .aside.index-aside {
  339. width: 16.3rem;
  340. }
  341. .hot-list-wrap {
  342. /* padding: 1.33rem 0 0.66rem; */
  343. background-color: #fff;
  344. border-radius: 4px;
  345. margin-bottom: 1.25rem;
  346. }
  347. .timeline-index-view.sidebar-block {
  348. box-shadow: none;
  349. }
  350. .sidebar-block {
  351. background-color: #fff;
  352. box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  353. border-radius: 2px;
  354. margin-bottom: 1rem;
  355. font-size: 1.16rem;
  356. line-height: 1.29;
  357. border-radius: 4px;
  358. color: #333;
  359. }
  360. .signin-tip {
  361. padding: 20px;
  362. background-color: #fff;
  363. box-sizing: border-box;
  364. }
  365. .first-line {
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. }
  370. .first-line .btn {
  371. cursor: pointer;
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. width: 240px;
  376. height: 56px;
  377. border-radius: 4px;
  378. font-size: 18px;
  379. font-weight: 500;
  380. color: #fff;
  381. background-color: #007fff;
  382. border: none;
  383. }
  384. .first-line .signed-btn {
  385. background-color: #e8f3ff;
  386. color: #1e80ff;
  387. }
  388. .first-line .btn-text {
  389. font-size: 14px;
  390. font-weight: 400;
  391. white-space: nowrap;
  392. }
  393. .first-line .title {
  394. color: #1d2129;
  395. font-size: 16px;
  396. font-weight: 600;
  397. line-height: 24px;
  398. }
  399. .second-line {
  400. color: #8a919f;
  401. font-size: 12px;
  402. font-weight: 400;
  403. line-height: 24px;
  404. margin-top: 2px;
  405. }
  406. .first-line .title-days {
  407. margin-left: 4px;
  408. color: #1e80ff;
  409. }
  410. .sidebar-block .avatar {
  411. display: flex;
  412. flex-direction: column;
  413. justify-content: center;
  414. align-items: center;
  415. }
  416. .avatar .name {
  417. margin-top: 2px;
  418. font-size: 1rem;
  419. font-weight: 600;
  420. color: #252933;
  421. }
  422. .sidebar-block .info {
  423. margin-top: 5px;
  424. }
  425. .info .info-item {
  426. font-size: 1rem;
  427. display: flex;
  428. justify-content: space-between;
  429. line-height: 2rem;
  430. }
  431. .info-item .blue {
  432. color: #1e80ff;
  433. }
  434. .sidebar-block.sticky-block {
  435. padding: 20px;
  436. background-color: #fff;
  437. box-sizing: border-box;
  438. position: fixed;
  439. box-shadow: none;
  440. opacity: 0;
  441. transition: all 0.2s;
  442. width: 16.3rem;
  443. z-index: -1;
  444. top: 67px;
  445. pointer-events: none;
  446. }
  447. .index-aside.sticky.top .sticky-block {
  448. top: 20px;
  449. }
  450. .index-aside.sticky .sticky-block {
  451. opacity: 1;
  452. top: 80px;
  453. z-index: 5;
  454. pointer-events: all;
  455. }
  456. </style>