Commit f59c101f authored by tao.huang's avatar tao.huang

Merge branch '20250528-dev-ht' of gitlab2.dui88.com:sparkprojects/20250528_FHQ1 into dev

parents 51fc5054 0c78a851
<template>
<view class="my-container">
<view class="bg-container">
<image
class="bg-img"
src="/static/my/cover_white_bg.png"
mode="aspectFit"
lazy-load="false"
binderror=""
bindload=""
/>
</view>
<!-- 用户信息区域 -->
<view class="user-info">
<view class="user-header">
<image class="avatar" :src="userInfo.avatar || '/static/my/avatar.png'" mode="aspectFill" />
<image
class="avatar"
:src="userInfo.avatar || '/static/my/avatar.png'"
mode="aspectFill"
/>
<view class="user-detail">
<text class="nickname">{{ userInfo.nickname || '未登录' }}</text>
<text class="nickname">{{ userInfo.nickname || "未登录" }}</text>
<view class="user-level">
<image class="level-icon" src="/static/my/level.png" mode="aspectFit" />
<image
class="level-icon"
src="/static/my/level.png"
mode="aspectFit"
/>
<text class="level-text">Lv.{{ userInfo.level || 1 }}</text>
</view>
</view>
<view class="edit-btn" @tap="handleEditProfile">
<image src="/static/my/edit.png" mode="aspectFit" />
</view>
</view>
<!-- user desc -->
<view class="user-desc">
<text class="desc-text"> </text>
</view>
</view>
<!-- 工具 -->
<view class="tool-container">
<text class="tool-title" selectable="false" space="false" decode="false">
工具
</text>
<view class="tool-list">
<view class="tool-item" v-for="item in toolList" :key="item.title">
<image class="tool-icon" :src="item.icon" mode="aspectFit" />
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { ref, onMounted } from "vue";
const toolList = ref([
{
icon: "/static/my/code.png",
title: "扫码积分",
url: "",
},
{
icon: "/static/my/suyuan.png",
title: "产品溯源",
url: "",
},
{
icon: "/static/my/book.png",
title: "奶娃宝典",
url: "",
},
{
icon: "/static/my/doctor.png",
title: "医生问诊",
url: "",
},
{
icon: "/static/my/literature.png",
title: "育儿百科",
url: "",
},
]);
// 用户信息
const userInfo = ref({
avatar: '',
nickname: '',
avatar: "",
nickname: "",
level: 1,
points: 0,
coupons: 0,
collects: 0
})
collects: 0,
});
// 订单数量统计
const orderCounts = ref({
......@@ -38,125 +102,131 @@ const orderCounts = ref({
shipping: 0,
receiving: 0,
comment: 0,
after: 0
})
after: 0,
});
// 页面跳转
const navigateTo = (url) => {
uni.navigateTo({
url,
fail: (err) => {
console.error('页面跳转失败:', err)
console.error("页面跳转失败:", err);
uni.showToast({
title: '页面跳转失败',
icon: 'none'
})
}
})
}
title: "页面跳转失败",
icon: "none",
});
},
});
};
// 编辑个人资料
const handleEditProfile = () => {
navigateTo('/pages/user/profile')
}
navigateTo("/pages/user/profile");
};
// 联系客服
const handleContactService = () => {
// #ifdef MP-WEIXIN
uni.openCustomerServiceChat({
extInfo: { url: 'YOUR_CUSTOMER_SERVICE_URL' },
corpId: 'YOUR_CORP_ID',
extInfo: { url: "YOUR_CUSTOMER_SERVICE_URL" },
corpId: "YOUR_CORP_ID",
success(res) {
console.log('打开客服会话成功')
console.log("打开客服会话成功");
},
fail(err) {
console.error('打开客服会话失败:', err)
console.error("打开客服会话失败:", err);
uni.showToast({
title: '打开客服会话失败',
icon: 'none'
})
}
})
title: "打开客服会话失败",
icon: "none",
});
},
});
// #endif
// #ifdef H5
window.open('YOUR_CUSTOMER_SERVICE_URL', '_blank')
window.open("YOUR_CUSTOMER_SERVICE_URL", "_blank");
// #endif
}
};
// 获取用户信息
const getUserInfo = async () => {
try {
// TODO: 调用获取用户信息接口
const res = await uni.request({
url: '/api/user/info',
method: 'GET'
})
url: "/api/user/info",
method: "GET",
});
if (res.data.code === 0) {
userInfo.value = res.data.data
userInfo.value = res.data.data;
}
} catch (error) {
console.error('获取用户信息失败:', error)
console.error("获取用户信息失败:", error);
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
title: "获取用户信息失败",
icon: "none",
});
}
}
};
// 获取订单数量
const getOrderCounts = async () => {
try {
// TODO: 调用获取订单数量接口
const res = await uni.request({
url: '/api/order/counts',
method: 'GET'
})
url: "/api/order/counts",
method: "GET",
});
if (res.data.code === 0) {
orderCounts.value = res.data.data
orderCounts.value = res.data.data;
}
} catch (error) {
console.error('获取订单数量失败:', error)
console.error("获取订单数量失败:", error);
}
}
// 下拉刷新
const onPullDownRefresh = async () => {
return
try {
await Promise.all([
getUserInfo(),
getOrderCounts()
])
uni.stopPullDownRefresh()
} catch (error) {
console.error('刷新数据失败:', error)
uni.stopPullDownRefresh()
}
}
};
// 页面加载
onMounted(() => {
// getUserInfo()
// getOrderCounts()
})
});
// 定义页面配置
defineExpose({
onPullDownRefresh
})
defineExpose({});
</script>
<style lang="scss" scoped>
.my-container {
.my-container {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 100rpx;
overflow: hidden;
.bg-container {
width: 750rpx;
height: 840rpx;
position: absolute;
top: 0;
left: 0;
z-index: 0;
.bg-img {
width: 100%;
height: 100%;
display: block;
}
}
.user-info {
background-color: #fff;
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
background-color: #fef7f2;
padding: 30rpx;
width: 686rpx;
height: 343rpx;
box-sizing: border-box;
border-radius: 32rpx;
position: relative;
margin: 0 auto;
margin-top: 676rpx;
.user-header {
display: flex;
......@@ -227,6 +297,52 @@ defineExpose({
}
}
}
.user-desc {
width: 100%;
height: 182rpx;
background-color: #fff;
border-radius: 32rpx;
padding: 30rpx 32rpx;
box-sizing: border-box;
position: absolute;
bottom: 0;
left: 0;
}
}
.tool-container {
margin: 0 auto;
margin-top: 48rpx;
width: 686rpx;
.tool-list {
display: flex;
flex-wrap: wrap;
margin: 32rpx 0;
}
.tool-title {
font-size: 32rpx;
font-weight: 500;
color: #1d1e25;
margin-left: 21rpx;
}
.tool-item {
width: 152rpx;
height: 152rpx;
margin-left: 26rpx;
margin-bottom: 24rpx;
.tool-icon {
width: 100%;
height: 100%;
display: block;
};
&:nth-child(4n+1) {
margin-left: 0;
}
}
}
.order-section {
......@@ -319,9 +435,9 @@ defineExpose({
}
}
}
}
}
.badge {
.badge {
position: absolute;
top: -8rpx;
right: -8rpx;
......@@ -332,9 +448,9 @@ defineExpose({
border-radius: 16rpx;
min-width: 32rpx;
text-align: center;
}
}
.type-item {
.type-item {
position: relative;
}
}
</style>
......@@ -47,11 +47,15 @@ const props = defineProps({
},
],
},
curTabIndex: {
type: Number,
default: 0,
},
});
const emit = defineEmits(["tabClick"]);
const currentIndex = ref(0);
const currentIndex = ref(props.curTabIndex);
const handleTabClick = (index, item) => {
currentIndex.value = index;
......
......@@ -4,7 +4,7 @@
<Brand v-if="curTabIndex == 1"></Brand>
<Integral v-if="curTabIndex == 2"></Integral>
<My v-if="curTabIndex == 3"></My>
<TabBar @tabClick="handleTabClick" />
<TabBar :curTabIndex="curTabIndex" @tabClick="handleTabClick" />
</view>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment