create.vue 13 KB

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