index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div class="container">
  3. <div class="userimg">
  4. <van-image round width="60" height="60" :src="walletStore.avatar" />
  5. </div>
  6. <div class="username">{{ walletStore.username || "Angel Token" }}</div>
  7. <div class="useraddress">
  8. <span>{{formatAddress(walletStore.account)}}</span>
  9. <svg-icon class="im-copy-btn" style="width: 18px; height: 18px" name="copy" :data-clipboard-text="walletStore.account"/>
  10. </div>
  11. <van-list class="user-bar-list">
  12. <van-cell
  13. title="修改暱稱"
  14. :value="walletStore.username"
  15. is-link
  16. @click="show = true"
  17. ></van-cell>
  18. <van-cell class="user-bar-list-last" title="修改頭像">
  19. <template #right-icon>
  20. <van-uploader :after-read="afterRead">
  21. <van-icon name="arrow" color="#969799" size="16" />
  22. </van-uploader>
  23. </template>
  24. </van-cell>
  25. </van-list>
  26. <div class="qrcode">
  27. <qrcode-vue
  28. :value="qrtext"
  29. :size="239"
  30. :margin="2"
  31. background="transparent"
  32. />
  33. <div class="text">掃一掃上面的二維碼,加我爲好友</div>
  34. </div>
  35. <van-popup v-model:show="show" :style="{ borderRadius: '25px' }">
  36. <div class="pop-content">
  37. <div class="pop-title">請輸入暱稱</div>
  38. <van-field v-model="nickname" class="pop-input" />
  39. <div class="pop-btn">
  40. <van-button type="default" class="btn cancel" @click="show = false"
  41. >取消</van-button
  42. >
  43. <van-button type="default" class="btn confirm" @click="updateUserName"
  44. >確定</van-button
  45. >
  46. </div>
  47. </div>
  48. </van-popup>
  49. </div>
  50. </template>
  51. <script setup>
  52. import QrcodeVue from "qrcode.vue";
  53. import { useWalletStore } from "@/stores/modules/walletStore";
  54. import { uploadFile, userInfoEdit } from "@/api/path/im.api";
  55. import { updateUserInfo } from "@/common/login";
  56. import { useCopy } from "@/hooks/use-copy.js";
  57. useCopy();
  58. const walletStore = useWalletStore();
  59. const show = ref(false);
  60. const nickname = ref("");
  61. const qrtext = ref(walletStore.account);
  62. const afterRead = async (file) => {
  63. const formData = new FormData();
  64. formData.append("uuid", walletStore.account);
  65. formData.append("file", file.file);
  66. const { code, data } = await uploadFile(formData);
  67. if (code === 200) {
  68. await updateUserInfo(walletStore.account,walletStore.id);
  69. }
  70. };
  71. const updateUserName = async () => {
  72. const { code} = await userInfoEdit({
  73. username: walletStore.account,
  74. nickname: nickname.value,
  75. });
  76. if (code === 200) {
  77. await updateUserInfo(walletStore.account,walletStore.id);
  78. }
  79. show.value = false;
  80. };
  81. const formatAddress = (address) => {
  82. if (!address) return '';
  83. return address.slice(0, 8) + '...' + address.slice(-6);
  84. };
  85. </script>
  86. <style lang="less" scoped>
  87. .container {
  88. margin: 25px 17px;
  89. .userimg {
  90. display: flex;
  91. justify-content: center;
  92. }
  93. .username {
  94. text-align: center;
  95. margin: 10px 0 4px;
  96. font-family:
  97. PingFang SC,
  98. PingFang SC;
  99. font-weight: 500;
  100. font-size: 16px;
  101. color: @theme-color1;
  102. }
  103. .useraddress {
  104. text-align: center;
  105. font-family:
  106. PingFang SC,
  107. PingFang SC;
  108. font-weight: 400;
  109. font-size: 12px;
  110. color: #8d8d8d;
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. }
  115. .van-cell {
  116. height: 44px;
  117. background: @bg-color1;
  118. border-bottom: 1px solid @bg-color1;
  119. font-size: 15px;
  120. &::after {
  121. border-bottom: 1px solid #f2f2f2;
  122. }
  123. }
  124. :deep(.van-cell__title){
  125. font-family: PingFang SC, PingFang SC;
  126. font-weight: 500 ;
  127. font-size: 15px;
  128. color: #000000;
  129. }
  130. :deep(.van-cell__value){
  131. font-family: PingFang SC, PingFang SC;
  132. font-weight: 400;
  133. font-size: 15px;
  134. color: #8D8D8D;
  135. }
  136. .user-bar-list-last::after {
  137. border-bottom: 0;
  138. }
  139. .user-bar-list {
  140. margin: 25px 0 37px;
  141. border-radius: 12px;
  142. overflow: hidden;
  143. }
  144. .qrcode {
  145. display: flex;
  146. flex-direction: column;
  147. align-items: center;
  148. .text {
  149. font-family:
  150. PingFang SC,
  151. PingFang SC;
  152. font-weight: 400;
  153. font-size: 15px;
  154. color: #8d8d8d;
  155. margin-top: 10px;
  156. }
  157. }
  158. .pop-content {
  159. padding: 27px 35px 25px 34px;
  160. .pop-title {
  161. font-family:
  162. PingFang SC,
  163. PingFang SC;
  164. font-weight: 500;
  165. font-size: 17px;
  166. color: #000000;
  167. text-align: center;
  168. }
  169. .pop-input {
  170. background: #f2f2f2;
  171. border-radius: 8px;
  172. height: 40px;
  173. margin: 21px 0 31px;
  174. }
  175. .pop-btn {
  176. display: flex;
  177. justify-content: center;
  178. .btn {
  179. width: 83px;
  180. height: 29px;
  181. line-height: 29px;
  182. padding: 5px 0 !important;
  183. border-radius: 6px;
  184. font-family:
  185. PingFang SC,
  186. PingFang SC;
  187. font-weight: 400;
  188. font-size: 15px;
  189. box-sizing: border-box;
  190. }
  191. .cancel {
  192. margin-right: 17px !important;
  193. border: 1px solid #d8d8d8;
  194. color: #000 !important;
  195. }
  196. .confirm {
  197. background: @theme-color1;
  198. color: #fff;
  199. font-weight: 500;
  200. }
  201. }
  202. }
  203. }
  204. :deep(.van-popup--center) {
  205. margin: 0 40px !important;
  206. width: auto !important;
  207. }
  208. </style>