123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <template>
- <view class="my__main">
- <!-- 账号 -->
- <view class="my__main-top">
- <view class="top-content">
- <button class="top-left" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
- <image class="img" :src="avatarUrl" mode="aspectFit"></image>
- </button>
- <view class="top-right">
- {{companyName}}
- </view>
- </view>
- </view>
- <!-- 功能部分 -->
- <view class="my__main-content">
- <view class="content-title">我的功能</view>
- <view class="content-cell">
- <u-cell-group :border="false">
- <u-cell class="content-cell-1" title="我的订单" isLink url="/pages/my/myOrder/myOrder">
- <u-icon slot="icon" size="18" name="list-dot"></u-icon>
- </u-cell>
- <u-cell class="content-cell-1" title="公司信息" isLink url="/pages/login/login">
- <u-icon slot="icon" size="18" name="man-add"></u-icon>
- </u-cell>
- <!-- <u-cell class="content-cell-1" isLink url="/pages/login/login">
- <view slot="title" class="u-slot-title">
- <view class="img">
- <image src="../../static/gongsimc.png" mode=""></image>
- </view>
- <view class="u-cell-text">公司信息</view>
- </view>
- </u-cell> -->
- <u-cell class="content-cell-1" :border="false" title="退出登录" @click="loginOut" isLink>
- <u-icon slot="icon" size="18" name="share-square"></u-icon>
- </u-cell>
- </u-cell-group>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getUserInfo,
- } from '@/api/login.js'
- export default {
- data() {
- return {
- avatarUrl: "../../static/avatar.png",
- companyName: '',
- };
- },
- methods: {
- // 头像账号
- onChooseAvatar(e) {
- // console.log(e)
- this.avatarUrl = e.detail.avatarUrl
- uni.setStorageSync('avatarUrl', this.avatarUrl); // 将头像 URL 存储到本地缓存中
- },
- loginOut() {
- uni.showModal({
- title: '提示',
- content: '确定退出吗?',
- success: res => {
- if (res.confirm) {
- uni.showToast({
- title: '操作成功',
- icon: 'none',
- duration: 800,
- mask: true,
- success: () => {
- setTimeout(() => {
- // uni.removeStorageSync(
- // 'avatarUrl'); // 移除本地缓存中的头像 URL
- uni.removeStorageSync('openId'); // 移除本地缓存中的openid
- uni.removeStorageSync('userInfo'); // 移除本地缓存中的公司信息
- uni.removeStorageSync('token')
- // uni.reLaunch({
- // url: '/pages/login/index',
- // })
- uni.navigateTo({
- url: '/pages/login/index',
- })
- }, 800)
- }
- })
- }
- }
- })
- }
- },
- onShow() {
- const avatarUrl = uni.getStorageSync('avatarUrl');
- if (avatarUrl) {
- this.avatarUrl = avatarUrl;
- }
- getUserInfo().then(res => {
- this.companyName = res.data.companyName
- }).catch(err => {});
- }
- }
- </script>
- <style lang="scss" scoped>
- .my__main {
- position: relative;
- width: 100%;
- height: 100%;
- background-color: #fff;
- // 顶部头像
- .my__main-top {
- height: 209px;
- // height: 132.4px;
- padding-top: 92px;
- // padding-top: 15.4px;
- background: linear-gradient(72deg, #2F74FF 28.55%, #4299FF 100.56%);
- .top-content {
- display: flex;
- width: 100%;
- height: 70px;
- .top-left {
- width: 70px;
- height: 70px;
- margin: 0px 17px 47px 20px;
- padding: 0 !important;
- border-radius: 50%;
- overflow: hidden;
- background: lightgray 50% / cover no-repeat;
- .img {
- width: 100%;
- height: 100%;
- // object-fit: contain;
- }
- }
- .top-right {
- color: #FFF;
- font-size: 20px;
- font-weight: 500;
- line-height: 70px;
- }
- }
- }
- // 功能列表
- .my__main-content {
- position: absolute;
- // top: 96.4px;
- top: 173px;
- width: 100%;
- border-radius: 22px;
- background-color: #fff;
- .content-title {
- color: #333;
- font-size: 18px;
- font-weight: 500;
- margin-left: 13px;
- margin-top: 16px;
- }
- .content-cell {
- padding: 0 16px;
- .content-cell-1 {
- height: 56px;
- }
- }
- }
- }
- .u-slot-title {
- display: flex;
- .img {
- width: 19.8px;
- height: 18px;
- margin-right: 9.2px;
- image {
- width: 100%;
- height: 100%;
- object-fit: contain;
- }
- }
- }
- ::v-deep .u-cell__body {
- padding: 16px 0px !important;
- }
- ::v-deep .u-icon__icon {
- margin-right: 9.2px;
- }
- </style>
|