<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" v-if="bannerData.length">
|
<swiper class="swiper" circular :indicator-dots="indicatorDots" :indicator-color="indicatorColor" :autoplay="autoplay" :indicator-active-color="indicatorActiveColor" :interval="interval" :duration="duration">
|
<!-- <swiper-item @tap="gotoUrl" v-if="bannerData.length>2">
|
<image lazy-load src="/static/imgs/sBanner.png" mode=""></image>
|
</swiper-item> -->
|
<!-- <swiper-item v-for="(item, index) in bannerData" @tap="$util.goPages('/pages/ginfo/ginfo?id=' + item.goodsid)"> -->
|
<swiper-item v-for="(item, index) in bannerData" @tap="gotoUrl(item)">
|
<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: {
|
gotoUrl(data) {
|
if(data.sort === 100) { // data.sort === 100:跳转第三方,否则跳转产品详情
|
uni.navigateTo({
|
url: '/pages/web/web-linkUrl?src=' + 'https://equity.dm-cube.com/#/entrance/login?sourceCode=H5_gongzhonghao_null_kefu_null_3&platform=h5&account=h5&redirection=%252Fpage%253Fplatform%253Dh5%2526sourceCode%253DH5_gongzhonghao_null_kefu_null_3%2526account%253Dh5',
|
})
|
} else { // 跳转产品详情
|
this.$util.goPages('/pages/ginfo/ginfo?id=' + data.goodsid)
|
}
|
},
|
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>
|