<!-- 用户信息 --> <template> <s-layout title="用户信息" class="set-userinfo-wrap"> <uni-forms :model="state.model" :rules="state.rules" labelPosition="left" border class="form-box" > <view class="bg-white"> <uni-list :border="false" class="ss-p-y-40"> <uni-list-chat clickable :avatar-circle="true" :title="state.model?.nickname" :avatar="state.model?.avatar" note="个性签名" @tap="sheep.$router.go('/pages/user/info')" > <view class="chat-custom-right"> <text class="_icon-forward" style="color: #bbbbbb; font-size: 32rpx" ></text> </view> </uni-list-chat> <uni-list-item clickable @tap="sheep.$router.go('/pages/user/address/list')" title="收货地址管理" showArrow :border="false" /> <uni-list-item clickable @tap="sheep.$router.go('/pages/user/invoice/list')" title="发票抬头管理" showArrow :border="false" /> <uni-list-item :clickable="!userInfo.mobile" @tap="sheep.$router.go('/pages/user/address/list')" title="实名认证" showArrow :border="false" > <template v-slot:body> <p style="width: 100%" >实名认证 {{ userInfo.mobile ? '已认证' : '未认证' }}<span style="float: right">{{ userInfo.mobile ? '' : '未认证' }}</span></p > </template> </uni-list-item> <uni-list-item title="推荐老师" :border="false"> <template v-slot:body> <p style="width: 100%">推荐老师 xxx</p> </template> </uni-list-item> <uni-list-item title="我的二维码" clickable @tap="sheep.$router.go('/pages/user/qrcode-share')" :border="false" > <template v-slot:body> <p style="width: 100%; display: flex; align-items: center"> 我的二维码 <su-image class="content-img" style="border: 1px solid #f4f4f4" :current="0" :src="state.model?.avatar" :height="100" :width="100" :radius="0" mode="scaleToFill" /> </p> </template> </uni-list-item> </uni-list> </view> </uni-forms> <!-- <su-fixed bottom placeholder bg="none"> <view class="footer-box ss-p-20"> <button class="ss-rest-button logout-btn ui-Shadow-Main" @tap="onSubmit">保存</button> </view> </su-fixed> --> </s-layout> </template> <script setup> import { computed, reactive, onBeforeMount } from 'vue'; import sheep from '@/sheep'; import { clone } from 'lodash'; import { showAuthModal, showShareModal } from '@/sheep/hooks/useModal'; import FileApi from '@/sheep/api/infra/file'; import UserApi from '@/sheep/api/member/user'; const state = reactive({ model: {}, // 个人信息 rules: {}, thirdInfo: {}, // 社交用户的信息 }); const placeholderStyle = 'color:#BBBBBB;font-size:28rpx;line-height:normal'; const userInfo = computed(() => sheep.$store('user').userInfo); // 绑定第三方账号 async function bindThirdOauth() { let result = await sheep.$platform.useProvider('wechat').bind(); if (result) { await getUserInfo(); } } // 解绑第三方账号 function unBindThirdOauth() { uni.showModal({ title: '解绑提醒', content: '解绑后您将无法通过微信登录此账号', cancelText: '再想想', confirmText: '确定', success: async function (res) { if (!res.confirm) { return; } const result = await sheep.$platform .useProvider('wechat') .unbind(state.thirdInfo.openid); if (result) { await getUserInfo(); } }, }); } // 保存信息 async function onSubmit() { const { code } = await UserApi.updateUser({ avatar: state.model.avatar, nickname: state.model.nickname, sex: state.model.sex, }); if (code === 0) { await getUserInfo(); } } // 获得用户信息 const getUserInfo = async () => { // 个人信息 const userInfo = await sheep.$store('user').getInfo(); state.model = clone(userInfo); // 获得社交用户的信息 if (sheep.$platform.name !== 'H5') { const result = await sheep.$platform.useProvider('wechat').getInfo(); state.thirdInfo = result || {}; } }; onBeforeMount(() => { getUserInfo(); }); </script> <style lang="scss" scoped> :deep() { .uni-file-picker { border-radius: 50%; } .uni-list-chat__content-extra { display: flex; justify-content: center; } .uni-file-picker__container { margin: -14rpx -12rpx; } .file-picker__progress { height: 0 !important; } .uni-list-item__content-title { font-size: 28rpx !important; color: #333333 !important; line-height: normal !important; } .uni-icons { font-size: 40rpx !important; } .is-disabled { color: #333333; } } :deep(.disabled) { opacity: 1; } .uni-list-item { min-height: 100rpx; } .gender-name { font-size: 28rpx; font-weight: 500; line-height: normal; color: #333333; } .title-box { font-size: 28rpx; font-weight: 500; color: #666666; line-height: 100rpx; } .logout-btn { width: 710rpx; height: 80rpx; background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient)); border-radius: 40rpx; font-size: 30rpx; font-weight: 500; color: $white; } .radio-dark { filter: grayscale(100%); filter: gray; opacity: 0.4; } .content-img { border-radius: 50%; } .header-box-content { position: relative; width: 160rpx; height: 160rpx; overflow: hidden; border-radius: 50%; } .avatar-action { position: absolute; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 1; width: 160rpx; height: 46rpx; background: rgba(#000000, 0.3); .avatar-action-btn { width: 160rpx; height: 46rpx; font-weight: 500; font-size: 24rpx; color: #ffffff; } } // 绑定项 .account-list { background-color: $white; height: 100rpx; padding: 0 20rpx; .list-img { width: 40rpx; height: 40rpx; margin-right: 10rpx; } .list-name { font-size: 28rpx; color: #333333; } .info { .avatar { width: 38rpx; height: 38rpx; border-radius: 50%; overflow: hidden; } .name { font-size: 28rpx; font-weight: 400; color: $dark-9; } } .bind-box { width: 100rpx; height: 50rpx; line-height: normal; display: flex; justify-content: center; align-items: center; font-size: 24rpx; .bind-btn { width: 100%; height: 100%; border-radius: 25rpx; background: #f4f4f4; color: #999999; } .relieve-btn { width: 100%; height: 100%; border-radius: 25rpx; background: var(--ui-BG-Main-opacity-1); color: var(--ui-BG-Main); } } } .list-border { font-size: 28rpx; font-weight: 400; color: #333333; border-bottom: 2rpx solid #eeeeee; } image { width: 100%; height: 100%; } </style>