confirm_list.vue 13 KB

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