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.

228 lines
4.1 KiB

4 weeks ago
4 weeks ago
4 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 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" v-model="verifyCode" 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. import {
  49. verifyCodeApi
  50. } from "@/api/start/login"
  51. const iSMT = ref(0)
  52. const email = ref('')
  53. const gettingCode = ref(false)
  54. const time = ref(60)
  55. const userEmail = ref('')
  56. const verifyCode = ref('')
  57. const userInfoPromise = getUserInfo()
  58. userInfoPromise.then(res => {
  59. if (res.code === 200) {
  60. console.log('个人信息', res.data)
  61. email.value = res.data.email
  62. } else {
  63. uni.showToast({
  64. title: '用户信息请求失败',
  65. icon: 'none',
  66. })
  67. }
  68. })
  69. const changeAccount = () => {
  70. if (!userEmail) {
  71. uni.showToast({
  72. title: '请输入邮箱',
  73. icon: 'none'
  74. })
  75. return
  76. }
  77. if (!verifyCode) {
  78. uni.showToast({
  79. title: '请输入验证码',
  80. icon: 'none'
  81. })
  82. return
  83. }
  84. const res1 = verifyCodeApi({
  85. loginType: 'EMAIL',
  86. account: userEmail.value,
  87. verifyCode: verifyCode.value
  88. })
  89. if (res1.code === 200) {
  90. const res2 = changeBind({
  91. verificateType: 0,
  92. account: userEmail.value
  93. })
  94. if (res2.code === 200) {
  95. uni.showToast({
  96. title: '绑定成功',
  97. icon: 'none',
  98. })
  99. uni.navigateTo({
  100. url: '/pages/home/member'
  101. })
  102. } else {
  103. uni.showToast({
  104. title: '用户绑定失败',
  105. icon: 'none',
  106. })
  107. }
  108. } else {
  109. uni.showToast({
  110. title: '验证失败,请检查验证码',
  111. icon: 'none',
  112. })
  113. return
  114. }
  115. }
  116. const getCode = () => {
  117. if (gettingCode.value) return
  118. gettingCode.value = true
  119. time.value = 2
  120. const timer = setInterval(() => {
  121. time.value--
  122. if (time.value <= 0) {
  123. clearInterval(timer)
  124. gettingCode.value = false
  125. time.value = 2
  126. }
  127. }, 1000)
  128. sendEmail({
  129. email: userEmail.value
  130. })
  131. }
  132. onMounted(() => {
  133. // 状态栏高度
  134. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  135. console.log('看看高度', iSMT.value)
  136. })
  137. </script>
  138. <style>
  139. .top {
  140. height: auto;
  141. background-color: white;
  142. display: flex;
  143. flex-direction: column;
  144. align-items: center;
  145. justify-content: center;
  146. }
  147. .top-list {
  148. width: 630rpx;
  149. height: 7vh;
  150. margin: 0rpx 40rpx;
  151. display: flex;
  152. align-items: center;
  153. border-bottom: 1rpx solid #eee;
  154. }
  155. .left {
  156. flex: 1;
  157. display: flex;
  158. align-items: center;
  159. }
  160. .label {
  161. font-size: 28rpx;
  162. margin-left: 10rpx;
  163. }
  164. .right {
  165. display: flex;
  166. align-items: center;
  167. justify-content: center;
  168. }
  169. .input {
  170. flex: 1;
  171. height: 70rpx;
  172. font-size: 29rpx;
  173. margin-left: 20rpx;
  174. }
  175. .verification {
  176. font-size: 24rpx;
  177. border-radius: 10rpx;
  178. background-color: rgb(230, 230, 230);
  179. }
  180. .bottom {
  181. height: 22vh;
  182. background-color: white;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. .change-btn {
  188. height: 85rpx;
  189. width: 610rpx;
  190. padding: 0 20rpx;
  191. background-color: black;
  192. color: white;
  193. border-radius: 40rpx;
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. }
  198. .image {
  199. width: 40rpx;
  200. height: 40rpx;
  201. }
  202. </style>