完成Salon小程序合规整改
This commit is contained in:
@@ -12,10 +12,51 @@ Page({
|
||||
codeLoading: false,
|
||||
countdown: 0,
|
||||
timer: null,
|
||||
smsExpanded: false
|
||||
smsExpanded: false,
|
||||
unbindMode: false,
|
||||
closureRequest: null
|
||||
},
|
||||
|
||||
onShow() { this.loadProfile() },
|
||||
onShow() { this.loadProfile(); this.loadClosureRequest() },
|
||||
|
||||
async loadClosureRequest() {
|
||||
try {
|
||||
const closureRequest = await userApi.getAccountClosure()
|
||||
this.setData({ closureRequest: closureRequest || null })
|
||||
} catch (error) {
|
||||
this.setData({ closureRequest: null })
|
||||
}
|
||||
},
|
||||
|
||||
async requestClosure() {
|
||||
const confirmed = await new Promise(resolve => wx.showModal({
|
||||
title: '申请注销账号',
|
||||
content: '申请提交后由管理人员处理。完成后会清理账号身份资料,必要业务记录仍按保存要求保留。你可以在处理前撤回。',
|
||||
confirmText: '提交申请',
|
||||
success: result => resolve(result.confirm),
|
||||
fail: () => resolve(false)
|
||||
}))
|
||||
if (!confirmed) return
|
||||
try {
|
||||
const closureRequest = await userApi.requestAccountClosure()
|
||||
this.setData({ closureRequest })
|
||||
wx.showToast({ title: '注销申请已提交' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '申请提交失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
async withdrawClosure() {
|
||||
const confirmed = await new Promise(resolve => wx.showModal({ title: '撤回注销申请', content: '确定撤回账号注销申请吗?', success: result => resolve(result.confirm), fail: () => resolve(false) }))
|
||||
if (!confirmed) return
|
||||
try {
|
||||
await userApi.withdrawAccountClosure()
|
||||
await this.loadClosureRequest()
|
||||
wx.showToast({ title: '申请已撤回' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '撤回失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
async loadProfile(options = {}) {
|
||||
this.setData({ loading: true })
|
||||
@@ -39,7 +80,11 @@ Page({
|
||||
},
|
||||
|
||||
toggleSms() {
|
||||
this.setData({ smsExpanded: !this.data.smsExpanded })
|
||||
this.setData({ smsExpanded: !this.data.smsExpanded, unbindMode: false })
|
||||
},
|
||||
|
||||
beginUnbind() {
|
||||
this.setData({ smsExpanded: true, unbindMode: true, 'smsForm.code': '' })
|
||||
},
|
||||
|
||||
async bindWechatPhone(event) {
|
||||
@@ -62,13 +107,14 @@ Page({
|
||||
|
||||
async sendCode() {
|
||||
const phone = String(this.data.smsForm.phone || '')
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
if (!this.data.unbindMode && !/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' }); return
|
||||
}
|
||||
if (this.data.codeLoading || this.data.countdown) return
|
||||
this.setData({ codeLoading: true })
|
||||
try {
|
||||
await userApi.sendBindPhoneCode(phone)
|
||||
if (this.data.unbindMode) await userApi.sendUnbindPhoneCode()
|
||||
else await userApi.sendBindPhoneCode(phone)
|
||||
this.startCountdown()
|
||||
wx.showToast({ title: '验证码已发送' })
|
||||
} catch (error) {
|
||||
@@ -107,6 +153,33 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async unbindSmsPhone() {
|
||||
const code = String(this.data.smsForm.code || '')
|
||||
if (!/^\d{6}$/.test(code)) {
|
||||
wx.showToast({ title: '请输入当前手机号收到的6位验证码', icon: 'none' }); return
|
||||
}
|
||||
const confirmed = await new Promise(resolve => wx.showModal({
|
||||
title: '解绑手机号',
|
||||
content: '解绑后手机号将从账号资料中删除,短信验证码仅用于验证当前手机号。确定继续吗?',
|
||||
confirmText: '确认解绑',
|
||||
success: result => resolve(result.confirm),
|
||||
fail: () => resolve(false)
|
||||
}))
|
||||
if (!confirmed) return
|
||||
this.setData({ binding: true })
|
||||
try {
|
||||
await userApi.unbindPhone(code)
|
||||
profileCache.invalidate()
|
||||
this.setData({ unbindMode: false, smsExpanded: false, 'smsForm.code': '' })
|
||||
await this.loadProfile({ force: true })
|
||||
wx.showToast({ title: '手机号已解绑' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '解绑失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ binding: false })
|
||||
}
|
||||
},
|
||||
|
||||
async logout() {
|
||||
const confirmed = await new Promise(resolve => wx.showModal({ title: '退出登录', content: '退出后将关闭自动登录,并清除本机提醒设置。', success: result => resolve(result.confirm), fail: () => resolve(false) }))
|
||||
if (!confirmed) return
|
||||
|
||||
@@ -3,14 +3,28 @@
|
||||
<view class="card phone-card">
|
||||
<view class="section-title">手机号</view>
|
||||
<view class="phone-status"><text>{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}</text><text class="status-tag {{profile.phoneVerified == 1 ? 'done' : ''}}">{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}</text></view>
|
||||
<view class="privacy-note">手机号绑定为可选,不绑定不影响基础使用。仅用于账号找回和必要订单通知;不会用于营销。</view>
|
||||
<button class="wechat-phone-btn" open-type="getPhoneNumber" loading="{{binding}}" bindgetphonenumber="bindWechatPhone">快速{{profile.phoneVerified == 1 ? '更换' : '绑定'}}手机号</button>
|
||||
<view class="sms-entry" bindtap="toggleSms"><text>{{profile.phoneVerified == 1 ? '使用短信验证码更换' : '使用短信验证码绑定'}}</text><text class="sms-arrow {{smsExpanded ? 'expanded' : ''}}">›</text></view>
|
||||
<view wx:if="{{smsExpanded}}" class="sms-panel">
|
||||
<view class="field"><input value="{{smsForm.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" /></view>
|
||||
<view wx:if="{{!unbindMode}}" class="field"><input value="{{smsForm.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" /></view>
|
||||
<view wx:if="{{unbindMode}}" class="privacy-note">验证码将发送到当前绑定的{{profile.maskedPhone || '手机号'}},仅用于核验解绑操作。</view>
|
||||
<view wx:if="{{!unbindMode}}" class="privacy-note">发送前再次确认:手机号仅用于账号找回和必要订单通知,不用于营销。</view>
|
||||
<view class="code-row"><input value="{{smsForm.code}}" data-field="code" bindinput="onInput" type="number" maxlength="6" placeholder="6位验证码" /><button bindtap="sendCode" disabled="{{codeLoading || countdown > 0}}">{{countdown > 0 ? countdown + 's' : '获取验证码'}}</button></view>
|
||||
<button class="sms-bind-btn" loading="{{binding}}" bindtap="bindSmsPhone">验证并绑定</button>
|
||||
<button wx:if="{{!unbindMode}}" class="sms-bind-btn" loading="{{binding}}" bindtap="bindSmsPhone">验证并绑定</button>
|
||||
<button wx:if="{{unbindMode}}" class="sms-bind-btn" loading="{{binding}}" bindtap="unbindSmsPhone">验证并解绑</button>
|
||||
</view>
|
||||
<view wx:if="{{profile.phoneVerified == 1}}" class="sms-entry unbind-entry" bindtap="beginUnbind"><text>解绑当前手机号</text><text class="sms-arrow">›</text></view>
|
||||
</view>
|
||||
<view class="account-note">微信身份是账号登录标识,手机号是可选资料,不作为主账号 ID。</view>
|
||||
<view class="card closure-card">
|
||||
<view class="section-title">账号注销</view>
|
||||
<view wx:if="{{closureRequest && (closureRequest.status === 'PENDING' || closureRequest.status === 'PROCESSING')}}" class="privacy-note">申请处理中,{{closureRequest.processingTargetText || '以管理人员审核和门店交接进度为准'}}</view>
|
||||
<view wx:elif="{{closureRequest && closureRequest.status === 'APPROVED'}}" class="privacy-note">账号资料已完成清理。</view>
|
||||
<view wx:elif="{{closureRequest && closureRequest.status === 'REJECTED'}}" class="privacy-note">上次申请未通过:{{closureRequest.reviewerNote || '请联系管理人员'}}</view>
|
||||
<view wx:else class="privacy-note">可申请注销工作台账号。提交后可在管理人员处理前撤回。</view>
|
||||
<button wx:if="{{closureRequest && closureRequest.status === 'PENDING'}}" class="closure-btn secondary" bindtap="withdrawClosure">撤回注销申请</button>
|
||||
<button wx:elif="{{!closureRequest || closureRequest.status !== 'APPROVED'}}" class="closure-btn" bindtap="requestClosure">申请注销账号</button>
|
||||
</view>
|
||||
<view class="account-note">手机号仅用于账号安全与必要联系,不作为微信快捷登录标识。</view>
|
||||
<button class="logout-btn" bindtap="logout">退出登录</button>
|
||||
</view>
|
||||
|
||||
@@ -1,2 +1,16 @@
|
||||
.settings-page { padding-top:24rpx; }.identity-card { display:flex; align-items:center; padding:26rpx; }.identity-mark { display:flex; align-items:center; justify-content:center; width:68rpx; height:68rpx; border-radius:20rpx; background:#e5f4ed; color:#247b63; font-size:28rpx; font-weight:800; }.identity-copy { display:flex; flex:1; flex-direction:column; margin-left:18rpx; }.identity-title,.section-title { color:#17211f; font-size:28rpx; font-weight:800; }.identity-status { margin-top:6rpx; color:#71807a; font-size:21rpx; }.linked-badge,.status-tag { padding:7rpx 14rpx; border-radius:999rpx; background:#e5f2e8; color:#397055; font-size:20rpx; }
|
||||
.phone-card { margin-top:20rpx; padding:28rpx; }.phone-status { display:flex; align-items:center; justify-content:space-between; margin-top:20rpx; padding:20rpx; border-radius:14rpx; background:#f3f7f4; color:#71807a; font-size:26rpx; }.status-tag { background:#fff0db; color:#9a682e; }.status-tag.done { background:#e5f2e8; color:#397055; }.wechat-phone-btn,.sms-bind-btn { height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#247b63; color:#fff; font-size:26rpx; line-height:80rpx; }.sms-entry { display:flex; min-height:82rpx; align-items:center; margin-top:22rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.sms-arrow { margin-left:auto; color:#95a198; font-size:36rpx; transition:transform 180ms ease; }.sms-arrow.expanded { transform:rotate(90deg); }.sms-panel { padding-top:2rpx; }.field input,.code-row input { box-sizing:border-box; height:78rpx; padding:0 20rpx; border:1rpx solid #dde8e0; border-radius:12rpx; background:#f8faf8; }.code-row { display:flex; gap:12rpx; margin-top:14rpx; }.code-row input { min-width:0; flex:1; }.code-row button { width:190rpx; height:78rpx; padding:0; border-radius:12rpx; background:#e7f0ea; color:#426c57; font-size:23rpx; line-height:78rpx; }.sms-bind-btn { background:#eef4f0; color:#247b63; }.account-note { margin:24rpx 18rpx; color:#71807a; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; }
|
||||
.privacy-note {
|
||||
margin: 12rpx 0;
|
||||
color: #73817b;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.unbind-entry {
|
||||
color: #8a5555;
|
||||
}
|
||||
|
||||
.closure-card { margin-top: 20rpx; padding: 28rpx; }
|
||||
.closure-btn { height: 76rpx; margin-top: 18rpx; border-radius: 12rpx; background: #fff1ef; color: #9a5147; font-size: 24rpx; line-height: 76rpx; }
|
||||
.closure-btn.secondary { background: #eef4f0; color: #426c57; }
|
||||
|
||||
Reference in New Issue
Block a user