You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

371 lines
7.6 KiB

4 weeks ago
  1. <template>
  2. <LoginPrompt ref="loginPrompt"></LoginPrompt>
  3. <view class="main">
  4. <view class="top">
  5. <view class="bell">
  6. <!-- <image class="image-bell" src="/static/my/bell.png" /> -->
  7. </view>
  8. <view class="msg">
  9. <view class="msg-left">
  10. <image class="avatar"
  11. :src="avatarUrl || 'https://d31zlh4on95l9h.cloudfront.net/default/1961d9d2e31e78e47e885231e7514a35.png'"
  12. mode="aspectFill" />
  13. </view>
  14. <view class=" msg-center">
  15. <view style="display: flex;">
  16. <template v-if="!isEditingName">
  17. <view class="userInfo">{{ username }}</view>
  18. <image class="image-editName" src="/static/my/editName.png" @click="startEditName" />
  19. </template>
  20. <template v-else>
  21. <input v-model="editingName" class="edit-input" @blur="finishEditName"
  22. @keyup.enter="finishEditName" autofocus placeholder="请输入用户名" />
  23. </template>
  24. </view>
  25. <view class="userId">ID:{{ dccode }}</view>
  26. </view>
  27. <!-- <view class="msg-right">
  28. <image class="image-attendance" src="/static/my/Check-in.png"/>
  29. <span style="font-size:10px;">签到</span>
  30. </view> -->
  31. </view>
  32. <view class="settings-buttons">
  33. <view class="setting-btn" @click="goToMarket">
  34. <image src="/static/my/MarketSettings.png" class="setting-icon" />
  35. <text>行情设置</text>
  36. </view>
  37. <view class="setting-btn" @click="goToGeneral">
  38. <image src="/static/my/Settings.png" class="setting-icon" />
  39. <text>通用设置</text>
  40. </view>
  41. </view>
  42. <view class="share" @click="goToShare">
  43. <image class="img-share" src="/static/my/share.png" mode="widthFix" />
  44. </view>
  45. </view>
  46. <view class="bottom">
  47. <view class="list-item" @click="goToAccount">
  48. <image src="/static/my/security.png" class="list-icon" />
  49. <text>账号与安全</text>
  50. <uni-icons type="arrowright" size="16" class="arrow" />
  51. </view>
  52. <!-- <view class="list-item">
  53. <image src="/static/my/connection.png" class="list-icon" />
  54. <text>联系我们</text>
  55. <uni-icons type="arrowright" size="16" class="arrow" />
  56. </view>
  57. <view class="list-item" @click="goToNewVersion">
  58. <image src="/static/my/update.png" class="list-icon" />
  59. <text>新版本更新</text>
  60. <view class="update-tip">有新版本可更新
  61. <view class="circle"></view>
  62. </view>
  63. <uni-icons type="arrowright" size="16" class="arrow" />
  64. </view>
  65. <view class="list-item">
  66. <image src="/static/my/opinion.png" class="list-icon" />
  67. <text>意见反馈</text>
  68. <uni-icons type="arrowright" size="16" class="arrow" />
  69. </view> -->
  70. <view class="list-item" @click="goToAbout">
  71. <image src="/static/my/about.png" class="list-icon" />
  72. <text>关于DeepChart</text>
  73. <uni-icons type="arrowright" size="16" class="arrow" />
  74. </view>
  75. </view>
  76. <footerBar class="static-footer" :type="type"></footerBar>
  77. </view>
  78. </template>
  79. <script setup>
  80. import {
  81. ref,
  82. onMounted
  83. } from 'vue'
  84. import {
  85. ArrowRight
  86. } from '@element-plus/icons-vue'
  87. import footerBar from '../../components/footerBar.vue'
  88. import {
  89. getUserInfo,
  90. updateUserInfo
  91. } from "@/api/member"
  92. import {
  93. useUserStore
  94. } from "../../stores/modules/userInfo"
  95. const userStore = useUserStore()
  96. const type = ref('member')
  97. const iSMT = ref(0)
  98. const username = ref('')
  99. const dccode = ref('')
  100. const avatarUrl = ref('')
  101. const isEditingName = ref(false)
  102. const editingName = ref('')
  103. const userInfoRes = ref() // 用户身份信息
  104. userInfoRes.value = getUserInfo()
  105. userInfoRes.value.then(res => {
  106. username.value = res.data.dcname
  107. dccode.value = res.data.dccode
  108. avatarUrl.value = res.data.avatar
  109. console.log('用户信息', userInfoRes.value)
  110. })
  111. const startEditName = () => {
  112. isEditingName.value = true
  113. editingName.value = username.value
  114. }
  115. const finishEditName = async () => {
  116. if (editingName.value.trim() === '' || editingName.value === username.value) {
  117. isEditingName.value = false
  118. return
  119. }
  120. try {
  121. await updateUserInfo({
  122. dcname: editingName.value
  123. })
  124. uni.showToast({
  125. title: '昵称修改成功',
  126. icon: 'none',
  127. })
  128. userInfoRes.value = getUserInfo()
  129. userInfoRes.value.then(res => {
  130. username.value = res.data.dcname
  131. dccode.value = res.data.dccode
  132. avatarUrl.value = res.data.avatar
  133. console.log('用户信息', userInfoRes.value)
  134. })
  135. } catch (err) {
  136. uni.showToast({
  137. title: '修改失败,请重试',
  138. icon: 'none'
  139. })
  140. } finally {
  141. isEditingName.value = false
  142. }
  143. }
  144. const goToGeneral = () => {
  145. uni.navigateTo({
  146. url: '/pages/setting/general'
  147. })
  148. }
  149. const goToMarket = () => {
  150. uni.navigateTo({
  151. url: '../setting/market'
  152. })
  153. }
  154. const goToAccount = () => {
  155. uni.navigateTo({
  156. url: '../setting/account'
  157. })
  158. }
  159. const goToNewVersion = () => {
  160. uni.navigateTo({
  161. url: '../setting/newVersion'
  162. })
  163. }
  164. const goToAbout = () => {
  165. uni.navigateTo({
  166. url: '../setting/about'
  167. })
  168. }
  169. const goToShare = () => {
  170. console.log('用户信息==========', userStore.userInfo.isVisitor)
  171. if (userStore.userInfo.visitor) {
  172. uni.showToast({
  173. title: '请先登录',
  174. icon: 'none'
  175. })
  176. return
  177. }
  178. uni.navigateTo({
  179. url: '../setting/share'
  180. })
  181. }
  182. onMounted(() => {
  183. // 状态栏高度
  184. iSMT.value = uni.getSystemInfoSync().statusBarHeight
  185. console.log('??????????????', iSMT.value)
  186. console.log('通信来的用户身份', userStore.userInfo)
  187. })
  188. </script>
  189. <style scoped>
  190. .static-footer {
  191. position: fixed;
  192. bottom: 0;
  193. }
  194. .top {
  195. height: 50vh;
  196. background-color: white;
  197. }
  198. .bell {
  199. height: 9.6vh;
  200. display: flex;
  201. align-items: flex-end;
  202. justify-content: flex-end;
  203. padding-right: 50rpx;
  204. }
  205. .image-bell {
  206. width: 26rpx;
  207. height: 32rpx;
  208. }
  209. .msg {
  210. height: 10.7vh;
  211. display: flex;
  212. margin-top: 3vh;
  213. margin-bottom: 3vh;
  214. }
  215. .msg-left {
  216. width: 252rpx;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. }
  221. .avatar {
  222. width: 175rpx;
  223. height: 175rpx;
  224. border-radius: 50%;
  225. background-color: black;
  226. }
  227. .msg-center {
  228. width: 388rpx;
  229. padding-left: 2.5vh;
  230. display: flex;
  231. flex-direction: column;
  232. justify-content: center;
  233. }
  234. .userInfo {
  235. font-size: 30rpx;
  236. font-weight: bold;
  237. }
  238. .userId {
  239. font-size: 14px;
  240. margin-top: 1vh;
  241. }
  242. .image-editName {
  243. width: 40rpx;
  244. height: 40rpx;
  245. margin-left: 15rpx;
  246. }
  247. .msg-right {
  248. display: flex;
  249. flex-direction: column;
  250. justify-content: center;
  251. }
  252. .image-attendance {
  253. width: 43rpx;
  254. height: 43rpx;
  255. }
  256. .settings-buttons {
  257. display: flex;
  258. justify-content: space-around;
  259. }
  260. .setting-btn {
  261. width: 349rpx;
  262. height: 135rpx;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. background-color: rgb(243, 243, 243);
  267. border-radius: 8%;
  268. margin-bottom: 1vh;
  269. }
  270. .setting-icon {
  271. width: 64.7rpx;
  272. height: 64.7rpx;
  273. margin-right: 25rpx;
  274. }
  275. .setting-btn text {
  276. font-size: 28rpx;
  277. font-weight: bold;
  278. color: #333;
  279. }
  280. .share {
  281. height: 12.6vh;
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. }
  286. .img-share {
  287. width: 720rpx;
  288. height: 160rpx;
  289. }
  290. .bottom {
  291. height: 44.5vh;
  292. margin-top: 1vh;
  293. background-color: rgb(255, 255, 255);
  294. }
  295. .list-item {
  296. width: 670rpx;
  297. height: 7vh;
  298. display: flex;
  299. align-items: center;
  300. margin: 0rpx 40rpx;
  301. border-bottom: 1rpx solid #eee;
  302. }
  303. .list-item:last-child {
  304. border-bottom: none;
  305. }
  306. .list-icon {
  307. width: 42rpx;
  308. height: 42rpx;
  309. margin-right: 18rpx;
  310. }
  311. .arrow {
  312. margin-left: auto;
  313. }
  314. .update-tip {
  315. display: flex;
  316. color: #999;
  317. font-size: 24rpx;
  318. align-items: center;
  319. margin-left: 200rpx;
  320. justify-content: center;
  321. }
  322. .circle {
  323. width: 10rpx;
  324. height: 10rpx;
  325. border-radius: 50%;
  326. background-color: red;
  327. margin-left: 10rpx;
  328. }
  329. .edit-input {
  330. background-color: #999;
  331. }
  332. </style>