123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <template>
- <view class="my-box">
- <view class="my-content">
- <view class="my-top"></view>
- <image class="my-avatar" @tap="$navigateTo('/subPages/myPage/myDetail/myDetail')" :src="user.portrait"
- mode="aspectFill"></image>
- <view class="name" @tap="$navigateTo('/subPages/myPage/myDetail/myDetail')">{{user.userName || '登录/注册'}}
- </view>
- <view class="organization" v-if="user.organizedName"
- @tap="$navigateTo('/subPages/myPage/changeOrganization/changeOrganization')">
- {{user.organizedName}}
- </view>
- <view class="my-list">
- <view class="my-list-box">
- <view class="my-item" @tap="$navigateTo('/subPages/shopPage/webview/webview?url=/order')">
- <view class="my-icon bg3">
- <uv-icon name="home-fill" color="#fff" size="56"></uv-icon>
- </view>
- <view class="item-content">
- 商城订单
- </view>
- <view class="my-forward">
- <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
- </view>
- </view>
- <view class="my-item" @tap="$navigateTo('/subPages/myPage/organization/organization')">
- <view class="my-icon bg3">
- <uv-icon name="home-fill" color="#fff" size="56"></uv-icon>
- </view>
- <view class="item-content">
- 我的公司
- </view>
- <view class="my-forward">
- <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
- </view>
- </view>
- <view class="my-item" @tap="$navigateTo('/subPages/myPage/download/download')">
- <view class="my-icon bg5">
- <uv-icon name="grid-fill" color="#fff" size="56"></uv-icon>
- </view>
- <view class="item-content">
- 我的下载
- </view>
- <view class="my-forward">
- <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="fab-box" v-if="isCustomer" @click="$navigateTo('/subPages/myPage/chatList/chatList')">
- <view class="fab-data">
- <uv-badge type="error" max="99" numberType="overflow" :value="badge" :absolute="true" :offset="[0,0]"
- :customStyle="{
- zIndex:99
- }">
- </uv-badge>
- <uv-icon name="server-fill" color="#fff" size="60" labelPos="bottom" labelSize="20">
- </uv-icon>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getUserInfoById,
- getCustomerServeListByQuery
- } from '@/request/api/my.js'
- export default {
- data() {
- return {
- user: {},
- isCustomer: false,
- badge: 0
- }
- },
- onReady() {
- uni.$on('changeChatList', this.initChat);
- },
- onShow() {
- this.initBadge();
- if (!uni.getStorageSync('token')) {
- this.user = {};
- this.isCustomer = false;
- } else {
- this.user = this.$store.getters.user;
- this.user.organizedName = this.$store.getters.organization && this.$store.getters.organization.name;
- this.init();
- this.initCustomerServe();
- }
- },
- methods: {
- async init() {
- let userInfo = await getUserInfoById(this.user.userId);
- if (userInfo.state) {
- this.user['userName'] = userInfo.data.name;
- this.user['userId'] = userInfo.data.id;
- this.user['portrait'] = userInfo.data.portrait;
- this.$store.dispatch('app/changeUser', this.user);
- }
- },
- async initCustomerServe() {
- let customerServe = await getCustomerServeListByQuery({
- organizationId: this.$store.getters.organization.id,
- userId: this.$store.getters.user.userId
- })
- if (customerServe.state && customerServe.data && customerServe.data.length > 0) {
- let data = customerServe.data[0];
- this.isCustomer = true;
- uni.setStorageSync('serveChatId', data.customerId);
- this.$customerServe.connect(data.customerId);
- this.initChat();
- }
- },
- initChat() {
- this.$customerServe.getConversationList(data => {
- let chatList = data.data.filter(node => node.conversationId !== 'system');
- let badge = 0;
- for (let i = 0; i < chatList.length; i++) {
- badge += chatList[i].unread
- }
- this.badge = badge;
- });
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .my-box {
- height: 100vh;
- background: #fff;
- overflow-y: auto;
- .my-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding-bottom: 80rpx;
- }
- .my-top {
- height: 260rpx;
- background-image: url('https://images.unsplash.com/photo-1558591710-4b4a1ae0f04d?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMDUzMDJ8MHwxfHNlYXJjaHw1fHxhYnN0cmFjdHxlbnwxfHx8fDE2NTI4OTYzNTU&ixlib=rb-1.2.1&q=80&w=1080');
- background-position: center center;
- background-size: cover;
- background-repeat: no-repeat;
- width: 100%;
- }
- .my-avatar {
- width: 200rpx;
- height: 200rpx;
- border-radius: 50%;
- margin-top: -100rpx;
- border: 6rpx solid #fff;
- background: #eee;
- }
- .name {
- font-size: 20px;
- font-weight: 700;
- margin: 10rpx 0;
- }
- .organization {
- font-weight: 300;
- }
- .my-list {
- width: 100%;
- padding: 60rpx 30rpx 30rpx 30rpx;
- box-sizing: border-box;
- .my-list-box {
- border-radius: 24rpx;
- box-shadow: 1px 1px 12px rgba(164, 164, 164, 0.25);
- overflow: hidden;
- }
- .my-item {
- display: flex;
- align-items: center;
- padding: 20rpx 30rpx;
- }
- .my-icon {
- width: 80rpx;
- height: 80rpx;
- border-radius: 16rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- background: #c1c0c8;
- &.bg1 {
- background: #88d498;
- }
- &.bg2 {
- background: #ffb997;
- }
- &.bg3 {
- background: #7ad9ff;
- }
- &.bg4 {
- background: #9ac0cd;
- }
- &.bg5 {
- background: #40e0d0;
- }
- }
- .item-content {
- flex: 1;
- width: 0;
- overflow: hidden;
- font-weight: 700;
- }
- }
- .fab-box {
- position: fixed;
- bottom: 60rpx;
- right: 30rpx;
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background: $uv-primary;
- .fab-data {
- width: 100%;
- height: 100%;
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- }
- </style>
|