123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <view class="content">
- <view class="one"
- :class="[courseInfo.type==='0'?'one0':courseInfo.type==='1'?'one1':courseInfo.type==='2'?'one2':courseInfo.type==='3'?'one3':'']">
- <view class="left">
- <view class="one_1 textOver">{{courseInfo.name||'暂无'}}</view>
- <view class="one_2">
- {{getDict(courseInfo.type,'type')}} {{getDict(courseInfo.grade,'grade')}}
- {{getDict(courseInfo.subject,'subject')}}
- </view>
- </view>
- <view class="right">
- <up-icon v-if="courseInfo.is_follow" name="star-fill" color="#FFA500" size="30"></up-icon>
- <up-icon v-else name="star" color="#FFA500" size="30"></up-icon>
- </view>
- </view>
- <view class="two">
- <view class="two_1">
- <span> 开始时间:{{courseInfo.start_time||'暂无'}}</span>
- <span> 结束时间:{{courseInfo.end_time||'暂无'}}</span>
- </view>
- <view class="two_2">¥{{courseInfo.money||'免费'}}</view>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import { inject, computed, ref } from 'vue';
- //该依赖已内置不需要单独安装
- import { onLoad } from "@dcloudio/uni-app";
- // 请求接口
- const $api = inject('$api');
- const id = ref('');
- // 基本信息
- const config = ref({ logo: [], file: [] });
- const courseInfo = ref({});
- const teacherInfo = ref({});
- // 字典表
- const subjectList = ref([]);
- const educationList = ref([]);
- const typeList = ref([]);
- const gradeList = ref([]);
- const genderList = ref([])
- const learnStatusList = ref([])
- // user
- const user = computed(() => {
- return uni.getStorageSync('user');
- })
- onLoad(async (options) => {
- id.value = options && options.id
- await searchConfig();
- await searchOther();
- await search();
- });
- // config信息
- const searchConfig = async () => {
- config.value = uni.getStorageSync('config');
- };
- // 其他查询信息
- const searchOther = async () => {
- let res;
- // 学科
- res = await $api(`dictData`, 'GET', { code: 'subject', is_use: '0' });
- if (res.errcode === 0) subjectList.value = res.data;
- // 年级
- res = await $api(`dictData`, 'GET', { code: 'grade', is_use: '0' });
- if (res.errcode === 0) gradeList.value = res.data;
- // 学历
- res = await $api(`dictData`, 'GET', { code: 'education', is_use: '0' });
- if (res.errcode === 0) educationList.value = res.data;
- // 类型
- res = await $api(`dictData`, 'GET', { code: 'courseType', is_use: '0' });
- if (res.errcode === 0) typeList.value = res.data;
- // 性别
- res = await $api(`dictData`, 'GET', { code: 'gender', is_use: '0' });
- if (res.errcode === 0) genderList.value = res.data;
- // 学业状态
- res = await $api(`dictData`, 'GET', { code: 'learnStatus', is_use: '0' });
- if (res.errcode === 0) learnStatusList.value = res.data;
- };
- // 查询
- const search = async () => {
- if (id.value) {
- const res = await $api(`course/appHomeDetail/${id.value}`, 'GET', {});
- if (res.errcode == '0') {
- courseInfo.value = res.data.courseInfo
- teacherInfo.value = res.data.teacherInfo
- }
- }
- };
- const getDict = (data, model) => {
- if (data) {
- let res
- if (model == 'education') res = educationList.value.find((f) => f.value == data)
- else if (model == 'subject') res = subjectList.value.find((f) => f.value == data)
- else if (model == 'grade') res = gradeList.value.find((f) => f.value == data)
- else if (model == 'type') res = typeList.value.find((f) => f.value == data)
- else if (model == 'gender') res = genderList.value.find((f) => f.value == data)
- else if (model == 'learnStatus') res = learnStatusList.value.find((f) => f.value == data)
- return res.label || '暂无'
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- display: flex;
- flex-direction: column;
- min-height: 100vh;
- background-color: var(--f1Color);
- .one {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin: 3vw;
- padding: 5vw;
- border-radius: 2vw;
- color: var(--mainColor);
- .left {
- .one_1 {
- font-size: var(--font16Size);
- font-weight: bold;
- margin: 0 0 2vw 0;
- }
- }
- .right {
- background-color: var(--mainColor);
- padding: 2vw;
- border-radius: 90px;
- }
- }
- .one0 {
- background-color: var(--d57Color);
- }
- .one1 {
- background-color: var(--1e9Color);
- }
- .one2 {
- background-color: var(--ff6Color);
- }
- .one3 {
- background-color: var(--40eColor);
- }
- }
- </style>
|