index.vue 15 KB

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