uniapp 微信小程序实现修改手机号

uniapp yekong

uniapp微信小程序修改手机号码

发送短信

页面使用到了发送短信 uniapp 微信小程序 发送短信

代码

<template>
	<view class="login">
		<u-sticky>
			<view>
				<div class="topbg">
					<u-navbar leftIconColor="#D5D9E7" :titleStyle="titleStyle" title="主体变更" :placeholder="true"
						:safeAreaInsetTop="true" :fixed="true" bgColor="rgba(0,0,0,0)" :autoBack="true">
					</u-navbar>
				</div>
			</view>
		</u-sticky>
		<div class="userInfo">
			<div class="userInfo1">
				<div class="userInfoName">
					<text>变更后手机号</text><text class="red">*</text>
				</div>
				<input v-model="data.Phone" type="text" placeholder="请填写"
					placeholder-style="font-size:32rpx;color: #D5D5E0;" />
			</div>
			<div class="userInfo1">
				<div class="userInfoName">
					<text>验证码</text><text class="red">*</text>
				</div>
				<div class="userInfo2">
					<input v-model="data.CheckCode" type="text" placeholder="请填写"
						placeholder-style="font-size:32rpx;color: #D5D5E0;" />
					<sendcode :Phone="data.Phone"></sendcode>
				</div>
			</div>
		</div>
		<u-gap height="100" bgColor="rgba(0,0,0,0)" marginTop="10" marginBottom="10"></u-gap>
		<div class="footerbut">
			<div class="footerbutinner" @tap="$u.debounce(save, 500)">
				确认
			</div>
		</div>
		<showToast ref="showToast"></showToast>
	</view>
</template>

<script>
	import {
		EditFunds,
		ChangePhone
	} from '@/config/api.js'
	import configs from '@/config/config.js'
	export default {
		data() {
			return {
				titleStyle: {
					color: '#FFFFFF',
					fontSize: '34rpx'
				},
				BelongId: '',
				data: {
					Phone: '',
					AccountId: '',
					CheckCode: '',
				}
			}
		},
		onShow() {
			var that = this;
			that.data.AccountId = JSON.parse(uni.getStorageSync('userData')).Id
		},
		methods: {
			// 更新
			save() {
				var that = this;
				if (!this.data.Phone) {
					this.$refs['showToast'].warn('请输入手机号');
					return
				}
				if (!this.data.CheckCode) {
					this.$refs['showToast'].warn('请输入验证码');
					return
				}
				ChangePhone(this.data, {
					custom: {
						auth: true
					}
				}).then(res => {
					if (res.Code == 200) {
						this.$refs['showToast'].success('修改成功');
						setTimeout(() => {
							uni.navigateBack({})
						}, 2000)

					}
				}).catch(err => {

				})
			}
		}
	}
</script>
<style>
	page {
		background: #F5F6FA;
	}
</style>
<style scoped lang="scss">
	.login {}

	.topbg {
		width: 100%;
		background: url(https://images.wanjunshijie.com/mini/buildingMaterialsCloud/gsgl/gsgl.png) center top no-repeat #F5F6FA;
		background-size: 750rpx 192rpx;
		position: relative;
		padding-bottom: 28rpx;
		border-radius: 0 0 20rpx 20rpx;
	}

	.userInfo {
		width: 694rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin: 0 auto;
		margin-top: 40rpx;

		.userInfo1 {
			width: 630rpx;
			min-height: 157rpx;
			background: rgba(216, 216, 216, 0);
			box-shadow: 0px 1rpx 0px 0px #F2F2F2;
			margin: 0 auto;

			.userInfoName {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				flex-wrap: nowrap;
				flex-direction: row;
				align-content: flex-start;
				padding-top: 32rpx;

				text {
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #151852;
				}

				.red {
					font-size: 24rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FF5252;
					margin-top: -15rpx;
				}

			}

			.userInfoName2 {
				text {
					color: #BABBCB;
				}

				.red {
					color: #FFD0CF;
				}
			}

			input {
				margin-top: 8rpx;
				color: #474A77;
				font-size: 32rpx;
				z-index: 1;
				position: relative;
			}

			.disabled {
				color: #C8C8D6;
			}
		}
	}

	.footerbut {
		position: fixed;
		bottom: 30rpx;
		display: flex;
		width: 750rpx;
		justify-content: center;
		align-items: center;
		z-index: 100;
		flex-wrap: nowrap;
		flex-direction: row;
		align-content: flex-start;

		.footerbutinner {
			width: 694rpx;
			height: 96rpx;
			cursor: pointer;
			background: #4087FF;
			border-radius: 20rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-wrap: nowrap;
			flex-direction: row;
			align-content: flex-start;
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.idcardbody {
		margin: 0 auto;
		margin-top: 20rpx;
		width: 630rpx;
	}

	.idcard {
		height: 245rpx;
		border-radius: 20rpx;
		width: 630rpx;
		border: 2rpx dashed rgba(#A1A8B3, 0.3);
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: nowrap;
		flex-direction: column;
		align-content: flex-start;

		.idcardimg {
			width: 436rpx;
			height: 267rpx;
		}

		.uploadbut {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-wrap: nowrap;
			flex-direction: row;
			align-content: flex-start;
			font-size: 30rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #006AFF;
			margin-top: 30rpx;

			image {
				width: 30rpx;
				height: 30rpx;
				margin-right: 12rpx;
			}
		}
	}

	.pb32 {
		padding-bottom: 32rpx;
	}

	.noborder {
		box-shadow: 0px 0px 0px 0px rgba(#000000, 0) !important;
	}

	.textarea {
		width: 100%;
		height: 245rpx;
	}

	.textarea {
		width: 100%;
		height: 170rpx;
	}

	.bodys {
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: nowrap;
		flex-direction: row;
		align-content: flex-start;

		image {
			width: 32rpx;
		}
	}

	.idcardbody {
		margin: 0 auto;
		margin-top: 20rpx;
		width: 630rpx;
	}

	.userInfo2 {
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: nowrap;
		flex-direction: row;
		align-content: flex-start;
	}
</style>

喜欢