detail.vue 13 KB

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