confirm_list.vue 12 KB

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