From 80c7f3e74841a1e0abf2cc084efdefe24739830a Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Thu, 18 Dec 2025 17:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/me/me.vue | 93 +++++++++++++++++++++++++++++++--------- pages/prize/index.vue | 99 ++++--------------------------------------- 2 files changed, 82 insertions(+), 110 deletions(-) diff --git a/pages/me/me.vue b/pages/me/me.vue index a1d767c..be762cc 100644 --- a/pages/me/me.vue +++ b/pages/me/me.vue @@ -20,7 +20,7 @@ - 收货地址 + 奖品快递地址 @@ -41,12 +41,18 @@ - - + + - 收货地址 - + 奖品快递地址 + @@ -81,10 +87,10 @@ > - 地址 + 奖品快递地址 @@ -202,7 +208,7 @@ @@ -269,6 +280,8 @@ joinContent: "", rulesContent: "", showAddress: false, + fromPrize: false, // 是否从抽奖页跳转 + forcePrizeAddress: false, // 是否为从抽奖页跳转过来的奖品地址,必须填写后才能关闭 addressForm: { name: "", mobile: "", @@ -300,8 +313,9 @@ }) }, async toAddress() { - - // 显示收货地址表单弹窗 + // 普通入口,允许关闭 + this.forcePrizeAddress = false; + // 显示奖品快递地址表单弹窗 this.showAddress = true; // 从用户信息中预填充表单 this.addressForm = { @@ -347,7 +361,8 @@ this.userInfo = res; toast('保存成功'); this.showAddress = false; - // 清空表单 + this.forcePrizeAddress = false; + // 重新获取用户信息 this.getUserInfo() }).catch((error) => { console.error('保存失败:', error); @@ -367,7 +382,7 @@ url: '/pages/answer/index' }) }, - async getUserInfo() { + async getUserInfo(option) { const res = await this.$u.api.user() this.$u.vuex('vuex_user', res); this.userInfo = res; @@ -375,6 +390,26 @@ uni.redirectTo({ url: '/pages/login/index' }) + return + } + + // 如果是从抽奖页跳转过来,且当前用户还没有填写奖品快递地址,则在获取到用户信息后再预填地址并弹窗 + if (option && option.fromPrize === '1') { + const hasAddress = + res.address && + typeof res.address === 'string' && + res.address.trim().length > 0 + + if (!hasAddress) { + this.fromPrize = true + this.forcePrizeAddress = true; + this.showAddress = true; + this.addressForm = { + name: this.userInfo.name || "", + mobile: this.userInfo.mobile || "", + address: this.userInfo.address || "" + }; + } } }, async getConfig() { @@ -404,9 +439,9 @@ if (item.key === "rules") { this.rulesContent = item.value; } - if (item.key == 'open_win') { - this.open_win = item.value == 1 ? true : false - } + if (item.key == 'open_win') { + this.open_win = item.value == 1 ? true : false + } }); } } catch (error) { @@ -433,10 +468,10 @@ }, }, - onLoad() { + onLoad(option) { this.getConfig() // 先获取用户信息 - this.getUserInfo(); + this.getUserInfo(option); // 获取奖品信息 this.getPrize(); }, @@ -783,7 +818,7 @@ ::v-deep .rule-text { color: #496690; - flex: 1; + flex: 1; } } } @@ -824,7 +859,7 @@ background: #f5f5f5; border-radius: 10rpx; padding: 20rpx 30rpx; - font-size: 28rpx; + font-size: 28rpx; color: #333; box-sizing: border-box; } @@ -870,6 +905,9 @@ font-weight: bold; text-align: center; white-space: nowrap; + .prize-text { + color: #fd9d0c; + } } .win-record-buttons { @@ -892,6 +930,23 @@ } } } + +/* 底部悬浮继续答题按钮 */ +.float-answer-btn { + position: fixed; + left: 50%; + bottom: 40rpx; + transform: translateX(-50%); + z-index: 1000; + min-width: 300rpx; + padding: 20rpx 60rpx; + text-align: center; + font-size: 32rpx; + color: #fff; + background: linear-gradient(to right, #57b0fe, #446efd); + border-radius: 999rpx; + box-shadow: 0 8rpx 20rpx rgba(68, 110, 253, 0.5); +} diff --git a/pages/prize/index.vue b/pages/prize/index.vue index 9c035be..28c7dd4 100644 --- a/pages/prize/index.vue +++ b/pages/prize/index.vue @@ -37,7 +37,6 @@ - @@ -45,53 +44,16 @@ 科普图书 一本! - 请填写收货地址 - - - - - - - - - + 提交 + >填写奖品快递地址 @@ -233,56 +195,11 @@ } } }, - isOnlyChinese(str) { - const chineseRegex = /^[\u4e00-\u9fa5]+$/; - return chineseRegex.test(str); - }, submitWinAddress() { - // 表单验证 - if (!this.winAddressForm.name || !this.winAddressForm.name.trim()) { - toast('请输入姓名'); - return; - } - if (!this.isOnlyChinese(this.winAddressForm.name.trim())) { - toast('请输入中文姓名'); - return; - } - if (!this.winAddressForm.mobile || !this.winAddressForm.mobile.trim()) { - toast('请输入手机号'); - return; - } - if (!uni.$u.test.mobile(this.winAddressForm.mobile.trim())) { - toast('请输入正确的手机号'); - return; - } - if (!this.winAddressForm.address || !this.winAddressForm.address.trim()) { - toast('请输入详细地址'); - return; - } - - this.submitting = true - - // 提交到 saveUser 接口 - this.$u.api.saveUser({ - name: this.winAddressForm.name.trim(), - mobile: this.winAddressForm.mobile.trim(), - address: this.winAddressForm.address.trim() - }).then((res) => { - this.submitting = false - this.$u.vuex('vuex_user', res); - toast('提交成功'); - this.showWinForm = false; - // 2秒后跳转到 pages/me/me - setTimeout(() => { - uni.redirectTo({ - url: '/pages/me/me' - }) - }, 2000) - }).catch((error) => { - this.submitting = false - console.error('提交失败:', error); - toast('提交失败,请重试'); - }); + // 不再在本页提交表单,跳转到“我的”页面,由“我的”页面弹出奖品快递地址弹窗 + uni.redirectTo({ + url: '/pages/me/me?fromPrize=1' + }) }, continueAnswer() { this.showNoWin = false @@ -438,7 +355,7 @@ display: flex; flex-direction: column; align-items: center; - padding: 200rpx 30rpx 30rpx; // 增加顶部padding,避免文字被图片遮挡 + padding: 80rpx 30rpx 30rpx; // 增加顶部padding,避免文字被图片遮挡 .win-title { font-size: 32rpx; @@ -461,7 +378,7 @@ .win-form-content { background: #f3f8ff; padding: 0 40rpx 40rpx; - + padding-bottom: 100rpx; .form-item { margin-bottom: 30rpx;