create.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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="#fff" size="20" @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" :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: '2021-01-01',
  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. calendar_show: false,
  127. maxDate: '2023-01-01',
  128. minDate: '',
  129. list3: [
  130. {
  131. name: '一',
  132. checked: false,
  133. disabled: false,
  134. id: 1
  135. },
  136. {
  137. name: '二',
  138. checked: false,
  139. disabled: false,
  140. id: 2
  141. },
  142. {
  143. name: '三',
  144. checked: false,
  145. disabled: false,
  146. id: 3
  147. },
  148. {
  149. name: '四',
  150. checked: false,
  151. disabled: false,
  152. id: 4
  153. },
  154. {
  155. name: '五',
  156. checked: false,
  157. disabled: false,
  158. id: 5
  159. },
  160. {
  161. name: '六',
  162. checked: false,
  163. disabled: false,
  164. id: 6
  165. },
  166. {
  167. name: '日',
  168. checked: false,
  169. disabled: false,
  170. id: 0
  171. }
  172. ],
  173. selWeek: '',
  174. index_review: 4,
  175. array_review: [1, 2, 3, 4, 5, 6, 7]
  176. };
  177. },
  178. onLoad(option) {
  179. this.minDate = this.$method.timestampToTime(new Date().getTime() / 1000);
  180. this.form.startDate = this.minDate;
  181. this.form.endDate = this.$method.timestampToTime(new Date().getTime() / 1000 + 24 * 3600 * 30);
  182. this.getGoods();
  183. // this.getMyCourse();
  184. },
  185. onShow() {},
  186. methods: {
  187. getGoods() {
  188. var self = this;
  189. self.$api.courseGoodsList().then(res => {
  190. if (res.data.code === 200) {
  191. if (res.data.rows.length) {
  192. for (let i = 0; i < res.data.rows.length; i++) {
  193. res.data.rows[i].checked = false;
  194. res.data.rows[i].disabled = false;
  195. res.data.rows[i].coverUrl = self.$method.splitImgHost(res.data.rows[i].coverUrl);
  196. }
  197. }
  198. self.list2 = res.data.rows;
  199. }
  200. });
  201. },
  202. resultForm(int) {
  203. if (this.list.length == 0) {
  204. uni.showModal({
  205. title: '提示',
  206. content: '请选择课程',
  207. showCancel: false
  208. });
  209. return;
  210. }
  211. // if (this.form.week == '请选择') {
  212. // uni.showModal({
  213. // title: '提示',
  214. // content: '请选择学习频率',
  215. // showCancel: false
  216. // });
  217. // return;
  218. // }
  219. let goodsId = [];
  220. for (let i = 0; i < this.list.length; i++) {
  221. goodsId.push(this.list[i].goodsId);
  222. }
  223. let ss = this.form.week.split('、');
  224. let weekArray = [];
  225. for (let i = 0; i < ss.length; i++) {
  226. if (ss[i] == '日') {
  227. weekArray.push(0);
  228. }
  229. if (ss[i] == '一') {
  230. weekArray.push(1);
  231. }
  232. if (ss[i] == '二') {
  233. weekArray.push(2);
  234. }
  235. if (ss[i] == '三') {
  236. weekArray.push(3);
  237. }
  238. if (ss[i] == '四') {
  239. weekArray.push(4);
  240. }
  241. if (ss[i] == '五') {
  242. weekArray.push(5);
  243. }
  244. if (ss[i] == '六') {
  245. weekArray.push(6);
  246. }
  247. }
  248. let data = {
  249. goodsId: goodsId,
  250. reminderTime: this.form.time,
  251. examDate: this.$method.TimeTotimestamp(this.form.date),
  252. startTime: this.$method.TimeTotimestamp(this.form.startDate),
  253. endTime: this.$method.TimeTotimestamp(this.form.endDate),
  254. studyCount: weekArray,
  255. studyDay: this.array_review[this.index_review],
  256. status: 1
  257. };
  258. console.log(data);
  259. if (int === 1) {
  260. this.$api.getsystemplanlistPlan(data).then(result => {
  261. if (result.data.code == 200) {
  262. this.studyNums = result.data.data.studyCourseKnob;
  263. } else {
  264. uni.showToast({
  265. title: result.data.msg,
  266. icon: 'none',
  267. duration: 2000
  268. });
  269. }
  270. });
  271. } else {
  272. this.$api.addsystemplan(data).then(result => {
  273. if (result.data.code == 200) {
  274. uni.showModal({
  275. title: '提示',
  276. content: '提交成功',
  277. showCancel: false,
  278. success: function(resst) {
  279. if (resst.confirm) {
  280. uni.setStorageSync('updateHome',1)
  281. uni.navigateBack();
  282. }
  283. }
  284. });
  285. } else {
  286. uni.showToast({
  287. title: result.data.msg,
  288. icon: 'none',
  289. duration: 2000
  290. });
  291. }
  292. });
  293. }
  294. },
  295. selItem(item) {
  296. console.log(34);
  297. item.checked = !item.checked;
  298. },
  299. getMyCourse() {
  300. let data = {
  301. typeId: 1
  302. };
  303. let self = this;
  304. this.$api.getUserBuy(data).then(result => {
  305. if (result.data.data.courseVoList !== null) {
  306. if (result.data.data.courseVoList.length > 0) {
  307. for (let i = 0; i < result.data.data.courseVoList.length; i++) {
  308. let item = result.data.data.courseVoList[i];
  309. item.checked = false;
  310. item.disabled = false;
  311. item.coverUrl = self.$method.splitImgHost(item.coverUrl);
  312. }
  313. self.list2 = result.data.data.courseVoList;
  314. }
  315. }
  316. });
  317. },
  318. bindPickerChangeReview(e) {
  319. this.index_review = e.detail.value;
  320. },
  321. week_submit() {
  322. if (this.selWeek == '') {
  323. uni.showModal({
  324. title: '提示',
  325. content: '至少选择一个'
  326. });
  327. return;
  328. }
  329. this.form.week = this.selWeek;
  330. this.week_show = false;
  331. },
  332. openWeek() {
  333. this.week_show = true;
  334. this.selWeek = this.form.week;
  335. let that = this;
  336. this.list3.map(val => {
  337. val.checked = false;
  338. if (that.form.week.indexOf(val.name) != -1) {
  339. val.checked = true;
  340. }
  341. });
  342. },
  343. checkboxGroupChange(e) {
  344. this.selWeek = e.join('、');
  345. },
  346. openCalendar() {
  347. this.calendar_show = true;
  348. },
  349. change(e) {
  350. console.log(e);
  351. this.form.startDate = e.startDate;
  352. this.form.endDate = e.endDate;
  353. },
  354. bindTimeChange(e) {
  355. this.form.time = e.detail.value;
  356. },
  357. bindDateChange(e) {
  358. this.form.date = e.detail.value;
  359. },
  360. submit() {
  361. let that = this;
  362. this.list2.map(val => {
  363. if (val.checked) {
  364. that.list.push(val);
  365. }
  366. });
  367. this.checkSameItem();
  368. this.show = false;
  369. if (this.list.length) {
  370. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  371. }
  372. },
  373. checkboxChange(e) {},
  374. checkSameItem() {
  375. this.list2.map(val => {
  376. val.disabled = false;
  377. this.list.map(val1 => {
  378. if (val.goodsId == val1.goodsId) {
  379. val.disabled = true;
  380. }
  381. val.checked = false;
  382. });
  383. });
  384. },
  385. delItem(index) {
  386. this.list.splice(index, 1);
  387. if (this.list.length === 0) {
  388. this.form.category = '';
  389. } else {
  390. this.form.category = this.list[0].educationName + '-' + this.list[0].projectName + '-' + this.list[0].businessName;
  391. }
  392. },
  393. openSel() {
  394. console.log(this.list2, 321);
  395. this.show = true;
  396. this.checkSameItem();
  397. }
  398. }
  399. };
  400. </script>
  401. <style>
  402. ::-webkit-scrollbar {
  403. width: 0;
  404. height: 0;
  405. color: transparent;
  406. }
  407. .u-drawer-content-visible {
  408. border-radius: 32rpx 32rpx 0rpx 0rpx;
  409. overflow: hidden;
  410. }
  411. </style>
  412. <style scope lang="scss">
  413. .dis_ss {
  414. display: flex;
  415. align-items: center;
  416. justify-content: center;
  417. width: 100%;
  418. padding: 22rpx 0rpx;
  419. border-bottom: 1rpx solid #eee;
  420. }
  421. .getNums {
  422. margin-left: 14rpx;
  423. color: #007aff;
  424. font-size: 30rpx;
  425. font-weight: bold;
  426. display: inline-block;
  427. text-decoration: underline;
  428. }
  429. .submit_btn {
  430. width: 526rpx;
  431. height: 80rpx;
  432. background: #007aff;
  433. border-radius: 40rpx;
  434. text-align: center;
  435. line-height: 80rpx;
  436. color: #ffffff;
  437. margin: 30rpx auto;
  438. }
  439. .picker {
  440. text-align: right;
  441. }
  442. .form {
  443. padding: 0 16rpx !important;
  444. margin-top: 16rpx;
  445. }
  446. input {
  447. text-align: right;
  448. }
  449. .popup_item {
  450. width: 100%;
  451. border-radius: 32rpx;
  452. margin: 10rpx 0;
  453. padding: 0 20rpx;
  454. display: flex;
  455. .course_item {
  456. display: flex;
  457. align-items: center;
  458. width:660rpx;
  459. padding:26rpx;
  460. &.selected {
  461. background:#EBF5FF;
  462. border-radius: 24rpx;
  463. }
  464. }
  465. }
  466. .popup_list {
  467. position:relative;
  468. flex:1;
  469. padding: 0 20rpx;
  470. .list_in {
  471. position: absolute;
  472. left:0;
  473. top:0;
  474. width:100%;
  475. height:100%;
  476. overflow: scroll;
  477. }
  478. }
  479. .submit_wrap {
  480. border-top:1px solid #eee;
  481. background:#fff;
  482. padding:18rpx 0;
  483. .title_l {
  484. margin:0 auto;
  485. text-align: center;
  486. line-height: 64rpx;
  487. width: 200rpx;
  488. height: 64rpx;
  489. background: linear-gradient(0deg, #015EEA, #00C0FA);
  490. border-radius: 32rpx;
  491. color:#fff;
  492. font-size: 30rpx;
  493. }
  494. }
  495. .title_r {
  496. font-size: 30rpx;
  497. font-family: PingFang SC;
  498. font-weight: bold;
  499. color: #2f4379;
  500. }
  501. .grade {
  502. font-size: 24rpx;
  503. color: #999999;
  504. margin: 0 auto;
  505. margin: 10rpx 0;
  506. text-align: center;
  507. }
  508. .line1 {
  509. width: 80rpx;
  510. height: 8rpx;
  511. background: #999999;
  512. border-radius: 4rpx;
  513. margin: 0 auto;
  514. margin-top: 15rpx;
  515. }
  516. .popup_box {
  517. height: 680rpx;
  518. display: flex;
  519. flex-direction: column;
  520. }
  521. .del_icon {
  522. border-radius:50%;
  523. overflow: hidden;
  524. background:rgba(255,54,87,1);
  525. width: 30rpx;
  526. height: 30rpx;
  527. position: absolute;
  528. right: -15rpx;
  529. top: -15rpx;
  530. display: flex;
  531. align-items: center;
  532. justify-content: center;
  533. }
  534. .item_add {
  535. background: #f9f9f9;
  536. border-radius: 14rpx;
  537. width: 100%;
  538. height: 134rpx;
  539. text-align: center;
  540. line-height: 134rpx;
  541. }
  542. .item text {
  543. font-size: 24rpx;
  544. color: #0c141f;
  545. }
  546. .item image {
  547. border-radius: 14rpx;
  548. width: 100%;
  549. height: 134rpx;
  550. }
  551. .item {
  552. width:278rpx;
  553. display: inline-block;
  554. position: relative;
  555. margin-right:16rpx;
  556. }
  557. .list_box {
  558. width: 100%;
  559. background: #ffffff;
  560. border-radius: 16rpx;
  561. padding: 24rpx;
  562. }
  563. page {
  564. background:rgba(234,238,241,1)
  565. }
  566. </style>