freight-ts-dy-web/src/pagesHome/profile.vue

309 lines
7.2 KiB
Vue
Raw Normal View History

2024-09-06 01:53:51 +00:00
<template>
<Layout :select="'我的'">
<view class="profile">
<view class="baseinfo">
<view class="head">
2024-09-22 07:15:17 +00:00
<image
:src="`${url}/static/img/profile/user.png`"
class="user"
></image>
2024-09-06 01:53:51 +00:00
<view>
<view>
2024-09-25 07:51:24 +00:00
<text class="name">{{ profile.name || "-" }}</text>
2024-09-06 01:53:51 +00:00
</view>
<view>
2024-09-25 07:51:24 +00:00
<text class="company">{{ profile.phone || "-" }}</text>
2024-09-06 01:53:51 +00:00
</view>
</view>
</view>
2024-09-22 07:15:17 +00:00
<view class="entry-card">
<uni-card
:shadow="'0rpx 0rpx 10rpx 0rpx rgba(5,68,37,0.12)'"
:padding="'10px'"
:margin="'10px 0px'"
:border="false"
>
<view class="title">我的订单</view>
<uni-grid :column="3" :showBorder="false" :square="false">
<uni-grid-item
v-for="(item, index) in entryItemList"
:key="index"
>
<view class="item">
<view @click="handleClickEntry(item)">
<view>
<image :src="`${url}/static/img/${item.path}`"></image>
</view>
<view>
<text class="text">{{ item.name }}</text>
</view>
</view>
</view>
</uni-grid-item>
</uni-grid>
</uni-card>
</view>
2024-09-06 01:53:51 +00:00
<view class="content">
<u-list :height="'200px'">
2024-10-09 02:37:18 +00:00
<u-list-item
v-for="(item, index) in isHasToken() ? list : list1"
:key="index"
>
2024-09-06 01:53:51 +00:00
<u-cell
:title="item.name"
arrow-direction="right"
isLink
:url="item.path"
:border="false"
@click="hanldeClick(item)"
>
<template #icon>
<view style="width: 40rpx">
<image
:src="`${url}/static/img/profile/${item.icon}`"
mode="widthFix"
/>
</view>
</template>
</u-cell>
</u-list-item>
</u-list>
</view>
</view>
</view>
2024-09-25 07:51:24 +00:00
<SmallModal
2024-10-09 02:37:18 +00:00
:title="'确认退出吗?'"
:content="'退出后将返回至登陆页'"
:okText="'确认退出'"
:isMain="true"
:show="isShowCancelModal"
@handleModal="(v:boolean) => {handleModal(v)}"
@handleOk="handleOk()"
/>
2024-09-06 01:53:51 +00:00
</Layout>
</template>
<script setup lang="ts">
import Layout from "@/components/Layout/index.vue";
2024-09-25 07:51:24 +00:00
import { useMemberStore } from "@/store/index";
import pinia from "@/store";
2024-09-06 01:53:51 +00:00
import { url } from "@/utils/data";
2024-09-25 07:51:24 +00:00
import { UserApi } from "@/services";
import SmallModal from "@/components/Modal/smallModal.vue";
const store = useMemberStore(pinia);
const profile = store.profile.userInfo;
2024-10-09 02:37:18 +00:00
function isHasToken () {
return store.profile.token !== ""
}
const list = reactive<any>([
2024-09-22 07:15:17 +00:00
{
name: "收款信息",
2024-09-25 07:51:24 +00:00
icon: "pay.png",
2024-09-22 07:15:17 +00:00
},
2024-09-06 01:53:51 +00:00
{
name: "用户协议",
icon: "4.png",
},
{
name: "隐私政策",
icon: "5.png",
},
2024-09-25 07:51:24 +00:00
{
name: "退出登录",
icon: "3.png",
path: "",
},
2024-09-06 01:53:51 +00:00
]);
2024-10-09 02:37:18 +00:00
const list1 = reactive<any>([
{
name: "收款信息",
icon: "pay.png",
},
{
name: "用户协议",
icon: "4.png",
},
{
name: "隐私政策",
icon: "5.png",
}
]);
2024-09-06 01:53:51 +00:00
2024-09-22 07:15:17 +00:00
const entryItemList = ref([
{
2024-09-25 07:51:24 +00:00
path: "p1.png",
2024-09-22 07:15:17 +00:00
name: "报废车辆回收",
url: "/pagesOrder/vehicle/index",
},
{
2024-09-25 07:51:24 +00:00
path: "p2.png",
2024-09-22 07:15:17 +00:00
name: "电池回收",
2024-09-24 07:45:18 +00:00
url: "/pagesOrder/battery/index",
2024-09-22 07:15:17 +00:00
},
{
2024-09-25 07:51:24 +00:00
path: "p3.png",
2024-09-22 07:15:17 +00:00
name: "加入我们",
2024-09-25 07:51:24 +00:00
url: "/pagesOrder/joinus/index",
2024-09-22 07:15:17 +00:00
},
]);
const handleClickEntry = (item: any) => {
uni.navigateTo({
url: item.url, // 要跳转到的页面路径
});
};
2024-09-06 01:53:51 +00:00
const hanldeClick = (item: any) => {
if (item.name === "用户协议") {
openDoc("在生万有用户协议");
} else if (item.name === "隐私政策") {
openDoc("在生万有隐私政策");
2024-09-25 07:51:24 +00:00
} else if (item.name === "收款信息") {
uni.navigateTo({
2024-10-09 02:37:18 +00:00
url: "/pagesOrder/collection", // 要跳转到的页面路径
});
2024-09-25 07:51:24 +00:00
} else if (item.name === "退出登录") {
handleModal(true);
2024-09-06 01:53:51 +00:00
}
};
2024-09-25 07:51:24 +00:00
const isShowCancelModal = ref(false);
const handleModal = (v: boolean) => {
isShowCancelModal.value = v;
};
const handleOk = () => {
UserApi.logOut({}).then((res: any) => {
if (res.code === 200) {
2024-10-09 02:37:18 +00:00
store.clearProfile();
2024-09-25 07:51:24 +00:00
uni.reLaunch({
url: "/pagesLogin/index", // 要跳转到的页面路径
});
}
});
};
2024-09-06 01:53:51 +00:00
const openDoc = (item: string) => {
//文件预览
2024-09-22 07:15:17 +00:00
const isWX = uni.getSystemInfoSync().uniPlatform === "mp-weixin";
console.log(
`${url}/static/${
isWX && item === "在生万有隐私政策" ? "weixin/" : ""
}${item}.docx`
);
2024-09-06 01:53:51 +00:00
uni.downloadFile({
2024-09-22 07:15:17 +00:00
url: `${url}/static/${
isWX && item === "在生万有隐私政策" ? "weixin/" : ""
}${item}.docx`,
2024-09-06 01:53:51 +00:00
success: function (res) {
setTimeout(
() =>
uni.openDocument({
filePath: res.tempFilePath,
showMenu: false,
success: function () {
console.log("打开文档成功");
},
fail: function () {
uni.showToast({
title: "暂不支持此类型",
duration: 2000,
icon: "none",
});
},
}),
100
);
},
fail: function (res) {
console.log(res); //失败
},
});
};
2024-09-14 06:16:32 +00:00
2024-09-22 07:15:17 +00:00
//隐藏官方的tabBar
// #ifdef MP-ALIPAY
my.hideTabBar({
animation: false, // 是否需要动画效果alipay 1.95.0支持此参数
success: (res) => {
// 隐藏成功的回调
console.log("TabBar has been hidden", res);
},
fail: (err) => {
// 隐藏失败的回调
console.error("Failed to hide TabBar", err);
},
});
// #endif
2024-09-14 08:08:23 +00:00
2024-10-09 02:37:18 +00:00
// #ifdef MP-WEIXN || MP-TOUTIAO || H5
2024-09-22 07:15:17 +00:00
uni.hideTabBar();
// #endif
2024-09-06 01:53:51 +00:00
</script>
<style lang="scss" scoped>
.profile {
.bg {
width: 100%;
position: absolute;
top: 0rpx;
z-index: -1;
}
.baseinfo {
padding: 25.64rpx;
.head {
display: flex;
align-items: center;
margin-left: 41rpx;
.user {
width: 110.9rpx;
height: 110.9rpx;
margin-right: 20.51rpx;
}
.name {
font-size: 27rpx;
font-family: Source Han Sans CN;
font-weight: 500;
color: #000000;
}
.company {
font-size: 21rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #000000;
}
}
.content {
background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx;
padding: 28.21rpx 21.15rpx;
margin-top: 24.36rpx;
image:nth-child(1) {
width: 100%;
}
}
2024-09-22 07:15:17 +00:00
.entry-card {
.title {
font-weight: 500;
font-size: 32rpx;
color: #000000;
margin-bottom: 30rpx;
}
.item {
text-align: center;
image {
width: 74rpx;
height: 76rpx;
}
.text {
font-size: 28rpx;
font-weight: 400;
line-height: 42rpx;
}
}
}
2024-09-06 01:53:51 +00:00
}
}
</style>