index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <view v-if="havePlan">
  4. <view class="card" v-if="havePlan">
  5. <view class="date_t1">
  6. <u-icon name="arrow-left" size="28" v-if="havePreviousMonth" @click="swipeMonth(-1)"></u-icon>
  7. <text style="padding: 0 15rpx;">{{ calendarStudyVo.year }}年 {{ calendarStudyVo.month }}月</text>
  8. <u-icon name="arrow-right" size="28" v-if="haveNextMonth" @click="swipeMonth(1)"></u-icon>
  9. </view>
  10. <view style="width: 100%;display: flex;justify-content:center;margin-top: 20rpx;">
  11. <view v-for="(item, index) in date" :key="index" class="card_date">{{ item }}</view>
  12. </view>
  13. <view style="width: 100%;margin-top: 20rpx;">
  14. <view v-for="(item, index) in showDayList" :key="index" class="date_num">
  15. <view v-if="item.color == 0" class="date_num_color0" v-show="item.date > 0">
  16. {{ item.date }}
  17. <view v-if="item.note > 0" class="date_note">{{ item.note }}</view>
  18. <view v-if="item.dot" class="date_dot"></view>
  19. </view>
  20. <view v-if="item.color == 1" class="date_num_color1">
  21. {{ item.date }}
  22. <view v-if="item.note > 0" class="date_note">{{ item.note }}</view>
  23. <view v-if="item.dot" class="date_dot"></view>
  24. </view>
  25. <view v-if="item.color == 2" class="date_num_color2">
  26. {{ item.date }}
  27. <view v-if="item.note > 0" class="date_note">{{ item.note }}</view>
  28. <view v-if="item.dot" class="date_dot"></view>
  29. </view>
  30. <view v-if="item.color == 3" class="date_num_color3">
  31. {{ item.date }}
  32. <view v-if="item.note > 0" class="date_note">{{ item.note }}</view>
  33. <view v-if="item.dot" class="date_dot"></view>
  34. </view>
  35. </view>
  36. </view>
  37. <view style="width: 100%;display: flex;justify-content: center;" v-if="isOpen == false">
  38. <view @click="oepn_calendar" style="height: 20rpx;width: 40rpx;padding:20rpx 0;"><view class="date_line"></view></view>
  39. </view>
  40. <view style="width: 100%;display: flex;justify-content: center;" v-else>
  41. <image class="date_line_close" @click="close_calendar" src="/static/close_card.png"></image>
  42. </view>
  43. <view v-for="(item, index) in workList">
  44. <view style="margin-left: 30rpx;margin-top: 10rpx;display: flex;align-items: center;" @click="jumpDetail(item)">
  45. <text class="date_t2">{{ item.courseName }}</text>
  46. <view class="circle_num" style="margin-left: 20rpx;">{{ item.chapterNum }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 列表-->
  51. <view>
  52. <uni-swipe-action>
  53. <uni-swipe-action-item :autoClose="false" @change="swipeChange($event, item)" :show="item.show" v-for="(item, index) in list" :key="index">
  54. <view class="list_item" :class="index % 2 == 0 ? 'list_item_bac1' : 'list_item_bac2'" @click.stop="openEdit(item)">
  55. <u-row>
  56. <u-col span="11">
  57. <text class="item_t1">{{ item.coursePlanVo[0].categoryName }}:{{ $method.timestampToTime(item.endTime) }}截止</text>
  58. </u-col>
  59. <u-col span="1"><image src="/static/more.png" class="img_more" @click.stop="openShow(item)"></image></u-col>
  60. </u-row>
  61. <view style="margin-top: 30rpx;">
  62. <image :src="$method.splitImgHost(item.coursePlanVo[0].coverUrl)" class="r_image"></image>
  63. <view class="r_t2">{{ item.coursePlanVo[0].courseName }}</view>
  64. </view>
  65. <view style="display: flex;margin-top: 30rpx;">
  66. <text class="item_t2">学习频率:</text>
  67. <view style="display: flex;justify-content:center;">
  68. <view v-for="(item1, index) in item.studyCount" :key="index" class="item_date">{{ replay(item1) }}</view>
  69. </view>
  70. </view>
  71. <view style="display: flex;margin-top: 20rpx;"><text class="item_t2">学习进度:{{item.studyNum}}/{{item.pitchNum}}</text></view>
  72. </view>
  73. <template v-slot:right>
  74. <view class="operate">
  75. <image src="/static/operate_1.png" class="operate_img operate_img1" @click="delWorker(item)"></image>
  76. <image src="/static/operate_2.png" class="operate_img operate_img2"></image>
  77. <image @click="edit(item)" src="/static/operate_3.png" class="operate_img operate_img3"></image>
  78. </view>
  79. </template>
  80. </uni-swipe-action-item>
  81. </uni-swipe-action>
  82. </view>
  83. <view class="newPlan" @click="newPlan()">新建计划</view>
  84. </view>
  85. <view v-else class="tipBox">
  86. <view class="tip">您暂无相关计划哦~</view>
  87. <view class="tipBtn" @click="newPlan()">马上制定~</view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. monthIndex: 0,
  96. haveNextMonth: false,
  97. havePreviousMonth: false,
  98. showDayList: [],
  99. workList: [],
  100. calendarStudyVo: {},
  101. index: 0,
  102. date: ['日', '一', '二', '三', '四', '五', '六'],
  103. list: [],
  104. isOpen: false,
  105. date_num: [
  106. {
  107. num: 20,
  108. color: 0,
  109. note: 0,
  110. dot: false
  111. },
  112. {
  113. num: 21,
  114. color: 1,
  115. note: 0,
  116. dot: false
  117. },
  118. {
  119. num: 22,
  120. color: 0,
  121. note: 0,
  122. dot: true
  123. },
  124. {
  125. num: 23,
  126. color: 2,
  127. note: 0,
  128. dot: false
  129. },
  130. {
  131. num: 24,
  132. color: 1,
  133. note: 0,
  134. dot: false
  135. },
  136. {
  137. num: 25,
  138. color: 3,
  139. note: 2,
  140. dot: false
  141. },
  142. {
  143. num: 26,
  144. color: 0,
  145. note: 1,
  146. dot: true
  147. }
  148. ],
  149. date_use: [],
  150. options: [
  151. {
  152. text: '取消',
  153. style: {
  154. backgroundColor: '#007aff'
  155. }
  156. },
  157. {
  158. text: '确认',
  159. style: {
  160. backgroundColor: '#dd524d'
  161. }
  162. }
  163. ],
  164. dayStudyList: [],
  165. listItem: {},
  166. currentMonth: 0,
  167. havePlan: false
  168. };
  169. },
  170. onLoad(option) {
  171. this.date_use = this.date_num;
  172. },
  173. onShow() {
  174. this.workList = []
  175. this.showDayList = []
  176. this.calendarStudyVo = {}
  177. this.isOpen = false
  178. // this.getList();
  179. },
  180. methods: {
  181. //删除计划
  182. delWorker(option) {
  183. var data = {
  184. planId: option.planId,
  185. status: 0
  186. };
  187. let self = this
  188. this.$api.planupdateGenerate(data).then(res => {
  189. self.getList()
  190. })
  191. },
  192. swipeMonth(index) {
  193. this.isOpen = false;
  194. this.haveNextMonth = false;
  195. this.havePreviousMonth = false;
  196. this.monthIndex = this.monthIndex + index;
  197. this.currentMonth = this.currentMonth + index;
  198. let item = this.listItem.calendarStudyVo[this.monthIndex];
  199. this.calendarStudyVo = item;
  200. this.workList = this.calendarStudyVo.coursePlanVo;
  201. if (this.monthIndex > 0) {
  202. this.havePreviousMonth = true;
  203. }
  204. if (this.monthIndex < this.listItem.calendarStudyVo.length - 1) {
  205. this.haveNextMonth = true;
  206. }
  207. this.dealDayList();
  208. },
  209. dealMonth() {
  210. let date = new Date();
  211. let currentMonth = date.getMonth() + 1;
  212. this.haveNextMonth = false;
  213. this.havePreviousMonth = false;
  214. this.workList = this.listItem.coursePlanVo;
  215. if (this.listItem !== undefined) {
  216. for (let i = 0; i < this.listItem.calendarStudyVo.length; i++) {
  217. let item = this.listItem.calendarStudyVo[i];
  218. if (item.month == currentMonth) {
  219. this.monthIndex = i;
  220. this.calendarStudyVo = item;
  221. if (i > 0) {
  222. this.havePreviousMonth = true;
  223. }
  224. if (i < this.listItem.calendarStudyVo.length - 1) {
  225. this.haveNextMonth = true;
  226. }
  227. }
  228. }
  229. this.dealDayList();
  230. }
  231. },
  232. openEdit(item) {
  233. this.listItem = item;
  234. this.isOpen = false;
  235. this.dealMonth();
  236. },
  237. dealDayList() {
  238. let firstItem = this.calendarStudyVo.dayStudyList[0];
  239. this.calendarStudyVo.miniDayStudyList = []; //创建缩放的数组
  240. let date = new Date();
  241. let num = date.getDate();
  242. for (let i = 0; i < firstItem.studyDay; i++) {
  243. this.calendarStudyVo.dayStudyList.unshift({ date: 0 });
  244. }
  245. let todayIndex;
  246. let todayItem;
  247. for (let i = 0; i < this.calendarStudyVo.dayStudyList.length; i++) {
  248. let item = this.calendarStudyVo.dayStudyList[i];
  249. item.color = 0;
  250. if (item.date == num) {
  251. if (date.getMonth() + 1 == this.calendarStudyVo.month) {
  252. item.color = 3;
  253. }
  254. todayIndex = i;
  255. todayItem = item;
  256. }
  257. if (item.perform == 1) {
  258. item.color = 1;
  259. }
  260. if (item.perform == 2) {
  261. item.color = 2;
  262. }
  263. item.note = item.studyCourseKnob;
  264. if (item.note > 0) {
  265. item.dot = true;
  266. }
  267. }
  268. let start = todayIndex - todayItem.studyDay;
  269. this.calendarStudyVo.miniDayStudyList = this.calendarStudyVo.dayStudyList.slice(start, start + 7);
  270. this.showDayList = this.calendarStudyVo.miniDayStudyList;
  271. },
  272. jumpDetail(item) {
  273. this.$navTo.togo('/pages2/course/detail', {
  274. id: item.courseId
  275. });
  276. return;
  277. },
  278. replay(index) {
  279. if (index == 0) {
  280. return '日';
  281. }
  282. if (index == 1) {
  283. return '一';
  284. }
  285. if (index == 2) {
  286. return '二';
  287. }
  288. if (index == 3) {
  289. return '三';
  290. }
  291. if (index == 4) {
  292. return '四';
  293. }
  294. if (index == 5) {
  295. return '五';
  296. }
  297. if (index == 6) {
  298. return '六';
  299. }
  300. },
  301. getList() {
  302. let self = this;
  303. this.$api.planUserPlan().then(result => {
  304. result.data.data.forEach((item, index) => {
  305. item.show = 'none';
  306. });
  307. self.list = result.data.data;
  308. if(result.data.data.length>0){
  309. self.listItem = self.list[0]
  310. self.dealMonth()
  311. if(self.list.length>0){
  312. self.listItem = self.list[0]
  313. self.dealMonth()
  314. self.havePlan = true
  315. }
  316. }else{
  317. self.havePlan = false
  318. }
  319. self.updateHomePlan()
  320. });
  321. },
  322. updateHomePlan(){
  323. const pages = getCurrentPages(); //获取页面栈
  324. const beforePage = pages[pages.length - 2]; //前一个页面
  325. beforePage.$vm.updateHomePlan();
  326. },
  327. newPlan() {
  328. this.$navTo.togo('/pages2/plan/create');
  329. },
  330. edit(item) {
  331. this.$navTo.togo('/pages2/plan/edit', {
  332. id: item.planId
  333. });
  334. },
  335. swipeChange(e, item) {
  336. item.show = e;
  337. },
  338. openShow(item) {
  339. if (item.show == 'none') {
  340. item.show = 'right';
  341. } else {
  342. item.show = 'none';
  343. }
  344. },
  345. close_calendar() {
  346. this.isOpen = false;
  347. this.showDayList = this.calendarStudyVo.miniDayStudyList;
  348. },
  349. oepn_calendar() {
  350. this.isOpen = true;
  351. this.showDayList = this.calendarStudyVo.dayStudyList;
  352. },
  353. random(min, max) {
  354. return Math.floor(Math.random() * (max - min)) + min;
  355. }
  356. }
  357. };
  358. </script>
  359. <style scope>
  360. .tipBtn{
  361. width: 160rpx;
  362. height: 56rpx;
  363. background: #007AFF;
  364. border-radius: 16rpx;
  365. color: #FFFFFF;
  366. text-align: center;
  367. line-height: 56rpx;
  368. margin-top: 30rpx;
  369. }
  370. .tipBox{
  371. display:flex;
  372. align-items:center;/*垂直居中*/
  373. justify-content: center;/*水平居中*/
  374. flex-direction: column;
  375. margin-top: 40%;
  376. }
  377. .tip{
  378. color: #999999;
  379. font-size: 32rpx;
  380. }
  381. .newPlan {
  382. width: 200rpx;
  383. height: 64rpx;
  384. background: #ffffff;
  385. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.15);
  386. border-radius: 32rpx;
  387. font-size: 24rpx;
  388. font-family: PingFang SC;
  389. font-weight: bold;
  390. color: #32467b;
  391. text-align: center;
  392. line-height: 64rpx;
  393. position: fixed;
  394. bottom: 60rpx;
  395. left: 50%;
  396. transform: translateX(-50%);
  397. }
  398. .operate_img3 {
  399. background: #3478f6;
  400. }
  401. .operate_img2 {
  402. background: #f09a37;
  403. }
  404. .operate_img1 {
  405. background: #eb4d3d;
  406. }
  407. .operate_img {
  408. width: 45rpx;
  409. height: 45rpx;
  410. border-radius: 50%;
  411. padding: 20rpx;
  412. margin: 10rpx 0;
  413. }
  414. .operate {
  415. height: 418rpx;
  416. width: 90rpx;
  417. display: flex;
  418. flex-direction: column;
  419. align-items: center;
  420. justify-content: center;
  421. }
  422. .item_t2 {
  423. font-size: 23rpx;
  424. color: #32467b;
  425. }
  426. .item_date {
  427. width: 26rpx;
  428. height: 26rpx;
  429. background: #32467b;
  430. border-radius: 50%;
  431. margin-left: 20rpx;
  432. font-size: 18rpx;
  433. color: #fefeff;
  434. text-align: center;
  435. }
  436. .r_t2 {
  437. font-size: 20rpx;
  438. font-family: PingFang SC;
  439. font-weight: 400;
  440. color: #0c141f;
  441. }
  442. .r_image {
  443. width: 278rpx;
  444. height: 134rpx;
  445. }
  446. .img_more {
  447. width: 26rpx;
  448. height: 26rpx;
  449. }
  450. .item_t1 {
  451. font-size: 30rpx;
  452. font-family: PingFang SC;
  453. font-weight: 500;
  454. color: #32467b;
  455. }
  456. .list_item_bac1 {
  457. background: linear-gradient(45deg, rgba(172, 203, 238, 0.2), rgba(231, 240, 253, 0.2));
  458. }
  459. .list_item_bac2 {
  460. background: linear-gradient(45deg, rgba(255, 232, 206, 0.3), rgba(251, 184, 160, 0.3));
  461. }
  462. .list_item {
  463. width: 100%;
  464. height: 418rpx;
  465. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.05);
  466. border-radius: 24rpx;
  467. margin-top: 20rpx;
  468. padding: 15rpx;
  469. }
  470. .date_dot {
  471. width: 6rpx;
  472. height: 6rpx;
  473. background: #ffcc00;
  474. border-radius: 50%;
  475. margin: 0 auto;
  476. }
  477. .date_note {
  478. border-radius: 50%;
  479. width: 29rpx;
  480. height: 29rpx;
  481. border: 1px solid #ffcc00;
  482. font-size: 18rpx;
  483. color: #ffcc00;
  484. text-align: center;
  485. display: inline-block;
  486. position: absolute;
  487. top: -19rpx;
  488. right: 9rpx;
  489. }
  490. .circle_num {
  491. border-radius: 50%;
  492. width: 29rpx;
  493. height: 29rpx;
  494. border: 1px solid #ffcc00;
  495. font-size: 18rpx;
  496. color: #ffcc00;
  497. text-align: center;
  498. display: inline-block;
  499. margin: 5rpx;
  500. }
  501. .date_t2 {
  502. font-size: 30rpx;
  503. font-family: PingFang SC;
  504. font-weight: 500;
  505. color: #2f4379;
  506. }
  507. .date_line_close {
  508. width: 40rpx;
  509. height: 20rpx;
  510. }
  511. .date_line {
  512. width: 40rpx;
  513. height: 6rpx;
  514. background: #7f8caf;
  515. border-radius: 2rpx;
  516. }
  517. .date_num {
  518. width: 14%;
  519. text-align: center;
  520. position: relative;
  521. display: inline-block;
  522. margin-top: 20rpx;
  523. }
  524. .date_num_color0 {
  525. color: #32467b;
  526. }
  527. .date_num_color1 {
  528. color: #34c759;
  529. }
  530. .date_num_color2 {
  531. color: #ff3b30;
  532. }
  533. .date_num_color3 {
  534. color: #ffffff;
  535. background-color: #ffcc00;
  536. border-radius: 50%;
  537. width: 40rpx;
  538. height: 40rpx;
  539. display: inline-block;
  540. }
  541. .card_date {
  542. width: 14%;
  543. text-align: center;
  544. color: #7f8caf;
  545. }
  546. .date_t1 {
  547. font-size: 24rpx;
  548. font-family: PingFang SC;
  549. font-weight: bold;
  550. color: #2f4379;
  551. width: 100%;
  552. text-align: center;
  553. padding: 20rpx 0;
  554. }
  555. .card {
  556. width: 100%;
  557. background: #ffffff;
  558. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.05);
  559. border-radius: 24rpx;
  560. padding-bottom: 20rpx;
  561. }
  562. page {
  563. background: #fdfdfd;
  564. }
  565. </style>