Files
jianbing/pages/index/index.vue
2025-09-04 17:04:21 +08:00

245 lines
6.3 KiB
Vue

<template>
<view class="content">
<view class="store u-flex u-row-between u-p-32">
<view class="flex1 u-line-1">
<view class="lg bold-400 u-flex">
<navigator class="u-flex" url="/pages/store/choose_store" hover-class="none">
时光煎饼店
<u-icon name="arrow-right" size="28" class="right-icon"></u-icon>
</navigator>
</view>
<!-- <view class="u-m-t-8 u-line-1">
<navigator class="u-flex " url="/bundle/pages/address/address?type=1" hover-class="none">
<u-icon name="map" size="32"></u-icon>
<view class="u-line-1">
{{userAddress || '请选择收货地址'}}
</view>
</navigator>
</view> -->
</view>
<view>
<u-button shape="circle" :hair-line="false" hover-class="none" :customStyle="{backgroundColor: themeColor, color: '#fff', border: 'none', padding: '36rpx'}" @click="signin">签到</u-button>
</view>
</view>
<!-- 轮播图 -->
<view class="swiper u-relative">
<u-swiper height="524" :list="adList" border-radius="0"></u-swiper>
<view class="balance bg-white row-between u-p-l-54 u-p-r-54">
<navigator class="u-flex u-row-center" url="/pages/my/wallet" hover-class="none">
<u-image :src="cloudPath + 'img/icon_balance.png'" width="52" height="52"></u-image>
<view class="u-m-l-60 u-text-center">
<view class="nr">{{userInfo.user_money || 0.00}}</view>
<view class="text-default xs">余额</view>
</view>
</navigator>
<navigator class="u-flex u-row-center" url="/bundle/pages/points/points" hover-class="none">
<u-image :src="cloudPath + 'img/icon_points.png'" width="52" height="52"></u-image>
<view class="u-m-l-60 u-text-center">
<view class="nr">{{ userInfo.user_integral || 0}}</view>
<view class="text-default xs">积分</view>
</view>
</navigator>
<navigator class="u-flex u-row-center" url="/bundle/pages/coupon/coupon" hover-class="none">
<u-image :src="cloudPath + 'img/icon_coupon.png'" width="52" height="52"></u-image>
<view class="u-m-l-60 u-text-center">
<view class="nr">{{ userInfo.coupon || 0}}</view>
<view class="text-default xs u-text-center"></view>
</view>
</navigator>
</view>
</view>
<!-- 下单 -->
<view class="order u-flex u-row-center bg-white" @click="toStore">
<view>
<view class="reserve">预约下单</view>
<view class="desc">极速送达更便捷</view>
</view>
<view>
<u-image :src="cloudPath + 'img/home_image1.png'" width="204" height="204"></u-image>
</view>
<!-- <view class="bg-white u-text-center">
<navigator url="/pages/store/store?type=1" hover-class="none">
<view class="text-default xxl">预约下单</view>
<view class="xs text-999">极速送达更便捷</view>
<view class="u-flex u-row-center">
<u-image :src="cloudPath + 'img/icon_p_order.png'" width="132" height="132"></u-image>
</view>
</navigator>
</view> -->
<!-- <view class="u-text-center">
<navigator url="/pages/store/store?type=2" hover-class="none">
<view class="text-default xxl">现在点单</view>
<view class="xs text-999">预约下单更便捷</view>
<view class="u-flex u-row-center">
<u-image :src="cloudPath + 'img/icon_order.png'" width="132" height="133" mode="aspectFit"></u-image>
</view>
</navigator>
</view> -->
</view>
<!-- 活动图 -->
<view class="mx20 u-m-b-64">
<u-image :src="cloudPath + 'img/activity.png'" height="264"></u-image>
</view>
</view>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import { getConfig } from '@/api/app'
import { getUser, getDefaultAddress, getOneAddress } from '@/api/user'
import { getAdList } from '@/api/store'
import { setTabbar } from '@/utils/tools'
export default {
data() {
return {
adList: [],
userAddress: '',
addressId: 0
}
},
onLoad() {
setTabbar()
this.getUserAddress()
//更改收货地址
uni.$on('selectaddress', (params) => {
this.addressId = params.id
this.updateUserAddress()
})
this.getAdListFun()
},
onShow() {
this.getUser()
this.getCartNum()
},
onUnload() {
// 取消全局监听
uni.$off(['selectaddress'])
},
methods: {
...mapActions(['getCartNum', 'getUser']),
// 获取广告轮播图
async getAdListFun() {
const { code, data } = await getAdList({
pid: 1,
client: 1
})
if (code) {
this.adList = data
}
},
// 获取默认物流地址
getUserAddress() {
getDefaultAddress().then(res => {
if (res.code == 1) {
const {id, province, city, district, address} = res.data
this.userAddress = `${province} ${city} ${district} ${address}`
this.addressId = id
}
})
},
// 用户切换物流地址
updateUserAddress() {
getOneAddress(this.addressId).then(res => {
if (res.code == 1) {
const {id, province, city, district, address} = res.data
this.userAddress = `${province} ${city} ${district} ${address}`
this.addressId = id
}
})
},
// 签到
signin() {
uni.navigateTo({
url: '/pages/signin/signin'
})
},
toStore() {
uni.navigateTo({
url: '/pages/store/store'
})
}
},
computed: {
...mapGetters(['cartNum', 'userInfo', 'inviteCode', 'appConfig', 'cityInfo']),
statusBar() {
return uni.getSystemInfoSync().statusBarHeight + 10
}
}
}
</script>
<style lang="scss">
.content {
.store {
background-color: #FFFAFB;
height: 108rpx;
.right-icon {
font-weight: bold;
margin-left: 4rpx;
}
}
.swiper {
height: 544rpx;
box-sizing: border-box;
width: 100%;
.balance {
// display: grid;
// grid-template-columns: repeat(3, 1fr);
// place-items: center;
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 140rpx;
border-radius: 16rpx;
}
}
.order {
margin: 30rpx 20rpx;
height: 300rpx;
justify-content: center;
align-items: center;
& > view {
border-radius: 16rpx;
}
.reserve {
font-weight: 500;
font-size: 44rpx;
color: #254062;
line-height: 26rpx;
font-weight: 500;
margin-bottom: 34rpx;
}
.desc {
font-weight: 400;
font-size: 22rpx;
color: #999999;
line-height: 26rpx;
text-align: center;
font-style: normal;
text-transform: none;
}
}
}
</style>