From e97dd8f15912a47680cb55dce385c96227838f17 Mon Sep 17 00:00:00 2001 From: R524809 Date: Thu, 18 Dec 2025 09:43:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:V2.5.4=20=E5=A2=9E=E5=8A=A0=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E6=88=91=E7=9A=84=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?Tip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../add-to-miniprogram-tip.json | 4 ++ .../add-to-miniprogram-tip.less | 44 ++++++++++++ .../add-to-miniprogram-tip.ts | 69 +++++++++++++++++++ .../add-to-miniprogram-tip.wxml | 12 ++++ miniprogram/pages/copyBook/copyBook.json | 3 +- miniprogram/pages/copyBook/copyBook.wxml | 1 + miniprogram/pages/focusIndex/focusIndex.json | 4 +- miniprogram/pages/focusIndex/focusIndex.wxml | 1 + miniprogram/pages/index/index.json | 1 + miniprogram/pages/index/index.wxml | 1 + miniprogram/pages/mathIndex/mathIndex.json | 4 +- miniprogram/pages/mathIndex/mathIndex.wxml | 1 + 12 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.json create mode 100644 miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.less create mode 100644 miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.ts create mode 100644 miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.wxml diff --git a/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.json b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.json new file mode 100644 index 0000000..59a1db6 --- /dev/null +++ b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} diff --git a/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.less b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.less new file mode 100644 index 0000000..5912a0f --- /dev/null +++ b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.less @@ -0,0 +1,44 @@ +.add-to-miniprogram-tip { + position: fixed; + z-index: 9999; + pointer-events: none; // 让点击事件穿透到内容区域 + + .tip-content { + background: rgba(0, 0, 0, 0.8); + border-radius: 12rpx; + padding: 24rpx 32rpx; + display: flex; + align-items: center; + gap: 24rpx; + max-width: 600rpx; + pointer-events: auto; // 内容区域可以点击 + box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.3); + position: relative; + } + + .tip-text { + font-size: 26rpx; + color: #ffffff; + line-height: 1.5; + flex: 1; + } + + .tip-close { + font-size: 26rpx; + color: #07c160; + font-weight: 500; + white-space: nowrap; + cursor: pointer; + } + + .tip-arrow { + position: absolute; + top: -15rpx; + width: 0; + height: 0; + border-left: 12rpx solid transparent; + border-right: 12rpx solid transparent; + border-bottom: 16rpx solid rgba(0, 0, 0, 0.8); + pointer-events: none; + } +} \ No newline at end of file diff --git a/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.ts b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.ts new file mode 100644 index 0000000..869ca2a --- /dev/null +++ b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.ts @@ -0,0 +1,69 @@ +Component({ + options: {}, + /** + * 组件的属性列表 + */ + properties: {}, + /** + * 组件的初始数据 + */ + data: { + show: false, // 是否显示Tip + top: 0, // Tip距离顶部的距离 + right: 0, // Tip距离右侧的距离 + arrowRight: 0, // 箭头距离右侧的距离 + }, + /** + * 组件生命周期 + */ + lifetimes: { + attached() { + // 检查用户是否已关闭过Tip + const tipClosed = + wx.getStorageSync('addToMiniprogramTipClosed') || false; + + // 如果用户未关闭过,则显示Tip + if (!tipClosed) { + this.setData({ + show: true, + }); + } + + // 获取胶囊按钮位置信息 + const menuButtonInfo = wx.getMenuButtonBoundingClientRect(); + const windowInfo = wx.getWindowInfo(); + console.log('windowInfo', windowInfo); + console.log('menuButtonInfo', menuButtonInfo); + // 计算Tip的位置 + // Tip应该在胶囊按钮下方,箭头向上指向胶囊按钮 + const top = 10; // 胶囊按钮下方20px + const right = windowInfo.windowWidth - menuButtonInfo.right; // 距离右侧的距离,与胶囊按钮右对齐 + + // 计算箭头位置:箭头应该指向胶囊按钮的中心 + // 胶囊按钮中心相对于Tip内容区域的右侧位置 + const capsuleCenterX = menuButtonInfo.left + 28; + const tipRightEdge = windowInfo.windowWidth - right; + const arrowRight = tipRightEdge - capsuleCenterX; // 箭头距离Tip右侧的距离 + + this.setData({ + top: top, + right: right, + arrowRight: arrowRight, + }); + }, + }, + /** + * 组件的方法列表 + */ + methods: { + /** 关闭Tip */ + onClose() { + // 保存关闭状态到本地存储 + wx.setStorageSync('addToMiniprogramTipClosed', true); + // 隐藏Tip + this.setData({ + show: false, + }); + }, + }, +}); diff --git a/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.wxml b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.wxml new file mode 100644 index 0000000..d090243 --- /dev/null +++ b/miniprogram/components/add-to-miniprogram-tip/add-to-miniprogram-tip.wxml @@ -0,0 +1,12 @@ + + + + + + 点击上方添加到我的小程序,方便下次使用! + 关闭 + + diff --git a/miniprogram/pages/copyBook/copyBook.json b/miniprogram/pages/copyBook/copyBook.json index d162fa0..c0417d9 100644 --- a/miniprogram/pages/copyBook/copyBook.json +++ b/miniprogram/pages/copyBook/copyBook.json @@ -12,6 +12,7 @@ "word-card": "/components/word-card/word-card", "word-picker": "/components/word-picker/word-picker", "empty-state": "/components/empty-state/empty-state", - "share-guide-popup": "/components/share-guide-popup/share-guide-popup" + "share-guide-popup": "/components/share-guide-popup/share-guide-popup", + "add-to-miniprogram-tip": "/components/add-to-miniprogram-tip/add-to-miniprogram-tip" } } diff --git a/miniprogram/pages/copyBook/copyBook.wxml b/miniprogram/pages/copyBook/copyBook.wxml index 2037b1c..6cb7596 100644 --- a/miniprogram/pages/copyBook/copyBook.wxml +++ b/miniprogram/pages/copyBook/copyBook.wxml @@ -95,6 +95,7 @@ show="{{showShareDialog}}" bind:onClose="onCloseShareDialog" bind:onShareSuccess="onShareSuccess" /> + diff --git a/miniprogram/pages/focusIndex/focusIndex.json b/miniprogram/pages/focusIndex/focusIndex.json index b9a043d..c6779a4 100644 --- a/miniprogram/pages/focusIndex/focusIndex.json +++ b/miniprogram/pages/focusIndex/focusIndex.json @@ -4,5 +4,7 @@ "homeButton": true, "backgroundColor": "#F6F6F6", "enablePullDownRefresh": false, - "usingComponents": {} + "usingComponents": { + "add-to-miniprogram-tip": "../../components/add-to-miniprogram-tip/add-to-miniprogram-tip" + } } diff --git a/miniprogram/pages/focusIndex/focusIndex.wxml b/miniprogram/pages/focusIndex/focusIndex.wxml index 3e20955..945996a 100644 --- a/miniprogram/pages/focusIndex/focusIndex.wxml +++ b/miniprogram/pages/focusIndex/focusIndex.wxml @@ -40,4 +40,5 @@ + diff --git a/miniprogram/pages/index/index.json b/miniprogram/pages/index/index.json index ed28c3c..db754f6 100644 --- a/miniprogram/pages/index/index.json +++ b/miniprogram/pages/index/index.json @@ -14,6 +14,7 @@ "color-picker": "../../components/color-picker/color-picker", "introduction-popup": "../../components/introduction-popup/introduction-popup", "share-guide-popup": "../../components/share-guide-popup/share-guide-popup", + "add-to-miniprogram-tip": "../../components/add-to-miniprogram-tip/add-to-miniprogram-tip", "toy-button": "../../ui/button/button", "word-picker": "../../components/word-picker/word-picker", "empty-state": "../../components/empty-state/empty-state" diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index 557399b..14ae9c6 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -142,3 +142,4 @@ show="{{showShareDialog}}" bind:onClose="onCloseShareDialog" bind:onShareSuccess="onShareSuccess" /> + diff --git a/miniprogram/pages/mathIndex/mathIndex.json b/miniprogram/pages/mathIndex/mathIndex.json index 01d1c09..60ad0a8 100644 --- a/miniprogram/pages/mathIndex/mathIndex.json +++ b/miniprogram/pages/mathIndex/mathIndex.json @@ -4,5 +4,7 @@ "homeButton": true, "backgroundColor": "#F6F6F6", "enablePullDownRefresh": false, - "usingComponents": {} + "usingComponents": { + "add-to-miniprogram-tip": "../../components/add-to-miniprogram-tip/add-to-miniprogram-tip" + } } diff --git a/miniprogram/pages/mathIndex/mathIndex.wxml b/miniprogram/pages/mathIndex/mathIndex.wxml index cae7d8a..f6516a9 100644 --- a/miniprogram/pages/mathIndex/mathIndex.wxml +++ b/miniprogram/pages/mathIndex/mathIndex.wxml @@ -40,4 +40,5 @@ +