create.vue 15 KB

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