From 1120f9d5a91d9b32a8b4522decf59680154cda22 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Wed, 21 Oct 2026 09:47:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=8F=E8=AE=AE=E6=9C=AA?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JC-Salon-WeChat/pages/login/index.js | 25 +- JC-Salon-WeChat/pages/login/index.test.js | 68 ++++ JC-Salon-WeChat/pages/login/index.wxml | 49 ++- JC-Salon-WeChat/pages/login/index.wxss | 392 +++++++++++++++++++++- 4 files changed, 518 insertions(+), 16 deletions(-) create mode 100644 JC-Salon-WeChat/pages/login/index.test.js diff --git a/JC-Salon-WeChat/pages/login/index.js b/JC-Salon-WeChat/pages/login/index.js index b94bb08a..4d51e47e 100644 --- a/JC-Salon-WeChat/pages/login/index.js +++ b/JC-Salon-WeChat/pages/login/index.js @@ -23,6 +23,7 @@ Page({ loading: false, rememberMe: false, agreementAccepted: false, + agreementPromptVisible: false, agreements: [], agreementLoading: false, agreementError: '', @@ -89,7 +90,12 @@ Page({ }, closeAgreementModal() { this.setData({ agreementModalVisible: false, selectedAgreement: {} }) }, - acceptAgreementModal() { this.setData({ agreementModalVisible: false, selectedAgreement: {}, agreementAccepted: true }) }, + acceptAgreementModal() { + const continueLogin = this.data.agreementPromptVisible + this.setData({ agreementModalVisible: false, selectedAgreement: {}, agreementAccepted: true, agreementPromptVisible: continueLogin ? false : this.data.agreementPromptVisible }, () => { + if (continueLogin) this.quickLogin() + }) + }, stopTap() {}, agreementPayload() { @@ -103,12 +109,7 @@ Page({ async ensureCanLogin() { await this.loadAgreements() if (!this.data.agreementAccepted) { - await new Promise(resolve => wx.showModal({ - title: '请先勾选协议', - content: '阅读并勾选用户协议和隐私政策后,才能使用快捷登录。', - showCancel: false, - complete: resolve - })) + this.setData({ agreementPromptVisible: true }) return false } const versions = this.agreementPayload().agreementVersions @@ -119,6 +120,16 @@ Page({ return true }, + acceptAgreementPrompt() { + this.setData({ agreementAccepted: true, agreementPromptVisible: false }, () => this.quickLogin()) + }, + + declineAgreementPrompt() { + wx.exitMiniProgram({ + fail: () => wx.showToast({ title: '请同意协议后使用', icon: 'none' }) + }) + }, + async chooseRememberMode() { if (this.data.rememberMe) return true return new Promise(resolve => wx.showModal({ diff --git a/JC-Salon-WeChat/pages/login/index.test.js b/JC-Salon-WeChat/pages/login/index.test.js new file mode 100644 index 00000000..9525659b --- /dev/null +++ b/JC-Salon-WeChat/pages/login/index.test.js @@ -0,0 +1,68 @@ +const assert = require('assert') +const fs = require('fs') +const path = require('path') + +let definition +let exitOptions +let toastOptions + +global.Page = value => { definition = value } +global.wx = { + exitMiniProgram(options) { + exitOptions = options + }, + showToast(options) { + toastOptions = options + } +} + +require('./index') + +function createPage() { + return { + ...definition, + data: { + ...definition.data, + agreements: [ + { agreementType: 'USER_TERMS', version: '1' }, + { agreementType: 'PRIVACY_POLICY', version: '1' } + ] + }, + setData(values, callback) { + Object.assign(this.data, values) + if (callback) callback() + } + } +} + +async function run() { + const page = createPage() + page.loadAgreements = async () => {} + + assert.strictEqual(await page.ensureCanLogin(), false) + assert.strictEqual(page.data.agreementPromptVisible, true) + + let loginStarted = false + page.quickLogin = () => { loginStarted = true } + page.acceptAgreementPrompt() + assert.strictEqual(page.data.agreementAccepted, true) + assert.strictEqual(page.data.agreementPromptVisible, false) + assert.strictEqual(loginStarted, true) + + page.declineAgreementPrompt() + assert.ok(exitOptions) + exitOptions.fail() + assert.strictEqual(toastOptions.title, '请同意协议后使用') + + const template = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8') + assert.match(template, /用户协议与隐私政策提示/) + assert.match(template, /不同意并退出/) + assert.match(template, /同意并继续/) + assert.match(template, /data-type="USER_TERMS" catchtap="openAgreement"/) + assert.match(template, /data-type="PRIVACY_POLICY" catchtap="openAgreement"/) +} + +run().catch(error => { + console.error(error) + process.exitCode = 1 +}) diff --git a/JC-Salon-WeChat/pages/login/index.wxml b/JC-Salon-WeChat/pages/login/index.wxml index 23e29adc..0c41e1b2 100644 --- a/JC-Salon-WeChat/pages/login/index.wxml +++ b/JC-Salon-WeChat/pages/login/index.wxml @@ -1,16 +1,53 @@ - {{appName}}Salon 门店工作台 + + {{appName}}Salon 门店工作台 + {{loginState.status === 'PENDING_REVIEW' ? '申请审核中' : loginState.status === 'REJECTED' ? '申请需要修改' : loginState.status === 'DISABLED' ? '账号暂不可用' : loginState.status === 'ERROR' ? '连接失败' : '账号状态'}}{{loginState.registrationRejectReason || loginState.message}} - - {{rememberMe ? '✓' : ''}}记住登录,后续可快速登录 + + + {{rememberMe ? '✓' : ''}}记住登录,后续可快速登录 + + + + {{agreementAccepted ? '✓' : ''}} + 登录即表示已阅读并同意《用户协议》和《隐私政策》 + - {{agreementAccepted ? '✓' : ''}}登录即表示已阅读并同意《用户协议》和《隐私政策》 {{agreementError}},点击重试 - {{selectedAgreement.title || '隐私保护提示'}}版本 {{selectedAgreement.version || '-'}}{{selectedAgreement.content || '暂无协议内容'}} - 选择本次登录门店店{{item.name}}›正在进入门店… + + + 用户协议与隐私政策提示 + + + 您需要完全同意《用户协议》和《隐私政策》后,才能使用 Salon 小程序服务。如您不同意,我们无法继续为您提供服务。 + + + 您可阅读《用户协议》和《隐私政策》了解详细内容。如您同意,请点击“同意并继续”开始使用我们的服务。 + + + + + + + + + + + {{selectedAgreement.title || '隐私保护提示'}}版本 {{selectedAgreement.version || '-'}} + {{selectedAgreement.content || '暂无协议内容'}} + + + + + 选择本次登录门店 + + 店{{item.name}}› + 正在进入门店… + + diff --git a/JC-Salon-WeChat/pages/login/index.wxss b/JC-Salon-WeChat/pages/login/index.wxss index ae82050d..3e72c788 100644 --- a/JC-Salon-WeChat/pages/login/index.wxss +++ b/JC-Salon-WeChat/pages/login/index.wxss @@ -1,3 +1,389 @@ -.login-page { box-sizing:border-box; display:flex; min-height:calc(100vh - 88rpx); flex-direction:column; padding:0 56rpx 38rpx; background:#fff; }.login-main { display:flex; flex:1; flex-direction:column; }.brand-area { display:flex; flex-direction:column; align-items:center; padding-top:190rpx; }.login-logo { width:196rpx; height:196rpx; border-radius:46rpx; }.brand-name { margin-top:26rpx; color:#17211f; font-size:40rpx; font-weight:800; letter-spacing:3rpx; }.brand-sub { margin-top:10rpx; color:#9a9f9c; font-size:22rpx; letter-spacing:4rpx; }.action-area { margin-top:118rpx; }.quick-btn { display:flex; align-items:center; justify-content:center; height:92rpx; border-radius:999rpx; background:#247b63; color:#fff; font-size:30rpx; font-weight:500; line-height:92rpx; box-shadow:0 10rpx 20rpx rgba(47,143,120,.16); }.quick-btn::after { border:0; }.wechat-symbol { display:flex; align-items:center; justify-content:center; width:38rpx; height:38rpx; margin-right:14rpx; border:2rpx solid rgba(255,255,255,.9); border-radius:50%; font-size:18rpx; font-weight:800; line-height:38rpx; }.remember-row { display:flex; align-items:center; justify-content:center; margin-top:30rpx; color:#737a76; font-size:23rpx; }.check { display:flex; align-items:center; justify-content:center; width:32rpx; height:32rpx; margin-right:12rpx; border:2rpx solid #b7bdb9; border-radius:50%; color:#fff; font-size:19rpx; }.check.small { width:28rpx; height:28rpx; flex:none; margin-right:8rpx; border-radius:7rpx; }.check.checked { border-color:#247b63; background:#247b63; }.state-line { display:flex; flex-direction:column; align-items:center; margin-top:34rpx; }.state-title { color:#765b32; font-size:24rpx; font-weight:700; }.state-message { margin-top:7rpx; color:#9a8260; font-size:20rpx; text-align:center; }.agreement-footer { padding-top:50rpx; }.agreement-line { display:flex; align-items:flex-start; justify-content:center; }.agreement-copy { color:#a0a4a1; font-size:20rpx; line-height:1.55; text-align:center; }.agreement-link { color:#6b7570; }.agreement-error { margin-top:10rpx; color:#ad6954; font-size:19rpx; text-align:center; } -.modal-mask { position:fixed; z-index:20; inset:0; display:flex; align-items:flex-end; background:rgba(0,0,0,.56); }.modal-mask.center { align-items:center; justify-content:center; padding:36rpx; }.agreement-sheet { box-sizing:border-box; width:100%; max-height:74vh; padding:34rpx 42rpx 48rpx; border-radius:28rpx 28rpx 0 0; background:#fff; }.sheet-handle { width:72rpx; height:8rpx; margin:0 auto 34rpx; border-radius:999rpx; background:#e4e5e4; }.modal-title { display:block; color:#17211f; font-size:34rpx; font-weight:800; }.modal-version { display:block; margin-top:10rpx; color:#a1a5a2; font-size:21rpx; }.modal-body { height:38vh; margin-top:24rpx; color:#707773; font-size:25rpx; line-height:1.75; white-space:pre-wrap; }.sheet-actions { display:flex; gap:24rpx; margin-top:30rpx; }.sheet-btn { height:88rpx; flex:1; border-radius:14rpx; font-size:29rpx; line-height:88rpx; }.sheet-btn.secondary { background:#f3f3f3; color:#17211f; }.sheet-btn.primary { background:#247b63; color:#fff; }.shop-dialog { box-sizing:border-box; width:100%; padding:34rpx; border-radius:24rpx; background:#fff; }.shop-option { display:flex; align-items:center; margin-top:20rpx; padding:22rpx; border-radius:16rpx; background:#f3f7f4; color:#17211f; font-size:26rpx; }.shop-icon { display:flex; align-items:center; justify-content:center; width:52rpx; height:52rpx; margin-right:16rpx; border-radius:14rpx; background:#e5f4ed; color:#247b63; font-weight:800; }.shop-arrow { margin-left:auto; color:#71807a; font-size:34rpx; }.switching { display:block; margin-top:20rpx; color:#71807a; text-align:center; } -@media (max-height:700px) { .brand-area { padding-top:90rpx; }.action-area { margin-top:70rpx; }.login-logo { width:160rpx; height:160rpx; } } +.login-page { + box-sizing: border-box; + display: flex; + min-height: calc(100vh - 88rpx); + flex-direction: column; + padding: 0 56rpx 38rpx; + background: #fff; +} + +.login-main { + display: flex; + flex: 1; + flex-direction: column; +} + +.brand-area { + display: flex; + flex-direction: column; + align-items: center; + padding-top: 190rpx; +} + +.login-logo { + width: 196rpx; + height: 196rpx; + border-radius: 46rpx; +} + +.brand-name { + margin-top: 26rpx; + color: #17211f; + font-size: 40rpx; + font-weight: 800; + letter-spacing: 3rpx; +} + +.brand-sub { + margin-top: 10rpx; + color: #9a9f9c; + font-size: 22rpx; + letter-spacing: 4rpx; +} + +.action-area { + margin-top: 118rpx; +} + +.quick-btn { + display: flex; + align-items: center; + justify-content: center; + height: 92rpx; + border-radius: 999rpx; + background: #247b63; + color: #fff; + font-size: 30rpx; + font-weight: 500; + line-height: 92rpx; + box-shadow: 0 10rpx 20rpx rgba(47, 143, 120, .16); +} + +.quick-btn::after { + border: 0; +} + +.wechat-symbol { + display: flex; + align-items: center; + justify-content: center; + width: 38rpx; + height: 38rpx; + margin-right: 14rpx; + border: 2rpx solid rgba(255, 255, 255, .9); + border-radius: 50%; + font-size: 18rpx; + font-weight: 800; + line-height: 38rpx; +} + +.remember-row { + display: flex; + align-items: center; + justify-content: center; + margin-top: 30rpx; + color: #737a76; + font-size: 23rpx; +} + +.check { + display: flex; + align-items: center; + justify-content: center; + width: 32rpx; + height: 32rpx; + margin-right: 12rpx; + border: 2rpx solid #b7bdb9; + border-radius: 50%; + color: #fff; + font-size: 19rpx; +} + +.check.small { + width: 28rpx; + height: 28rpx; + flex: none; + margin-right: 8rpx; + border-radius: 7rpx; +} + +.check.checked { + border-color: #247b63; + background: #247b63; +} + +.state-line { + display: flex; + flex-direction: column; + align-items: center; + margin-top: 34rpx; +} + +.state-title { + color: #765b32; + font-size: 24rpx; + font-weight: 700; +} + +.state-message { + margin-top: 7rpx; + color: #9a8260; + font-size: 20rpx; + text-align: center; +} + +.agreement-footer { + padding-top: 50rpx; +} + +.agreement-line { + display: flex; + align-items: flex-start; + justify-content: center; + margin-top: 1rem; +} + +.agreement-copy { + color: #a0a4a1; + font-size: 20rpx; + line-height: 1.55; + text-align: center; +} + +.agreement-link { + color: #6b7570; +} + +.agreement-error { + margin-top: 10rpx; + color: #ad6954; + font-size: 19rpx; + text-align: center; +} + +.agreement-prompt-mask { + position: fixed; + z-index: 30; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + padding: 28rpx; + background: rgba(0, 0, 0, .56); +} + +.agreement-prompt { + box-sizing: border-box; + width: 100%; + overflow: hidden; + border-radius: 30rpx; + background: #fff; +} + +.agreement-prompt-title { + display: block; + padding: 48rpx 28rpx 0; + color: #171a18; + font-size: 36rpx; + font-weight: 700; + line-height: 1.45; + text-align: center; +} + +.agreement-prompt-body { + padding: 56rpx 38rpx 48rpx; + color: #8a8e8b; + font-size: 29rpx; + line-height: 1.72; + text-align: center; +} + +.agreement-prompt-paragraph + .agreement-prompt-paragraph { + margin-top: 12rpx; +} + +.agreement-prompt-link { + color: #247b63; +} + +.agreement-prompt-actions { + display: flex; + align-items: center; + height: 112rpx; + border-top: 1rpx solid #e5e5e5; +} + +.agreement-prompt-button { + box-sizing: border-box; + height: 100%; + flex: 1; + margin: 0; + padding: 0 12rpx; + border: 0; + border-radius: 0; + background: #fff; + font-size: 30rpx; + line-height: 112rpx; +} + +.agreement-prompt-button::after { + border: 0; +} + +.agreement-prompt-decline { + color: #888d8a; +} + +.agreement-prompt-accept { + color: #247b63; +} + +.agreement-prompt-divider { + width: 1rpx; + height: 100%; + background: #e5e5e5; +} + +.modal-mask { + position: fixed; + z-index: 20; + inset: 0; + display: flex; + align-items: flex-end; + background: rgba(0, 0, 0, .56); +} + +.agreement-document-modal { + z-index: 40; +} + +.modal-mask.center { + align-items: center; + justify-content: center; + padding: 36rpx; +} + +.agreement-sheet { + box-sizing: border-box; + width: 100%; + max-height: 74vh; + padding: 34rpx 42rpx 48rpx; + border-radius: 28rpx 28rpx 0 0; + background: #fff; +} + +.sheet-handle { + width: 72rpx; + height: 8rpx; + margin: 0 auto 34rpx; + border-radius: 999rpx; + background: #e4e5e4; +} + +.modal-title { + display: block; + color: #17211f; + font-size: 34rpx; + font-weight: 800; +} + +.modal-version { + display: block; + margin-top: 10rpx; + color: #a1a5a2; + font-size: 21rpx; +} + +.modal-body { + height: 38vh; + margin-top: 24rpx; + color: #707773; + font-size: 25rpx; + line-height: 1.75; + white-space: pre-wrap; +} + +.sheet-actions { + display: flex; + gap: 24rpx; + margin-top: 30rpx; +} + +.sheet-btn { + height: 88rpx; + flex: 1; + border-radius: 14rpx; + font-size: 29rpx; + line-height: 88rpx; +} + +.sheet-btn.secondary { + background: #f3f3f3; + color: #17211f; +} + +.sheet-btn.primary { + background: #247b63; + color: #fff; +} + +.shop-dialog { + box-sizing: border-box; + width: 100%; + padding: 34rpx; + border-radius: 24rpx; + background: #fff; +} + +.shop-option { + display: flex; + align-items: center; + margin-top: 20rpx; + padding: 22rpx; + border-radius: 16rpx; + background: #f3f7f4; + color: #17211f; + font-size: 26rpx; +} + +.shop-icon { + display: flex; + align-items: center; + justify-content: center; + width: 52rpx; + height: 52rpx; + margin-right: 16rpx; + border-radius: 14rpx; + background: #e5f4ed; + color: #247b63; + font-weight: 800; +} + +.shop-arrow { + margin-left: auto; + color: #71807a; + font-size: 34rpx; +} + +.switching { + display: block; + margin-top: 20rpx; + color: #71807a; + text-align: center; +} + +@media (max-height:700px) { + .brand-area { + padding-top: 90rpx; + } + + .action-area { + margin-top: 70rpx; + } + + .login-logo { + width: 160rpx; + height: 160rpx; + } +}