123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <template>
- <div class="container">
- <div class="userimg">
- <van-image round width="60" height="60" :src="walletStore.avatar" />
- </div>
- <div class="username">{{ walletStore.username || "Angel Token" }}</div>
- <div class="useraddress">
- <span>{{formatAddress(walletStore.account)}}</span>
- <svg-icon class="im-copy-btn" style="width: 18px; height: 18px" name="copy" :data-clipboard-text="walletStore.account"/>
- </div>
- <van-list class="user-bar-list">
- <van-cell
- title="修改暱稱"
- :value="walletStore.username"
- is-link
- @click="show = true"
- ></van-cell>
- <van-cell class="user-bar-list-last" title="修改頭像">
- <template #right-icon>
- <van-uploader :after-read="afterRead">
- <van-icon name="arrow" color="#969799" size="16" />
- </van-uploader>
- </template>
- </van-cell>
- </van-list>
- <div class="qrcode">
- <qrcode-vue
- :value="qrtext"
- :size="239"
- :margin="2"
- background="transparent"
- />
- <div class="text">掃一掃上面的二維碼,加我爲好友</div>
- </div>
- <van-popup v-model:show="show" :style="{ borderRadius: '25px' }">
- <div class="pop-content">
- <div class="pop-title">請輸入暱稱</div>
- <van-field v-model="nickname" class="pop-input" />
- <div class="pop-btn">
- <van-button type="default" class="btn cancel" @click="show = false"
- >取消</van-button
- >
- <van-button type="default" class="btn confirm" @click="updateUserName"
- >確定</van-button
- >
- </div>
- </div>
- </van-popup>
- </div>
- </template>
- <script setup>
- import QrcodeVue from "qrcode.vue";
- import { useWalletStore } from "@/stores/modules/walletStore";
- import { uploadFile, userInfoEdit } from "@/api/path/im.api";
- import { updateUserInfo } from "@/common/login";
- import { useCopy } from "@/hooks/use-copy.js";
- useCopy();
- const walletStore = useWalletStore();
- const show = ref(false);
- const nickname = ref("");
- const qrtext = ref(walletStore.account);
- const afterRead = async (file) => {
- const formData = new FormData();
- formData.append("uuid", walletStore.account);
- formData.append("file", file.file);
- const { code, data } = await uploadFile(formData);
- if (code === 200) {
- await updateUserInfo(walletStore.account,walletStore.id);
- }
- };
- const updateUserName = async () => {
- const { code} = await userInfoEdit({
- username: walletStore.account,
- nickname: nickname.value,
- });
- if (code === 200) {
- await updateUserInfo(walletStore.account,walletStore.id);
- }
- show.value = false;
- };
- const formatAddress = (address) => {
- if (!address) return '';
- return address.slice(0, 8) + '...' + address.slice(-6);
- };
- </script>
- <style lang="less" scoped>
- .container {
- margin: 25px 17px;
- .userimg {
- display: flex;
- justify-content: center;
- }
- .username {
- text-align: center;
- margin: 10px 0 4px;
- font-family:
- PingFang SC,
- PingFang SC;
- font-weight: 500;
- font-size: 16px;
- color: @theme-color1;
- }
- .useraddress {
- text-align: center;
- font-family:
- PingFang SC,
- PingFang SC;
- font-weight: 400;
- font-size: 12px;
- color: #8d8d8d;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .van-cell {
- height: 44px;
- background: @bg-color1;
- border-bottom: 1px solid @bg-color1;
- font-size: 15px;
- &::after {
- border-bottom: 1px solid #f2f2f2;
- }
- }
- :deep(.van-cell__title){
- font-family: PingFang SC, PingFang SC;
- font-weight: 500 ;
- font-size: 15px;
- color: #000000;
- }
- :deep(.van-cell__value){
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 15px;
- color: #8D8D8D;
- }
- .user-bar-list-last::after {
- border-bottom: 0;
- }
- .user-bar-list {
- margin: 25px 0 37px;
- border-radius: 12px;
- overflow: hidden;
- }
- .qrcode {
- display: flex;
- flex-direction: column;
- align-items: center;
- .text {
- font-family:
- PingFang SC,
- PingFang SC;
- font-weight: 400;
- font-size: 15px;
- color: #8d8d8d;
- margin-top: 10px;
- }
- }
- .pop-content {
- padding: 27px 35px 25px 34px;
- .pop-title {
- font-family:
- PingFang SC,
- PingFang SC;
- font-weight: 500;
- font-size: 17px;
- color: #000000;
- text-align: center;
- }
- .pop-input {
- background: #f2f2f2;
- border-radius: 8px;
- height: 40px;
- margin: 21px 0 31px;
- }
- .pop-btn {
- display: flex;
- justify-content: center;
- .btn {
- width: 83px;
- height: 29px;
- line-height: 29px;
- padding: 5px 0 !important;
- border-radius: 6px;
- font-family:
- PingFang SC,
- PingFang SC;
- font-weight: 400;
- font-size: 15px;
- box-sizing: border-box;
- }
- .cancel {
- margin-right: 17px !important;
- border: 1px solid #d8d8d8;
- color: #000 !important;
- }
- .confirm {
- background: @theme-color1;
- color: #fff;
- font-weight: 500;
- }
- }
- }
- }
- :deep(.van-popup--center) {
- margin: 0 40px !important;
- width: auto !important;
- }
- </style>
|