diff --git a/JC-Salon-WeChat/pages/account-settings/index.js b/JC-Salon-WeChat/pages/account-settings/index.js index 2da5f167..7168aa80 100644 --- a/JC-Salon-WeChat/pages/account-settings/index.js +++ b/JC-Salon-WeChat/pages/account-settings/index.js @@ -10,7 +10,8 @@ Page({ smsForm: { phone: '', code: '' }, codeLoading: false, countdown: 0, - timer: null + timer: null, + smsExpanded: false }, onShow() { this.loadProfile() }, @@ -36,6 +37,10 @@ Page({ this.setData({ [`smsForm.${field}`]: value }) }, + toggleSms() { + this.setData({ smsExpanded: !this.data.smsExpanded }) + }, + async bindWechatPhone(event) { const phoneCode = event.detail && event.detail.code if (!phoneCode) { diff --git a/JC-Salon-WeChat/pages/account-settings/index.wxml b/JC-Salon-WeChat/pages/account-settings/index.wxml index c023dc4a..00554c21 100644 --- a/JC-Salon-WeChat/pages/account-settings/index.wxml +++ b/JC-Salon-WeChat/pages/account-settings/index.wxml @@ -1,6 +1,16 @@ 微微信身份已安全关联当前账号已关联 - 手机号{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}或使用短信验证码 + + 手机号 + {{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}} + + {{profile.phoneVerified == 1 ? '使用短信验证码更换' : '使用短信验证码绑定'}}› + + + + + + 手机号仅用于账号安全与必要联系,不作为微信快捷登录标识。 diff --git a/JC-Salon-WeChat/pages/account-settings/index.wxss b/JC-Salon-WeChat/pages/account-settings/index.wxss index 154bc961..4eab3ccf 100644 --- a/JC-Salon-WeChat/pages/account-settings/index.wxss +++ b/JC-Salon-WeChat/pages/account-settings/index.wxss @@ -1,2 +1,2 @@ .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:#dcebe1; color:#35634d; font-size:28rpx; font-weight:800; }.identity-copy { display:flex; flex:1; flex-direction:column; margin-left:18rpx; }.identity-title,.section-title { color:#30483c; font-size:28rpx; font-weight:800; }.identity-status { margin-top:6rpx; color:#8a9a91; 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:#f4f8f5; color:#425b4e; 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:#35634d; color:#fff; font-size:26rpx; line-height:80rpx; }.divider { display:flex; align-items:center; justify-content:center; margin:28rpx 0 18rpx; color:#9aa79f; font-size:20rpx; }.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:#35634d; }.account-note { margin:24rpx 18rpx; color:#8e9c94; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; } +.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:#f4f8f5; color:#425b4e; 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:#35634d; 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:#627269; 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:#35634d; }.account-note { margin:24rpx 18rpx; color:#8e9c94; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; } diff --git a/JC-Salon-WeChat/pages/profile-edit/index.js b/JC-Salon-WeChat/pages/profile-edit/index.js index 169a85bc..daec287b 100644 --- a/JC-Salon-WeChat/pages/profile-edit/index.js +++ b/JC-Salon-WeChat/pages/profile-edit/index.js @@ -20,10 +20,10 @@ function buildPageState(profile, fallbackShopName) { avatarText: card.avatarText, roleText: resolveRoleText(source.type), shopName: card.shopName, + phoneDisplay: source.maskedPhone || source.phone || '未绑定', form: { nickname: source.nickname || '', avatar: normalizeAvatar(source.avatar), - contactPhone: source.contactPhone || '', wechatId: source.wechatId || '', signature: source.signature || '' } @@ -39,7 +39,9 @@ Page({ avatarText: '用', roleText: '管理端', shopName: BRAND_CONFIG.defaultShopName, - form: { nickname: '', avatar: '', contactPhone: '', wechatId: '', signature: '' } + phoneDisplay: '未绑定', + wechatProfileExpanded: false, + form: { nickname: '', avatar: '', wechatId: '', signature: '' } }, onLoad() { @@ -92,18 +94,50 @@ Page({ this.setData(nextData) }, + toggleWechatProfile() { + this.setData({ wechatProfileExpanded: !this.data.wechatProfileExpanded }) + }, + + onWechatNicknameInput(event) { + const nickname = event.detail.value + this.setData({ + 'form.nickname': nickname, + avatarText: Array.from(String(nickname || '').trim())[0] || '用' + }) + }, + + goAccountSettings() { + wx.navigateTo({ url: '/pages/account-settings/index' }) + }, + + async uploadAvatar(filePath) { + if (!filePath) return + this.setData({ avatarUploading: true }) + try { + const avatar = await uploadProfileImage(filePath) + this.setData({ 'form.avatar': avatar }) + } finally { + this.setData({ avatarUploading: false }) + } + }, + async chooseAvatar() { if (this.data.avatarUploading || this.data.saving) return try { const filePath = await chooseImageFilePath() if (!filePath) return - this.setData({ avatarUploading: true }) - const avatar = await uploadProfileImage(filePath) - this.setData({ 'form.avatar': avatar }) + await this.uploadAvatar(filePath) } catch (error) { wx.showToast({ title: error.message || '头像上传失败', icon: 'none' }) - } finally { - this.setData({ avatarUploading: false }) + } + }, + + async chooseWechatAvatar(event) { + if (this.data.avatarUploading || this.data.saving) return + try { + await this.uploadAvatar(event.detail && event.detail.avatarUrl) + } catch (error) { + wx.showToast({ title: error.message || '微信头像获取失败', icon: 'none' }) } }, @@ -111,21 +145,15 @@ Page({ if (this.data.saving || this.data.avatarUploading) return const form = this.data.form const nickname = String(form.nickname || '').trim() - const contactPhone = String(form.contactPhone || '').trim() if (!nickname) { wx.showToast({ title: '请填写昵称', icon: 'none' }) return } - if (contactPhone && !/^1[3-9]\d{9}$/.test(contactPhone)) { - wx.showToast({ title: '请输入正确联系电话', icon: 'none' }) - return - } this.setData({ saving: true }) try { await userApi.updateInfo({ nickname, avatar: form.avatar || '', - contactPhone, wechatId: String(form.wechatId || '').trim(), signature: String(form.signature || '').trim() }) diff --git a/JC-Salon-WeChat/pages/profile-edit/index.wxml b/JC-Salon-WeChat/pages/profile-edit/index.wxml index a198111f..774ebb12 100644 --- a/JC-Salon-WeChat/pages/profile-edit/index.wxml +++ b/JC-Salon-WeChat/pages/profile-edit/index.wxml @@ -13,10 +13,26 @@ + + + 微 + 使用微信资料 + › + + + + + + + 基本资料 昵称 - 联系电话 + 手机号{{phoneDisplay}}› 微信号 个性签名