Files
dvcp_v2_wechat_app/src/project/tianfuxing/AppHome/AppHome.vue

402 lines
9.5 KiB
Vue
Raw Normal View History

2022-11-01 18:30:12 +08:00
<template>
2022-11-01 19:08:20 +08:00
<div class="home">
2022-11-03 11:28:10 +08:00
<!-- <div class="header" :class="[isFixed ? 'header-active' : '']">
2022-11-02 17:47:19 +08:00
<div class="status-bar" :style="{height: statusBarHeight + 'px'}"></div>
<div class="nav-bar">
<h2>天府星小程序</h2>
2022-11-01 19:08:20 +08:00
</div>
</div>
2022-11-02 17:47:19 +08:00
<div></div>
2022-11-03 11:28:10 +08:00
<image class="bg-img" src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/home-bg.png" /> -->
2022-11-02 17:47:19 +08:00
<div class="wrapper">
<div class="nav">
2022-11-07 17:35:37 +08:00
<div class="nav-item" hover-class="text-hover" @click="$linkTo('./ActivityList')">
<image mode="aspectFill" src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/home1.png" />
<span>活动签到</span>
</div>
2022-11-02 17:47:19 +08:00
<div class="nav-item" hover-class="text-hover" @click="$linkTo('./PhotoReport')">
2022-11-07 17:35:37 +08:00
<image mode="aspectFill" src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/home2.png" />
2022-11-11 08:36:42 +08:00
<span>文明拍</span>
2022-11-02 17:47:19 +08:00
</div>
<div class="nav-item" hover-class="text-hover" @click="$linkTo('./Culture')">
2022-11-07 17:35:37 +08:00
<image mode="aspectFill" src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/home3.png" />
<span>海报接力</span>
</div>
<div class="nav-item" hover-class="text-hover" @click="$linkTo('./Ranking')">
<image mode="aspectFill" src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/home4.png" />
<span>文明榜单</span>
2022-11-02 17:47:19 +08:00
</div>
</div>
2022-11-08 18:51:19 +08:00
<swiper class="banner" indicatorDots circular :autoplay="true" :interval="5000" v-if="bannerList.length">
2023-01-04 17:09:50 +08:00
<swiper-item v-for="(item, index) in bannerList" :key="index" @click="toDetail(item)">
2022-11-08 18:10:21 +08:00
<image :src="item.imgUrl" mode="aspectFill" />
</swiper-item>
</swiper>
2022-11-07 17:35:37 +08:00
<div class="section yh">
<h2>商家优惠</h2>
<div class="yh-list">
2022-11-08 13:58:55 +08:00
<div class="yh-item" v-for="(item, index) in list" :key="index" hover-class="text-hover" @click="$linkTo('./StoreDetail?id=' + item.id)">
2022-11-11 08:36:42 +08:00
<image :src="item.logoFiles[0].url" mode="aspectFill" />
2022-11-07 17:35:37 +08:00
<div class="right">
2022-11-08 13:58:55 +08:00
<h2>{{ item.merchantName }}</h2>
<p>{{ item.title }}</p>
2022-11-01 19:08:20 +08:00
</div>
</div>
2022-11-08 13:58:55 +08:00
<AiEmpty v-if="!list.length"></AiEmpty>
2022-11-01 19:08:20 +08:00
</div>
2022-11-08 18:10:21 +08:00
<div class="more" v-if="list.length" @click="$linkTo('./Store')" hover-class="text-hover">查看更多优惠</div>
2022-11-07 17:35:37 +08:00
</div>
2022-11-08 18:10:21 +08:00
<div class="section rz" v-if="!user.merchantInfo || user.merchantInfo.status !== '1'" >
2022-11-07 17:35:37 +08:00
<h2>商家入驻</h2>
<div class="rz-info">
<div class="rz-item">
<h3>商家权益</h3>
2022-11-08 18:10:21 +08:00
<!-- <span>成都市金牛区xxxx大厦成都</span> -->
2022-11-07 17:35:37 +08:00
</div>
<div class="rz-item">
<h3>免费入驻</h3>
<span>面对50万新区市民免费展示推荐</span>
</div>
<div class="rz-item">
<h3>宣传报道</h3>
<span>分批次获得媒体公开点名</span>
</div>
<div class="rz-item">
<h3>出席仪式</h3>
<span>邀请重点协会与商家代表参与启动仪式颁奖仪式</span>
</div>
<div class="rz-item">
<h3>直通车</h3>
<span>商家诉求收集汇总反馈</span>
</div>
</div>
2022-11-08 18:10:21 +08:00
<div class="more" @click="$linkTo('./AddMerchants')" hover-class="text-hover">我是商家我要入驻</div>
2022-11-01 19:08:20 +08:00
</div>
</div>
2022-11-01 18:30:12 +08:00
</div>
</template>
<script>
2022-11-02 14:11:53 +08:00
import { mapActions, mapState } from 'vuex'
2022-11-01 18:30:12 +08:00
export default {
2022-11-02 17:47:19 +08:00
appName: '首页',
navigationBarTitleText: '天府星小程序',
2022-11-02 14:11:53 +08:00
name: 'AppHome',
2022-11-09 11:51:51 +08:00
enablePullDownRefresh: true,
2022-11-02 14:11:53 +08:00
data () {
return {
current: 1,
list: [],
2022-11-02 17:47:19 +08:00
isMore: false,
isFixed: false,
statusBarHeight: 20,
2022-11-08 18:10:21 +08:00
bannerList: []
2022-11-02 14:11:53 +08:00
}
},
computed: {
...mapState(['user', 'token'])
},
2022-11-08 18:51:19 +08:00
onShow () {
this.isMore = false
this.getList()
},
2022-11-02 14:11:53 +08:00
onLoad () {
if (!this.token) {
this.autoLogin()
} else {
this.getUserInfo()
}
2022-11-08 13:58:55 +08:00
2022-11-08 18:10:21 +08:00
this.getBannerList()
2022-11-02 14:11:53 +08:00
},
methods: {
2022-11-08 13:58:55 +08:00
...mapActions(['autoLogin', 'getUserInfo']),
2022-11-08 18:10:21 +08:00
getBannerList () {
this.$instance.post(`/api/appbanner/getList`, null, {
withoutToken: true
}).then(res => {
if (res.code === 0) {
this.bannerList = res.data
}
}).catch(() => {
})
},
2023-01-04 17:09:50 +08:00
toDetail (e) {
if (e.type == '0') { //0 h5链接 1 小程序链接; 2外部小程序
this.$linkTo(`/subPages/h5/webview?link=${e.linkUrl}&title=${e.title}`)
2023-01-05 17:01:10 +08:00
} else if (e.type == '2') {
2023-01-04 17:09:50 +08:00
wx.navigateToMiniProgram({
appId: e.linkUrl
})
2023-01-05 17:01:10 +08:00
} else if (e.type == '3') {
this.$linkTo(`./News?id=${e.id}`)
2023-01-04 17:09:50 +08:00
}
},
2022-11-08 13:58:55 +08:00
getList () {
this.$instance.post(`/api/appmerchantinfo/discountList`, null, {
withoutToken: true,
params: {
current: 1,
size: 4,
status: 1
}
}).then(res => {
if (res.code === 0) {
this.list = res.data.records
this.isMore = true
2022-11-09 11:51:51 +08:00
uni.stopPullDownRefresh()
2022-11-08 13:58:55 +08:00
} else {
this.isMore = true
2022-11-09 11:51:51 +08:00
uni.stopPullDownRefresh()
2022-11-08 13:58:55 +08:00
}
}).catch(() => {
2022-11-09 11:51:51 +08:00
uni.stopPullDownRefresh()
2022-11-08 13:58:55 +08:00
})
}
2022-11-09 11:51:51 +08:00
},
onPullDownRefresh() {
this.isMore = false
this.current = 1
this.getList()
this.getBannerList()
2022-11-02 14:11:53 +08:00
}
2022-11-01 18:30:12 +08:00
}
</script>
<style lang="scss" scoped>
2022-11-01 19:08:20 +08:00
.home {
2022-11-02 17:47:19 +08:00
position: relative;
2022-11-07 17:35:37 +08:00
padding: 32px 0 60px;
2022-11-01 19:08:20 +08:00
2022-11-02 17:47:19 +08:00
.bg-img {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 512px;
}
.wrapper {
position: relative;
z-index: 11;
2022-11-07 17:35:37 +08:00
margin: 0 32px 32px;
}
.yh {
.more {
width: 100%;
height: 88px;
line-height: 88px;
text-align: center;
color: #687DA6;
font-size: 28px;
}
.yh-list {
padding: 0 24px;
}
.yh-item {
display: flex;
align-items: center;
padding: 24px 0;
border-bottom: 1px solid #EEEEEE;
image {
width: 112px;
height: 112px;
margin-right: 12px;
border-radius: 8px;
}
.right {
flex: 1;
h2 {
line-height: 48px;
margin-bottom: 8px;
font-size: 34px;
color: #333333;
}
p {
color: #FFB94C;
font-size: 26px;
}
}
}
}
.rz {
padding-bottom: 48px;
.rz-info {
padding: 0 24px;
}
.rz-item {
display: flex;
margin-bottom: 24px;
&:last-child {
margin-bottom: 0;
}
h3 {
width: 120px;
line-height: 40px;
margin-right: 40px;
color: #999999;
font-size: 28px;
text-align: justify;
}
span {
flex: 1;
line-height: 40px;
color: #333333;
font-size: 28px;
}
}
.more {
width: 638px;
height: 88px;
line-height: 88px;
margin: 36px auto 0;
font-size: 34px;
color: #FFFFFF;
text-align: center;
background-image: linear-gradient(90deg, #75BDFF 0%, #4783FF 100%);
box-shadow: 0 8px 12px -4px rgba(133,196,255,0.65);
border-radius: 8px;
}
}
.section {
margin-bottom: 24px;
background: #FFFFFF;
box-shadow: 0 0 8px 0 rgba(0,0,0,0.02);
border-radius: 16px;
overflow: hidden;
& > h2 {
height: 96px;
line-height: 96px;
padding: 0 24px;
font-size: 34px;
color: #1D2229;
background-image: linear-gradient(180deg, #DCEFFF 0%, rgba(220,239,255,0.00) 100%);
}
2022-11-02 17:47:19 +08:00
}
.back-wrapper {
position: fixed;
z-index: 11;
left: 20px;
top: 24px;
width: 40px;
height: 40px;
image {
width: 40px;
height: 40px;
}
}
.header {
position: fixed;
left: 0;
top: 0;
z-index: 111;
width: 100%;
opacity: 1;
transition: all 0.2s ease;
.nav-bar {
position: relative;
height: 88px;
line-height: 88px;
color: #000;
font-size: 34px;
font-weight: 600;
text-align: center;
image {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 40px;
height: 40px;
padding: 24px 20px 0 20px;
box-sizing: content-box;
}
}
&.header-active {
z-index: 1111;
opacity: 1;
color: #fff;
background: linear-gradient(180deg, #2D7DFF 0%, #2D7DFF 40%);
.nav-bar {
color: #fff;
}
}
}
2022-11-07 17:35:37 +08:00
2022-11-01 19:08:20 +08:00
.banner {
display: block;
width: 686px;
2022-11-07 17:35:37 +08:00
height: 352px;
2022-11-08 18:10:21 +08:00
margin: 0 auto 32px;
2022-11-07 17:35:37 +08:00
border-radius: 8px;
2022-11-08 18:10:21 +08:00
overflow: hidden;
image {
width: 686px;
height: 352px;
border-radius: 8px;
}
2022-11-01 19:08:20 +08:00
}
.nav {
display: flex;
align-items: center;
justify-content: space-between;
2022-11-07 17:35:37 +08:00
margin: 0 0 32px;
padding: 0 36px;
2022-11-01 19:08:20 +08:00
.nav-item {
2022-11-07 17:35:37 +08:00
width: 112px;
line-height: 1;
text-align: center;
2022-11-01 19:08:20 +08:00
image {
2022-11-07 17:35:37 +08:00
width: 112px;
height: 116px;
2022-11-01 19:08:20 +08:00
}
2022-11-07 17:35:37 +08:00
span {
display: block;
text-align: center;
color: #333;
font-size: 28px;
2022-11-01 19:08:20 +08:00
}
}
}
}
2022-11-01 18:30:12 +08:00
</style>