|
|
<template> <view class="main"> <view class="status_bar"></view> <view class="TopCon pad" > <!-- 地址、 --> <view class="adrsCon"> <view class="adr" v-if="vuex_cityInfo.city">{{ vuex_cityInfo.city }} </view> <view class="adr" v-else @click="getLatLngFn" style="display: flex;align-items: center;"> <text>获取定位信息</text> <image src="@/static/images/icon/down.png" mode="" style="width: 18rpx;height: 18rpx;margin-left: 6rpx;"></image> </view> <!-- <view class="adrsIcon"> <image src="@/static/images/icon/down.png" mode=""></image> </view> --> </view> <view class="flex-b"> <!-- 搜索 --> <view class="searchCon" > <searchRow placeholder="搜索驾校名称" :disable="true" bg="#fff" @searchFn="$goPage('/pages/indexEntry/findShcool/searchShcool/searchShcool')"></searchRow> </view> <!-- 扫一扫 --> <view class="scan" @click="scanCodeClick"> <image src="@/static/images/indexIcon/sancode.png" mode="aspectFill"></image> </view> </view> </view> <!-- 海报 --> <view class="pad"> <uni-swiper-dot class="uni-swiper-dot-box bannerCon" :info="swiperInfo" v-if="swiperInfo.length" :current="current" :mode="mode" :dots-styles="dotsStyles" field="content"> <swiper class="swiper-box" @change="change" :current="swiperDotIndex" > <swiper-item v-for="(item, index) in swiperInfo" :key="index" @click="bannerClick(item)" > <view class="swiper-item" :class="'swiper-item' + index"> <view class="imgBox"> <image :src="item.imgUrl" mode=""></image> </view> </view> </swiper-item> </swiper> </uni-swiper-dot> </view> <view class="pad"> <!-- 精钢区 --> <view class="card"> <view class="ul"> <view class="li" v-for="(item,index) in entrySection" :key="index" @tap="entrySectionClick(item)"> <view class="icon"> <image :src="item.icon" mode=""></image> </view> <view class="name">{{ item.text }}</view> </view> </view> </view> <!-- 优质驾校 --> <view class="schoolCon card" v-if="recommendSchool.length"> <view class="h1_row"> <view class="h1" ><text class="active">风采驾校</text></view> <moreRight text="查看全部" @click.native="$goPage('/pages/indexEntry/findShcool/findShcool')"/> </view> <view class="li" v-for="(item,index) in recommendSchool" :key="index" @click="$goPage('/pages/indexEntry/findShcool/shcoolDetail/shcoolDetail?schoolId='+ item.id)"> <schoolItem :item="item"/> </view> </view> <!-- 推荐教练 --> <view class="coachCon" v-if="coachList.length"> <view class="h1_row"> <view class="h1" ><text class="active">推荐教练</text></view> <moreRight text="查看全部" @click.native="$goPage('/pages/indexEntry/findCoach/findCoach')"/> </view> <scroll-view style="width: 100%;" scroll-x="true" scroll-with-animation > <view class="ul3"> <view class="li3" v-for="item in coachList" :key="item.id" @click="goCoachDetail(item)"> <coachItem :item="item"/> </view> </view> </scroll-view> </view> <!-- 行业资讯,政策法规 --> <view class="card"> <view class="h1_row"> <view class="tabs"> <view class="h1" @click="changeInforma(1)"><text :class="{active: informa==1}">行业资讯</text></view> <view class="h1" @click="changeInforma(2)"><text :class="{active: informa==2}" style="margin-left: 30rpx;">政策法规</text></view> </view> <moreRight text="查看全部" @click.native="$goPage('/pages/indexEntry/industryPolicy/industryPolicy?type='+ informa)"/> </view> <view class="ul2"> <view class="li2" v-for="(item,index) in informList" :key="index"> <informaItem :item="item"/> </view> </view> </view> <!-- 服务专区 --> <view class="card"> <view class="h1" style="margin-top: 20rpx;"><text class="active">服务专区</text></view> <view class="severCon"> <view class="severItem" @click="$goPage('/pages/indexEntry/parse/parse')"> <view class="tit">学车指南</view> <view class="tps">政府平台 一站服务</view> <view class="go"> <view class="goTxt">GO</view> <u-icon name="arrow-right" color="#fff" size="14"></u-icon> </view> </view> <view class="severItem tow" @click="$goPage('/pages/indexEntry/consult/consult')"> <view class="tit">咨询投诉</view> <view class="tps">畅达沟通 听取民声</view> <view class="go"> <view class="goTxt">GO</view> <u-icon name="arrow-right" color="#fff" size="14"></u-icon> </view> </view> </view> </view> </view> <u-popup :show="showPrivacy" mode="center" :round="20" > <privacyPopup @disagree="showPrivacy=false" @agree="showPrivacy=false"></privacyPopup> </u-popup> </view> </template>
<script> import { imgUrl } from '@/config/site.config' import { getarticleList, getBannerList, getarticlezcList,getRecommendList, recommendSchoolList } from '@/config/api.js' import schoolItem from './comp/schoolItem' import informaItem from './comp/informaItem' import coachItem from './comp/coachItem' import { scanCodeFn } from '@/config/utils.js' import location from '@/common/js/location.js' export default { components: { schoolItem, informaItem, coachItem }, data() { return { showPrivacy: false, imgUrl: imgUrl+'banner.png', backgroundSize: '100% 100%', keywords: '', entrySection: [{ text: '学车报名', icon: require('../../../static/images/indexIcon/entryIcon (3).png'), url: '/pages/indexEntry/enroll/enroll', }, { text: '找驾校', icon: require('../../../static/images/indexIcon/entryIcon (4).png'), url: '/pages/indexEntry/findShcool/findShcool', }, { text: '找教练', icon: require('../../../static/images/indexIcon/entryIcon (1).png'), url: '/pages/indexEntry/findCoach/findCoach', }, { text: '签到签退', icon: require('../../../static/images/indexIcon/entryIcon (5).png'), url: '/pages/indexEntry/signIn/signIn', }, // {
// text: '理论学习',
// icon: require('../../../static/images/indexIcon/entryIcon (2).png'),
// url: '/pages/indexEntry/theory/theory',
// },
], swiperDotIndex: 0, current: 1, mode: 'default', swiperInfo: [], dotsStyles: { backgroundColor: '#E8E9EC', border: '1px #E8E9EC solid', color: '#fff', selectedBackgroundColor: '#1989FA', selectedBorder: '1px #1989FA solid' }, bgColor: 'transparent', informList: [], informa: 1, coachList: [],//推荐教练
recommendSchool: [],//推荐驾校
sweixin:null } }, async onLoad() { }, onPullDownRefresh() { this.initApi() }, onShow() { let _this = this // if(!this.vuex_cityInfo.lat) {
// location.getLocation(()=>{
// _this.$store.dispatch('getCity')
// uni.showModal({
// content: '为了您更好的给您推荐附近的驾校数据,需要获取位置信息,app想要获取您的位权限',
// confirmText: "确定",
// success: function(res) {
// if (res.confirm) {
// _this.$store.dispatch('getCity')
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// });
// });
// }
let token = this.$store.state.user.vuex_loginInfo.accessToken if(token) { this.$store.dispatch('getUserInfo') } if(!this.swiperInfo.length) { this.getBannerListFn() // this.getarticleListFn()
} this.initApi() }, computed: { }, methods: { async getLatLngFn() { await this.$store.dispatch('getCity') this.recommendSchoolList() }, // 点击海报图
bannerClick(item) { let link = item.jumpPath console.log(link) if(!link) return false this.$store.commit('updateWebVeiwUrl', link) this.$goPage('/pages/indexEntry/webView/webView') }, initApi() { this.getarticleListFn() this.getRecommendList() this.recommendSchoolList() }, goCoachDetail(item) { let objStr = encodeURIComponent(JSON.stringify(item)) this.$goPage('/pages/indexEntry/findShcool/coachComment/coachComment?item='+ objStr) }, // 推荐教练
async getRecommendList() { const {data: res} = await getRecommendList({pageNo:1,pageSize: 20, }) this.coachList = res console.log(res) }, // 推荐驾校
async recommendSchoolList() { // if(!this.vuex_cityInfo.lat) {
// await this.$store.dispatch('getCity')
// }
const {data: res} = await recommendSchoolList({pageNo:1,pageSize: 3, lat: this.vuex_cityInfo.lat||'34.682945', lng: this.vuex_cityInfo.lng||'112.477298'}) this.recommendSchool = res console.log(res) }, async getBannerListFn() { const {data: res} = await getBannerList() this.swiperInfo = res.list console.log(this.swiperInfo) }, async entrySectionClick(item) { if(item.text=='学车报名') { this.$store.commit('upDateSchoolCoach', {}) this.$store.commit('upDateSchoolClass', {}) this.$store.commit('updateSchool', {}) return this.$u.utils.clickSignUp() }else if(item.text=='签到签退') { if(this.vuex_userInfo.applyStep<6) return this.$u.toast('请先报名学员') } this.$goPage(item.url) }, changeInforma(val) { if(this.informa == val) return this.informa = val this.getarticleListFn() }, // 行业资讯
async getarticleListFn() { const {data: res} = await getarticlezcList({pageSize: 3, type: this.informa}) this.informList = res.list }, async refereshFn() { const res = await this.$store.dispatch('refreshToken') console.log(res) uni.$u.http.setConfig((config) => { config.header.Authorization = 'Bearer ' + this.$store.state.user.vuex_loginInfo.accessToken console.log(111) return config }) console.log(222) // this.$store.dispatch('getUserInfo')
}, close() { }, goPageSection(item) { uni.navigateTo({ url:item.url }) }, // 扫码
scanCodeClick() { scanCodeFn(this) }, clickItem(e) { this.swiperDotIndex = e }, change(e) { this.current = e.detail.current }, goPage() { uni.navigateTo({ url: '/pages/userCenter/login/loginByPhone' }) }, } } </script>
<style lang="scss" scoped> .h1_row { display: flex; align-items: center; justify-content: space-between; } .h1 { padding: 20rpx 0 20rpx 0; } .main { width: 100%; background: url('https://jiangxijiakao-1.oss-cn-hangzhou.aliyuncs.com/complain/2024-02-27/1709013363812-0') #F6F7FA no-repeat; background-size: 100% 600rpx; .TopCon { width: 100%; // height: 120rpx;
.flex-b { display: flex; height: 100%; height: 72rpx; margin-bottom: 20rpx; } .adrsCon { display: flex; align-items: center; // width: 180rpx;
height: 88rpx; .adrsIcon { width: 17rpx; height: 17rpx; margin-top: 4rpx; } .adr { padding-right: 14rpx; font-size: 28rpx; color: #fff; } } .searchCon { flex:1; } .scan { width: 100rpx; height: 100%; display: flex; justify-content: flex-end; align-items: center; image { width: 52rpx; height: 52rpx; } } }
.bannerCon { border-radius: 20rpx; margin-bottom: 20rpx; overflow: hidden; }
.card { background: #FFFFFF; border-radius: 16rpx; margin-bottom: 20rpx; padding: 0 20rpx; .ul { height: 164rpx; display: flex; justify-content: space-between; align-items: center;
.li { flex: 1; display: flex; align-items: center; flex-direction: column;
.icon { width: 72rpx; height: 72rpx; }
.name { font-size: 26rpx; color: #333; padding-top: 20rpx; text-align: center; } } } } } .tabs { display: flex; } .severCon { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 0rpx 20rpx 0rpx; } .severItem { width: 320rpx; height: 186rpx; background: url('../../../static/images/indexIcon/xccard.png') no-repeat; background-size: 100% 100%; padding: 30rpx 20rpx; font-size: 24rpx; color: #fff; &.tow { background: url('../../../static/images/indexIcon/zxcard.png') no-repeat; background-size: 100% 100%; .go { background: #2AB188; } } .tit { font-size: 32rpx; } .tps { opacity: 0.8; margin: 12rpx 0; } .go { width: 70rpx; height: 38rpx; background: #1A61FB; border-radius: 10rpx; display: flex; align-items: center; .goTxt { padding-left: 4rpx; } } } .ul3 { display: flex; margin: 20rpx 0; } .swiper-box { .swiper-item { .imgBox { width: 100%; height: 300rpx; display: block; } } } </style>
|