confirm_list.vue 17 KB

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