Dining_Hall/pages/mine/me/updatePhone.vue

192 lines
3.8 KiB
Vue
Raw Normal View History

2025-01-03 18:28:23 +08:00
<template>
<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
2025-01-03 18:28:23 +08:00
<view class="container">
<!-- 顶部导航栏 -->
<!-- <view class="header">-->
<!-- <view class="back-icon" @click="goBack">-->
<!-- <image class="icon" :src="require('@/static/images/icons/back.png')" mode="aspectFit"></image>-->
<!-- </view>-->
<!-- </view>-->
<!-- 主要内容区域 -->
<view class="content">
<view class="title-section">
<text class="title">输入新的手机号</text>
<text class="subtitle">换绑手机号后将使用新的手机号登录</text>
</view>
<!-- 手机号输入框 -->
<view class="input-wrapper">
2025-01-16 11:09:35 +08:00
<input type="number" v-model="phoneNumber" placeholder="请输入手机号" maxlength="11" class="phone-input"/>
2025-01-03 18:28:23 +08:00
<view class="clear-icon" v-if="phoneNumber" @click="clearPhoneNumber">
<image class="icon" :src="require('@/static/images/my/cancel.png')" mode="aspectFit"></image>
</view>
</view>
<!-- 获取验证码按钮 -->
2025-01-16 11:09:35 +08:00
<!-- <button class="verify-btn" :disabled="!isValidPhone" @click="handleGetVerifyCode">获取短信验证码</button> -->
<button class="verify-btn" @click="handleGetVerifyCode">修改</button>
2025-01-03 18:28:23 +08:00
</view>
</view>
</template>
<script>
2025-01-16 11:09:35 +08:00
import {
getUserProfile,
updateUserProfile
} from "@/api/system/user"
2025-01-03 18:28:23 +08:00
export default {
data() {
return {
fontValue:uni.getStorageSync('fontSize') || 8,
phoneNumber: '',
countdown: 0,
userInfo: {}
2025-01-03 18:28:23 +08:00
}
},
computed: {
isValidPhone() {
return /^1[3-9]\d{9}$/.test(this.phoneNumber)
}
},
2025-01-16 11:09:35 +08:00
onLoad() {
this.getUserInfo()
},
2025-01-03 18:28:23 +08:00
methods: {
2025-01-16 11:09:35 +08:00
getUserInfo() {
2025-02-19 09:34:34 +08:00
getUserProfile({'custId':uni.getStorageSync('custId'),"sourceType":7}).then(res => {
2025-01-16 11:09:35 +08:00
this.userInfo = res.user
})
},
2025-01-03 18:28:23 +08:00
goBack() {
uni.navigateBack()
},
2025-01-16 11:09:35 +08:00
2025-01-03 18:28:23 +08:00
clearPhoneNumber() {
this.phoneNumber = ''
},
2025-01-16 11:09:35 +08:00
2025-01-03 18:28:23 +08:00
handleGetVerifyCode() {
2025-02-19 09:34:34 +08:00
if (!this.isValidPhone) {
uni.showToast({ title: '请正确输入手机号', icon: 'none' })
return
}
// this.userInfo.phonenumber = this.phoneNumber
// updateUserProfile(this.userInfo).then(res => {
// uni.showToast({ title: '修改成功', icon: 'success',duration: 2000 });
// setTimeout(() => {
// uni.navigateBack()
// },2000)
// })
2025-01-03 18:28:23 +08:00
// 这里添加获取验证码的逻辑
2025-02-19 09:34:34 +08:00
uni.navigateTo({
url: `/pages/mine/me/phoneCode?phone=${this.phoneNumber}`
})
2025-01-03 18:28:23 +08:00
}
}
}
</script>
<style lang="scss">
.container {
min-height: 100vh;
background-color: #fff;
}
.header {
padding: 44px 32rpx 0;
height: 88rpx;
display: flex;
align-items: center;
.back-icon {
padding: 20rpx;
margin-left: -20rpx;
.icon {
width: 40rpx;
height: 40rpx;
}
}
}
.content {
padding: 32rpx;
}
.title-section {
margin-bottom: 48rpx;
.title {
font-size: 40rpx;
font-weight: 500;
color: #333;
margin-bottom: 16rpx;
display: block;
}
.subtitle {
font-size: 28rpx;
color: #999;
}
}
.input-wrapper {
position: relative;
margin-bottom: 48rpx;
.phone-input {
width: 100%;
height: 96rpx;
background: #F5F5F5;
border-radius: 48rpx;
padding: 0 88rpx 0 48rpx;
font-size: 32rpx;
color: #333;
&::placeholder {
color: #999;
}
}
.clear-icon {
position: absolute;
right: 32rpx;
top: 50%;
transform: translateY(-50%);
padding: 16rpx;
.icon {
width: 32rpx;
height: 32rpx;
}
}
}
.verify-btn {
width: 100%;
height: 72rpx;
2025-01-03 18:28:23 +08:00
background: #FF8126;
color: #fff;
font-size: 28rpx;
2025-01-03 18:28:23 +08:00
font-weight: 500;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
border: none;
&:disabled {
opacity: 0.5;
}
&:active {
opacity: 0.9;
}
}
</style>