Commit 91c0ec8a authored by 秦嘉's avatar 秦嘉

增加小程序首页

parent 19532d92
import {
request
} from '../utils/request.js';
// 查询训练体验列表
export function listExercise(query) {
return request({
url: '/system/course/selectCourseList',
method: 'get',
})
}
// 查询热门活动列表
export function listActivityStart(query) {
return request({
url: '/tjt-activity/activity/selectActivityListStart',
method: 'get',
})
}
//有token时调用
// 查询训练体验列表
export function listExerciseHaveToken(query) {
return request({
url: '/system/course/selectCourseListToken',
method: 'get',
})
}
// 查询热门活动列表
export function listActivityStartHaveToken(query) {
return request({
url: '/tjt-activity/activity/selectActivityListStartToken',
method: 'get',
})
}
\ No newline at end of file
{
"pages": [{
"pages": [
{
"path" : "pages_home/tjty_home_page/tjty_home_page",
"style": {
"navigationBarTitleText": "天体运动"
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "天体运动"
......
<template>
<view class="home_container">
<view class="home_content_head">
<image src="../../static/home-imgs/home_bg@2x.png"></image>
<view class="headMenu">
<ul>
<li>
<navigator url="" hover-class="none" open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/home_icon_fengcai@2x.png"></image>
</view>
<view style="color: #1F86EE; line-height: 21px;height: 100%;width: 100%;">天体风采</view>
</view>
</navigator>
</li>
<li>
<navigator url="../../pages_activity/activity/activity" hover-class="none" open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/home_icon_saishi@2x.png"></image>
</view>
<view style="color: #EC6669; line-height: 21px;height: 100%;width: 100%;">赛事活动</view>
</view>
</navigator>
</li>
<li>
<navigator url="../../pages_course/tjty_course_course/course" hover-class="none"
open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/home_icon_xunlian@2x.png"></image>
</view>
<view style="color: #FCA624; line-height: 21px;height: 100%;width: 100%;">训练体验</view>
</view>
</navigator>
</li>
<li>
<navigator url="../../pages_service/tjty_customer/tjty_customer" hover-class="none"
open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/home_icon_kefu@2x.png"></image>
</view>
<view style="color: #6951E3; line-height: 21px;height: 100%;width: 100%;">天体客服</view>
</view>
</navigator>
</li>
</ul>
</view>
</view>
<view class="home_content_body">
<view class="home_activity">
<view class="home_activity_title">
<image style="width: 80px; height: 20px; margin-left: 11px;"
src="../../static/home-imgs/home_pic_remen@2x.png"></image>
<image style="width: 51px; height: 16px; float: right; margin-right: 11px;"
src="../../static/home-imgs/home_pic_gengduo@2x.png" @click="toActMore()"></image>
</view>
<view class="home_activity_item" v-for="(item1,index1) in activityList" :key="index1"
@click="goActDetil(item1)">
<view class="activity_image">
<image class="image" :src="item1.bannerImage"></image>
</view>
<view class="activity-body">
<view class="activity_image_title">
<view style="padding: 2% 4%;">{{item1.activityName}}</view>
</view>
</view>
</view>
</view>
<view class="home_exercise">
<view class="home_exercise_title">
<image style="width: 80px; height: 20px; margin-left: 11px;"
src="../../static/home-imgs/home_pic_xunlian@2x.png"></image>
<image style="width: 51px; height: 16px; float: right; margin-right: 11px;"
src="../../static/home-imgs/home_pic_gengduo@2x.png" @click="toExeMore()"></image>
</view>
<view class="home_exercise_item" v-for="(item,index) in exerciseList" :key="index">
<view class="ima">
<image style="width: 116px;height:116px;border-radius:16px "
:src="item.image"></image>
</view>
<view>
<view style="height: 80px;width: 265px">
<view class="a-card">
{{item.mechanismName}}
</view>
<view class="c-card">
适用人群:&nbsp;&nbsp;{{item.propertyPeople}}
</view>
</view>
<view style="width: 265px;">
<button class="b-card" @click="toAppoint(item)">
详情
</button>
</view>
</view>
</view>
</view>
</view>
<view class="home_content_footer">
<view>
<view class="line"></view>
<view>
<navigator url="" hover-class="none" open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/tab_icon_home_selected@2x.png"></image>
</view>
<view style="color: #3B7CDE; line-height: 10px;height: 100%;width: 100%; font-size: 10px;">
首页</view>
</view>
</navigator>
<navigator url="../../pages_new_media/tity_new_media/tity_new_media" hover-class="none"
open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/tab_icon_xinmeiti_default@2x.png"></image>
</view>
<view style="color: #333333; line-height: 10px;height: 100%;width: 100%; font-size: 10px;">
新媒体服务</view>
</view>
</navigator>
<navigator url="../../pages_my/my/my" hover-class="none" open-type="navigate">
<view style="text-align: center;">
<view>
<image src="../../static/home-imgs/tab_icon_geren_default@2x.png"></image>
</view>
<view style="color: #333333; line-height: 10px;height: 100%;width: 100%; font-size: 10px;">
个人中心</view>
</view>
</navigator>
</view>
</view>
</view>
</view>
</template>
<script>
import {
listExercise,
listActivityStart,
listExerciseHaveToken,
listActivityStartHaveToken
} from "@/api/homePage.js";
import {
getToken
} from '@/api/login.js';
import {
mapMutations,
mapState
} from 'vuex';
export default {
data() {
return {
activityList: [],
exerciseList: []
};
},
computed: {
...mapState('m_user', ['userInfo']),
...mapState('m_user', ['token'])
},
methods: {
...mapMutations('m_user', ['updateToken']),
...mapMutations('m_user', ['updateUserInfo']),
//登录判断
login() {
if (!this.token) {
this.getActivityList()
this.getExerciseList()
} else {
this.getExerciseListHaveToken()
this.getActivityListHaveToken()
}
},
getExerciseListHaveToken() {
listExerciseHaveToken().then(res => {
this.exerciseList = [...this.exerciseList, ...res.data] || []
}).catch(err => {
})
},
getActivityListHaveToken() {
listActivityStartHaveToken().then(res => {
this.activityList = [...this.activityList, ...res.data] || []
}).catch(err => {
})
},
getActivityList() {
listActivityStart().then(res => {
this.activityList = [...this.activityList, ...res.data] || []
}).catch(err => {
})
},
getExerciseList() {
listExercise().then(res => {
this.exerciseList = [...this.exerciseList, ...res.data] || []
}).catch(err => {
})
},
toAppoint(item) {
if (!this.token) {
uni.reLaunch({
url: '/pages/login/login?url=' + this.url
})
} else {
uni.navigateTo({
url: '/pages_course/tjty_course_appointment/appointment?id=' + item.courseId
})
}
},
toActMore() {
uni.navigateTo({
url: '/pages_activity/activity/activity'
})
},
toExeMore() {
uni.navigateTo({
url: '/pages_course/tjty_course_course/course'
})
},
goActDetil(item) {
if (!this.token) {
console.log("没有token")
uni.reLaunch({
url: '/pages/login/login?url=' + this.url
})
} else {
if (item.type == '1') {
uni.navigateTo({
url: '/pages_activity/activity_detail/activity_detail?activity_id=' + item.activityId
})
}
if (item.type == '2') {
uni.navigateTo({
url: `/pages_events/tjty_ans_detail/tjty_ans_detail?activityId=${item.activityId}`
})
}
}
}
},
created() {
this.login()
}
}
</script>
<style lang="scss" scoped>
.home_container {
width: 100%;
height: 100%;
.home_content_head {
width: 100%;
height: 212px;
position: relative;
overflow-x: hidden;
.headMenu {
z-index: 1;
position: absolute;
width: 100%;
top: 35%;
}
}
.home_content_head image {
width: 100%;
height: 212px;
}
.headMenu ul {
width: 100%;
padding-top: 10rpx;
}
.headMenu ul li {
width: 25%;
font-size: 14px;
font-family: Source Han Sans CN;
display: inline-block;
}
.headMenu ul li navigator {
width: 95%;
}
.headMenu image {
width: 58px;
height: 58px;
}
.home_content_body {
width: 100%;
height: calc(100% - 272px);
overflow: auto;
.home_activity {
margin-top: 30px;
.home_activity_item {
margin: 30rpx 30rpx 30rpx 30rpx;
background: #ffffff;
border-radius: 16px;
box-shadow: 0rpx 6rpx 20rpx 0rpx #dddddd;
:nth-child(1) {
position: relative;
}
.image {
border-top-left-radius: 15rpx;
border-top-right-radius: 15rpx;
width: 100%;
}
}
}
.home_exercise {
margin-top: 32px;
.home_exercise_item {
display: flex;
margin: 10rpx;
width: 96%;
margin: 3% 2% 4% 2%;
min-height: 130px;
height: auto;
background: #ffffff;
border-radius: 16px;
box-shadow: 0px 3px 10px 0px #dddddd;
text-align: right;
button {
margin-right: 5%;
}
.ima {
margin: 8px;
width: 116px;
height: 116px;
background: rgba(0, 0, 0, 0.00);
}
.c-card {
font-size: 32rpx;
width: 500rpx;
height: 80rpx;
font-family: Source Han Sans CN, Source Han Sans CN-Regular;
font-weight: 400;
text-align: left;
color: #666666;
line-height: 50px;
}
.a-card {
font-size: 32rpx;
width: 500rpx;
font-family: Source Han Sans CN, Source Han Sans CN-Bold;
font-weight: 700;
text-align: left;
color: #333333;
line-height: 42px;
}
.b-card {
// left: 132px;
top: 25rpx;
width: 152rpx;
height: 64rpx;
right: 0%;
// height: auto;
text-align: center;
color: #ffffff;
font-size: 14px;
line-height: 32px;
background: #3b7cde;
border-radius: 16px;
// margin-top: -100rpx;
// margin-right: 100rpx;
}
}
}
}
.home_content_footer {
.line {
width: 100%;
height: 1px;
background: #333333
}
width: 100%;
// position: fixed;
bottom: 0;
left: 0;
height: 60px;
navigator {
margin-top: 7px;
display: inline-block;
width: 33%;
}
image {
width: 24px;
height: 24px;
}
}
}
</style>
......@@ -167,7 +167,7 @@
this.updateToken('')
this.updateUserInfo('')
uni.navigateTo({
url: '/pages/index/index'
url: '/pages_home/tjty_home_page/tjty_home_page'
})
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment