添加测试消息订阅的功能

This commit is contained in:
张成
2025-11-25 14:05:58 +08:00
parent 515336c666
commit 6751ec3c00
5 changed files with 112 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
export default defineAppConfig({ export default defineAppConfig({
pages: [ pages: [
// "test_pages/index", //测试页
"home_pages/index", //中转页 "home_pages/index", //中转页
"main_pages/index", // 主容器页面合并三个tab "main_pages/index", // 主容器页面合并三个tab
"login_pages/index/index", "login_pages/index/index",
@@ -59,7 +60,7 @@ export default defineAppConfig({
"favorites/index", // 收藏页 "favorites/index", // 收藏页
"ntrp-evaluate/index", // NTRP评估页 "ntrp-evaluate/index", // NTRP评估页
], ],
} },
], ],
"preloadRule": { "preloadRule": {

28
src/test_pages/1.md Normal file
View File

@@ -0,0 +1,28 @@
模板ID
TRw1earo9xJ2cyyMBTN4qIOdM6YDLw6VBYm89uZ8-uk
模板编号
512
标题
签到提醒
类目
办公
操作人
m****Om 2025-07-11 添加
详细内容
活动名称
{{thing1.DATA}}
日期
{{date4.DATA}}
时间
{{time5.DATA}}
签到地点
{{thing14.DATA}}
温馨提示
{{thing16.DATA}}
场景说明
球局演示

View File

@@ -0,0 +1,6 @@
export default definePageConfig({
navigationBarTitleText: '测试页面',
enablePullDownRefresh: false,
backgroundTextStyle: 'dark',
});

23
src/test_pages/index.scss Normal file
View File

@@ -0,0 +1,23 @@
.test_page {
width: 100%;
min-height: 100vh;
background-color: #fafafa;
padding: 40rpx;
&__content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 200rpx;
}
&__button {
width: 400rpx;
height: 88rpx;
line-height: 88rpx;
border-radius: 44rpx;
font-size: 32rpx;
}
}

53
src/test_pages/index.tsx Normal file
View File

@@ -0,0 +1,53 @@
import React from 'react';
import { View, Button } from '@tarojs/components';
import Taro from '@tarojs/taro';
import './index.scss';
const TestPage: React.FC = () => {
// 请求订阅消息
const handle_request_subscribe_message = () => {
Taro.requestSubscribeMessage({
tmplIds: ['TRw1earo9xJ2cyyMBTN4qIOdM6YDLw6VBYm89uZ8-uk'],
success(res) {
console.log('授权结果:', res);
if (res['TRw1earo9xJ2cyyMBTN4qIOdM6YDLw6VBYm89uZ8-uk'] === 'accept') {
console.log('用户允许订阅');
Taro.showToast({
title: '订阅成功',
icon: 'success',
});
} else if (res['TRw1earo9xJ2cyyMBTN4qIOdM6YDLw6VBYm89uZ8-uk'] === 'reject') {
console.log('用户拒绝订阅');
Taro.showToast({
title: '已取消订阅',
icon: 'none',
});
}
},
fail(err) {
console.error('订阅失败:', err);
Taro.showToast({
title: '订阅失败',
icon: 'error',
});
},
});
};
return (
<View className="test_page">
<View className="test_page__content">
<Button
className="test_page__button"
type="primary"
onClick={handle_request_subscribe_message}
>
</Button>
</View>
</View>
);
};
export default TestPage;