create.vue 13 KB

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