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.

189 lines
3.5 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <view class="main">
  3. <view :style="{height:iSMT+'px'}"></view>
  4. <view style="height:1.5vh;" />
  5. <view class="top">
  6. <view class="top-list">
  7. <view class="left">
  8. <image class="image" src="/static/my/bindedEmail.png" />
  9. <text class="label">已绑邮箱{{ email }}</text>
  10. </view>
  11. </view>
  12. <view class="top-list">
  13. <view class="left">
  14. <image class="image" src="/static/my/changeEmail.png" />
  15. <input v-model="userEmail" placeholder="请输入您的换绑邮箱" class="input" />
  16. </view>
  17. <view class="right">
  18. <button class="verification" :class="{ 'disabled': gettingCode }" @click="getCode"
  19. :disabled="gettingCode">
  20. {{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }}
  21. </button>
  22. </view>
  23. </view>
  24. <view class="top-list">
  25. <view class="left">
  26. <image class="image" src="/static/my/verification.png" />
  27. <input type="text" placeholder="请输入验证码" class="input" />
  28. </view>
  29. </view>
  30. </view>
  31. <view class="bottom">
  32. <button class="change-btn" @click="changeAccount">换绑</button>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {
  38. ref,
  39. onMounted
  40. } from 'vue'
  41. import {
  42. getUserInfo
  43. } from "@/api/member"
  44. import {
  45. sendEmail,
  46. changeBind
  47. } from "@/api/setting/password"
  48. const iSMT = ref(0)
  49. const email = ref('')
  50. const gettingCode = ref(false)
  51. const time = ref(60)
  52. const userEmail = ref('')
  53. const userInfoPromise = getUserInfo()
  54. userInfoPromise.then(res => {
  55. if (res.code === 200) {
  56. console.log('个人信息', res.data)
  57. email.value = res.data.email
  58. } else {
  59. uni.showToast({
  60. title: '用户信息请求失败',
  61. icon: 'none',
  62. })
  63. }
  64. })
  65. const changeAccount = () => {
  66. const res = changeBind({
  67. verificateType: 0,
  68. account: userEmail.value
  69. })
  70. if(res.code === 200){
  71. uni.showToast({
  72. title: '绑定成功',
  73. icon: 'none',
  74. })
  75. }else {
  76. uni.showToast({
  77. title: '用户绑定失败',
  78. icon: 'none',
  79. })
  80. }
  81. }
  82. const getCode = () => {
  83. if (gettingCode.value) return
  84. gettingCode.value = true
  85. time.value = 2
  86. const timer = setInterval(() => {
  87. time.value--
  88. if (time.value <= 0) {
  89. clearInterval(timer)
  90. gettingCode.value = false
  91. time.value = 2
  92. }
  93. }, 1000)
  94. sendEmail({
  95. email: userEmail.value
  96. })
  97. }
  98. onMounted(() => {
  99. // 状态栏高度
  100. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  101. console.log('看看高度', iSMT.value)
  102. })
  103. </script>
  104. <style>
  105. .top {
  106. height: auto;
  107. background-color: white;
  108. display: flex;
  109. flex-direction: column;
  110. align-items: center;
  111. justify-content: center;
  112. }
  113. .top-list {
  114. width: 630rpx;
  115. height: 7vh;
  116. margin: 0rpx 40rpx;
  117. display: flex;
  118. align-items: center;
  119. border-bottom: 1rpx solid #eee;
  120. }
  121. .left {
  122. flex: 1;
  123. display: flex;
  124. align-items: center;
  125. }
  126. .label {
  127. font-size: 28rpx;
  128. margin-left: 10rpx;
  129. }
  130. .right {
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. }
  135. .input {
  136. flex: 1;
  137. height: 70rpx;
  138. font-size: 29rpx;
  139. margin-left: 20rpx;
  140. }
  141. .verification {
  142. font-size: 24rpx;
  143. border-radius: 10rpx;
  144. background-color: rgb(230, 230, 230);
  145. }
  146. .bottom {
  147. height: 22vh;
  148. background-color: white;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. }
  153. .change-btn {
  154. height: 85rpx;
  155. width: 610rpx;
  156. padding: 0 20rpx;
  157. background-color: black;
  158. color: white;
  159. border-radius: 40rpx;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. }
  164. .image{
  165. width:40rpx;
  166. height:40rpx;
  167. }
  168. </style>