| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <template>
- <view>
- <view>
- <!--#ifdef APP-PLUS-->
- <view class="lz-status_bar">
- <view class="lz-top_view"></view>
- </view>
- <!--#endif-->
- <!-- #ifndef MP-WEIXIN -->
- <view class="kaoshi-head">
- <view class="kaoshi-head-top">
- <view class="kaoshi-head-left">
- <view class="iconfont icon-zuojiantou" @tap="$navigateBack"></view>
- </view>
- <view class="kaoshi-head-m">选择科目</view>
- <view class="kaoshi-head-right"></view>
- </view>
- </view>
- <!--#endif-->
- </view>
- <view class="kaoshi-subject">
- <view class="classifybox">
- <view class="classify" v-for="(item,index) in list" :key="index"
- :class="classifytype == index ? 'active' : ''" @tap="changeclassify(index,item.id)">
- <view class="classifytext">{{item.subject_name}}</view>
- </view>
- </view>
- <view class="liebiaobox">
- <view class="class" v-for="(item,index) in classlist" :key="index">
- <view :class="Subject_id == item.id ? 'active' : ''" class="classtext"
- @tap="tap_handle_choice_subject(item)">{{item.subject_name}}</view>
- <view v-if="Subject_id == item.id" class="iconfont icon-dui1"></view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex'
- export default {
- data() {
- return {
- list: [], //科目列表
- Subject_id: 0, //已选的科目id
- classifytype: 0,
- classlist: [], //科目2级列表
- }
- },
- onShow() {
- // 获取科目列表
- this.getSub()
- this.Subject_id = this.subject.id
- },
- computed: {
- ...mapState(['subject', 'userinfo', 'subjectVip'])
- },
- methods: {
- async getSub() {
- let res = await this.$myHttp.post({
- url: this.$myHttp.urlMap.subjectList,
- data: {
- page: 1,
- limit: 0
- },
- needLogin: false
- })
- if (res.code === 1) {
- this.list = res.data
- this.classlist = this.list[0].childlist
- }
- },
- async tap_handle_choice_subject(item) {
- this.$store.commit('setSubject', {
- subject: {
- id: item.id,
- subject_name: item.subject_name
- }
- })
- if (this.userinfo.user_id !== undefined) {
- await this.$myUserLogin.getSubvip(this.subject.id)
- }
- this.$myUtils.$router.switchTab({
- url: '/pages/index/index'
- })
- },
- changeclassify(index, id) {
- this.classifytype = index
- this.classlist = this.list[index].childlist
- }
- }
- }
- </script>
- <style>
- page {
- background: #fff
- }
- .kaoshi-subject {
- display: flex;
- align-items: flex-start;
- background: #fff;
- height: 100vh;
- }
- .classifybox {
- width: 40%;
- background-color: #f6f9fc;
- height: 100vh;
- }
- .classify,
- .class {
- display: flex;
- align-items: center;
- height: 50px;
- }
- .classifytext {
- margin-left: 15px;
- padding-left: 10px;
- font-size: 15px;
- line-height: 18px;
- border-left: 3px solid transparent;
- }
- .classify.active {
- background-color: #fff;
- }
- .classify.active .classifytext {
- border-left: 3px solid #3a79f7;
- }
- .liebiaobox {
- width: 60%;
- height: 100vh;
- }
- .class {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 15px;
- font-size: 14px;
- }
- .classtext.active {
- font-weight: bold;
- }
- .icon-dui1 {
- color: #0ec380;
- }
- </style>
|