添加测试消息订阅的功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
export default defineAppConfig({
|
||||
pages: [
|
||||
// "test_pages/index", //测试页
|
||||
"home_pages/index", //中转页
|
||||
"main_pages/index", // 主容器页面(合并三个tab)
|
||||
"login_pages/index/index",
|
||||
@@ -59,7 +60,7 @@ export default defineAppConfig({
|
||||
"favorites/index", // 收藏页
|
||||
"ntrp-evaluate/index", // NTRP评估页
|
||||
],
|
||||
}
|
||||
},
|
||||
],
|
||||
|
||||
"preloadRule": {
|
||||
|
||||
28
src/test_pages/1.md
Normal file
28
src/test_pages/1.md
Normal file
@@ -0,0 +1,28 @@
|
||||
模板ID
|
||||
TRw1earo9xJ2cyyMBTN4qIOdM6YDLw6VBYm89uZ8-uk
|
||||
模板编号
|
||||
512
|
||||
标题
|
||||
签到提醒
|
||||
类目
|
||||
办公
|
||||
操作人
|
||||
m****Om 2025-07-11 添加
|
||||
详细内容
|
||||
活动名称
|
||||
{{thing1.DATA}}
|
||||
|
||||
日期
|
||||
{{date4.DATA}}
|
||||
|
||||
时间
|
||||
{{time5.DATA}}
|
||||
|
||||
签到地点
|
||||
{{thing14.DATA}}
|
||||
|
||||
温馨提示
|
||||
{{thing16.DATA}}
|
||||
|
||||
场景说明
|
||||
球局演示
|
||||
6
src/test_pages/index.config.ts
Normal file
6
src/test_pages/index.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '测试页面',
|
||||
enablePullDownRefresh: false,
|
||||
backgroundTextStyle: 'dark',
|
||||
});
|
||||
|
||||
23
src/test_pages/index.scss
Normal file
23
src/test_pages/index.scss
Normal 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
53
src/test_pages/index.tsx
Normal 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;
|
||||
|
||||
Reference in New Issue
Block a user