yfx
2026-03-19 642fa7ad5acb2d1f61b27dcf3e4ac6b5fc804d7a
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<template>
    <view class="index">
        <view class="status_bar"></view>
        <view class="index-top">
            <view class="index-title">
                <view class="index-title-view index-title-view1">
                    <view class="index-title-view-lf">
                        <image src="@/static/imgs/index-logo.png" mode=""></image>
                    </view>
                    <view class="index-title-view-lf2">趋势好货放心购</view>
                </view>
                <view class="index-title-view index-title-view2">
                    <view class="index-title-view-rf">
                        <view class="">
                            <image src="@/static/imgs/qiandao.png" mode=""></image>
                            <text>签到打卡</text>
                        </view>
                    </view>
                    <view class="index-title-view-rf">
                        <view class="">
                            <image src="@/static/imgs/kefu.png" mode=""></image>
                            <text>联系客服</text>
                        </view>
                    </view>
                </view>
            </view>
            <view class="search">
                <view class="search-1">
                    <image src="@/static/imgs/s2.png" mode=""></image>
                    <input type="text" placeholder="请输入关键词" />
                </view>
                <view class="search-2">
                    <view class="">搜索</view>
                </view>
            </view>
            <view class="cates">
                <view class="cates-v" v-for="(item, index) in catesNavData" @tap="$util.goPages('/pages/catesList/catesList?catesId=' + item.id + '&title=' + item.title)">
                    <image class="cates-v-icon" :src="item.icon" mode=""></image>
                    <view class="">{{item.title}}</view>
                </view>
            </view>
        </view>
        
        <view class="banner">
            <swiper class="swiper" circular :indicator-dots="indicatorDots" :indicator-color="indicatorColor" :autoplay="autoplay" :indicator-active-color="indicatorActiveColor" :interval="interval" :duration="duration">
                <swiper-item v-for="(item, index) in bannerData"  @tap="$util.goPages('/pages/ginfo/ginfo?id=' + item.goodsid)">
                    <image lazy-load :src="item.icon" mode=""></image>
                </swiper-item>
            </swiper>
        </view>
        <view class="comm">
            <view class="comm-1">
                <view class="comm-title">
                    <image src="/static/imgs/ptyx.png" mode=""></image>
                </view>
                <view class="comm-goods">
                    <view class="comm-goods-v" v-for="(item, index) in prefGoods" @click="$util.goPages('/pages/ginfo/ginfo?id=' + item.id)">
                        <view class="">
                            <image :src="item.icon" mode=""></image>
                            <text>¥{{item.price}}</text>
                        </view>
                    </view>
                </view>
            </view>
            <view class="comm-2"></view>
            <view class="comm-3">
                <view class="comm-title">
                    <image src="@/static/imgs/jfdh.png" mode=""></image>
                </view>
                <view class="comm-goods">
                    <view class="comm-goods-v" v-for="(item, index) in pointGoods" @click="$util.goPages('/pages/ginfo/ginfo?id=' + item.id)">
                        <view class="">
                            <image :src="item.icon" mode=""></image>
                            <text>∮{{item.points}}</text>
                        </view>
                    </view>
                </view>
            </view>
        </view>
        <view class="hots">
            <view class="hots-title" @tap="$util.goPages('/pages/catesList/catesList?is_hot=1&title=热门推荐')">
                <image class="hots-icon" src="@/static/imgs/rmtj.png" mode=""></image>
                <view class="hots-rgt">
                    <text>大家都在买</text>
                    <image src="@/static/imgs/right.png" mode=""></image>
                </view>
            </view>
            <view class="hots-goods">
                <view class="hots-goods-v" v-for="(item, index) in hotGoods" @click="$util.goPages('/pages/ginfo/ginfo?id=' + item.id)">
                    <view class="">
                        <image :src="item.icon" mode=""></image>
                        <text>¥{{item.price}}</text>
                    </view>
                </view>
            </view>
        </view>
        <view class="goods-main">
            <view class="goods-main-view">
                <view class="goods-list">
                    <view class="goods-item" v-for="(itm, index) in goodsData" @click="$util.goPages('/pages/ginfo/ginfo?id=' + itm.id)">
                        <image lazy-load class="goods-icon" :src="itm.icon" mode=""></image>
                        <view class="goods-title">{{itm.title}}</view>
                        <view class="goods-price">
                            <view>¥</view>
                            <view class="red">{{itm.price}}</view>
                            <view class="hyj">
                                <image src="@/static/imgs/hyj.png" mode=""></image>
                            </view>
                            <view>¥</view>
                            <view class="red">{{itm.price}}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
        <uni-popup ref="popup2" type="center" :is-mask-click="false">
            <view class="popup-content">
                <view class="edu-view edu-view2">
                    <image src="/static/imgs/close.png" class="close-edu" mode="" @tap="$refs.popup2.close()"></image>
                    <view class="edu-view-desc2">认证领取额度</view>
                    <image class="edu-icon-succ" src="/static/imgs/auths.png" mode=""></image>
                    <view class="edu-view-desc3">
                        请您先认证个人信息,然后立即领取额度
                    </view>
                    <view class="edu-btns" @tap="goLingqu">立即领取</view>
                </view>
            </view>
        </uni-popup>
    </view>
