From ad1629e4f90490758dbd91c4d8a9bed4a8693dfc Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 11 二月 2026 15:59:14 +0800
Subject: [PATCH] 合并

---
 mini-program/pages/change-binding/change-binding.vue |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 101 insertions(+), 7 deletions(-)

diff --git a/mini-program/pages/change-binding/change-binding.vue b/mini-program/pages/change-binding/change-binding.vue
index c4d6a16..9934a22 100644
--- a/mini-program/pages/change-binding/change-binding.vue
+++ b/mini-program/pages/change-binding/change-binding.vue
@@ -2,29 +2,123 @@
 	<view class="box">
 		<view class="box-info">
 			<text>楠岃瘉褰撳墠鐧诲綍鎵嬫満鍙�</text>
-			<text>璇疯緭鍏� 153****1677 鏀跺埌鐨勭煭淇¢獙璇佺爜</text>
+			<text v-if="status === 1">璇疯緭鍏� {{phone1}} 鏀跺埌鐨勭煭淇¢獙璇佺爜</text>
+			<text v-if="status === 2">鎹㈢粦鏂版墜鏈哄彿涔嬪悗锛屽彲浠ョ敤鏂扮殑鎵嬫満鍙风櫥褰�</text>
 		</view>
 		<view class="list">
-			<view class="input">
+			<view class="input" v-if="status === 2">
 				<view class="input-label">鎵嬫満鍙�</view>
-				<input type="number" placeholder="璇疯緭鍏ユ墜鏈哄彿" />
+				<input type="number" v-model="newPhone" placeholder="璇疯緭鍏ユ墜鏈哄彿" />
 			</view>
 			<view class="input">
 				<view class="input-label">鐭俊楠岃瘉鐮�</view>
-				<input type="number" placeholder="璇疯緭鍏ラ獙璇佺爜" />
-				<view class="input-send">鑾峰彇楠岃瘉鐮�</view>
+				<input type="number" v-model="code" placeholder="璇疯緭鍏ラ獙璇佺爜" />
+				<view class="input-send" @click="send" v-if="num === 0">鑾峰彇楠岃瘉鐮�</view>
+				<view class="input-send" v-else>{{num}}</view>
 			</view>
 		</view>
-		<view class="btn">涓嬩竴姝�</view>
+		<view class="btn" @click="submit">涓嬩竴姝�</view>
 	</view>
 </template>
 
 <script>
+	import { mapState } from 'vuex'
+	import { formatPhoneStar } from '@/utils/utils.js'
 	export default {
+		computed: {
+			...mapState(['userInfo'])
+		},
 		data() {
 			return {
-				
+				status: 1,
+				phone: '',
+				phone1: '',
+				newPhone: '',
+				code: '',
+				timer: null,
+				num: 0
 			};
+		},
+		onLoad() {
+			this.phone = this.userInfo.phone
+			this.phone1 = this.returnPhone(this.userInfo.phone)
+		},
+		methods: {
+			returnPhone(phone) {
+				return formatPhoneStar(phone)
+			},
+			// 涓嬩竴姝�
+			submit() {
+				if (this.status === 1) {
+					this.$u.api.verifyCode({
+						code: this.code,
+						phone: this.phone
+					}).then(res => {
+						if (res.code === 200) {
+							this.status = 2
+							this.code = ''
+							this.num = 0
+						}
+					})
+				} else if (this.status === 2) {
+					this.$u.api.updateUserPhone({
+						code: this.code,
+						phone: this.newPhone
+					}).then(res => {
+						if (res.code === 200) {
+							this.num = 0
+							uni.showToast({
+								title: '鎹㈢粦鎴愬姛!',
+								icon: 'none'
+							})
+							uni.navigateBack({ delta: 1 });
+						}
+					})
+				}
+				if (this.timer) {
+					clearInterval(this.timer)
+					this.timer = null
+				}
+			},
+			// 鍙戦�侀獙璇佺爜
+			send() {
+				if (this.status === 1) {
+					this.$u.api.sendSmsCode({
+						phone: this.phone
+					}).then(res => {
+						if (res.code === 200) {
+							uni.showToast({
+								title: '楠岃瘉鐮佸彂閫佹垚鍔�',
+								icon: 'none'
+							})
+							this.jishi()
+						}
+					})
+				} else {
+					this.$u.api.sendSmsCode({
+						phone: this.newPhone
+					}).then(res => {
+						if (res.code === 200) {
+							uni.showToast({
+								title: '楠岃瘉鐮佸彂閫佹垚鍔�',
+								icon: 'none'
+							})
+							this.jishi()
+						}
+					})
+				}
+			},
+			jishi() {
+				this.num = 10
+				this.timer = setInterval(() => {
+					if (this.num > 0) {
+						this.num--
+					} else {
+						clearInterval(this.timer)
+						this.timer = null
+					}
+				}, 1000)
+			}
 		}
 	}
 </script>

--
Gitblit v1.9.3