xuxueyang
2024-07-08 8580ef310f61f4bc275c19ddcc6ebd2135720d4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<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&&currentNotice.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">&nbsp;</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>