create.vue 13 KB

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