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.
 
 
 
 
 

185 lines
3.4 KiB

<template>
<view class="main">
<view :style="{height:iSMT+'px'}"></view>
<view style="height:1.5vh;" />
<view class="top">
<view class="top-list">
<view class="left">
<img src="/static/my/bindedPhone.png" />
<text class="label">已绑手机号{{ phone }}</text>
</view>
</view>
<view class="top-list">
<view class="left">
<img src="/static/my/changeBindPhone.png" />
<text class="label">+86</text>
<input type="number" v-model="userPhone" placeholder="请输入您的换绑手机号" class="input" />
</view>
<view class="right">
<button class="verification" :class="{ 'disabled': gettingCode }" @click="getCode"
:disabled="gettingCode">
{{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }}
</button>
</view>
</view>
<view class="top-list">
<view class="left">
<img src="/static/my/verification.png" />
<input type="text" placeholder="请输入验证码" class="input" />
</view>
</view>
</view>
<view class="bottom">
<button class="change-btn" @click="changeAccount">换绑</button>
</view>
</view>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue'
import {
sendPhone,
changeBind
} from "@/api/setting/password"
import {
getUserInfo
} from "@/api/member"
const iSMT = ref(0)
const phone = ref('')
const gettingCode = ref(false)
const time = ref(60)
const userPhone = ref('')
const userInfoPromise = getUserInfo()
userInfoPromise.then(res => {
if (res.code === 200) {
console.log('个人信息', res.data)
phone.value = res.data.phone
} else {
uni.showToast({
title: '用户信息请求失败',
icon: 'none',
})
}
})
const getCode = () => {
if (gettingCode.value) return
gettingCode.value = true
time.value = 60
const timer = setInterval(() => {
time.value--
if (time.value <= 0) {
clearInterval(timer)
gettingCode.value = false
}
}, 1000)
sendPhone({
phone: userPhone.value
})
}
const changeAccount = () => {
const res = changeBind({
verificateType: 1,
account: userPhone.value
})
if(res.code === 200){
uni.showToast({
title: '绑定成功',
icon: 'none',
})
}else {
uni.showToast({
title: '用户绑定失败',
icon: 'none',
})
}
}
onMounted(() => {
// 状态栏高度
iSMT.value = uni.getSystemInfoSync().statusBarHeight;
console.log('看看高度', iSMT.value)
})
</script>
<style>
.top {
height: auto;
background-color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.top-list {
width: 630rpx;
height: 7vh;
margin: 0rpx 40rpx;
display: flex;
align-items: center;
border-bottom: 1rpx solid #eee;
}
.left {
flex: 1;
display: flex;
align-items: center;
}
.label {
font-size: 28rpx;
margin-left: 10rpx;
}
.right {
display: flex;
align-items: center;
justify-content: center;
}
.input {
flex: 1;
height: 70rpx;
font-size: 29rpx;
margin-left: 20rpx;
}
.verification {
font-size: 24rpx;
border-radius: 10rpx;
background-color: rgb(230, 230, 230);
}
.bottom {
height: 22vh;
background-color: white;
display: flex;
align-items: center;
justify-content: center;
}
.change-btn {
height: 85rpx;
width: 610rpx;
padding:0 20rpx;
background-color: black;
color: white;
border-radius: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
</style>