confirm_list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view>
  3. <nav-bar title="确认订单"></nav-bar>
  4. <view style="padding: 8rpx;padding-bottom: 98rpx;">
  5. <view >
  6. <view class="item">
  7. <view style="display: flex;justify-content: space-between;padding: 16rpx;">
  8. <image :src="$method.splitImgHost(detail.coverUrl)" style="height: 134rpx;width: 278rpx;border-radius: 16rpx;"></image>
  9. <view style="margin-left: 20rpx;">
  10. <view style="color: #333333;font-size: 30rpx;font-weight: bold;">
  11. {{detail.goodsName}}
  12. </view>
  13. <view class="priceTag">
  14. ¥ {{detail.standPrice}}
  15. </view>
  16. </view>
  17. </view>
  18. <view v-if="detail.templateType!=null&&detail.goodsType==1">
  19. <u-line color="#D6D6DB" />
  20. <view v-if="detail.templateType=='class'" style="display: flex;justify-content: space-between;align-items: center;height: 80rpx;padding:16rpx;" @click="openPopup(0)">
  21. <view style="color: #666666;font-size: 24rpx;">{{gradeIndex < 0 ?'选择班级':gradeList[gradeIndex].className}}</view>
  22. <view><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
  23. </view>
  24. <view v-if="detail.templateType=='apply'" style="display: flex;justify-content: space-between;align-items: center;height: 80rpx;padding:16rpx;" @click="openPopup(1)">
  25. <view style="color: #666666;font-size: 24rpx;" >{{!applyAreas.areaName?'报考地区':examDate.examineName+'-'+applyAreas.areaName+'-'+applyAreas.cityName}}</view>
  26. <view><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="bottomBox safeArea">
  33. <view class="sums">
  34. <text class="all_sum">订单金额:</text>
  35. <text class="priceTag">¥ {{detail.standPrice}}</text>
  36. </view>
  37. <view style="display: flex;color: #FFFFFF;align-items: center;">
  38. <view class="btn2" :class="{able:isAble()}" @click="goBuy()">确认购买</view>
  39. </view>
  40. </view>
  41. <u-popup v-model="show" mode="bottom" border-radius="40">
  42. <view class="popup_box">
  43. <view style="margin-bottom: 20rpx;">
  44. <view class="line1"></view>
  45. <view class="grade">选择班级</view>
  46. </view>
  47. <u-line color="#D6D6DB" />
  48. <view>
  49. <scroll-view scroll-y="true" style="height: 536rpx;">
  50. <view>
  51. <u-radio-group v-model="gradeValue" @change="radioGroupChange">
  52. <view v-for="(item, index) in gradeList" :key="index" >
  53. <view style="display: flex;align-items: center;padding: 20rpx;">
  54. <view>
  55. <u-radio
  56. shape="circle"
  57. :name="index"
  58. :disabled="item.studentNum > 0 && item.studentNum == item.studentUpper"
  59. >
  60. <view :class="index==gradeValue?'white-box blue-box':'white-box'" >
  61. <view>
  62. <view class="blackTxt">{{item.className}}</view>
  63. <view class="redTxt" v-if="item.classEndTime">有效期至:{{$method.timestampToTime(item.classEndTime)}}</view>
  64. <view class="redTxt" v-if="item.classEndTime">本班还剩{{$method.GetRTime(item.classEndTime)}}天将结束学习</view>
  65. </view>
  66. </view>
  67. </u-radio>
  68. </view>
  69. </view>
  70. </view>
  71. </u-radio-group>
  72. </view>
  73. </scroll-view>
  74. </view>
  75. <view class="confrim-btn">
  76. <view class="okBtn" @click="okPopup(0)">确定</view>
  77. </view>
  78. </view>
  79. </u-popup>
  80. <u-popup v-model="show1" mode="bottom" border-radius="40">
  81. <view class="popup_box">
  82. <view style="margin-bottom: 20rpx;">
  83. <view class="line1"></view>
  84. <view class="grade">选择考期/地区</view>
  85. </view>
  86. <u-line color="#D6D6DB" />
  87. <view style="display: flex;height: 500rpx;">
  88. <view style="width: 50%;">
  89. <view class="topTxt">考期</view>
  90. <view>
  91. <picker-view :indicator-style="indicatorStyle" :value="value" @change="bindChangeE" class="picker-view">
  92. <picker-view-column>
  93. <view class="picker-item" v-for="(item,index) in examine" :key="index">{{item.examineName}}</view>
  94. </picker-view-column>
  95. </picker-view>
  96. </view>
  97. </view>
  98. <view style="width: 50%;">
  99. <view class="topTxt">地区</view>
  100. <view>
  101. <picker-view :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
  102. <picker-view-column>
  103. <view class="picker-item" v-for="(item,index) in provinceList" :key="index">{{item.areaName}}</view>
  104. </picker-view-column>
  105. <picker-view-column>
  106. <view class="picker-item" v-for="(item,index) in cityList" :key="index">{{item.areaName}}</view>
  107. </picker-view-column>
  108. </picker-view>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="confrim-btn">
  113. <view class="okBtn" @click="okPopup(1)">确定</view>
  114. </view>
  115. </view>
  116. </u-popup>
  117. </view>
  118. </template>
  119. <script>
  120. import { mapGetters } from 'vuex';
  121. export default {
  122. components: {
  123. },
  124. data() {
  125. return {
  126. gradeValue:-1,
  127. gradeIndex:-1,
  128. id:0,
  129. indicatorStyle: `height: 50px;`,
  130. showArea:true,
  131. show1:false,
  132. value1:'',
  133. show:false,
  134. detail:{},
  135. gradeList:[],
  136. provinceList:[],
  137. cityList:[],
  138. pAreaIndex:0,
  139. cAreaIndex:0,
  140. examine:[],
  141. examIndex:0,
  142. applyAreas:{},
  143. examDate:{},
  144. applyObj:{
  145. applyAreasJson:null,
  146. examDateJson:null
  147. },
  148. fromCart:'',
  149. isBK:'',//是不是补考商品
  150. };
  151. },
  152. onPullDownRefresh(){
  153. },
  154. onLoad(option) {
  155. this.id = option.id;
  156. this.isBK = option.isBK
  157. if(option.fromCart) {
  158. this.fromCart = option.fromCart
  159. }
  160. this.getDetail()
  161. },
  162. onShow() {
  163. /* if(this.current === 2 && this.$method.isLogin()){
  164. this.$refs.refMy.init();
  165. } */
  166. },
  167. methods: {
  168. getExamine(id) {
  169. let self = this
  170. this.$api.getExamine({projectId:id}).then(res => {
  171. if(res.data.code==200){
  172. self.examine = res.data.rows
  173. }
  174. });
  175. },
  176. getCityList(id) {
  177. let self = this
  178. this.$api.getCityList({parentId:id}).then(res => {
  179. if(res.data.code==200){
  180. self.cityList = res.data.rows
  181. }
  182. });
  183. },
  184. getProvinceList() {
  185. let self = this
  186. if(self.provinceList.length>0){
  187. return
  188. }
  189. this.$api.getProvinceList().then(res => {
  190. if(res.data.code==200){
  191. self.provinceList = res.data.rows
  192. if(self.provinceList.length>0){
  193. self.getCityList(self.provinceList[0].areaId)
  194. }
  195. }
  196. });
  197. },
  198. //弹出框确定
  199. okPopup(index){
  200. if(index==0){
  201. if(!this.checkData()){
  202. return
  203. }
  204. this.gradeIndex = this.gradeValue
  205. this.detail.gradObj = this.gradeList[this.gradeIndex]
  206. this.show = false
  207. }else{
  208. if(!this.checkAreaData()){
  209. return
  210. }
  211. this.examDate = this.examine[this.examIndex]
  212. let pData = this.provinceList[this.pAreaIndex]
  213. let cData = this.cityList[this.cAreaIndex]
  214. this.applyAreas = {areaName:pData.areaName,areaId:pData.areaId,cityId:cData.areaId,cityName:cData.areaName}
  215. this.applyObj.applyAreasJson = JSON.stringify(this.applyAreas)
  216. this.applyObj.examDateJson = JSON.stringify(this.examDate)
  217. this.detail.examDate = this.examDate
  218. this.detail.applyAreas = this.applyAreas
  219. this.show1 = false
  220. }
  221. },
  222. checkAreaData(){
  223. if(this.examine.length==0){
  224. uni.showModal({
  225. title: "提示",
  226. content: '请选择考期',
  227. showCancel: false
  228. })
  229. return false
  230. }
  231. // if(this.provinceList.length==0){
  232. // uni.showModal({
  233. // title: "提示",
  234. // content: '请选择报考地区',
  235. // showCancel: false
  236. // })
  237. // return false
  238. // }
  239. // if(this.cityList.length==0){
  240. // uni.showModal({
  241. // title: "提示",
  242. // content: '请选择报考地区',
  243. // showCancel: false
  244. // })
  245. // return false
  246. // }
  247. return true
  248. },
  249. isAble() {
  250. if(this.detail.templateType=='class'&&this.detail.goodsType==1){
  251. if(this.gradeValue<0){
  252. return false
  253. }
  254. }
  255. else if(this.detail.templateType=='apply'&&this.detail.goodsType==1){
  256. /* if(!this.applyObj.examDateJson){
  257. uni.showModal({
  258. title: "提示",
  259. content: '请选择考期',
  260. showCancel: false
  261. })
  262. return false
  263. } */
  264. }
  265. return true;
  266. },
  267. checkData(){
  268. if(this.detail.templateType=='class'&&this.detail.goodsType==1){
  269. if(this.gradeValue<0){
  270. uni.showModal({
  271. title: "提示",
  272. content: '请选择班级',
  273. showCancel: false
  274. })
  275. return false
  276. }
  277. }
  278. else if(this.detail.templateType=='apply'&&this.detail.goodsType==1){
  279. // if(!this.applyObj.applyAreasJson){
  280. // uni.showModal({
  281. // title: "提示",
  282. // content: '请选择报考地区',
  283. // showCancel: false
  284. // })
  285. // return false
  286. // }
  287. /* if(!this.applyObj.examDateJson){
  288. uni.showModal({
  289. title: "提示",
  290. content: '请选择考期',
  291. showCancel: false
  292. })
  293. return false
  294. } */
  295. }
  296. return true;
  297. },
  298. radioGroupChange(e){
  299. console.log(e);
  300. },
  301. goodsGradeList() {
  302. let self = this
  303. this.$api.goodsGradeList({goodsId:this.id}).then(res => {
  304. if(res.data.code==200){
  305. self.gradeList = res.data.rows
  306. if(self.gradeList.length==0){
  307. let item = {
  308. className:'系统分班',
  309. gradeId:0
  310. }
  311. self.gradeList.push(item)
  312. } else {
  313. let isGradeFull = self.gradeList.every(item => (item.studentNum > 0 && item.studentNum == item.studentUpper))
  314. //所有班级都满了
  315. if(isGradeFull) {
  316. let item = {
  317. className:'系统分班',
  318. gradeId:0
  319. }
  320. self.gradeList.unshift(item)
  321. }
  322. }
  323. }
  324. });
  325. },
  326. goBuy(){
  327. if(!this.checkData()){
  328. return
  329. }
  330. let checkGoodsList = []
  331. checkGoodsList.push(this.detail)
  332. this.$store.commit('setShoppingCartList', {shoppingCartList :checkGoodsList});
  333. if(this.isBK == '1'){
  334. this.$navTo.togo('/pages2/order/confirm_pay',{
  335. isBK : '1',
  336. fromCart:this.fromCart
  337. });
  338. }else{
  339. this.$navTo.togo('/pages2/order/confirm_pay',{
  340. fromCart:this.fromCart
  341. });
  342. }
  343. },
  344. getDetail() {
  345. let self = this
  346. this.$api.commonGoodsDetail(this.id).then(res => {
  347. if(res.data.code==200){
  348. self.detail = res.data.data
  349. self.getExamine(self.detail.projectId)
  350. }
  351. });
  352. },
  353. bindChangeE(e){
  354. console.log(e.detail.value)
  355. this.examIndex = e.detail.value[0]
  356. },
  357. bindChange(e) {
  358. const val = e.detail.value
  359. if(this.pAreaIndex!=e.detail.value[0]){
  360. this.pAreaIndex = e.detail.value[0]
  361. this.getCityList(this.provinceList[this.pAreaIndex].areaId)
  362. }
  363. if(this.cAreaIndex!=e.detail.value[1]){
  364. this.cAreaIndex = e.detail.value[1]
  365. }
  366. },
  367. openPopup(index){
  368. if(index==0){
  369. this.show = true
  370. this.goodsGradeList()
  371. }else{
  372. this.show1 = true
  373. this.getProvinceList()
  374. }
  375. }
  376. },
  377. onReachBottom() {},
  378. computed: { ...mapGetters(['userInfo']) }
  379. };
  380. </script>
  381. <style >
  382. page{
  383. background-color: #EAEEF1;
  384. }
  385. </style>
  386. <style scoped lang="scss">
  387. .picker-item {
  388. height: 50px;
  389. align-items: center;
  390. justify-content: center;
  391. text-align: center;
  392. }
  393. .picker-view {
  394. width: 100%;
  395. height: 420rpx;
  396. text-align: center;
  397. }
  398. .topTxt{
  399. font-size: 30rpx;
  400. color: #666666;
  401. text-align: center;
  402. padding: 20rpx 0;
  403. }
  404. .blackTxt{
  405. font-size: 30rpx;
  406. font-family: PingFang SC;
  407. font-weight: bold;
  408. color: #333333;
  409. }
  410. .redTxt{
  411. font-size: 30rpx;
  412. font-family: PingFang SC;
  413. color: #FF2D55;
  414. margin-top: 13rpx;
  415. }
  416. .blue-box{
  417. background: #EBF5FF;
  418. }
  419. .white-box{
  420. width: 646rpx;
  421. border-radius: 24rpx;
  422. align-items: center;
  423. display: flex;
  424. padding-left: 15rpx;
  425. }
  426. .okBtn{
  427. width: 200rpx;
  428. height: 64rpx;
  429. background: linear-gradient(0deg, #015EEA, #00C0FA);
  430. border-radius: 32rpx;
  431. color: #FFFFFF;
  432. text-align: center;
  433. line-height: 64rpx;
  434. }
  435. .confrim-btn{
  436. border-top:1px solid #eee;
  437. height: 98rpx;
  438. width: 100%;
  439. display: flex;
  440. align-items: center;
  441. justify-content:center;
  442. }
  443. .grade{
  444. height: 23rpx;
  445. font-size: 24rpx;
  446. color: #999999;
  447. margin: 0 auto;
  448. margin-top: 15rpx;
  449. text-align: center;
  450. }
  451. .line1{
  452. width: 80rpx;
  453. height: 8rpx;
  454. background: #999999;
  455. border-radius: 4rpx;
  456. margin: 0 auto;
  457. margin-top: 15rpx;
  458. }
  459. .popup_box {
  460. height: 700rpx;
  461. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  462. border-radius: 32rpx 32rpx 0rpx 0rpx;
  463. }
  464. .item{
  465. width: 100%;
  466. background: #FFFFFF;
  467. border-radius: 16rpx;
  468. margin-bottom: 20rpx;
  469. }
  470. .priceTag{
  471. font-size: 30rpx;
  472. font-family: PingFang SC;
  473. font-weight: bold;
  474. color: #FF2D55;
  475. display: flex;
  476. flex-direction: row-reverse;
  477. }
  478. .btn2{
  479. width: 232rpx;
  480. height: 92rpx;
  481. background: #FC3F3F;
  482. border-radius: 120rpx;
  483. // width: 200rpx;
  484. // height: 64rpx;
  485. // background: linear-gradient(0deg, #015EEA, #00C0FA);
  486. text-align: center;
  487. line-height: 92rpx;
  488. &.able {
  489. opacity: 1;
  490. }
  491. }
  492. .bottomBox{
  493. position: fixed;
  494. bottom: 0;
  495. width: 100%;
  496. left: 0;
  497. height: 132rpx ;
  498. background-color: #FFFFFF;
  499. display: flex;
  500. justify-content: space-between;
  501. align-items: center;
  502. box-sizing: unset;
  503. box-shadow: 0px -2px 6px 0px rgba(0,0,0,0.1000);
  504. >view{
  505. margin: 0 30rpx;
  506. }
  507. .sums {
  508. display: flex;
  509. }
  510. .all_sum {
  511. font-size: 28rpx;
  512. font-weight: 500;
  513. color: #303030;
  514. }
  515. }
  516. </style>