create.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view style="padding: 16rpx;">
  3. <view class="list_box">
  4. <view class="item" v-for="(item, index) in list" :key="index">
  5. <image :src="item.coverUrl"></image>
  6. <view style="height: 80rpx;overflow: hidden;">
  7. <text >{{ item.goodsName }}</text>
  8. <text style="color:#999;margin-left:12rpx;">{{ item.secAllNum }}节</text>
  9. </view>
  10. <view class="del_icon"><u-icon name="close" color="#EB4D3D" size="40" @click="delItem(index)"></u-icon></view>
  11. </view>
  12. <view class="item" style="vertical-align: top;">
  13. <view class="item_add" @click="openSel"><u-icon name="plus-circle-fill" color="#007AFF" size="32"></u-icon></view>
  14. <view style="color:#999;text-align: center;">添加网课</view>
  15. </view>
  16. </view>
  17. <view class="list_box form">
  18. <u-form :model="form" ref="uForm">
  19. <u-form-item label="课程类型" :label-width="auto">
  20. <view style="line-height: 40rpx;text-align: right;" v-if="form.category">{{ form.category }}</view>
  21. <view v-else style="text-align: right;">请添加网课</view>
  22. </u-form-item>
  23. <u-form-item label="考试日期" prop="birth" :label-width="auto">
  24. <picker mode="date" :start="stateDate" :value="form.date" @change="bindDateChange">
  25. <view class="picker">{{ form.date }}</view>
  26. </picker>
  27. </u-form-item>
  28. <u-form-item label="学习提醒" prop="birth" :label-width="auto">
  29. <picker mode="time" :value="form.time" @change="bindTimeChange">
  30. <view class="picker">{{ form.time }}</view>
  31. </picker>
  32. </u-form-item>
  33. <u-form-item label="学习频率" :label-width="auto">
  34. <view class="picker" @click="openWeek">{{ form.week }}</view>
  35. </u-form-item>
  36. <u-form-item label="复习天数" :label-width="auto">
  37. <picker @change="bindPickerChangeReview" :value="index_review" :range="array_review">
  38. <view class="picker">{{ array_review[index_review] }}</view>
  39. </picker>
  40. </u-form-item>
  41. <u-form-item label="起止日期" :label-width="auto">
  42. <view class="picker" @click="openCalendar">{{ form.startDate }}~{{ form.endDate }}</view>
  43. </u-form-item>
  44. </u-form>
  45. </view>
  46. <view class="list_box form">
  47. <view class="dis_ss">
  48. <image src="@/static/icon/computeIcon.png" style="width:32rpx;height:32rpx;" mode=""></image>
  49. <text class="getNums" @click="resultForm(1)">点击计算</text>
  50. </view>
  51. <view style="padding: 25rpx 0rpx; color: #999;text-align: center;font-size: 30rpx;">
  52. 根据当前计划每个学习日需完成
  53. <text style="color: #FF9500;margin: 0rpx 10rpx;font-size: 30rpx;font-weight: bold;">{{ studyNums }}</text>
  54. 个学时
  55. </view>
  56. </view>
  57. <u-calendar v-model="calendar_show" :min-date="minDate" :mode="calendar" @change="change" :max-date="maxDate"></u-calendar>
  58. <!-- 弹框-->
  59. <u-popup v-model="week_show" mode="bottom">
  60. <view style="height: 400rpx;text-align: center">
  61. <view style="padding-top: 100rpx;padding-left: 40rpx;text-align: center;">
  62. <u-checkbox-group @change="checkboxGroupChange">
  63. <u-checkbox v-model="item.checked" v-for="(item, index) in list3" :key="index" :name="item.name">{{ item.name }}</u-checkbox>
  64. </u-checkbox-group>
  65. <view class="title_l" @click="week_submit" style="margin: 50rpx auto;">确认</view>
  66. </view>
  67. </view>
  68. </u-popup>
  69. <u-popup v-model="show" mode="bottom">
  70. <view class="popup_box">
  71. <view>
  72. <view class="line1"></view>
  73. <view class="grade">选择课程</view>
  74. <u-line></u-line>
  75. </view>
  76. <view class="popup_list" v-if="list2.length !== 0">
  77. <scroll-view class="list_in" scroll-y="true">
  78. <view class="popup_item" v-for="(item, index) in list2" :key="index">
  79. <u-checkbox
  80. :disabled="item.disabled"
  81. @change="checkboxChange"
  82. shape="circle"
  83. active-color="#007AFF"
  84. v-model="item.checked"
  85. :key="index"
  86. :name="item.goodsId"
  87. >
  88. <view class="course_item" :class="{selected:item.checked}">
  89. <view style="display: flex;align-items: center;"><image :src="item.coverUrl" style="width: 278rpx;height: 134rpx;"></image></view>
  90. <view style="margin: 16rpx;">
  91. <view>{{ item.goodsName }}</view>
  92. <view style="color:#999;">{{ item.secAllNum }}节</view>
  93. </view>
  94. </view>
  95. </u-checkbox>
  96. </view>
  97. </scroll-view>
  98. </view>
  99. <view class="popup_list" v-else><u-empty text="请前往购买课程" mode="list"></u-empty></view>
  100. <view class="submit_wrap">
  101. <view class="title_l" @click="submit">确认</view>
  102. </view>
  103. </view>
  104. </u-popup>
  105. <view @click="resultForm" class="submit_btn">确认计划</view>
  106. </view>
  107. </template>
  108. <script>
  109. export default {
  110. data() {
  111. return {
  112. week_show: false,
  113. form: {
  114. category: '',
  115. date: this.$method.timestampToTime(new Date().valueOf()/1000, true),
  116. time: '20:30',
  117. startDate: '2021-05-07',
  118. endDate: '2021-05-31',
  119. week: '一、三、五'
  120. },
  121. studyNums: '?',
  122. calendar: 'range',
  123. list: [],
  124. list2: [],
  125. show: false,
  126. stateDate:this.$method.timestampToTime(new Date().valueOf()/1000, true),
  127. calendar_show: false,
  128. maxDate: '2023-01-01',
  129. minDate: '',
  130. businessId:'',
  131. list3: [
  132. {
  133. name: '一',
  134. checked: false,
  135. disabled: false,
  136. id: 1
  137. },
  138. {
  139. name: '二',
  140. checked: false,
  141. disabled: false,
  142. id: 2
  143. },
  144. {
  145. name: '三',
  146. checked: false,
  147. disabled: false,
  148. id: 3
  149. },
  150. {
  151. name: '四',
  152. checked: false,
  153. disabled: false,
  154. id: 4
  155. },
  156. {
  157. name: '五',
  158. checked: false,
  159. disabled: false,
  160. id: 5
  161. },
  162. {
  163. name: '六',
  164. checked: false,
  165. disabled: false,
  166. id: 6
  167. },
  168. {
  169. name: '日',
  170. checked: false,
  171. disabled: false,
  172. id: 0
  173. }
  174. ],
  175. selWeek: '',
  176. index_review: 4,
  177. array_review: [1, 2, 3, 4, 5, 6, 7]
  178. };
  179. },
  180. onLoad(option) {
  181. this.minDate = this.$method.timestampToTime(new Date().getTime() / 1000);
  182. this.form.startDate = this.minDate;
  183. this.form.endDate = this.$method.timestampToTime(new Date().getTime() / 1000 + 24 * 3600 * 30);
  184. this.getGoods();
  185. // this.getMyCourse();
  186. },
  187. onShow() {},
  188. methods: {
  189. getGoods() {
  190. var self = this;
  191. self.$api.courseGoodsList().then(res => {
  192. if (res.data.code === 200) {
  193. if (res.data.rows.length) {
  194. for (let i = 0; i < res.data.rows.length; i++) {
  195. res.data.rows[i].checked = false;
  196. res.data.rows[i].disabled = false;
  197. res.data.rows[i].coverUrl = self.$method.splitImgHost(res.data.rows[i].coverUrl);
  198. }
  199. }
  200. self.list2 = res.data.rows;
  201. }
  202. });
  203. },
  204. resultForm(int) {
  205. if (this.list.length == 0) {
  206. uni.showModal({
  207. title: '提示',
  208. content: '请选择课程',
  209. showCancel: false
  210. });
  211. return;
  212. }
  213. // if (this.form.week == '请选择') {
  214. // uni.showModal({
  215. // title: '提示',
  216. // content: '请选择学习频率',
  217. // showCancel: false
  218. // });
  219. // return;
  220. // }
  221. let goodsId = [];
  222. for (let i = 0; i < this.list.length; i++) {
  223. goodsId.push(this.list[i].goodsId);
  224. }
  225. let ss = this.form.week.split('、');
  226. let weekArray = [];
  227. for (let i = 0; i < ss.length; i++) {
  228. if (ss[i] == '日') {
  229. weekArray.push(0);
  230. }
  231. if (ss[i] == '一') {
  232. weekArray.push(1);
  233. }
  234. if (ss[i] == '二') {
  235. weekArray.push(2);
  236. }
  237. if (ss[i] == '三') {
  238. weekArray.push(3);
  239. }
  240. if (ss[i] == '四') {
  241. weekArray.push(4);
  242. }
  243. if (ss[i] == '五') {
  244. weekArray.push(5);
  245. }
  246. if (ss[i] == '六') {
  247. weekArray.push(6);
  248. }
  249. }
  250. let data = {
  251. goodsId: goodsId,
  252. reminderTime: this.form.time,
  253. examDate: this.$method.TimeTotimestamp(this.form.date),
  254. startTime: this.$method.TimeTotimestamp(this.form.startDate),
  255. endTime: this.$method.TimeTotimestamp(this.form.endDate),
  256. studyCount: weekArray,
  257. studyDay: this.array_review[this.index_review],
  258. status: 1
  259. };
  260. console.log(data);
  261. if (int === 1) {
  262. this.$api.getsystemplanlistPlan(data).then(result => {
  263. if (result.data.code == 200) {
  264. this.studyNums = result.data.data.studyCourseKnob;
  265. } else {
  266. uni.showToast({
  267. title: result.data.msg,
  268. icon: 'none',
  269. duration: 2000
  270. });
  271. }
  272. });
  273. } else {
  274. this.$api.addsystemplan(data).then(result => {
  275. if (result.data.code == 200) {
  276. uni.showModal({
  277. title: '提示',
  278. content: '提交成功',
  279. showCancel: false,
  280. success: function(resst) {
  281. if (resst.confirm) {
  282. uni.setStorageSync('updateHome',1)
  283. uni.navigateBack();
  284. }
  285. }
  286. });
  287. } else {
  288. uni.showToast({
  289. title: result.data.msg,
  290. icon: 'none',
  291. duration: 2000
  292. });
  293. }
  294. });
  295. }
  296. },
  297. selItem(item) {
  298. console.log(34);
  299. item.checked = !item.checked;
  300. },
  301. getMyCourse() {
  302. let data = {
  303. typeId: 1
  304. };
  305. let self = this;
  306. this.$api.getUserBuy(data).then(result => {
  307. if (result.data.data.courseVoList !== null) {
  308. if (result.data.data.courseVoList.length > 0) {
  309. for (let i = 0; i < result.data.data.courseVoList.length; i++) {
  310. let item = result.data.data.courseVoList[i];
  311. item.checked = false;
  312. item.disabled = false;
  313. item.coverUrl = self.$method.splitImgHost(item.coverUrl);
  314. }
  315. self.list2 = result.data.data.courseVoList;
  316. }
  317. }
  318. });
  319. },
  320. bindPickerChangeReview(e) {
  321. this.index_review = e.detail.value;
  322. },
  323. week_submit() {
  324. if (this.selWeek == '') {
  325. uni.showModal({
  326. title: '提示',
  327. content: '至少选择一个'
  328. });
  329. return;
  330. }
  331. this.form.week = this.selWeek;
  332. this.week_show = false;
  333. },
  334. openWeek() {
  335. this.week_show = true;
  336. this.selWeek = this.form.week;
  337. let that = this;
  338. this.list3.map(val => {
  339. val.checked = false;
  340. if (that.form.week.indexOf(val.name) != -1) {
  341. val.checked = true;
  342. }
  343. });
  344. },
  345. checkboxGroupChange(e) {
  346. this.selWeek = e.join('、');
  347. },
  348. openCalendar() {
  349. this.calendar_show = true;
  350. },
  351. change(e) {
  352. console.log(e);
  353. this.form.startDate = e.startDate;
  354. this.form.endDate = e.endDate;
  355. },
  356. bindTimeChange(e) {
  357. this.form.time = e.detail.value;
  358. },
  359. bindDateChange(e) {
  360. this.form.date = e.detail.value;
  361. },
  362. submit() {
  363. let that = this;
  364. this.list2.map(val => {
  365. if (val.checked) {
  366. that.list.push(val);
  367. }
  368. });
  369. this.checkSameItem();
  370. this.show = false;
  371. if (this.list.length) {
  372. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  373. }
  374. },
  375. checkboxChange(e) {
  376. let goodsId = e.name;
  377. if(e.value) { //勾选
  378. this.businessId = this.list2.find(listItem => listItem.goodsId == goodsId).businessId;
  379. this.list2.forEach(listItem => {
  380. if(listItem.businessId != this.businessId) {
  381. listItem.disabled = true;
  382. }
  383. })
  384. } else { //取消
  385. this.$nextTick(() => {
  386. let checkedNum = this.list2.filter(listItem => {
  387. if(listItem.checked) {
  388. return true;
  389. } else {
  390. if(this.list.length) {
  391. return true;
  392. } else {
  393. return false;
  394. }
  395. }
  396. }).length;
  397. if(checkedNum == 0) { //全部取消,且没有已选择的
  398. this.businessId = '';
  399. this.list2.forEach(listItem => {
  400. console.log(listItem)
  401. listItem.disabled = false;
  402. })
  403. }
  404. })
  405. }
  406. },
  407. checkSameItem() {
  408. this.list2.map(val => {
  409. val.disabled = false;
  410. if(this.businessId) {
  411. if(val.businessId != this.businessId) {
  412. val.disabled = true;
  413. }
  414. }
  415. this.list.map(val1 => {
  416. if (val.goodsId == val1.goodsId) {
  417. val.disabled = true;
  418. }
  419. val.checked = false;
  420. });
  421. });
  422. },
  423. delItem(index) {
  424. this.list.splice(index, 1);
  425. if (this.list.length === 0) {
  426. this.businessId = '';
  427. this.form.category = '';
  428. } else {
  429. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  430. }
  431. },
  432. openSel() {
  433. console.log(this.list2, 321);
  434. this.show = true;
  435. this.checkSameItem();
  436. }
  437. }
  438. };
  439. </script>
  440. <style>
  441. ::-webkit-scrollbar {
  442. width: 0;
  443. height: 0;
  444. color: transparent;
  445. }
  446. .u-drawer-content-visible {
  447. border-radius: 32rpx 32rpx 0rpx 0rpx;
  448. overflow: hidden;
  449. }
  450. </style>
  451. <style scope lang="scss">
  452. .dis_ss {
  453. display: flex;
  454. align-items: center;
  455. justify-content: center;
  456. width: 100%;
  457. padding: 22rpx 0rpx;
  458. border-bottom: 1rpx solid #eee;
  459. }
  460. .getNums {
  461. margin-left: 14rpx;
  462. color: #007aff;
  463. font-size: 30rpx;
  464. font-weight: bold;
  465. display: inline-block;
  466. text-decoration: underline;
  467. }
  468. .submit_btn {
  469. width: 526rpx;
  470. height: 80rpx;
  471. background: #007aff;
  472. border-radius: 40rpx;
  473. text-align: center;
  474. line-height: 80rpx;
  475. color: #ffffff;
  476. margin: 30rpx auto;
  477. }
  478. .picker {
  479. text-align: right;
  480. }
  481. .form {
  482. padding: 0 16rpx !important;
  483. margin-top: 16rpx;
  484. }
  485. input {
  486. text-align: right;
  487. }
  488. .popup_item {
  489. width: 100%;
  490. border-radius: 32rpx;
  491. margin: 10rpx 0;
  492. padding: 0 20rpx;
  493. display: flex;
  494. .course_item {
  495. display: flex;
  496. align-items: center;
  497. width:660rpx;
  498. padding:26rpx;
  499. &.selected {
  500. background:#EBF5FF;
  501. border-radius: 24rpx;
  502. }
  503. }
  504. }
  505. .popup_list {
  506. position:relative;
  507. flex:1;
  508. padding: 0 20rpx;
  509. .list_in {
  510. position: absolute;
  511. left:0;
  512. top:0;
  513. width:100%;
  514. height:100%;
  515. overflow: scroll;
  516. }
  517. }
  518. .submit_wrap {
  519. border-top:1px solid #eee;
  520. background:#fff;
  521. padding:18rpx 0;
  522. .title_l {
  523. margin:0 auto;
  524. text-align: center;
  525. line-height: 64rpx;
  526. width: 200rpx;
  527. height: 64rpx;
  528. background: linear-gradient(0deg, #015EEA, #00C0FA);
  529. border-radius: 32rpx;
  530. color:#fff;
  531. font-size: 30rpx;
  532. }
  533. }
  534. .title_r {
  535. font-size: 30rpx;
  536. font-family: PingFang SC;
  537. font-weight: bold;
  538. color: #2f4379;
  539. }
  540. .grade {
  541. font-size: 24rpx;
  542. color: #999999;
  543. margin: 0 auto;
  544. margin: 10rpx 0;
  545. text-align: center;
  546. }
  547. .line1 {
  548. width: 80rpx;
  549. height: 8rpx;
  550. background: #999999;
  551. border-radius: 4rpx;
  552. margin: 0 auto;
  553. margin-top: 15rpx;
  554. }
  555. .popup_box {
  556. height: 680rpx;
  557. display: flex;
  558. flex-direction: column;
  559. }
  560. .del_icon {
  561. border-radius:50%;
  562. overflow: hidden;
  563. background:rgba(255,54,87,1);
  564. width: 30rpx;
  565. height: 30rpx;
  566. position: absolute;
  567. right: -15rpx;
  568. top: -15rpx;
  569. display: flex;
  570. align-items: center;
  571. justify-content: center;
  572. }
  573. .item_add {
  574. background: #f9f9f9;
  575. border-radius: 14rpx;
  576. width: 100%;
  577. height: 134rpx;
  578. text-align: center;
  579. line-height: 134rpx;
  580. }
  581. .item text {
  582. font-size: 24rpx;
  583. color: #0c141f;
  584. }
  585. .item image {
  586. border-radius: 14rpx;
  587. width: 100%;
  588. height: 134rpx;
  589. }
  590. .item {
  591. width:278rpx;
  592. display: inline-block;
  593. position: relative;
  594. margin-right:16rpx;
  595. }
  596. .list_box {
  597. width: 100%;
  598. background: #ffffff;
  599. border-radius: 16rpx;
  600. padding: 24rpx;
  601. }
  602. page {
  603. background:rgba(234,238,241,1)
  604. }
  605. </style>