| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- <template>
- <uv-navbar leftIcon="" title="我的" bg-color="#C6171E"></uv-navbar>
- <view class="w100 bg" style="background-color:#C6171E "></view>
- <!-- <image src="/static/user/user-bg.png" mode="widthFix" class="bg"/>-->
- <block>
- <view class="container" :style="containerStyle">
- <view class="header">
- <view class="flex-center">
- <image
- src="/static/user/round.png"
- mode="heightFix"
- style="width: 120rpx;height: 120rpx"/>
- </view>
- <view class="main">
- <image
- class="avatar"
- src='/static/iconfont/me.svg'>
- </image>
- <view class="phone fw-500">{{ user.mobilePhone }}</view>
- <view class="money-box">
- <view class="money" @click="toPage({path: '/pages-user/wallet/index'})">
- <view class="money-left">
- <uv-icon name="coupon" size="24" color="#C6171E"></uv-icon>
- <!-- <image src="/static/iconfont/chongzhi.svg" mode="widthFit" style="width: 40rpx;height: 40rpx"></image>-->
- <!-- <uv-icon name="red-packet" size="24" color="#C6171E"></uv-icon>-->
- <view style="font-size: 16px;margin-left: 10rpx;">钱包 | 充值</view>
- </view>
- <view class="money-right">
- <view class="money-right_balance"> ¥ {{ ((user.balance || 0) / 100).toFixed(2) }}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="body">
- <block v-for="(item, index) in menu" :key="index">
- <view
- class="menu-item"
- @click="toPage(item)">
- <view class="menu-item_left">
- <image :src="item.icon"></image>
- <view class="menu-item_left-title">{{ item.title }}</view>
- </view>
- <view class="menu-item_right">
- <uv-icon name="arrow-right" size="16"></uv-icon>
- </view>
- </view>
- </block>
- <view class="logout-btn" v-if="isLogin">
- <view class="mt20 logout-btn-wrap" type="error" @click="logoutUser">退出登录</view>
- </view>
- </view>
- </view>
- </block>
- <!-- <cover-view class="login_bar" v-if="!isLogin">
- <login-bar class="w100 text-center"></login-bar>
- </cover-view>-->
- <!-- <view class="logout-btn">
- <uv-button :custom-style="customStyle" type="error" @click="logoutUser">退出登录</uv-button>
- </view>-->
- <tab-bar :index="2"/>
- </template>
- <script setup lang="ts">
- import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
- import {computed, ref} from "vue";
- import TabBar from "@/components/tab-bar/index.vue";
- import LoginBar from "@/components/login-bar/index.vue";
- import {checkLogin, clearToken} from "@/utils/auth"
- import {get} from "@/utils/https";
- import {getServicePhone} from "@/utils/common";
- const containerStyle = ref({});
- const user = ref<any>({
- id: 0,
- avatar: "",
- mobilePhoneFormat: '',
- balance: 0,
- });
- const isLogin = ref(false)
- const service = ref("15012341234");
- const menu = ref([
- {
- title: "绑定车辆",
- path: "/pages-user/profile/index",
- icon: '/static/user/profile.png'
- },
- /* {
- title: "我的卡包",
- path: "/pages/coupon/index",
- icon: '/static/user/coupon.png'
- },*/
- {
- title: "我的订单",
- path: "/pages-order/list/index",
- icon: '/static/user/faq.png'
- },
- /* {
- title: "我的收藏",
- path: "/pages-user/fav/index",
- icon: '/static/user/fav.png'
- },*/
- {
- title: "联系我们",
- path: "/pages-user/contact/index",
- icon: '/static/user/contact.png'
- },
- {
- title: "洗车指导",
- path: "/pages-user/faq/index",
- icon: '/static/iconfont/default/guide.svg'
- },
- {
- title: "纠错上报",
- path: "/pages-user/feedback/index",
- icon: '/static/user/feedback.png'
- },
- ]);
- const toPage = (item: any) => {
- checkLogin().then(() => {
- let {title, path} = item;
- let servicePhone = getServicePhone();
- if (path.includes('contact')) {
- uni.makePhoneCall({
- phoneNumber: servicePhone,
- fail: (error) => {
- console.log(error)
- }
- });
- return;
- }
- uni.navigateTo({
- url: item.path,
- });
- }).catch(e => {
- console.error("handleMenuClick 校验,跳转登录页", e)
- uni.navigateTo({
- url: '/pages-user/login/index'
- })
- })
- };
- const loginListen = () => {
- }
- const logoutUser = () => {
- uni.showModal({
- title: "温馨提示",
- content: "确定退出登录吗?",
- confirmColor: "#C6171E",
- confirmText: "确定退出",
- cancelText: "手滑了",
- success: (res) => {
- if (res.confirm) {
- uni.showLoading({
- title: "退出中",
- });
- get(`/user/logout`).then(() => {
- uni.hideLoading();
- uni.showToast({
- icon: "success",
- title: "已退出",
- });
- getApp<any>().globalData.manualLogout = true;
- clearToken();
- setTimeout(() => {
- uni.exitMiniProgram()
- }, 1500);
- })
- }
- },
- });
- };
- onLoad(() => {
- uni.setNavigationBarTitle({title: '个人中心'})
- const bound = uni.getMenuButtonBoundingClientRect();
- containerStyle.value = {
- top: `${bound.bottom + 10}px`,
- };
- });
- const addListener = () => {
- uni.$on('login', function (data) {
- isLogin.value = data.isLogin;
- console.log("event>>>", data)
- if (data.isLogin) {
- user.value = getApp<any>().globalData.user;
- console.log("event1111>>>", user.value)
- }
- })
- uni.$on('logout', function (data) {
- isLogin.value = false;
- user.value = {}
- })
- }
- const removeListener = () => {
- uni.$off('logout');
- uni.$off('login');
- }
- onShow(() => {
- const userData = getApp<any>().globalData.user;
- if (userData && userData.id) {
- isLogin.value = true;
- user.value = userData;
- }
- // loginListen();
- addListener();
- });
- onHide(()=>{
- removeListener();
- })
- </script>
- <style lang="scss" scope>
- page{
- background-color: #fafafa;
- }
- .bg {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 460rpx;
- }
- .container {
- position: absolute;
- left: 0;
- top: 0;
- height: calc(100vh - 250rpx);
- width: 100%;
- overflow-y: hidden;
- }
- .header {
- //height: 400rpx;
- width: 100%;
- flex-direction: column;
- .main {
- //height: 234rpx;
- //padding: 60rpx auto;
- background: rgba(254, 255, 255, 0.7);
- border-radius: 40rpx 40rpx 0 0;
- position: relative;
- text-align: center;
- z-index: 999;
- .avatar {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- top: -90rpx;
- width: 110rpx;
- height: 110rpx;
- border: 2rpx solid #ffffff;
- //filter: drop-shadow(0px 4rpx 8rpx rgba(0, 24, 60, 0.1));
- background-size: cover;
- background-repeat: no-repeat;
- border-radius: 50%;
- }
- .phone {
- padding-top: 20rpx;
- //padding-top: 78rpx;
- color: #000;
- //padding: 30rpx auto;
- font-size: 40rpx;
- }
- .money-box{
- background: #EEB9BB;
- padding: 60rpx 20rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- align-content: center;
- .money {
- //position: absolute;
- //left: 0;
- //bottom: 0;
- width: 600rpx;
- //height: 98rpx;
- background: #fff;
- border-radius: 120rpx;
- //margin: 130rpx auto 40rpx auto;
- //color: #000000;
- padding: 20rpx;
- font-size: 22px;
- display: flex;
- align-content: center;
- align-items: center;
- justify-content: space-between;
- &-left {
- opacity: 1;
- color: $uni-color-primary;
- display: inline-flex;
- align-items: flex-end;
- font-size: 22px;
- }
- &-right {
- font-size: 22px;
- opacity: 1;
- color: $uni-color-primary;
- display: inline-flex;
- align-items: flex-end;
- &_balance {
- padding-left: 5px;
- font-size: 26px;
- font-weight: 600;
- margin-right: 10px;
- }
- }
- }
- }
- }
- }
- .body {
- width: 100%;
- background-color: #fff;
- //border-top: 1px solid $uni-color-primary;
- //padding: 0rpx 30rpx;
- .menu-item {
- display: inline-flex;
- justify-content: space-between;
- background-color: #fff;
- height: 90rpx;
- border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
- align-items: center;
- width: 100%;
- &_left {
- display: flex;
- align-items: center;
- align-content: center;
- margin-left: 20rpx;
- image {
- width: 42rpx;
- height: 42rpx;
- margin-right: 20rpx;
- }
- &-title {
- font-size: 13px;
- }
- }
- &_right {
- text-align: right;
- width: 60rpx;
- }
- &:last-child {
- border-bottom: none;
- }
- }
- }
- .logout-btn {
- width: calc(100vw - 60rpx);
- margin: 60rpx auto;
- &-wrap{
- height: 80rpx;
- border-radius: 40rpx;
- font-size: 28rpx;
- margin: 20px auto;
- width: 540rpx;
- text-align: center;
- background: #dd524d;
- color: white;
- display: flex;
- align-items: center;
- align-content: center;
- justify-content: center;
- }
- }
- </style>
|