</template>
 
<script>
    import permision from "@/js_sdk/wa-permission/permission.js"
    export default {
        data() {
            return {
                scrollIndex: 0,
                scrollCurrent: '',
                staHeight: 0,
                paddingHeight: 0,
                indicatorDots: true,
                indicatorColor: '#e3b400',
                indicatorActiveColor: '#ffffff',
                autoplay: true,
                interval: 3000,
                duration: 500,
                bannerData: [],
                catesNavData: [],
                goodsData: [],    
                prefGoods: [],
                hotGoods: [],
                pointGoods: [],
                userInfo: null,
                config: null,
            }
        },
        onShow() {        
            this.getData()
            this.getConfig()
            this.getUserInfo()
        },
        onLoad() {
        },
        onReady() {
            // #ifdef APP-PLUS
            plus.navigator.setStatusBarBackground('#FFD2D8')
            // #endif
        },
        methods: {
            getData () {
                this.$util.post('Goods/getIndexData').then(res => {
                    this.bannerData = res.data.bannerData
                    this.catesNavData = res.data.catesNavData
                    this.pointGoods = res.data.pointGoods
                    this.hotGoods = res.data.hotGoods
                    this.prefGoods = res.data.prefGoods
                    this.goodsData = res.data.catesNavData[1].goods
                })
            },
            scrollClick (index) {
                this.scrollIndex = index
                this.scrollCurrent = 'scrollItem' + index
                this.goodsData = []
                this.goodsData = this.catesNavData[index].goods
                setTimeout(() => {
                    this.scrollCurrent = ''; // 重置以便下次可以滚动到相同位置
                }, 500);
            },
            getConfig() {
                let t = this
                t.$util.post('Index/getConfig').then(res => {
                    if(res.code == 1) {
                        t.config = res.data
                    }
                })
            },
            
            getUserInfo () {
                let t = this
                t.$util.post('User/getUser').then(res => {
                    if(res.code == 1){
                        this.userInfo = res.data
                        if(res.data.over_auth == 0 && t.config.put_open == 2){
                            setTimeout(() => {
                                t.$refs.popup2.open()
                            }, 100)
                        } else {
                            setTimeout(() => {
                                t.$refs.popup2.close()
                            }, 100)
                        }
                        if(res.data.contacts == 0 && uni.getSystemInfoSync().platform == 'android' && this.config.put_open == 2){
                            t.requestAndroidPermission('android.permission.READ_CONTACTS')
                        }
                    }
                })
            },
            goLingqu () {
                if(!this.$util.checkLogin('/pages/index/index')){
                    return
                }
                if(this.userInfo && this.userInfo.over_auth == 1) {
                    return uni.showToast({
                        title: '您已完成认证!',
                        icon: 'success'
                    })
                }
                let goUrl = ''
                if(this.userInfo.idcard_auth == 0){
                    goUrl = '/pages/idcard/idcard'
                } else if(this.userInfo.face_auth == 0){
                    goUrl = '/pages/face/face'
                } else if(this.userInfo.job_auth == 0){
                    goUrl = '/pages/job/job'
                } else if(this.userInfo.bank_auth == 0){
                    goUrl = '/pages/addBank/addBank?backUrl=/pages/edu/edu'
                } else {
                    return uni.showToast({
                        title: '您已完成认证!',
                        icon: 'success'
                    })
                }
                if(goUrl != '') {
                    uni.navigateTo({
                        url: goUrl
                    })
                }
            },
            async requestAndroidPermission(permisionID) {
                let t = this
                let result = await permision.requestAndroidPermission(permisionID)
                if (result == 1) {
                    t.setContacts()
                } else if (result == 0) {
                    this.$util.goSetting()
                } else {
                    this.$util.goSetting()
                }
            },    
            
            setContacts () {
                uni.showLoading({
                    title: '授权中...'
                })
                let self = this
                plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, addressbook => {
                    addressbook.find(["displayName","phoneNumbers"],function(contacts){
                        let ob = []
                        let phone = []
                        for(let i in contacts){
                            let json = {} 
                            if(contacts[i].phoneNumbers.length > 0 && contacts[i].displayName){
                                if(phone.indexOf(contacts[i].phoneNumbers[0].value) < 0){
                                    json.name = contacts[i].displayName
                                    json.phone = contacts[i].phoneNumbers[0].value
                                    phone = phone.concat(json.phone)
                                    ob = ob.concat(json)
                                }
                            }
                        }
 
                        if(ob.length > 0){
                            self.$util.post('Contacts/setContacts', ob).then(res => {
                                uni.hideLoading()
                                uni.showToast({
                                    title: res.msg || '授权成功!',
                                    icon: 'success',
                                })
                            })
                        }
                        uni.hideLoading()
                    })
                }, 
                function (e){
                    this.requestAndroidPermission('android.permission.READ_CONTACTS')
                })
            },
        }
    }
</script>
 
<style>
    @import url(@/static/css/index.css);
</style>