更新小程序,优化单页模式下的用户引导逻辑,确保用户在朋友圈等环境中能够顺利登录和访问完整内容。调整章节内容获取逻辑,确保未授权用户无法访问完整内容。新增手机号同步功能,提升用户资料管理体验。

This commit is contained in:
Alex-larget
2026-03-10 20:20:03 +08:00
parent 3b942fd7a4
commit dc3597c906
8 changed files with 165 additions and 19 deletions

View File

@@ -370,6 +370,9 @@ Page({
this.setData({ showLeadModal: false, leadPhone: '' })
},
// 阻止弹窗内部点击事件冒泡到遮罩层
stopPropagation() {},
onLeadPhoneInput(e) {
this.setData({ leadPhone: (e.detail.value || '').trim() })
},
@@ -407,6 +410,30 @@ Page({
this.setData({ showLeadModal: false, leadPhone: '' })
if (res && res.success) {
wx.setStorageSync('lead_last_submit_ts', Date.now())
// 若用户资料中尚未保存手机号,则顺手同步到资料(不影响本次提交结果)
try {
const currentPhone = (app.globalData.userInfo?.phone || '').trim()
if (!currentPhone && userId) {
await app.request({
url: '/api/miniprogram/user/profile',
method: 'POST',
data: {
userId,
phone
}
})
if (app.globalData.userInfo) {
app.globalData.userInfo.phone = phone
wx.setStorageSync('userInfo', app.globalData.userInfo)
}
wx.setStorageSync('user_phone', phone)
}
} catch (e) {
// 资料同步失败不影响前端提示
console.log('[Index] 同步手机号到用户资料失败:', e && e.message)
}
wx.showToast({ title: res.message || '提交成功,卡若会尽快联系您', icon: 'success' })
} else {
wx.showToast({ title: (res && res.message) || '提交失败', icon: 'none' })

View File

@@ -189,7 +189,8 @@
<!-- 链接卡若 - 留资弹窗(未填手机/微信号时) -->
<view class="lead-mask" wx:if="{{showLeadModal}}" catchtap="closeLeadModal">
<view class="lead-box" catchtap="">
<!-- 使用 catchtap="stopPropagation" 阻止内部点击冒泡到遮罩层,避免点击输入框时弹窗被关闭 -->
<view class="lead-box" catchtap="stopPropagation">
<text class="lead-title">留下联系方式</text>
<text class="lead-desc">方便卡若与您联系</text>
<input class="lead-input" placeholder="请输入手机号" type="number" maxlength="11" value="{{leadPhone}}" bindinput="onLeadPhoneInput"/>

View File

@@ -898,7 +898,11 @@
.lead-btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
/* 使用 flex 垂直居中文本,避免小程序默认 padding 导致按钮文字下沉 */
display: flex;
align-items: center;
justify-content: center;
padding: 0;
border-radius: 16rpx;
font-size: 30rpx;
font-weight: 500;