index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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" :key="index">
  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 style="transform: rotate(180deg);" src="/static/icon/openSwith.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 item.goodsVos" :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="planNow()">马上选课</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. planNow(){
  198. uni.switchTab({
  199. url: '/pages/course/index'
  200. });
  201. },
  202. getUserGoodsList() {
  203. this.$api.courseGoodsList().then(res => {
  204. if (res.data.code === 200) {
  205. this.goodsList = res.data.rows;
  206. }
  207. });
  208. },
  209. //删除计划
  210. delWorker(option) {
  211. var data = {
  212. planId: option.planId,
  213. status: -1
  214. };
  215. let self = this;
  216. this.$api.editsystemplan(data).then(res => {
  217. uni.setStorageSync('updateHome', 1);
  218. self.getList();
  219. });
  220. },
  221. swipeMonth(index) {
  222. this.isOpen = false;
  223. this.haveNextMonth = false;
  224. this.havePreviousMonth = false;
  225. this.monthIndex = this.monthIndex + index;
  226. this.currentMonth = this.currentMonth + index;
  227. let item = this.listItem.calendarStudyVo[this.monthIndex];
  228. this.calendarStudyVo = item;
  229. this.workList = this.calendarStudyVo.goodsVos;
  230. if (this.monthIndex > 0) {
  231. this.havePreviousMonth = true;
  232. }
  233. if (this.monthIndex < this.listItem.calendarStudyVo.length - 1) {
  234. this.haveNextMonth = true;
  235. }
  236. this.dealDayList();
  237. },
  238. dealMonth() {
  239. let date = new Date();
  240. let currentMonth = date.getMonth() + 1;
  241. this.haveNextMonth = false;
  242. this.havePreviousMonth = false;
  243. this.workList = this.listItem.goodsVos;
  244. if (this.listItem !== undefined) {
  245. for (let i = 0; i < this.listItem.calendarStudyVo.length; i++) {
  246. let item = this.listItem.calendarStudyVo[i];
  247. if (item.month == currentMonth) {
  248. this.monthIndex = i;
  249. this.calendarStudyVo = item;
  250. if (i > 0) {
  251. this.havePreviousMonth = true;
  252. }
  253. if (i < this.listItem.calendarStudyVo.length - 1) {
  254. this.haveNextMonth = true;
  255. }
  256. }
  257. }
  258. this.dealDayList();
  259. }
  260. },
  261. openEdit(item) {
  262. this.listItem = item;
  263. this.isOpen = false;
  264. this.dealMonth();
  265. },
  266. dealDayList() {
  267. let firstItem = this.calendarStudyVo.dayStudyList[0];
  268. this.calendarStudyVo.miniDayStudyList = []; //创建缩放的数组
  269. let date = new Date();
  270. let num = date.getDate();
  271. /* for (let i = 0; i < firstItem.studyDay; i++) {
  272. this.calendarStudyVo.dayStudyList.unshift({ date: 0 });
  273. } */
  274. let todayIndex;
  275. let todayItem;
  276. for (let i = 0; i < this.calendarStudyVo.dayStudyList.length; i++) {
  277. let item = this.calendarStudyVo.dayStudyList[i];
  278. item.color = 0;
  279. if (item.date == num) {
  280. if (date.getMonth() + 1 == this.calendarStudyVo.month) {
  281. item.color = 3;
  282. }
  283. todayIndex = i;
  284. todayItem = item;
  285. }
  286. if (item.perform == 1) {
  287. item.color = 1;
  288. }
  289. if (item.perform == 2) {
  290. item.color = 2;
  291. }
  292. item.note = item.studyCourseKnob;
  293. if (item.note > 0) {
  294. item.dot = true;
  295. }
  296. }
  297. let start
  298. if(todayItem){
  299. start = todayIndex - todayItem.studyDay;
  300. }else{
  301. //今天在下个月不存在,例如31号
  302. todayIndex = this.calendarStudyVo.dayStudyList.length-1
  303. todayItem = this.calendarStudyVo.dayStudyList[todayIndex]
  304. start = todayIndex - todayItem.studyDay;
  305. }
  306. /* this.calendarStudyVo.miniDayStudyList = []
  307. for(let i=start;i<start + 7;i++){
  308. this.calendarStudyVo.miniDayStudyList.push(this.calendarStudyVo.dayStudyList[i])
  309. } */
  310. console.log(this.calendarStudyVo.miniDayStudyList,789)
  311. this.calendarStudyVo.miniDayStudyList = this.calendarStudyVo.dayStudyList.slice(start, start + 7);
  312. this.showDayList = this.calendarStudyVo.miniDayStudyList;
  313. },
  314. jumpDetail(item) {
  315. this.$navTo.togo('/pages2/wd/course', {
  316. id: item.goodsId
  317. });
  318. return;
  319. },
  320. replay(index) {
  321. if (index == 0) {
  322. return '日';
  323. }
  324. if (index == 1) {
  325. return '一';
  326. }
  327. if (index == 2) {
  328. return '二';
  329. }
  330. if (index == 3) {
  331. return '三';
  332. }
  333. if (index == 4) {
  334. return '四';
  335. }
  336. if (index == 5) {
  337. return '五';
  338. }
  339. if (index == 6) {
  340. return '六';
  341. }
  342. },
  343. getList() {
  344. let self = this;
  345. this.$api.getsystemplanlist({ status: 1 }).then(result => {
  346. result.data.rows.forEach((item, index) => {
  347. item.show = 'none';
  348. });
  349. self.list = result.data.rows;
  350. if (result.data.rows.length > 0) {
  351. self.listItem = self.list[0];
  352. self.dealMonth();
  353. if (self.list.length > 0) {
  354. self.listItem = self.list[0];
  355. self.dealMonth();
  356. self.havePlan = true;
  357. }
  358. } else {
  359. self.havePlan = false;
  360. }
  361. self.updateHomePlan();
  362. });
  363. },
  364. updateHomePlan() {
  365. /* const pages = getCurrentPages(); //获取页面栈
  366. const beforePage = pages[pages.length - 2]; //前一个页面
  367. beforePage.$vm.updateHomePlan(); */
  368. },
  369. newPlan() {
  370. this.$navTo.togo('/pages2/plan/create');
  371. },
  372. edit(item) {
  373. this.$navTo.togo('/pages2/plan/edit', {
  374. id: item.planId
  375. });
  376. },
  377. swipeChange(e, item) {
  378. item.show = e;
  379. },
  380. openShow(item) {
  381. if (item.show == 'none') {
  382. item.show = 'right';
  383. } else {
  384. item.show = 'none';
  385. }
  386. },
  387. updateHomePlan() {
  388. const pages = getCurrentPages(); //获取页面栈
  389. const beforePage = pages[pages.length - 2]; //前一个页面
  390. // beforePage.$vm.updateHomePlan();
  391. },
  392. close_calendar() {
  393. this.isOpen = false;
  394. this.showDayList = this.calendarStudyVo.miniDayStudyList;
  395. },
  396. oepn_calendar() {
  397. this.isOpen = true;
  398. this.showDayList = this.calendarStudyVo.dayStudyList;
  399. },
  400. random(min, max) {
  401. return Math.floor(Math.random() * (max - min)) + min;
  402. }
  403. }
  404. };
  405. </script>
  406. <style scope>
  407. .dis_ffs {
  408. display: flex;
  409. flex-direction: column;
  410. align-items: center;
  411. justify-content: center;
  412. }
  413. .tipBtn {
  414. width: 160rpx;
  415. height: 56rpx;
  416. background: #007aff;
  417. border-radius: 16rpx;
  418. color: #ffffff;
  419. text-align: center;
  420. line-height: 56rpx;
  421. margin-top: 30rpx;
  422. }
  423. .tipBox {
  424. display: flex;
  425. align-items: center; /*垂直居中*/
  426. justify-content: center; /*水平居中*/
  427. flex-direction: column;
  428. margin-top: 40%;
  429. }
  430. .tip {
  431. color: #999999;
  432. font-size: 32rpx;
  433. }
  434. .newPlan {
  435. width: 200rpx;
  436. height: 64rpx;
  437. background: #ffffff;
  438. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.15);
  439. border-radius: 32rpx;
  440. font-size: 24rpx;
  441. font-family: PingFang SC;
  442. font-weight: bold;
  443. color: #32467b;
  444. text-align: center;
  445. line-height: 64rpx;
  446. position: fixed;
  447. bottom: 60rpx;
  448. left: 50%;
  449. transform: translateX(-50%);
  450. }
  451. .operate_img3 {
  452. background: #3478f6;
  453. }
  454. .operate_img2 {
  455. background: #f09a37;
  456. }
  457. .operate_img1 {
  458. background: #eb4d3d;
  459. }
  460. .operate_img {
  461. width: 45rpx;
  462. height: 45rpx;
  463. border-radius: 50%;
  464. padding: 20rpx;
  465. margin: 10rpx 0;
  466. }
  467. .operate {
  468. height: 418rpx;
  469. width: 90rpx;
  470. display: flex;
  471. flex-direction: column;
  472. align-items: center;
  473. justify-content: center;
  474. }
  475. .item_t2 {
  476. font-size: 23rpx;
  477. color: #32467b;
  478. }
  479. .item_date {
  480. width: 26rpx;
  481. height: 26rpx;
  482. background: #32467b;
  483. border-radius: 50%;
  484. margin-left: 20rpx;
  485. font-size: 18rpx;
  486. color: #fefeff;
  487. text-align: center;
  488. }
  489. .r_t2 {
  490. font-size: 20rpx;
  491. font-family: PingFang SC;
  492. font-weight: 400;
  493. color: #0c141f;
  494. white-space: pre-wrap;
  495. }
  496. .r_image {
  497. width: 278rpx;
  498. height: 134rpx;
  499. border-radius: 16rpx;
  500. }
  501. .img_more {
  502. width: 26rpx;
  503. height: 26rpx;
  504. }
  505. .item_t1 {
  506. font-size: 30rpx;
  507. font-family: PingFang SC;
  508. font-weight: 500;
  509. color: #32467b;
  510. }
  511. .list_item_bac1 {
  512. background: linear-gradient(45deg, rgba(172, 203, 238, 0.2), rgba(231, 240, 253, 0.2));
  513. }
  514. .list_item_bac2 {
  515. background: linear-gradient(45deg, rgba(255, 232, 206, 0.3), rgba(251, 184, 160, 0.3));
  516. }
  517. .list_item {
  518. width: 100%;
  519. min-height: 418rpx;
  520. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.05);
  521. border-radius: 24rpx;
  522. margin-top: 20rpx;
  523. padding: 15rpx;
  524. }
  525. .date_dot {
  526. width: 6rpx;
  527. height: 6rpx;
  528. background: #ffcc00;
  529. border-radius: 50%;
  530. margin: 0 auto;
  531. }
  532. .date_note {
  533. border-radius: 50%;
  534. width: 29rpx;
  535. height: 29rpx;
  536. border: 1px solid #ffcc00;
  537. font-size: 18rpx;
  538. color: #ffcc00;
  539. text-align: center;
  540. display: inline-block;
  541. position: absolute;
  542. top: -19rpx;
  543. right: 9rpx;
  544. }
  545. .circle_num {
  546. border-radius: 50%;
  547. width: 29rpx;
  548. height: 29rpx;
  549. border: 1px solid #ffcc00;
  550. font-size: 18rpx;
  551. color: #ffcc00;
  552. text-align: center;
  553. display: inline-block;
  554. margin: 5rpx;
  555. }
  556. .date_t2 {
  557. font-size: 30rpx;
  558. font-family: PingFang SC;
  559. font-weight: 500;
  560. color: #2f4379;
  561. }
  562. .date_line_close {
  563. width: 40rpx;
  564. height: 20rpx;
  565. }
  566. .date_line {
  567. width: 40rpx;
  568. height: 6rpx;
  569. background: #7f8caf;
  570. border-radius: 2rpx;
  571. }
  572. .date_num {
  573. width: 14%;
  574. text-align: center;
  575. position: relative;
  576. display: inline-block;
  577. margin-top: 20rpx;
  578. }
  579. .date_num_color0 {
  580. color: #32467b;
  581. }
  582. .date_num_color1 {
  583. color: #34c759;
  584. }
  585. .date_num_color2 {
  586. color: #ff3b30;
  587. }
  588. .date_num_color3 {
  589. color: #ffffff;
  590. background-color: #ffcc00;
  591. border-radius: 50%;
  592. width: 40rpx;
  593. height: 40rpx;
  594. display: inline-block;
  595. }
  596. .card_date {
  597. width: 14%;
  598. text-align: center;
  599. color: #7f8caf;
  600. }
  601. .date_t1 {
  602. font-size: 24rpx;
  603. font-family: PingFang SC;
  604. font-weight: bold;
  605. color: #2f4379;
  606. width: 100%;
  607. text-align: center;
  608. padding: 20rpx 0;
  609. }
  610. .card {
  611. width: 100%;
  612. background: #ffffff;
  613. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.05);
  614. border-radius: 24rpx;
  615. padding-bottom: 20rpx;
  616. }
  617. page {
  618. background: #fdfdfd;
  619. }
  620. </style>