index.vue 15 KB

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