此项目为微信对话开放平台开源项目,用于微信开发者进行插件快速接入、 组件复写功能开发时的参考Demo。微信开发者可以参考项目中的代码来开发应用,也可以直接使用项目中的代码到自己的App中。
开发者可以自由使用并传播本代码,但需要保留原作者信息。
插件申请使用地址:
https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx8c631f7e9f2465e1
微信对话开放平台小程序插件复写示例提供了对插件的开放能力, 可以随意定制化。
请在
project.config.json
中配置自己小程序的appid或测试ID 此示例代码仅做为接入微信对话开放平台小程序插件的示例供开发者参考
由于区分原始插件和复写插件, 所以当前页面将插件配置项在 rewritePluginPage.js
和 originalPluginPage.js
中初始化
在 rewritePluginPage
中初始化
var plugin = requirePlugin("myPlugin");
plugin.init({
appid: "VEgbxLa9kYqzGOzstdeSF3xDbkS9zK",
// textToSpeech: true,
// guideList: [],
welcome: '请问需要什么帮助',
// background: "#eee",
guideCardHeight: 50,
operateCardHeight: 120,
// history: true,
// historySize: 60,
navHeight: 88, // 自定义导航栏高度
success: () => {
this.setData({
flag: true
})
},
fail: error => {}
});
在 originalPluginPage
中初始化
var plugin = requirePlugin("myPlugin");
plugin.init({
appid: "VEgbxLa9kYqzGOzstdeSF3xDbkS9zK",
// textToSpeech: true,
// guideList: [],
welcome: '请问需要什么帮助',
// background: "#eee",
// guideCardHeight: 40,
// operateCardHeight: 145,
// history: true,
// historySize: 60,
navHeight: 88, // 自定义导航栏高度
success: () => {
this.setData({
flag: true
})
},
fail: error => {}
});
如果在 app.js
中初始化, 需要将 rewritePluginPage.wxml
中 wx:if="{{flag}}"
删除
var plugin = requirePlugin("myPlugin");
plugin.init({
appid: "VEgbxLa9kYqzGOzstdeSF3xDbkS9zK",
// textToSpeech: true,
// guideList: [],
welcome: '请问需要什么帮助',
// background: "#eee",
guideCardHeight: 50,
operateCardHeight: 120,
// history: true,
// historySize: 60,
navHeight: 88, // 自定义导航栏高度
success: () => {
},
fail: error => {}
});
在 rewritePluginPage.json
中引入复写组件
{
"usingComponents": {
"customTextMessage": "../../components/customTextMessage/customTextMessage"
}
}
{
"usingComponents": {
"customWeatherMessage": "../../components/customWeatherMessage/customWeatherMessage"
}
}
{
"usingComponents": {
"customImageMessage": "../../components/customImageMessage/customImageMessage"
}
}
{
"usingComponents": {
"customGuideCard": "../../components/customGuideCard/customGuideCard"
}
}
{
"usingComponents": {
"customOperateCard": "../../components/customOperateCard/customOperateCard"
}
}
{
"usingComponents": {
"customQueryMessage": "../../components/customQueryMessage/customQueryMessage"
}
}
{
"usingComponents": {
"customMusicMessage": "../../components/customMusicMessage/customMusicMessage"
}
}
{
"usingComponents": {
"customNewsMessage": "../../components/customNewsMessage/customNewsMessage"
}
}
{
"usingComponents": {
"customUnsupportedMessage": "../../components/customUnsupportedMessage/customUnsupportedMessage"
}
}
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.