348 lines
9.2 KiB
Vue
348 lines
9.2 KiB
Vue
<template>
|
||
<view class="page-content">
|
||
<view v-if="userInfo" class="user-box flex" :style="{'padding-top': statusBaeHeight + 60 + 'px'}">
|
||
<image v-if="userInfo.avatar" :src="userInfo.avatar" class="avatar-img"></image>
|
||
<image v-else-if="barInfo.barLogo" :src="barInfo.barLogo" class="avatar-img"></image>
|
||
<view v-else class="avatar-placeholder flex align-center justify-center">
|
||
<text class="cuIcon-people" style="font-size: 60rpx; color: #FFFFFF;"></text>
|
||
</view>
|
||
<view class="flex-direction flex">
|
||
<text class="text-bold text-xxl margin-bottom">{{ barInfo.nickName || barInfo.barContactPhone }}</text>
|
||
<text class="text-sm margin-bottom-sm" style="color:#A0A5BA">店铺名称:{{ barInfo.barName || '-'}}</text>
|
||
<text class="text-sm" style="color:#A0A5BA">店铺ID:{{ barInfo.barNumber || '-' }}</text>
|
||
</view>
|
||
</view>
|
||
<view v-else class="user-box flex align-center justify-start" :style="{'padding-top': statusBaeHeight + 60 + 'px'}" @click="$refs.loginRef.open()">
|
||
<view class="avatar-placeholder flex align-center justify-center">
|
||
<image src="/static/default-avatar.svg" class="default-avatar"></image>
|
||
</view>
|
||
<view class="login-text flex align-center">
|
||
<text style="color: #333333; font-size: 36rpx; margin-right: 12rpx;">登录/认证</text>
|
||
<text class="cuIcon-right" style="color: #999999; font-size: 32rpx;"></text>
|
||
</view>
|
||
</view>
|
||
<view v-if="barInfo" class="scan-box">
|
||
<view v-if="barInfo.authState == 0 || !barInfo.authEndTime" class="exprieTime">未认证</view>
|
||
<view v-else class="exprieTime">{{ barInfo.authEndTime }}认证到期</view>
|
||
<text>本月累计扫码酒款数量</text>
|
||
<view class="margin-top">
|
||
<view class="flex justify-between align-end margin-bottom-xs">
|
||
<text class="text-xxl text-bold">{{myScanData.scanCount}}</text>
|
||
<text class="text-xs">击败全国{{myScanData.percent}}%入驻门店</text>
|
||
</view>
|
||
|
||
<view class="cu-progress round striped active">
|
||
<view class="bg-green" :style="[{ width:`${myScanData.percent}%`}]"></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 功能区 -->
|
||
<view class="fun-box">
|
||
<view class="flex justify-between align-center margin-bottom" @click="toPage(1)">
|
||
<view class="flex align-center">
|
||
<image src="../../static/order.png" class="icon"></image>
|
||
<text class="text-lg">我参与的</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
<view class="flex justify-between align-center margin-bottom" @click="toPage(2)">
|
||
<view class="flex align-center">
|
||
<image src="../../static/collect.png" class="icon"></image>
|
||
<text class="text-lg">我的收藏</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
<view class="flex justify-between align-center margin-bottom" @click="toPage(3)">
|
||
<view class="flex align-center">
|
||
<image src="../../static/wineReview.png" class="icon"></image>
|
||
<text class="text-lg">我的酒评</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
<view class="flex justify-between align-center" @click="toPage(4)">
|
||
<view class="flex align-center">
|
||
<image src="../../static/address.png" class="icon"></image>
|
||
<text class="text-lg">地址信息</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
</view>
|
||
<view class="fun-box">
|
||
<view class="flex justify-between align-center margin-bottom" @click="toPage(5)">
|
||
<view class="flex align-center">
|
||
<image src="@/static/wenhao.png" class="icon"></image>
|
||
<text class="text-lg">添加枝点小助手</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
<view class="flex justify-between align-center margin-bottom" @click="toPage(6)">
|
||
<view class="flex align-center">
|
||
<image src="@/static/code.png" class="icon"></image>
|
||
<text class="text-lg">意见反馈</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
<view class="flex justify-between align-center" @click="toPage(7)">
|
||
<view class="flex align-center">
|
||
<image src="../../static/setting.png" class="icon"></image>
|
||
<text class="text-lg">设置</text>
|
||
</view>
|
||
<text class="cuIcon-right"></text>
|
||
</view>
|
||
</view>
|
||
<view v-if="userInfo" class="flex justify-center">
|
||
<button class="cu-btn btn" style="background-color: #dedede;" @click="logout">退出登录</button>
|
||
</view>
|
||
<loginPopup ref="loginRef" @loginSuccess="loginSuccess"></loginPopup>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
getBarInfo
|
||
} from '@/api/bar.js'
|
||
import { getMyScanData } from '@/api/user.js'
|
||
import loginPopup from '@/components/loginPopup.vue';
|
||
export default {
|
||
components: {
|
||
loginPopup
|
||
},
|
||
data() {
|
||
return {
|
||
userInfo: null,
|
||
loading: true,
|
||
barInfo: null,
|
||
myScanData: null,
|
||
isLoggedIn: false,
|
||
statusBaeHeight: 40
|
||
};
|
||
},
|
||
onLoad() {
|
||
this.statusBaeHeight = uni.getWindowInfo.statusBarHeight
|
||
},
|
||
onShow() {
|
||
this.checkLoginStatus()
|
||
if (this.isLoggedIn) {
|
||
this.getBarInfoFun()
|
||
this.getMyScanDataFun()
|
||
}
|
||
},
|
||
methods: {
|
||
// 检查登录状态
|
||
checkLoginStatus() {
|
||
const token = uni.getStorageSync('token')
|
||
const userInfo = uni.getStorageSync('userInfo')
|
||
this.isLoggedIn = !!(token && userInfo)
|
||
this.userInfo = userInfo
|
||
this.loading = false
|
||
},
|
||
loginSuccess() {
|
||
this.userInfo = uni.getStorageSync('userInfo')
|
||
this.getBarInfoFun()
|
||
this.getMyScanDataFun()
|
||
},
|
||
// 获取酒吧信息
|
||
getBarInfoFun() {
|
||
if (!this.isLoggedIn) return
|
||
getBarInfo().then(res => {
|
||
if (res.code === 200) {
|
||
this.barInfo = res.data
|
||
}
|
||
}).catch(err => {
|
||
console.error('获取酒吧信息失败:', err)
|
||
uni.showToast({
|
||
title: '获取酒吧信息失败',
|
||
icon: 'none'
|
||
})
|
||
})
|
||
},
|
||
// 获取我的扫码数据
|
||
getMyScanDataFun() {
|
||
if (!this.isLoggedIn) return
|
||
getMyScanData().then(res => {
|
||
if (res.code === 200) {
|
||
this.myScanData = res.data
|
||
}
|
||
}).catch(err => {
|
||
console.error('获取扫码数据失败:', err)
|
||
uni.showToast({
|
||
title: '获取扫码数据失败',
|
||
icon: 'none'
|
||
})
|
||
})
|
||
},
|
||
// 页面跳转
|
||
toPage(index) {
|
||
// 添加枝点小助手不需要登录
|
||
if (index === 5) {
|
||
uni.navigateTo({
|
||
url: '/pagesMy/addAiad'
|
||
})
|
||
return
|
||
}
|
||
|
||
// 检查登录状态
|
||
if (!this.isLoggedIn) {
|
||
this.$refs.loginRef.open()
|
||
return
|
||
}
|
||
|
||
// 已登录状态,执行对应操作
|
||
switch (index) {
|
||
case 1: // 我参与的
|
||
uni.switchTab({
|
||
url: '/pages/index/myJoin'
|
||
})
|
||
break;
|
||
case 2: // 我的关注
|
||
uni.navigateTo({
|
||
url: '/pagesMy/myAttention'
|
||
})
|
||
break;
|
||
case 3: // 我的酒评
|
||
uni.navigateTo({
|
||
url: '/pagesMy/myWineReview'
|
||
})
|
||
break;
|
||
case 4: // 我的地址
|
||
uni.navigateTo({
|
||
url: '/pagesMy/myAddress'
|
||
})
|
||
break;
|
||
case 6: // 意见反馈
|
||
uni.navigateTo({
|
||
url: '/pagesMy/feedback'
|
||
})
|
||
break;
|
||
case 7: // 设置
|
||
uni.navigateTo({
|
||
url: '/pagesMy/setting'
|
||
})
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
},
|
||
// 退出登录
|
||
logout() {
|
||
if (!this.isLoggedIn) return
|
||
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '确定要退出登录吗?',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
// 清除登录状态
|
||
uni.removeStorageSync('token')
|
||
uni.removeStorageSync('userInfo')
|
||
this.isLoggedIn = false
|
||
this.userInfo = null
|
||
this.barInfo = null
|
||
this.myScanData = null
|
||
|
||
// 跳转到登录页
|
||
uni.reLaunch({
|
||
url: '/pages/index/chooseLogin'
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
// 关闭登录弹窗
|
||
closeLoginPopup() {
|
||
this.$refs.loginRef.close()
|
||
},
|
||
// 去登录
|
||
toLogin() {
|
||
uni.navigateTo({
|
||
url: '/pages/index/registration'
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.page-content {
|
||
height: 100vh;
|
||
overflow-y: auto;
|
||
padding-bottom: 40rpx;
|
||
background: #F2F2F2;
|
||
|
||
.user-box {
|
||
margin-left: 36rpx;
|
||
margin-right: 32rpx;
|
||
}
|
||
|
||
.scan-box {
|
||
position: relative;
|
||
margin-top: 52rpx;
|
||
background-color: #FFF;
|
||
padding: 28rpx 24rpx;
|
||
margin-left: 36rpx;
|
||
margin-right: 32rpx;
|
||
border-radius: 20rpx;
|
||
|
||
.exprieTime {
|
||
position: absolute;
|
||
right: 0;
|
||
top: 0;
|
||
background-color: #FFED34;
|
||
border-radius: 0 20rpx 0 30rpx;
|
||
padding: 10rpx 20rpx;
|
||
}
|
||
}
|
||
|
||
.fun-box {
|
||
border-radius: 30rpx;
|
||
padding: 40rpx 38rpx;
|
||
background-color: #FFF;
|
||
margin: 26rpx 32rpx 32rpx 36rpx;
|
||
|
||
.icon {
|
||
width: 80rpx;
|
||
height: 80rpx;
|
||
margin-right: 40rpx;
|
||
}
|
||
}
|
||
|
||
.avatar-img {
|
||
width: 160rpx;
|
||
height: 160rpx;
|
||
border-radius: 50%;
|
||
margin-right: 48rpx;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.avatar-placeholder {
|
||
width: 160rpx;
|
||
height: 160rpx;
|
||
border-radius: 50%;
|
||
margin-right: 48rpx;
|
||
background: #F7F7F7;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
||
overflow: hidden;
|
||
}
|
||
|
||
.default-avatar {
|
||
width: 80rpx;
|
||
height: 80rpx;
|
||
}
|
||
|
||
.login-text {
|
||
height: 160rpx;
|
||
transition: opacity 0.3s ease;
|
||
|
||
&:active {
|
||
opacity: 0.7;
|
||
}
|
||
}
|
||
}
|
||
|
||
.btn {
|
||
width: 686rpx;
|
||
height: 104rpx;
|
||
border-radius: 30rpx;
|
||
margin: 0 auto;
|
||
}
|
||
</style> |