2025-03-30 18:00:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="page-content">
|
2025-04-07 18:36:18 +08:00
|
|
|
|
<view v-if="userStatus === 'verified'" class="user-box flex" :style="{'padding-top': statusBaeHeight + 60 + 'px'}" @click="toSettings">
|
2025-03-30 18:00:11 +08:00
|
|
|
|
<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">
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="cuIcon-people text-xl"></text>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="flex-direction flex">
|
2025-04-07 18:36:18 +08:00
|
|
|
|
<text class="text-xl font-bold margin-bottom">{{ userInfo.nickName || barInfo.nickName || '未设置昵称' }}</text>
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="text-sm margin-bottom-sm text-gray">门店名称:{{ barInfo.barName || '-'}}</text>
|
2025-04-06 12:46:05 +08:00
|
|
|
|
<view class="flex align-center">
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="text-sm text-gray">门店ID:{{ barInfo.barNumber || '-' }}</text>
|
2025-04-06 12:46:05 +08:00
|
|
|
|
<view class="copy-btn" @click.stop="copyBarNumber">
|
|
|
|
|
<text class="cuIcon-copy"></text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-04-03 20:14:11 +08:00
|
|
|
|
<view v-else class="user-box flex align-center justify-start" :style="{'padding-top': statusBaeHeight + 60 + 'px'}" @click="handleUserBoxClick">
|
2025-03-30 18:00:11 +08:00
|
|
|
|
<view class="avatar-placeholder flex align-center justify-center">
|
2025-03-30 22:23:11 +08:00
|
|
|
|
<image src="/static/default-avatar.svg" class="default-avatar"></image>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="login-text flex align-center">
|
2025-04-03 22:11:37 +08:00
|
|
|
|
<view class="flex-col status-text">
|
|
|
|
|
<block v-if="userStatus === 'guest'">
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="text-xl font-bold">登录/认证</text>
|
2025-04-03 22:11:37 +08:00
|
|
|
|
</block>
|
|
|
|
|
<block v-else-if="userStatus === 'unverified'">
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="text-xl font-bold">请点击认证门店信息</text>
|
2025-04-03 22:11:37 +08:00
|
|
|
|
</block>
|
|
|
|
|
<block v-else-if="userStatus === 'verifying'">
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="text-xl font-bold">正在认证审核中</text>
|
|
|
|
|
<text class="text-xs text-gray">请耐心等待</text>
|
2025-04-03 22:11:37 +08:00
|
|
|
|
</block>
|
|
|
|
|
</view>
|
2025-04-06 14:25:59 +08:00
|
|
|
|
<text class="cuIcon-right text-gray"></text>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="barInfo" class="scan-box">
|
2025-04-03 20:14:11 +08:00
|
|
|
|
<view v-if="barInfo.authState == 0" class="exprieTime">未认证</view>
|
2025-04-07 17:33:39 +08:00
|
|
|
|
<view v-else-if="barInfo.authState == 2" class="exprieTime">认证中</view>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
<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>
|
2025-04-03 00:24:29 +08:00
|
|
|
|
<text class="text-xs">击败全国{{myScanData.percent}}%认证门店</text>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</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>
|
2025-04-07 18:36:18 +08:00
|
|
|
|
<text class="text-lg">我的关注</text>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</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>
|
2025-04-06 12:46:05 +08:00
|
|
|
|
<text class="text-lg">添加啤啤猩球小助手</text>
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</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';
|
2025-04-06 14:25:59 +08:00
|
|
|
|
import { getToken, removeToken, getUserInfo as getUserInfoFromAuth, checkLogin, clearLoginStatus } from '@/utils/auth.js';
|
|
|
|
|
|
2025-03-30 18:00:11 +08:00
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
loginPopup
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
userInfo: null,
|
2025-04-01 20:53:26 +08:00
|
|
|
|
loading: true,
|
2025-03-30 18:00:11 +08:00
|
|
|
|
barInfo: null,
|
2025-04-01 20:53:26 +08:00
|
|
|
|
myScanData: null,
|
2025-04-06 14:25:59 +08:00
|
|
|
|
statusBaeHeight: 40,
|
|
|
|
|
isLoggedIn: false
|
2025-03-30 18:00:11 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
2025-04-03 20:14:11 +08:00
|
|
|
|
computed: {
|
|
|
|
|
// 用户状态
|
|
|
|
|
userStatus() {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
console.log('登录状态检查:', {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
isLoggedIn: this.isLoggedIn,
|
|
|
|
|
barInfo: this.barInfo,
|
|
|
|
|
authState: this.barInfo ? this.barInfo.authState : 'barInfo为空'
|
|
|
|
|
});
|
|
|
|
|
|
2025-04-06 14:25:59 +08:00
|
|
|
|
if (!this.isLoggedIn) return 'guest';
|
|
|
|
|
if (!this.barInfo || this.barInfo.authState === 0) return 'unverified';
|
2025-04-07 17:33:39 +08:00
|
|
|
|
if (this.barInfo.authState === 2) return 'verifying';
|
2025-04-06 14:25:59 +08:00
|
|
|
|
return 'verified';
|
2025-04-06 12:46:05 +08:00
|
|
|
|
},
|
|
|
|
|
maskedPhone() {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
if (!this.barInfo || !this.barInfo.barContactPhone) return '';
|
2025-04-06 12:46:05 +08:00
|
|
|
|
return this.barInfo.barContactPhone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
2025-04-03 20:14:11 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2025-03-30 18:00:11 +08:00
|
|
|
|
onLoad() {
|
|
|
|
|
this.statusBaeHeight = uni.getWindowInfo.statusBarHeight
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
console.log('页面显示,检查登录状态');
|
|
|
|
|
this.checkLoginStatus();
|
2025-03-30 18:00:11 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2025-04-01 20:53:26 +08:00
|
|
|
|
// 检查登录状态
|
2025-04-06 14:25:59 +08:00
|
|
|
|
async checkLoginStatus() {
|
|
|
|
|
try {
|
|
|
|
|
const token = uni.getStorageSync('token');
|
|
|
|
|
const userInfo = uni.getStorageSync('userInfo');
|
|
|
|
|
|
|
|
|
|
// 检查token和userInfo是否有效
|
|
|
|
|
if (!token || token.startsWith('temp_') || !userInfo) {
|
|
|
|
|
this.isLoggedIn = false;
|
|
|
|
|
this.userInfo = null;
|
|
|
|
|
this.barInfo = null;
|
|
|
|
|
this.myScanData = null;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.isLoggedIn = true;
|
|
|
|
|
this.userInfo = userInfo;
|
|
|
|
|
|
2025-04-06 14:55:47 +08:00
|
|
|
|
// 先获取酒吧信息
|
|
|
|
|
await getBarInfo().then(res => {
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
this.barInfo = res.data;
|
|
|
|
|
// 如果是认证中状态,设置默认的扫码数据
|
2025-04-07 17:33:39 +08:00
|
|
|
|
if (this.barInfo.authState === 2) {
|
2025-04-06 14:55:47 +08:00
|
|
|
|
this.myScanData = { scanCount: 0, percent: 0 };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error('获取酒吧信息失败:', err);
|
|
|
|
|
if (err.code === 500 && err.msg.includes('门店未认证')) {
|
|
|
|
|
this.barInfo = {
|
2025-04-07 17:33:39 +08:00
|
|
|
|
authState: 2,
|
2025-04-06 14:55:47 +08:00
|
|
|
|
barName: '',
|
|
|
|
|
barNumber: '',
|
|
|
|
|
barContactPhone: ''
|
|
|
|
|
};
|
|
|
|
|
this.myScanData = { scanCount: 0, percent: 0 };
|
|
|
|
|
} else {
|
|
|
|
|
this.barInfo = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 如果不是认证中状态,获取扫码数据
|
2025-04-07 17:33:39 +08:00
|
|
|
|
if (this.barInfo && this.barInfo.authState !== 2) {
|
2025-04-06 14:55:47 +08:00
|
|
|
|
await getMyScanData().then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.myScanData = res.data;
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error('获取扫码数据失败:', err);
|
|
|
|
|
this.myScanData = { scanCount: 0, percent: 0 };
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('检查登录状态失败:', error);
|
|
|
|
|
return false;
|
|
|
|
|
} finally {
|
|
|
|
|
this.loading = false;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
}
|
2025-04-01 20:53:26 +08:00
|
|
|
|
},
|
2025-03-30 18:00:11 +08:00
|
|
|
|
loginSuccess() {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
console.log('登录成功,开始更新页面数据');
|
|
|
|
|
// 更新登录状态
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.userInfo = getUserInfoFromAuth();
|
2025-04-05 14:07:39 +08:00
|
|
|
|
this.isLoggedIn = true;
|
|
|
|
|
|
|
|
|
|
// 使用 Promise.all 同时获取所有需要的数据
|
|
|
|
|
Promise.all([
|
|
|
|
|
this.getBarInfoFun(),
|
|
|
|
|
this.getMyScanDataFun()
|
|
|
|
|
]).then(() => {
|
|
|
|
|
console.log('所有数据更新完成');
|
|
|
|
|
// 强制更新视图
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
// 显示登录成功提示
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '登录成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1500
|
|
|
|
|
});
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error('数据更新失败:', err);
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '数据更新失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
},
|
|
|
|
|
// 获取酒吧信息
|
|
|
|
|
getBarInfoFun() {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
if (!this.isLoggedIn) {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
console.log('用户未登录,不获取酒吧信息');
|
|
|
|
|
return Promise.reject('未登录');
|
2025-04-05 14:07:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-06 14:25:59 +08:00
|
|
|
|
return getBarInfo().then(res => {
|
|
|
|
|
console.log('获取酒吧信息成功:', res);
|
2025-04-05 14:07:39 +08:00
|
|
|
|
if (res && res.data) {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.barInfo = res.data;
|
2025-04-05 14:07:39 +08:00
|
|
|
|
// 强制更新视图
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
return this.barInfo;
|
2025-04-05 14:07:39 +08:00
|
|
|
|
} else {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
console.log('获取酒吧信息成功,但数据为空');
|
|
|
|
|
this.barInfo = null;
|
|
|
|
|
return Promise.reject('数据为空');
|
2025-04-01 20:53:26 +08:00
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
console.error('获取酒吧信息失败:', err);
|
|
|
|
|
this.barInfo = null;
|
|
|
|
|
return Promise.reject(err);
|
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
},
|
|
|
|
|
// 获取我的扫码数据
|
|
|
|
|
getMyScanDataFun() {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
if (!this.isLoggedIn) {
|
|
|
|
|
return Promise.reject('未登录');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getMyScanData().then(res => {
|
2025-04-01 20:53:26 +08:00
|
|
|
|
if (res.code === 200) {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
this.myScanData = res.data;
|
|
|
|
|
return this.myScanData;
|
|
|
|
|
} else {
|
|
|
|
|
return Promise.reject(res);
|
2025-04-01 20:53:26 +08:00
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
2025-04-05 14:07:39 +08:00
|
|
|
|
console.error('获取扫码数据失败:', err);
|
2025-04-01 20:53:26 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '获取扫码数据失败',
|
|
|
|
|
icon: 'none'
|
2025-04-05 14:07:39 +08:00
|
|
|
|
});
|
|
|
|
|
return Promise.reject(err);
|
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
},
|
2025-04-03 20:14:11 +08:00
|
|
|
|
// 处理用户信息区域点击
|
|
|
|
|
handleUserBoxClick() {
|
|
|
|
|
switch (this.userStatus) {
|
|
|
|
|
case 'guest':
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.$refs.loginRef.open();
|
|
|
|
|
break;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
case 'unverified':
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/index/registration'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
break;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
case 'verifying':
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '您的门店正在认证中,请耐心等待',
|
|
|
|
|
icon: 'none'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
break;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
default:
|
2025-04-06 14:25:59 +08:00
|
|
|
|
break;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2025-04-01 20:53:26 +08:00
|
|
|
|
// 页面跳转
|
2025-03-30 18:00:11 +08:00
|
|
|
|
toPage(index) {
|
2025-04-01 20:53:26 +08:00
|
|
|
|
// 添加枝点小助手不需要登录
|
|
|
|
|
if (index === 5) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/addAiad'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
return;
|
2025-04-01 20:53:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查登录状态
|
|
|
|
|
if (!this.isLoggedIn) {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.$refs.loginRef.open();
|
|
|
|
|
return;
|
2025-03-30 18:00:11 +08:00
|
|
|
|
}
|
2025-04-01 20:53:26 +08:00
|
|
|
|
|
2025-04-03 20:14:11 +08:00
|
|
|
|
// 检查认证状态
|
|
|
|
|
if (this.userStatus === 'unverified') {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/index/registration'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
return;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 认证中状态只能查看部分功能
|
|
|
|
|
if (this.userStatus === 'verifying') {
|
|
|
|
|
if (index === 6) { // 意见反馈
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/feedback'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
return;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
}
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '您的门店正在认证中,请耐心等待',
|
|
|
|
|
icon: 'none'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
|
|
|
|
return;
|
2025-04-03 20:14:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 已认证状态可以访问所有功能
|
2025-03-30 18:00:11 +08:00
|
|
|
|
switch (index) {
|
|
|
|
|
case 1: // 我参与的
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: '/pages/index/myJoin'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 2: // 我的关注
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/myAttention'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 3: // 我的酒评
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/myWineReview'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 4: // 我的地址
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/myAddress'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 6: // 意见反馈
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/feedback'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 7: // 设置
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/setting'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-01 20:53:26 +08:00
|
|
|
|
break;
|
2025-03-30 18:00:11 +08:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 退出登录
|
|
|
|
|
logout() {
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '确定要退出登录吗?',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
2025-04-03 22:18:04 +08:00
|
|
|
|
// 清除本地存储的用户信息
|
2025-04-06 14:25:59 +08:00
|
|
|
|
clearLoginStatus();
|
2025-04-01 20:53:26 +08:00
|
|
|
|
|
2025-04-03 22:18:04 +08:00
|
|
|
|
// 跳转到首页
|
2025-04-01 20:53:26 +08:00
|
|
|
|
uni.reLaunch({
|
2025-04-03 22:18:04 +08:00
|
|
|
|
url: '/pages/index/index'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-03-30 18:00:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-01 20:53:26 +08:00
|
|
|
|
},
|
|
|
|
|
// 关闭登录弹窗
|
|
|
|
|
closeLoginPopup() {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.$refs.loginRef.close();
|
2025-04-01 20:53:26 +08:00
|
|
|
|
},
|
|
|
|
|
// 去登录
|
|
|
|
|
toLogin() {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/index/registration'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
},
|
2025-04-07 18:36:18 +08:00
|
|
|
|
// 跳转到设置页面
|
|
|
|
|
toSettings() {
|
|
|
|
|
if (this.userStatus === 'verified') {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/setting'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2025-04-06 12:46:05 +08:00
|
|
|
|
// 显示修改头像提示
|
|
|
|
|
showChangeAvatar() {
|
|
|
|
|
uni.showActionSheet({
|
|
|
|
|
itemList: ['修改头像'],
|
|
|
|
|
success: () => {
|
2025-04-07 18:36:18 +08:00
|
|
|
|
this.toSettings();
|
2025-04-06 12:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2025-04-07 18:36:18 +08:00
|
|
|
|
// 跳转到设置页面(统一使用这个方法)
|
2025-04-06 12:46:05 +08:00
|
|
|
|
toSetting() {
|
2025-04-07 18:36:18 +08:00
|
|
|
|
if (this.userStatus === 'verified') {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pagesMy/setting'
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-04-06 12:46:05 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取用户信息
|
2025-04-06 14:25:59 +08:00
|
|
|
|
async getUserInfo() {
|
|
|
|
|
try {
|
|
|
|
|
if (!this.isLoggedIn) {
|
|
|
|
|
console.log('未登录状态');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const result = await getUserInfoFromAuth();
|
|
|
|
|
console.log('获取用户信息结果:', result);
|
|
|
|
|
|
|
|
|
|
if (result && result.barId) {
|
|
|
|
|
this.barInfo = result;
|
|
|
|
|
// 如果用户没有昵称,设置默认昵称
|
|
|
|
|
if (!this.barInfo.nickName) {
|
|
|
|
|
this.barInfo.nickName = this.barInfo.barName + '01';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
console.error('获取用户信息失败:', result);
|
|
|
|
|
// 不重置登录状态,只显示错误提示
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '获取用户信息失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
}
|
2025-04-06 14:25:59 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取用户信息出错:', error);
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '获取用户信息失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 复制门店ID
|
|
|
|
|
copyBarNumber() {
|
|
|
|
|
if (!this.barInfo || !this.barInfo.barNumber) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '暂无门店ID',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uni.setClipboardData({
|
|
|
|
|
data: this.barInfo.barNumber,
|
|
|
|
|
success: () => {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '复制成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 选择头像
|
|
|
|
|
async onChooseAvatar() {
|
|
|
|
|
try {
|
|
|
|
|
// 调用微信选择头像接口
|
|
|
|
|
const res = await uni.chooseImage({
|
|
|
|
|
count: 1,
|
|
|
|
|
sizeType: ['compressed'],
|
|
|
|
|
sourceType: ['album', 'camera']
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
|
|
if (res.tempFilePaths && res.tempFilePaths.length > 0) {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '上传中...'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
|
|
// 上传头像
|
|
|
|
|
const uploadRes = await uni.uploadFile({
|
|
|
|
|
url: '/bar/barinfo', // 使用编辑酒吧信息接口
|
|
|
|
|
filePath: res.tempFilePaths[0],
|
|
|
|
|
name: 'barLogo', // 修改为正确的参数名
|
|
|
|
|
header: {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
'Authorization': getToken()
|
2025-04-06 12:46:05 +08:00
|
|
|
|
},
|
|
|
|
|
formData: {
|
|
|
|
|
// 添加其他必要的参数
|
|
|
|
|
barNumber: this.barInfo.barNumber
|
|
|
|
|
}
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
|
|
// 解析响应数据
|
2025-04-06 14:25:59 +08:00
|
|
|
|
let result;
|
2025-04-06 12:46:05 +08:00
|
|
|
|
try {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
result = JSON.parse(uploadRes.data);
|
2025-04-06 12:46:05 +08:00
|
|
|
|
} catch (e) {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
result = uploadRes.data;
|
2025-04-06 12:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result.code === 200 && result.data) {
|
|
|
|
|
// 更新本地存储的门店信息
|
2025-04-06 14:25:59 +08:00
|
|
|
|
const barInfo = uni.getStorageSync('barInfo');
|
|
|
|
|
barInfo.barLogo = result.data;
|
|
|
|
|
uni.setStorageSync('barInfo', barInfo);
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
|
|
// 更新页面显示
|
2025-04-06 14:25:59 +08:00
|
|
|
|
this.barInfo = barInfo;
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '更新成功',
|
|
|
|
|
icon: 'success'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
} else {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
throw new Error(result.msg || '上传失败');
|
2025-04-06 12:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
console.error('选择头像失败:', error);
|
2025-04-06 12:46:05 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
title: error.message || '选择头像失败',
|
|
|
|
|
icon: 'none'
|
2025-04-06 14:25:59 +08:00
|
|
|
|
});
|
2025-04-06 12:46:05 +08:00
|
|
|
|
} finally {
|
2025-04-06 14:25:59 +08:00
|
|
|
|
uni.hideLoading();
|
2025-04-06 12:46:05 +08:00
|
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.page-content {
|
|
|
|
|
height: 100vh;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
padding-bottom: 40rpx;
|
2025-04-04 00:10:01 +08:00
|
|
|
|
background: #f9f9f9;
|
2025-03-30 18:00:11 +08:00
|
|
|
|
|
|
|
|
|
.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;
|
|
|
|
|
}
|
2025-04-03 22:11:37 +08:00
|
|
|
|
|
|
|
|
|
.status-text {
|
|
|
|
|
margin-right: 12rpx;
|
|
|
|
|
|
|
|
|
|
text {
|
|
|
|
|
&:first-child {
|
|
|
|
|
margin-bottom: 8rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
|
width: 686rpx;
|
|
|
|
|
height: 104rpx;
|
|
|
|
|
border-radius: 30rpx;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
}
|
2025-04-06 12:46:05 +08:00
|
|
|
|
|
|
|
|
|
.copy-btn {
|
|
|
|
|
margin-left: 16rpx;
|
|
|
|
|
padding: 4rpx 12rpx;
|
|
|
|
|
background: #F5F5F5;
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
|
|
|
|
|
|
.cuIcon-copy {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
color: #666666;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-06 14:25:59 +08:00
|
|
|
|
|
|
|
|
|
.text-gray {
|
|
|
|
|
color: #999999;
|
|
|
|
|
}
|
2025-03-30 18:00:11 +08:00
|
|
|
|
</style>
|