index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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>0xF3fefE…EcaB</span>
  9. <svg-icon style="width: 18px; height: 18px" name="copy" />
  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 { useSystemStore } from "@/stores/modules/systemStore";
  54. import { useWalletStore } from "@/stores/modules/walletStore";
  55. import { uploadFile, userInfoEdit } from "@/api/path/im.api";
  56. import { updateUserInfo } from "@/common/login";
  57. const walletStore = useWalletStore();
  58. const show = ref(false);
  59. const nickname = ref("");
  60. const qrtext = ref(walletStore.account);
  61. const afterRead = async (file) => {
  62. const formData = new FormData();
  63. formData.append("uuid", walletStore.account);
  64. formData.append("file", file.file);
  65. const { code, data } = await uploadFile(formData);
  66. if (code === 200) {
  67. await updateUserInfo(walletStore.account);
  68. }
  69. };
  70. const updateUserName = async () => {
  71. const { code} = await userInfoEdit({
  72. username: walletStore.account,
  73. nickname: nickname.value,
  74. });
  75. if (code === 200) {
  76. await updateUserInfo(walletStore.account);
  77. }
  78. show.value = false;
  79. };
  80. </script>
  81. <style lang="less" scoped>
  82. .container {
  83. margin: 25px 17px;
  84. .userimg {
  85. display: flex;
  86. justify-content: center;
  87. }
  88. .username {
  89. text-align: center;
  90. margin: 10px 0 4px;
  91. font-family:
  92. PingFang SC,
  93. PingFang SC;
  94. font-weight: 500;
  95. font-size: 16px;
  96. color: @theme-color1;
  97. }
  98. .useraddress {
  99. text-align: center;
  100. font-family:
  101. PingFang SC,
  102. PingFang SC;
  103. font-weight: 400;
  104. font-size: 12px;
  105. color: #8d8d8d;
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. }
  110. .van-cell {
  111. height: 42px;
  112. background: @bg-color1;
  113. border-bottom: 1px solid @bg-color1;
  114. font-size: 15px;
  115. &::after {
  116. border-bottom: 1px solid #f2f2f2;
  117. }
  118. }
  119. .user-bar-list-last::after {
  120. border-bottom: 0;
  121. }
  122. .user-bar-list {
  123. margin: 25px 0 37px;
  124. border-radius: 12px;
  125. overflow: hidden;
  126. }
  127. .qrcode {
  128. display: flex;
  129. flex-direction: column;
  130. align-items: center;
  131. .text {
  132. font-family:
  133. PingFang SC,
  134. PingFang SC;
  135. font-weight: 400;
  136. font-size: 15px;
  137. color: #8d8d8d;
  138. margin-top: 10px;
  139. }
  140. }
  141. .pop-content {
  142. padding: 27px 35px 25px 34px;
  143. .pop-title {
  144. font-family:
  145. PingFang SC,
  146. PingFang SC;
  147. font-weight: 500;
  148. font-size: 17px;
  149. color: #000000;
  150. text-align: center;
  151. }
  152. .pop-input {
  153. background: #f2f2f2;
  154. border-radius: 8px;
  155. height: 40px;
  156. margin: 21px 0 31px;
  157. }
  158. .pop-btn {
  159. display: flex;
  160. justify-content: center;
  161. .btn {
  162. width: 83px;
  163. height: 29px;
  164. line-height: 29px;
  165. padding: 5px 0 !important;
  166. border-radius: 6px;
  167. font-family:
  168. PingFang SC,
  169. PingFang SC;
  170. font-weight: 400;
  171. font-size: 15px;
  172. box-sizing: border-box;
  173. }
  174. .cancel {
  175. margin-right: 17px !important;
  176. border: 1px solid #d8d8d8;
  177. color: #000 !important;
  178. }
  179. .confirm {
  180. background: @theme-color1;
  181. color: #fff;
  182. font-weight: 500;
  183. }
  184. }
  185. }
  186. }
  187. :deep(.van-popup--center) {
  188. margin: 0 40px !important;
  189. width: auto !important;
  190. }
  191. </style>