<template>
|
<view class="main-container home">
|
<!-- 顶部,可能 -->
|
<view class="school" :style="{'background-color': color,'padding-top':(StatusBar)+'px'
|
,height:CustomBar+'rpx','line-height':CustomBar+'rpx' }">
|
<!-- <picker @change="PickerChangeSchool" :value="schoolIndex" :range="schools" range-key="name">
|
<view class="picker">
|
<uni-icons type="location" class="m-l-15 m-r-10"></uni-icons>
|
{{ schoolIndex>=0&&schools[schoolIndex].s_name ? schools[schoolIndex].s_name : '选择校区' }}
|
</view>
|
</picker> -->
|
</view>
|
<!-- <view :style="{'background-color': color,'padding-top':(StatusBar)+'px',height:CustomBar+'px'}"></view> -->
|
|
|
<!-- banner -->
|
<uni-swiper-dot class="uni-swiper-dot-box" @clickItem=clickItem :info="info" :current="currentBanner"
|
:mode="'dot'" :dots-styles="dotsStyles[0]" field="content">
|
<swiper class="swiper-box" @change="changeBanner" :current="0" :interval="10000" :circular="true" v-if="banners&&banners.length>0" :autoplay="true">
|
<swiper-item v-for="(item, index) in banners" :key="index">
|
<view class="swiper-item" :class="'swiper-item' + index">
|
<image @click="previewImg(item.imageSmall||item.image)" class="home-banner-image" mode="aspectFit" :src="item.imageSmall||item.image">
|
</image>
|
</view>
|
</swiper-item>
|
</swiper>
|
<swiper class="swiper-box" @change="changeBanner" :current="0" v-if="!banners||banners.length==0">
|
<swiper-item v-for="(item, index) in 1" :key="index">
|
<view class="swiper-item" :class="'swiper-item' + index">
|
<image class="home-banner-image" mode="scaleToFill"
|
src="https://xy-go.oss-cn-beijing.aliyuncs.com/fd/fdcf045d4da848938d65d85a8a512c1bhome-banner.png">
|
</image>
|
</view>
|
</swiper-item>
|
</swiper>
|
</uni-swiper-dot>
|
<!-- tip -->
|
<view class="p10">
|
<uni-notice-bar @click="getNoticeMore" v-if="currentNotice&¤tNotice.id" class="notice-bar"
|
color="#333" background-color="#fff" show-get-more show-icon :scrollable="scrollable"
|
:text="currentNotice.title" :key="currentNotice.id" />
|
<span v-if="!currentNotice||!currentNotice.id"> </span>
|
</view>
|
|
<!-- 各种按钮 -->
|
<home-buttons source="bussiness"></home-buttons>
|
|
<view style="padding-bottom:200rpx">
|
</view>
|
<bussincess-footer flg="0"></bussincess-footer>
|
|
</view>
|
</template>
|
|
<script>
|
import homeButtons from './components/home-buttons.vue'
|
import homeGoods from './components/home-goods.vue'
|
|
|
export default {
|
components: {
|
homeButtons,
|
homeGoods
|
},
|
data() {
|
return {
|
CustomBar: uni.getStorageSync('CustomBar'),
|
StatusBar: uni.getStorageSync('StatusBar'),
|
// StatusBar:0,
|
color: '#fff',
|
schools: [],
|
schoolIndex: -1,
|
tabs: [{
|
name: '团购',
|
id: 'shop'
|
},
|
{
|
name: '粗去玩',
|
id: 'travel'
|
},
|
{
|
name: '挖宝商品',
|
id: 'good'
|
},
|
],
|
tabIndex: 2,
|
info: [{
|
colorClass: 'uni-bg-red',
|
url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
|
content: '内容 A'
|
},
|
{
|
colorClass: 'uni-bg-green',
|
url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
|
content: '内容 B'
|
},
|
{
|
colorClass: 'uni-bg-blue',
|
url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
|
content: '内容 C'
|
}
|
],
|
dotStyle: [{
|
backgroundColor: 'rgba(0, 0, 0, .3)',
|
border: '1px rgba(0, 0, 0, .3) solid',
|
color: '#fff',
|
selectedBackgroundColor: 'rgba(0, 0, 0, .9)',
|
selectedBorder: '1px rgba(0, 0, 0, .9) solid'
|
},
|
{
|
backgroundColor: 'rgba(255, 90, 95,0.3)',
|
border: '1px rgba(255, 90, 95,0.3) solid',
|
color: '#fff',
|
selectedBackgroundColor: 'rgba(255, 90, 95,0.9)',
|
selectedBorder: '1px rgba(255, 90, 95,0.9) solid'
|
},
|
{
|
backgroundColor: 'rgba(83, 200, 249,0.3)',
|
border: '1px rgba(83, 200, 249,0.3) solid',
|
color: '#fff',
|
selectedBackgroundColor: 'rgba(83, 200, 249,0.9)',
|
selectedBorder: '1px rgba(83, 200, 249,0.9) solid'
|
}
|
],
|
currentBanner: 0,
|
banners: [],
|
noticeList: [],
|
currentNoticeIndex: 0,
|
currentNotice: {
|
|
}
|
};
|
},
|
onLoad() {
|
// console.log('home created')
|
//这里进行一次初始化即可
|
// console.log('home created')
|
//这里进行一次初始化即可
|
// this.$http.request('get','/api/school/area/list',{
|
|
// }).then(res=>{
|
// if(res.code==0){
|
// this.schools = res.data || []
|
// }
|
// })
|
//获取banner图
|
this.$http.request('get', '/api/ua/banner/list', {
|
|
}).then(res => {
|
if (res.code == 0) {
|
this.banners = res.data.records || []
|
}
|
})
|
// uni.setStorageSync('schoolId', this.school[parseInt(e.detail.value)].id);
|
// uni.setStorageSync('schoolIndex', parseInt(e.detail.value));
|
// var schoolIndex = uni.getStorageSync('schoolIndex')
|
// if(!schoolIndex&&schoolIndex!==0){
|
|
// }else{
|
// this.schoolIndex = schoolIndex
|
// }
|
//公告
|
this.$http.request('get', '/api/ua/announcement/list', {
|
params: {
|
size: 5,
|
status: 'A'
|
}
|
}).then(res => {
|
if (res.code == 0) {
|
this.noticeList = (res.data && res.data.records || [])
|
if (this.noticeList.length > 0) {
|
this.currentNotice = this.noticeList[0]
|
if (this.currentNotice.title && this.currentNotice.title.length >= 30) {
|
this.scrollable = true
|
} else {
|
this.scrollable = false
|
}
|
let that = this
|
if (this.noticeList.length >= 1) {
|
setInterval(() => {
|
console.log('interval,1')
|
|
that.currentNoticeIndex += 1
|
that.currentNoticeIndex %= that.noticeList.length
|
that.currentNotice = that.noticeList[that.currentNoticeIndex]
|
if (that.currentNotice.title && that.currentNotice.title.length >= 30) {
|
that.scrollable = true
|
} else {
|
that.scrollable = false
|
}
|
}, 8000)
|
}
|
|
}
|
}
|
})
|
|
},
|
methods: {
|
changeBanner(e) {
|
this.currentBanner = e.detail.current
|
},
|
changeTab(e) {
|
|
},
|
getNoticeMore() {
|
if (this.currentNotice.id) {
|
// uni.navigateTo({
|
// url: '/pages/notice/notice?id=' + this.currentNotice.id
|
// })
|
}
|
uni.navigateTo({
|
url: '/pages/notice/list?id=' + this.currentNotice.id
|
})
|
},
|
PickerChangeSchool(e) {
|
if (e.detail.value == '-1') {
|
this.$message.showToast('未选择校区')
|
return
|
}
|
console.log(' this.schools', this.schools, parseInt(e.detail.value), e);
|
// this.setData({
|
// index: e.detail.value,
|
// schoolInfo: this.school[parseInt(e.detail.value)],
|
// s_id: this.school[parseInt(e.detail.value)].s_id,
|
// current: 0
|
// });
|
|
this.schoolIndex = parseInt(e.detail.value)
|
uni.setStorageSync('schoolId', this.schools[parseInt(e.detail.value)].id);
|
uni.setStorageSync('schoolIndex', parseInt(e.detail.value));
|
// if (uni.getStorageSync('token')) {
|
// this.userChangeSchool(this.school[parseInt(e.detail.value)].s_id)
|
// }
|
// this.getSchoolInfo(this.school[parseInt(e.detail.value)].s_id);
|
// this.getSysparment(); //全局加载变量设置为真,信息圈的列表需要重新加载
|
// // this.getOrderData();
|
// // this.getHistoryList();
|
// this.getRank();
|
// this.setData({
|
// dataList: []
|
// });
|
},
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "./home.scss";
|
</style>
|