xnzt/xnzt-h5/pages/index/train/index.vue
2024-11-11 10:27:27 +08:00

305 lines
6.0 KiB
Vue

<template>
<!-- 贷款 -->
<view class="container">
<view class="train-top">
<view class="title">
培训类别
</view>
<view class="list">
<view class="i" @click="$pageTo(`/pages/index/train/courseList?id=${item.id}`)" v-for="(item,index) in list" :key="index">
<image :src="$config.imageBaseUrl + item.icon" mode="aspectFill" v-if="item.icon"></image>
<image src="@/static/images/index/px1.png" mode="aspectFill" v-else></image>
<text>{{item.name}}</text>
</view>
</view>
<view class="gg">
<image src="@/static/images/index/gg.png" mode="aspectFill"></image>
<view class="l">
培训课程
</view>
<view class="r" @click="$pageTo('/pages/index/train/trainApply')">
立即申请
</view>
</view>
</view>
<view class="t-bottom">
<view class="titlex u-flex u-row-between u-col-center">
<view class="l">
培训课程
</view>
<view class="r u-flex u-row-right u-col-center" @click="$pageTo('/pages/index/train/courseList')">
<text>更多</text>
<image src="@/static/images/index/more.png" mode="aspectFill"></image>
</view>
</view>
<view class="list u-flex u-row-between u-col-center">
<view class="item" v-for="(item,index) in list2" :key="index" @click="$pageTo(`/pages/index/train/video?id=${item.id}`)">
<view class="img">
<image :src="$config.imageBaseUrl + item.coverImg" mode="aspectFill" v-if="item.coverImg"></image>
<image src="@/static/images/index/news.png" mode="aspectFill" v-else></image>
<text>{{item.count}}人学习</text>
</view>
<view class="con">
<view class="title u-l-1">
{{item.title}}
</view>
<!-- <view class="type">
{{item.number}}
</view> -->
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { trainingList,trainiCngourse } from '@/api/home.js'
import config from "@/config";
export default {
data() {
return {
list:[],
list2:[],
id:'',
}
},
onLoad() {
let user = uni.getStorageSync('user')
this.userId = user.userId
if (!user.userId) {
uni.reLaunch({
url: '/pages/index/login'
})
return
}
this.getList()
},
methods: {
getList2(){
let id = this.list[0].id
trainiCngourse().then(res => {
if (res.code == 200) {
console.log(res)
this.list2 = res.data
} else {
uni.showToast({
title: res.msg,
icon: "none",
duration: 1500
});
}
})
},
getList() {
trainingList({
type: 3
}).then(res => {
if (res.code == 200) {
console.log(res)
this.list = res.data
this.getList2()
} else {
uni.showToast({
title: res.msg,
icon: "none",
duration: 1500
});
}
})
},
}
}
</script>
<style lang="scss" scoped>
$color: #FCAA30;
.container {
.train-top {
background-color: #fff;
padding: 20rpx 0;
margin-bottom: 20rpx;
.title {
padding: 0 30rpx;
font-size: 30rpx;
color: #0D0D0D;
line-height: 60rpx;
height: 60rpx;
border-bottom: 2rpx solid #eee;
font-weight: bold;
}
.list {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 20rpx 20rpx;
.i {
padding: 20rpx 0;
width: 25%;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
text-align: center;
image {
width: 100rpx;
height: 100rpx;
}
text {
margin-top: 20rpx;
font-size: 26rpx;
font-weight: 500;
color: #4D4D4D;
line-height: 40rpx;
height: 40rpx;
}
}
}
}
.gg {
display: flex;
align-items: center;justify-content: space-between;
padding-left: 60rpx;padding-right: 40rpx;
width:690rpx;
height: 120rpx;
margin: 40rpx auto 0;
border-radius: 60rpx;overflow: hidden;
position: relative;
box-sizing: border-box;
image {
position: absolute;top:0;left:0;right: 0;bottom:0;
width: 100%;
height: 100%;
z-index: 1;
}
.l{
position: relative;z-index: 999;
font-size: 30rpx;
font-weight: bold;
color: #0D0D0D;
height: 120rpx;
line-height: 120rpx;
}
.r{
position: relative;z-index: 999;
text-align: center;
width: 210rpx;
height: 73rpx;
line-height: 73rpx;
background: #FFFFFF;
border-radius: 37rpx;
font-size: 30rpx;
font-weight: bold;
color: #41C748;
}
}
.t-bottom {
background-color: #fff;
width:100%;
.list {
flex-wrap: wrap;
padding: 30rpx;
.item {
width: calc(50% - 10rpx);
margin-bottom: 20rpx;
.img {
width: 100%;
height: 210rpx;
position: relative;
border-radius: 20rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
text {
position: absolute;
bottom: 0;
left: 0;
height: 40rpx;
line-height: 40rpx;
background-color: rgba(0, 0, 0, 0.6);
color: #E6E6E6;
padding: 0 30rpx 0 20rpx;
border-radius: 0rpx 39rpx 0rpx 12rpx;
font-size: 22rpx;
}
}
.con {
padding: 10rpx 20rpx;
.title {
font-size: 30rpx;
color: #333;
line-height: 50rpx;
height: 50rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
white-space: normal;
}
.type {
font-size: 26rpx;
color: #999;
line-height: 40rpx;
height: 40rpx;
}
}
}
}
.titlex {
padding: 0 30rpx;
height: 80rpx;
line-height: 80rpx;
border-bottom: 2rpx solid #eee;
.l {
font-weight: 600;
font-size: 30rpx;
color: #333;
}
.r {
image {
margin-left: 10rpx;
width: 20rpx;
height: 20rpx;
}
text {
font-size: 26rpx;
font-weight: 500;
color: #999999;
line-height: 34rpx;
height: 34rpx;
}
}
}
}
}
</style>