2025-11-12 14:15:43 +08:00

955 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<s-layout title="我的" tabbar="/pages/index/user" navbar="custom" :bgStyle="template.style?.background"
:navbarStyle="template.style?.navbar" onShareAppMessage :showFloatButton="true">
<!-- 顶部状态栏当页面滚动超过50rpx时显示 -->
<view v-if="topStatusBarVisible" class="top-status-bar" :style="statusBarStyle">
<su-status-bar />
<view class="status-bar-content">
<!-- <text>我的</text> -->
</view>
</view>
<!-- 登录信息 -->
<view class="myBox">
<scroll-view :refresher-enabled="false" scroll-y="true" class="flex align-items"
style="box-sizing: border-box;height: 94vh;" @scroll="handleScroll" :scroll-top="scrollTop">
<!-- :style="{height: isIphone ? `calc(90vh - ${systemInfo.safeAreaInsets.bottom}px)` : '94vh',}" -->
<view class="con-center flex flex-start flex-column">
<view class="header">
<!-- 用户信息 -->
<view class="hea-left flex">
<view class="head-avatar" v-if="isLogin == true"
@click="sheep.$router.go('/pages/user/info')">
<image style="width: 130rpx;height: 130rpx;border-radius: 152rpx;"
:src="baseUrl + userInfo.avatar" mode="aspectFill"></image>
</view>
<view class="head-avatar" v-else @click="toLogin">
<image style="width: 130rpx;height: 130rpx;border-radius: 152rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/defaultAvatar.png">
</image>
</view>
<view class="headAvatar-info justify-start">
<view class="info-name fs-36 weight8 flexD" v-if="isLogin == true">
<view style="font-weight: 800;" @click="sheep.$router.go('/pages/user/info')">
{{ userInfo.nickname}}
</view>
</view>
<view class="info-name fs-36 weight8 flexD" v-else>
<view style="font-weight: 800;" @click="toLogin">登录/注册</view>
</view>
<!-- <view class="fs-28 weight4" style="margin-top: 30rpx;">会员到期时间
剩余{{ userInfo.all_mobile_num ? userInfo.all_mobile_num : 0 }}
</view> -->
</view>
</view>
</view>
<!-- 我的订单 -->
<view class="myOrder">
<view class="myOrder-first" @click="toPage('/pages/order/list')">
<view style="font-weight: 800;font-size: 34rpx;line-height: 28rpx;color: #3d3d3d;">我的订单
</view>
<view style="display: flex;align-items: center;justify-content: center;">
<view style="font-size: 26rpx;line-height: 26rpx;font-weight: 400;color: #999999;">全部订单
</view>
<image style="width: 28rpx;height: 28rpx;margin-left: 10rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/rightMore.png" mode=""></image>
<!-- <uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons> -->
</view>
</view>
<view class="myOrder-second">
<view class="pendingBox" @click="toPage('/pages/order/list?type=1')">
<image class="pendImg" src="https://mall.jiangxiaoxian.hschool.com.cn/pendPay.png"></image>
<view class="fs-28 weight4" style="margin-top: 20rpx;color: #3d3d3d;">待支付</view>
</view>
<view class="pendingBox" @click="toPage('/pages/order/list?type=2')">
<image class="pendImg" src="https://mall.jiangxiaoxian.hschool.com.cn/shipment.png"></image>
<view class="fs-28 weight4" style="margin-top: 20rpx;color: #3d3d3d;">待发货</view>
</view>
<view class="pendingBox" @click="toPage('/pages/order/list?type=3')">
<image class="pendImg" src="https://mall.jiangxiaoxian.hschool.com.cn/pendingDoods.png">
</image>
<view class="fs-28 weight4" style="margin-top: 20rpx;color: #3d3d3d;">待收货</view>
</view>
<view class="pendingBox" @click="toPage('/pages/order/list?type=4')">
<image class="pendImg" src="https://mall.jiangxiaoxian.hschool.com.cn/completed.png"></image>
<view class="fs-28 weight4" style="margin-top: 20rpx;color: #3d3d3d;">已完成</view>
</view>
</view>
</view>
<!-- 发布分享等 -->
<view class="sixBox">
<!-- 官方客服 @click="toPage('/pages/chat/index')" -->
<view class="fabuBox" @click="handleService()">
<view class="flex align-items">
<image style="width: 36rpx;height: 36rpx;margin-right: 20rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/service.png"></image>
<view style="font-size: 30rpx;font-weight: 800;line-height: 28rpx;color: #333333;">官方客服
</view>
</view>
<image style="width: 28rpx;height: 28rpx;margin-left: 10rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/rightMore.png" mode=""></image>
</view>
<view class="line-row" style="margin: 40rpx 0;"></view>
<!-- 关于我们 -->
<view class="fabuBox" @click="toPage(`/pages/public/richtext?id=`+ appInfo.about_us.id + '&title='+ appInfo.about_us.title)">
<view class="flex align-items">
<image style="width: 36rpx;height: 36rpx;margin-right: 20rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/aboutUs.png"></image>
<view style="font-size: 30rpx;font-weight: 800;line-height: 28rpx;color: #333333;">关于我们
</view>
</view>
<image style="width: 28rpx;height: 28rpx;margin-left: 10rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/rightMore.png" mode=""></image>
</view>
<view class="line-row" style="margin: 40rpx 0;"></view>
<!-- 退出登录 -->
<view class="fabuBox" @click="onLogout()">
<view class="flex align-items">
<image style="width: 36rpx;height: 36rpx;margin-right: 20rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/outLogin.png"></image>
<view style="font-size: 30rpx;font-weight: 800;line-height: 28rpx;color: #333333;">退出登录
</view>
</view>
<image style="width: 28rpx;height: 28rpx;margin-left: 10rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/rightMore.png" mode=""></image>
</view>
</view>
<view style="height: 180rpx;width: 100%;"></view>
</view>
<view class="width:100%;height:200rpx"></view>
</scroll-view>
<su-popup :show="showLogin == true" type="center" round="10" @close="showLogin = false"
@open="showLogin = true">
<view class="popup">
<button class="texbut" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- <image style="width: 100%;height: 136rpx;" src="https://mall.jiangxiaoxian.hschool.com.cn/loginBtnTwo.png"></image> -->
<!-- 授权登录 -->
</button>
</view>
<view style="margin: 0 auto;position: absolute;bottom: -90rpx;width: 100%;text-align: center;">
<image style="width: 50rpx;height: 50rpx;"
src="https://mall.jiangxiaoxian.hschool.com.cn/registerCancel.png" mode="aspectFill"
@click="showLogin = false"></image>
</view>
</su-popup>
<!-- <u-toast ref="uToast"></u-toast> -->
</view>
<!-- <s-block v-for="(item, index) in template.data" :key="index" :styles="item.style">
<s-block-item :type="item.type" :data="item.data" :styles="item.style" />
</s-block> -->
</s-layout>
</template>
<script setup>
import {
computed,
ref,
reactive,
onMounted
} from 'vue';
import {
onShow,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import sheep from '@/sheep';
import userApi from '@/sheep/api/user';
import third from '@/sheep/api/third';
import {
baseUrl,
} from '@/sheep/config';
import {
showShareModal
} from '@/sheep/hooks/useModal';
const appInfo = computed(() => sheep.$store('app').info);
// 状态栏置顶相关变量
const topStatusBarVisible = ref(false);
// 状态栏和胶囊按钮信息
const statusBarHeight = ref(0);
const menuButtonInfo = ref({});
const platform = ref('');
// 获取系统信息
const getSystemInfo = () => {
const systemInfo = uni.getSystemInfoSync();
platform.value = systemInfo.platform;
statusBarHeight.value = systemInfo.statusBarHeight;
// 获取胶囊按钮信息
const menuButton = uni.getMenuButtonBoundingClientRect();
menuButtonInfo.value = menuButton;
console.log('平台:', platform.value);
console.log('状态栏高度:', statusBarHeight.value);
console.log('胶囊按钮信息:', menuButton);
};
// 计算状态栏样式
const statusBarStyle = computed(() => {
// 统一使用状态栏高度 + 导航栏高度,确保在各平台都正确显示
const navHeight = 44; // 标准导航栏高度
// const height = statusBarHeight.value + navHeight;
let height = 0;
if (platform.value === 'ios') {
// iOS平台使用状态栏高度 + 导航栏高度
height = navHeight;
} else {
// Android平台使用稍小的高度
height = statusBarHeight.value + 42; // Android平台导航栏稍小
}
return {
height: height + 'px',
// paddingTop: statusBarHeight.value + 'px'
};
});
onMounted(() => {
getSystemInfo();
});
// 滚动处理函数
function handleScroll(e) {
// 当滚动距离超过50rpx时显示状态栏
if (e.detail.scrollTop > 45) {
topStatusBarVisible.value = true;
} else {
topStatusBarVisible.value = false;
}
}
const showLogin = ref(false);
const iv = ref('');
const wxCode = ref('');
const encryptedData = ref('');
const urlE = ref('');
// 隐藏原生tabBar
uni.hideTabBar({
fail: () => {},
});
const template = computed(() => sheep.$store('app').template.user);
const isLogin = computed(() => sheep.$store('user').isLogin);
const userInfo = computed(() => sheep.$store('user').userInfo);
const authenInfo = computed(() => sheep.$store('user').authenInfo);
const systemInfo = ref()
const isIphone = ref(false)
const scrollHeight = ref()
onShow(() => {
// console.log('onShow',authenInfo.value.status);
isIos();
getSystemInfo(); // 添加这行
sheep.$store('user').updateUserData();
getStaffInfo();
});
// 页面滚动事件(保留原有功能)
onPageScroll(() => {});
function isIos() {
systemInfo.value = uni.getSystemInfoSync();
console.log('systemInfo.value', systemInfo.value.windowHeight);
isIphone.value = systemInfo.platform === 'ios' || /iphone|ipad/i.test(systemInfo.model);
console.log('isIphone', isIphone.value);
// 计算屏幕可用高度的百分比px 单位)
// const totalHeight = systemInfo.value.windowHeight; // 可使用窗口高度(不含导航栏等)
// const iphoneHeight = Math.floor(totalHeight * 1); // 70% 屏幕高度
// const androidHeight = Math.floor(totalHeight * 0.78); // 78% 屏幕高度
// scrollHeight.value = isIphone.value ? `${iphoneHeight}px` : `${androidHeight}px`;
// if (isIphone.value) {
// this.footerStyle = 'padding-bottom: 68rpx;';
// }
}
// 打开登录的弹框
function toLogin() {
console.log('toLogin', showLogin.value);
showLogin.value = true;
console.log('showLogin', showLogin.value);
}
// 关闭登录弹框
function closeLogin() {
console.log('closeLogin');
showLogin.value = false;
}
// 打开登录的弹框
function openLogin() {
console.log('openLogin');
showLogin.value = true;
}
// 使用微信手机号
async function getPhoneNumber(e) {
console.log('获取手机号', e, e.detail.errMsg);
if (e.detail.errMsg !== 'getPhoneNumber:ok') {} else {
encryptedData.value = e.detail.encryptedData // 用于解密
iv.value = e.detail.iv // 用于解密
getCode()
// let result = await sheep.$platform.useProvider().bindUserPhoneNumber(e.detail);
// console.log('result', result);
// if (result) {
// sheep.$store('user').getInfo();
// // closeAuthModal();
// closeLogin();
// }
}
}
// 获取code和sessionId
function getCode() {
uni.login({
provider: 'weixin',
success: (res) => {
wxCode.value = res.code
// loginResult.value = res
// getSessionId();
Login();
}
})
}
// 登录接口
function Login() {
const session_id = uni.getStorageSync('sessionId')
console.log('session_id', session_id);
return new Promise(async (resolve, reject) => {
const {
code
} = await third.wechat.wxLogin({
platform: 'miniProgram',
payload: encodeURIComponent(
JSON.stringify({
sessionId: session_id,
iv: iv.value,
encryptedData: encryptedData.value,
code: wxCode.code,
}),
),
});
if (code === 1) {
resolve(true);
getStaffInfo();
showLogin.value = false;
toPage(urlE.value);
if (canShareApp.value == true) {
shareApp();
}
if (servicePan.value == true) {
getInfoUser();
}
if (setShow.value == true) {
toSetting();
}
}
resolve(false);
});
}
//设置跳转页面
const setShow = ref(false);
function toSetting() {
console.log('isLogin', isLogin.value);
if (isLogin.value == true) {
setShow.value = false;
uni.navigateTo({
url: '/pages/user/info'
})
} else {
toLogin();
setShow.value = true;
// sheep.$helper.toast('请先登录');
// uni.showToast({
// title: '请先登录',
// icon: 'none'
// })
}
}
//页面跳转
const toPage = (e) => {
if (isLogin.value == true) {
uni.navigateTo({
url: e
})
// if(e == '/pages/staff/staffIndex') {
// sheep.$api.staff.staffInfo().then(res => {
// console.log('员工信息接口返回值res:', res);
// if (res.code == 1) {
// staffBaseInfo.value = res.data.info;
// console.log('员工信息staffBaseInfo:', staffBaseInfo.value);
// } else {
// sheep.$helper.toast(res.msg);
// }
// })
// }else {
// uni.navigateTo({
// url: e
// })
// }
} else {
// showLogin.value = true;
toLogin()
urlE.value = e;
// sheep.$helper.toast('请先登录');
// setTimeout(function() {
// uni.switchTab({
// url: '/pages/index/user'
// })
// }, 2000);
}
}
//退出登录
function onLogout() {
uni.showModal({
title: '提示',
content: '确认退出账号?',
success: async function (res) {
if (res.confirm) {
const result = await sheep.$store('user').logout();
if (result) {
sheep.$router.go('/pages/index/user');
}
}
},
});
}
//分享限制
const canShareApp = ref(false);
function shareApp() {
if (isLogin.value == true) {
canShareApp.value = false;
showShareModal();
} else {
toLogin();
canShareApp.value = true;
}
}
//获取平台客服电话
function getInfoUser() {
userApi.profile().then(res => {
if (res.code == 1) {
console.log('获取个人信息:', res.data);
userInfo.value = res.data;
console.log('联系平台客服', userInfo.value.platform_contact_number);
handleService();
};
});
}
//联系平台客服
const servicePan = ref(false);
function handleService() {
if (isLogin.value == true) {
servicePan.value = false;
console.log('联系平台客服', userInfo.value.platform_contact_number);
wx.makePhoneCall({
phoneNumber: userInfo.value.platform_contact_number,
success: function() {
console.log("拨打电话成功")
},
fail: function(err) {
console.log("拨打电话失败", err)
}
})
} else {
toLogin();
servicePan.value = true;
}
}
const staffBaseInfo = ref({});
//员工信息
function getStaffInfo() {
console.log('获取员工信息');
sheep.$api.staff.staffInfo().then(res => {
console.log('员工信息接口返回值res:', res);
if (res.code == 1) {
staffBaseInfo.value = res.data.info;
console.log('员工信息staffBaseInfo:', staffBaseInfo.value);
} else {
sheep.$helper.toast(res.msg);
}
})
}
onPullDownRefresh(() => {
sheep.$store('user').updateUserData();
getStaffInfo();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
});
</script>
<style lang="scss" scoped>
.pendImg {
width: 70rpx;
height: 70rpx;
}
.weight4 {
font-weight: 400;
}
.weight8 {
font-weight: 400;
}
.fs-28 {
font-size: 28rpx;
line-height: 28rpx;
}
.fs-36 {
font-size: 36rpx;
line-height: 36rpx;
}
.fs-20 {
font-size: 20rpx;
line-height: 20rpx;
}
.flexD {
display: flex;
}
.gird {
display: grid;
}
.w-100 {
width: 100%;
}
.flex {
display: flex;
}
.flex-start {
align-items: flex-start;
}
.justify-center {
justify-content: center;
}
.align-items {
align-items: center;
}
.flex-column {
flex-flow: column;
}
.justify-start {
justify-content: start;
}
.myBox {
position: fixed;
width: 750rpx;
min-height: 100vh;
background-color: #F5F5F5;
background-size: 100%;
background-repeat: no-repeat;
}
.con-center {
min-height: 80vh;
padding: 30 30rpx;
.header {
width: 93%;
height: 440rpx;
padding: 0 30rpx;
position: relative;
// top: 100rpx;
justify-content: space-between;
align-items: center;
// margin: 0 auto;
// padding: 30rpx;
background-image: url('https://mall.jiangxiaoxian.hschool.com.cn/topback.png');
background-size: 100%;
.hea-left {
width: 100%;
height: 140rpx;
align-items: center;
position: relative;
top: 180rpx;
.avatar {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
}
.head-avatar {
width: 130rpx;
height: 130rpx;
margin-right: 30rpx;
}
.headAvatar-info {
display: gird;
// align-items: center;
// justify-content: center;
.info-name {
display: flex;
justify-content: flex-start;
font-weight: 900rpx;
align-items: center;
.UnAuthenBox {
margin-left: 10rpx;
// background-color: #EBECEE;
border-radius: 8rpx;
width: 80rpx;
height: 30rpx;
// color: #8D93B3;
display: flex;
// padding: 5rpx 10rpx;
align-items: center;
justify-content: center;
}
.authenticationBox {
margin-left: 10rpx;
// background-color: #333333;
border-radius: 8rpx;
width: 80rpx;
height: 30rpx;
// color: #fecc4e;
display: flex;
// padding: 5rpx 10rpx;
align-items: center;
justify-content: center;
}
}
}
.head-signInBox {
width: 156rpx;
height: 70rpx;
position: absolute;
right: -30rpx;
display: flex;
justify-content: center;
background-color: #fff;
align-items: center;
border-radius: 116rpx 0 0 116rpx;
.signInText {
font-size: 30rpx;
font-weight: 800;
line-height: 28rpx;
color: #333333;
}
}
.line {
width: 320rpx;
height: 1rpx;
background: #BABDC7;
border-radius: 0rpx 0rpx 0rpx 0rpx;
margin: 19rpx 0 7rpx 0;
}
.red {
font-family: PingFang SC, PingFang SC;
font-weight: 800;
font-size: 26rpx;
color: #FF4949;
line-height: 32rpx;
}
}
.head-secondBox {
margin-top: 50rpx;
display: flex;
justify-content: space-around;
align-items: center;
height: 76rpx;
width: 100%;
position: relative;
top: 190rpx;
.collect {
display: grid;
align-items: center;
text-align: center;
justify-content: center;
width: 158rpx;
height: 100%;
.collect-num {
font-size: 34rpx;
font-weight: 800;
color: #333333;
line-height: 28rpx;
}
.collect-text {
margin-top: 20rpx;
font-size: 28rpx;
font-weight: 400;
color: #333333;
line-height: 28rpx;
}
}
.feetPrint {
display: grid;
align-items: center;
text-align: center;
justify-content: center;
width: 188rpx;
height: 100%;
.feetPrint-num {
font-size: 34rpx;
font-weight: 800;
color: #333333;
line-height: 28rpx;
}
.feetPrint-text {
margin-top: 20rpx;
font-size: 28rpx;
font-weight: 400;
color: #333333;
line-height: 28rpx;
}
}
}
.line {}
}
.myOrder {
width: 630rpx;
height: 206rpx;
margin: 0 auto;
position: relative;
bottom: 90rpx;
background-color: #ffffff;
border-radius: 18rpx;
display: block;
padding: 40rpx 30rpx;
.myOrder-first {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.myOrder-second {
width: 100%;
display: flex;
margin-top: 40rpx;
justify-content: space-between;
.pendingBox {
display: block;
justify-content: center;
align-items: center;
}
}
}
.sixBox {
width: 630rpx;
// height: 637rpx;
display: block;
background-color: #ffffff;
border-radius: 18rpx;
padding: 40rpx 30rpx;
margin: 0 auto;
position: relative;
bottom: 50rpx;
.fabuBox {
display: flex;
align-items: center;
justify-content: space-between;
}
.line-row {
width: 630rpx;
height: 1rpx;
background: #EEEEEE;
border-radius: 0rpx 0rpx 0rpx 0rpx;
margin: 40rpx 0;
}
}
}
/* 顶部状态栏样式 */
.top-status-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
width: 100%;
z-index: 9999999;
background-image: url('https://mall.jiangxiaoxian.hschool.com.cn/topback.png');
background-size: 100%;
background-repeat: no-repeat;
// padding-top: 20rpx;
// height: 140rpx; /* 预留足够的高度 */
}
.status-bar-content {
display: flex;
align-items: center;
justify-content: center;
padding: 0 30rpx;
/* 高度通过内联样式动态设置 */
box-sizing: border-box;
}
.status-bar-content text {
font-size: 32rpx;
font-weight: bold;
color: #FFFFFF;
}
/* 安全区域适配 */
.top-status-bar {
padding-top: constant(safe-area-inset-top);
/* iOS 11.0 */
padding-top: env(safe-area-inset-top);
/* iOS 11.2+ */
}
/* 平台特定样式 */
/* iOS 样式 */
:global(.uni-page-head) {
.top-status-bar {
background-position: 0 0;
}
}
/* Android 样式 */
@media (platform: android) {
.top-status-bar {
background-position: 0 -10rpx;
/* 微调背景图位置 */
}
}
// .status-bar-content {
// height: 110rpx;
// /* 减去padding后的可用高度 */
// display: flex;
// align-items: center;
// justify-content: center;
// }
// .status-bar-content text {
// font-size: 32rpx;
// font-weight: bold;
// color: #FFFFFF;
// /* 白色文字以匹配背景 */
// }
.popup {
background-image: url('https://mall.jiangxiaoxian.hschool.com.cn/loginBack.png');
background-size: 100%;
width: 540rpx;
height: 640rpx;
display: flex;
padding-bottom: 44rpx;
flex-direction: column;
align-items: baseline;
justify-content: flex-end;
padding-left: 73rpx;
padding-right: 73rpx;
.img_shouquan {
position: absolute;
width: 680rpx;
height: 857rpx;
left: -25rpx;
top: -390rpx;
}
#txt2 {
text-align: center;
margin-top: 200rpx;
font-size: 28rpx;
color: #525252;
margin-bottom: 60rpx;
position: relative;
font-weight: 500;
}
.texbut {
width: 507rpx;
height: 93rpx;
border-radius: 16rpx;
// background: #ffbd25;
background-image: url('https://mall.jiangxiaoxian.hschool.com.cn/loginBtnTwo.png');
background-size: 100%;
font-size: 34rpx;
color: #3d3d3d;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
margin-top: 30rpx;
// margin: 0 auto;
}
}
</style>