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.

184 lines
3.4 KiB

  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. <img src="/static/my/bindedPhone.png" />
  9. <text class="label">已绑手机号{{ phone }}</text>
  10. </view>
  11. </view>
  12. <view class="top-list">
  13. <view class="left">
  14. <img src="/static/my/changeBindPhone.png" />
  15. <text class="label">+86</text>
  16. <input type="number" v-model="userPhone" placeholder="请输入您的换绑手机号" class="input" />
  17. </view>
  18. <view class="right">
  19. <button class="verification" :class="{ 'disabled': gettingCode }" @click="getCode"
  20. :disabled="gettingCode">
  21. {{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }}
  22. </button>
  23. </view>
  24. </view>
  25. <view class="top-list">
  26. <view class="left">
  27. <img src="/static/my/verification.png" />
  28. <input type="text" placeholder="请输入验证码" class="input" />
  29. </view>
  30. </view>
  31. </view>
  32. <view class="bottom">
  33. <button class="change-btn" @click="changeAccount">换绑</button>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import {
  39. ref,
  40. onMounted
  41. } from 'vue'
  42. import {
  43. sendPhone,
  44. changeBind
  45. } from "@/api/setting/password"
  46. import {
  47. getUserInfo
  48. } from "@/api/member"
  49. const iSMT = ref(0)
  50. const phone = ref('')
  51. const gettingCode = ref(false)
  52. const time = ref(60)
  53. const userPhone = ref('')
  54. const userInfoPromise = getUserInfo()
  55. userInfoPromise.then(res => {
  56. if (res.code === 200) {
  57. console.log('个人信息', res.data)
  58. phone.value = res.data.phone
  59. } else {
  60. uni.showToast({
  61. title: '用户信息请求失败',
  62. icon: 'none',
  63. })
  64. }
  65. })
  66. const getCode = () => {
  67. if (gettingCode.value) return
  68. gettingCode.value = true
  69. time.value = 60
  70. const timer = setInterval(() => {
  71. time.value--
  72. if (time.value <= 0) {
  73. clearInterval(timer)
  74. gettingCode.value = false
  75. }
  76. }, 1000)
  77. sendPhone({
  78. phone: userPhone.value
  79. })
  80. }
  81. const changeAccount = () => {
  82. const res = changeBind({
  83. verificateType: 1,
  84. account: userPhone.value
  85. })
  86. if(res.code === 200){
  87. uni.showToast({
  88. title: '绑定成功',
  89. icon: 'none',
  90. })
  91. }else {
  92. uni.showToast({
  93. title: '用户绑定失败',
  94. icon: 'none',
  95. })
  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. </style>