confirm_list.vue 12 KB

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