create.vue 11 KB

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