index.vue 17 KB

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