edit.vue 11 KB

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