confirm_list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <template>
  2. <view class="confirms">
  3. <nav-bar title="确认订单"></nav-bar>
  4. <view class="contents">
  5. <!-- <view > -->
  6. <view class="item">
  7. <view style="display: flex; justify-content: space-between">
  8. <image
  9. :src="$method.splitImgHost(detail.coverUrl)"
  10. style="height: 120rpx; width: 204rpx; border-radius: 16rpx"
  11. ></image>
  12. <view class="right_con" style="margin-left: 20rpx">
  13. <view style="color: #333333; font-size: 30rpx; font-weight: bold">
  14. {{ detail.goodsName }}
  15. </view>
  16. <view class="priceTag"> ¥ {{ detail.standPrice }} </view>
  17. <view
  18. class="input_c"
  19. v-if="detail.templateType != null && detail.goodsType == 1"
  20. >
  21. <view
  22. v-if="detail.templateType == 'class'"
  23. style="
  24. display: flex;
  25. justify-content: space-between;
  26. align-items: center;
  27. height: 56rpx;
  28. padding: 8rpx;
  29. border-radius: 8rpx;
  30. "
  31. @click="openPopup(0)"
  32. >
  33. <view style="color: #666666; font-size: 24rpx">{{
  34. gradeIndex < 0 ? "选择班级" : gradeList[gradeIndex].className
  35. }}</view>
  36. <view
  37. ><u-icon name="arrow-down" color="#999999" size="28"></u-icon
  38. ></view>
  39. </view>
  40. <view
  41. v-if="detail.templateType == 'apply'"
  42. style="
  43. display: flex;
  44. justify-content: space-between;
  45. align-items: center;
  46. height: 56rpx;
  47. padding: 8rpx;
  48. border-radius: 8rpx;
  49. "
  50. @click="openPopup(1)"
  51. >
  52. <view style="color: #666666; font-size: 24rpx">{{
  53. !applyAreas.areaName
  54. ? "报考地区"
  55. : examDate.examineName +
  56. "-" +
  57. applyAreas.areaName +
  58. "-" +
  59. applyAreas.cityName
  60. }}</view>
  61. <view
  62. ><u-icon name="arrow-down" color="#999999" size="28"></u-icon
  63. ></view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- </view> -->
  70. </view>
  71. <view class="bottomBox safeArea">
  72. <view class="sums">
  73. <text class="all_sum">订单金额:</text>
  74. <text class="priceTag">¥ {{ detail.standPrice }}</text>
  75. </view>
  76. <view style="display: flex; color: #ffffff; align-items: center">
  77. <view class="btn2" :class="{ able: isAble() }" @click="goBuy()"
  78. >确认购买</view
  79. >
  80. </view>
  81. </view>
  82. <u-popup v-model="show" mode="bottom" border-radius="40">
  83. <view class="popup_box">
  84. <view class="check_head">
  85. <!-- <view class="line1"></view> -->
  86. <view class="grade">选择班级</view>
  87. <u-icon
  88. name="close"
  89. color="#CFCFCF"
  90. size="30"
  91. @click="closePop(0)"
  92. ></u-icon>
  93. </view>
  94. <!-- <u-line color="#D6D6DB" /> -->
  95. <view class="check_con">
  96. <scroll-view scroll-y="true" style="height: 580rpx">
  97. <view>
  98. <u-radio-group v-model="gradeValue" @change="radioGroupChange">
  99. <view
  100. v-for="(item, index) in gradeList"
  101. :key="index"
  102. class="items_c"
  103. >
  104. <view class="border_c">
  105. <view>
  106. <u-radio
  107. shape="circle"
  108. active-color="#FC3F3F"
  109. :name="index"
  110. :disabled="
  111. item.studentNum > 0 &&
  112. item.studentNum == item.studentUpper
  113. "
  114. >
  115. <view
  116. :class="
  117. index == gradeValue
  118. ? 'white-box blue-box'
  119. : 'white-box'
  120. "
  121. >
  122. <view>
  123. <view class="blackTxt">{{ item.className }}</view>
  124. <Class-time-tip :classInfo="item"></Class-time-tip>
  125. </view>
  126. </view>
  127. </u-radio>
  128. </view>
  129. </view>
  130. </view>
  131. </u-radio-group>
  132. </view>
  133. </scroll-view>
  134. </view>
  135. <view class="confrim-btn">
  136. <view class="okBtn" @click="okPopup(0)">确定</view>
  137. </view>
  138. </view>
  139. </u-popup>
  140. <u-popup v-model="show1" mode="bottom" border-radius="40">
  141. <view class="popup_box">
  142. <view class="check_head">
  143. <view class="grade">选择考期/地区</view>
  144. <u-icon
  145. name="close"
  146. color="#CFCFCF"
  147. size="30"
  148. @click="closePop(1)"
  149. ></u-icon>
  150. </view>
  151. <view style="display: flex; height: 550rpx">
  152. <view style="width: 50%">
  153. <view class="topTxt">考期</view>
  154. <view>
  155. <picker-view
  156. :indicator-style="indicatorStyle"
  157. :value="value"
  158. @change="bindChangeE"
  159. class="picker-view"
  160. >
  161. <picker-view-column>
  162. <view
  163. class="picker-item"
  164. v-for="(item, index) in examine"
  165. :key="index"
  166. >{{ item.examineName }}</view
  167. >
  168. </picker-view-column>
  169. </picker-view>
  170. </view>
  171. </view>
  172. <view style="width: 50%">
  173. <view class="topTxt">地区</view>
  174. <view>
  175. <picker-view
  176. :indicator-style="indicatorStyle"
  177. :value="value"
  178. @change="bindChange"
  179. class="picker-view"
  180. >
  181. <picker-view-column>
  182. <view
  183. class="picker-item"
  184. v-for="(item, index) in provinceList"
  185. :key="index"
  186. >{{ item.areaName }}</view
  187. >
  188. </picker-view-column>
  189. <picker-view-column>
  190. <view
  191. class="picker-item"
  192. v-for="(item, index) in cityList"
  193. :key="index"
  194. >{{ item.areaName }}</view
  195. >
  196. </picker-view-column>
  197. </picker-view>
  198. </view>
  199. </view>
  200. </view>
  201. <view class="confrim-btn">
  202. <view class="okBtn" @click="okPopup(1)">确定</view>
  203. </view>
  204. </view>
  205. </u-popup>
  206. </view>
  207. </template>
  208. <script>
  209. import ClassTimeTip from "../../components/common/ClassTimeTip.vue";
  210. import { mapGetters } from "vuex";
  211. export default {
  212. components: { ClassTimeTip },
  213. data() {
  214. return {
  215. gradeValue: 0,
  216. gradeIndex: 0,
  217. id: 0,
  218. indicatorStyle: `height: 50px;`,
  219. showArea: true,
  220. show1: false,
  221. value1: "",
  222. show: false,
  223. detail: {},
  224. gradeList: [],
  225. provinceList: [],
  226. cityList: [],
  227. pAreaIndex: 0,
  228. cAreaIndex: 0,
  229. examine: [],
  230. examIndex: 0,
  231. applyAreas: {},
  232. examDate: {},
  233. applyObj: {
  234. applyAreasJson: null,
  235. examDateJson: null,
  236. },
  237. fromCart: "",
  238. isBK: "", //是不是补考商品
  239. };
  240. },
  241. onPullDownRefresh() {},
  242. onLoad(option) {
  243. this.id = option.id;
  244. this.isBK = option.isBK;
  245. if (option.fromCart) {
  246. this.fromCart = option.fromCart;
  247. }
  248. this.options = option;
  249. this.disCode ? this.getFxDetail() : this.getDetail();
  250. },
  251. onShow() {
  252. /* if(this.current === 2 && this.$method.isLogin()){
  253. this.$refs.refMy.init();
  254. } */
  255. },
  256. methods: {
  257. getExamine(id) {
  258. let self = this;
  259. this.$api.getExamine({ projectId: id }).then((res) => {
  260. if (res.data.code == 200) {
  261. self.examine = res.data.rows;
  262. }
  263. });
  264. },
  265. getCityList(id) {
  266. let self = this;
  267. this.$api.getCityList({ parentId: id }).then((res) => {
  268. if (res.data.code == 200) {
  269. self.cityList = res.data.rows;
  270. }
  271. });
  272. },
  273. getProvinceList() {
  274. let self = this;
  275. if (self.provinceList.length > 0) {
  276. return;
  277. }
  278. this.$api.getProvinceList().then((res) => {
  279. if (res.data.code == 200) {
  280. self.provinceList = res.data.rows;
  281. if (self.provinceList.length > 0) {
  282. self.getCityList(self.provinceList[0].areaId);
  283. }
  284. }
  285. });
  286. },
  287. //弹出框确定
  288. okPopup(index) {
  289. if (index == 0) {
  290. if (!this.checkData()) {
  291. return;
  292. }
  293. this.gradeIndex = this.gradeValue;
  294. this.detail.gradObj = this.gradeList[this.gradeIndex];
  295. this.show = false;
  296. } else {
  297. if (!this.checkAreaData()) {
  298. return;
  299. }
  300. this.examDate = this.examine[this.examIndex];
  301. let pData = this.provinceList[this.pAreaIndex];
  302. let cData = this.cityList[this.cAreaIndex];
  303. this.applyAreas = {
  304. areaName: pData.areaName,
  305. areaId: pData.areaId,
  306. cityId: cData.areaId,
  307. cityName: cData.areaName,
  308. };
  309. this.applyObj.applyAreasJson = JSON.stringify(this.applyAreas);
  310. this.applyObj.examDateJson = JSON.stringify(this.examDate);
  311. this.detail.examDate = this.examDate;
  312. this.detail.applyAreas = this.applyAreas;
  313. this.show1 = false;
  314. }
  315. },
  316. checkAreaData() {
  317. if (this.examine.length == 0) {
  318. uni.showModal({
  319. title: "提示",
  320. content: "请选择考期",
  321. showCancel: false,
  322. });
  323. return false;
  324. }
  325. return true;
  326. },
  327. isAble() {
  328. if (this.detail.templateType == "class" && this.detail.goodsType == 1) {
  329. if (this.gradeValue < 0) {
  330. return false;
  331. }
  332. } else if (
  333. this.detail.templateType == "apply" &&
  334. this.detail.goodsType == 1
  335. ) {
  336. /* if(!this.applyObj.examDateJson){
  337. uni.showModal({
  338. title: "提示",
  339. content: '请选择考期',
  340. showCancel: false
  341. })
  342. return false
  343. } */
  344. }
  345. return true;
  346. },
  347. checkData() {
  348. if (this.detail.templateType == "class" && this.detail.goodsType == 1) {
  349. if (this.gradeValue < 0) {
  350. uni.showModal({
  351. title: "提示",
  352. content: "请选择班级",
  353. showCancel: false,
  354. });
  355. return false;
  356. }
  357. } else if (
  358. this.detail.templateType == "apply" &&
  359. this.detail.goodsType == 1
  360. ) {
  361. // if(!this.applyObj.applyAreasJson){
  362. // uni.showModal({
  363. // title: "提示",
  364. // content: '请选择报考地区',
  365. // showCancel: false
  366. // })
  367. // return false
  368. // }
  369. /* if(!this.applyObj.examDateJson){
  370. uni.showModal({
  371. title: "提示",
  372. content: '请选择考期',
  373. showCancel: false
  374. })
  375. return false
  376. } */
  377. }
  378. return true;
  379. },
  380. radioGroupChange(e) {
  381. console.log(e);
  382. },
  383. goodsGradeList() {
  384. this.$api.goodsGradeList({ goodsId: this.id }).then((res) => {
  385. if (res.data.code == 200) {
  386. this.gradeList = res.data.rows;
  387. if (this.gradeList.length == 0) {
  388. let item = {
  389. className: "系统分班",
  390. gradeId: 0,
  391. };
  392. this.gradeList.push(item);
  393. } else {
  394. let isGradeFull = this.gradeList.every(
  395. (item) =>
  396. item.studentNum > 0 && item.studentNum == item.studentUpper
  397. );
  398. //所有班级都满了
  399. if (isGradeFull) {
  400. let item = {
  401. className: "系统分班",
  402. gradeId: 0,
  403. };
  404. this.gradeList.unshift(item);
  405. }
  406. }
  407. this.detail.gradObj = this.gradeList[this.gradeIndex];
  408. }
  409. });
  410. },
  411. goBuy() {
  412. if (!this.checkData()) {
  413. return;
  414. }
  415. let checkGoodsList = [];
  416. checkGoodsList.push(this.detail);
  417. this.$store.commit("setShoppingCartList", {
  418. shoppingCartList: checkGoodsList,
  419. });
  420. if (this.isBK == "1") {
  421. this.$navTo.togo("/pages2/order/confirm_pay", {
  422. isBK: "1",
  423. ...this.addParam(),
  424. });
  425. } else {
  426. this.$navTo.togo("/pages2/order/confirm_pay", {
  427. ...this.addParam(),
  428. });
  429. }
  430. },
  431. addParam() {
  432. let data = { fromCart: this.fromCart };
  433. if (this.disCode) {
  434. data.distributionCode = this.disCode;
  435. }
  436. if (this.options.linkCode) {
  437. data.linkCode = this.options.linkCode;
  438. }
  439. return data;
  440. },
  441. getDetail() {
  442. let self = this;
  443. this.$api.commonGoodsDetail(this.id).then((res) => {
  444. if (res.data.code == 200) {
  445. self.detail = res.data.data;
  446. if (self.detail.templateType != null && self.detail.goodsType == 1) {
  447. this.goodsGradeList();
  448. }
  449. self.getExamine(self.detail.projectId);
  450. }
  451. });
  452. },
  453. getFxDetail() {
  454. let self = this;
  455. this.$api
  456. .fxGoodsDetail({
  457. goodsId: this.id,
  458. disCode: this.disCode,
  459. })
  460. .then((res) => {
  461. if (res.data.code == 200) {
  462. self.detail = res.data.data;
  463. self.getExamine(self.detail.projectId);
  464. }
  465. });
  466. },
  467. bindChangeE(e) {
  468. console.log(e.detail.value);
  469. this.examIndex = e.detail.value[0];
  470. },
  471. bindChange(e) {
  472. const val = e.detail.value;
  473. if (this.pAreaIndex != e.detail.value[0]) {
  474. this.pAreaIndex = e.detail.value[0];
  475. this.getCityList(this.provinceList[this.pAreaIndex].areaId);
  476. }
  477. if (this.cAreaIndex != e.detail.value[1]) {
  478. this.cAreaIndex = e.detail.value[1];
  479. }
  480. },
  481. openPopup(index) {
  482. if (index == 0) {
  483. this.show = true;
  484. } else {
  485. this.getProvinceList()
  486. this.show1 = true;
  487. }
  488. },
  489. closePop(index) {
  490. if (index == 0) {
  491. this.show = false;
  492. } else {
  493. this.show1 = false;
  494. }
  495. },
  496. },
  497. onReachBottom() {},
  498. computed: {
  499. ...mapGetters(["userInfo"]),
  500. disCode() {
  501. return this.options.distributionCode;
  502. },
  503. },
  504. };
  505. </script>
  506. <style>
  507. page {
  508. background-color: #fff;
  509. }
  510. </style>
  511. <style scoped lang="scss">
  512. .confirms {
  513. width: 100%;
  514. height: 100vh;
  515. // background: #fff;
  516. .contents {
  517. padding: 32rpx 32rpx 132rpx 32rpx;
  518. }
  519. .right_con {
  520. width: 450rpx;
  521. }
  522. }
  523. .picker-item {
  524. height: 50px;
  525. align-items: center;
  526. justify-content: center;
  527. text-align: center;
  528. }
  529. .picker-view {
  530. width: 100%;
  531. height: 420rpx;
  532. text-align: center;
  533. }
  534. .topTxt {
  535. font-size: 30rpx;
  536. color: #666666;
  537. text-align: center;
  538. padding: 20rpx 0;
  539. }
  540. .blackTxt {
  541. font-size: 30rpx;
  542. font-family: PingFang SC;
  543. font-weight: bold;
  544. color: #333333;
  545. }
  546. .blue-box {
  547. background: #ebf5ff;
  548. }
  549. .white-box {
  550. width: 646rpx;
  551. border-radius: 24rpx;
  552. align-items: center;
  553. display: flex;
  554. padding-left: 15rpx;
  555. }
  556. .okBtn {
  557. width: 232rpx;
  558. height: 92rpx;
  559. line-height: 92rpx;
  560. background: #fc3f3f;
  561. border-radius: 120rpx;
  562. color: #ffffff;
  563. text-align: center;
  564. font-size: 32rpx;
  565. font-weight: 500;
  566. }
  567. .confrim-btn {
  568. // border-top:1px solid #eee;
  569. height: 98rpx;
  570. width: 100%;
  571. display: flex;
  572. align-items: center;
  573. justify-content: center;
  574. }
  575. .grade {
  576. // height: 23rpx;
  577. font-size: 32rpx;
  578. color: #222;
  579. // margin: 0 auto;
  580. // margin-top: 15rpx;
  581. font-weight: 500;
  582. text-align: center;
  583. }
  584. .line1 {
  585. width: 80rpx;
  586. height: 8rpx;
  587. background: #999999;
  588. border-radius: 4rpx;
  589. margin: 0 auto;
  590. margin-top: 15rpx;
  591. }
  592. .popup_box {
  593. height: 824rpx;
  594. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  595. border-radius: 28rpx 28rpx 0rpx 0rpx;
  596. .check_head {
  597. padding: 0rpx 32rpx;
  598. display: flex;
  599. align-items: center;
  600. justify-content: space-between;
  601. height: 104rpx;
  602. background: #f2f2f2;
  603. }
  604. .items_c {
  605. padding: 0rpx 32rpx;
  606. }
  607. .border_c {
  608. display: flex;
  609. align-items: center;
  610. padding: 20rpx 0rpx;
  611. border-bottom: 1rpx solid #f2f2f2;
  612. }
  613. }
  614. .item {
  615. width: 100%;
  616. background: #ffffff;
  617. border-radius: 16rpx;
  618. margin-bottom: 20rpx;
  619. }
  620. .priceTag {
  621. font-size: 28rpx;
  622. font-family: PingFang SC;
  623. font-weight: bold;
  624. color: #fc3f3f;
  625. margin-top: 6rpx;
  626. margin-bottom: 16rpx;
  627. }
  628. .input_c {
  629. background: #f8f8f8;
  630. }
  631. .btn2 {
  632. width: 232rpx;
  633. height: 92rpx;
  634. background: #fc3f3f;
  635. border-radius: 120rpx;
  636. // width: 200rpx;
  637. // height: 64rpx;
  638. // background: linear-gradient(0deg, #015EEA, #00C0FA);
  639. text-align: center;
  640. line-height: 92rpx;
  641. &.able {
  642. opacity: 1;
  643. }
  644. }
  645. .bottomBox {
  646. position: fixed;
  647. bottom: 0;
  648. width: 100%;
  649. left: 0;
  650. height: 132rpx;
  651. background-color: #ffffff;
  652. display: flex;
  653. justify-content: space-between;
  654. align-items: center;
  655. box-sizing: unset;
  656. box-shadow: 0px -2px 6px 0px rgba(0, 0, 0, 0.1);
  657. > view {
  658. margin: 0 30rpx;
  659. }
  660. .sums {
  661. display: flex;
  662. }
  663. .all_sum {
  664. font-size: 28rpx;
  665. font-weight: 500;
  666. color: #303030;
  667. }
  668. }
  669. </style>