create.vue 14 KB

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