[
{
"name": "select_runtype",
"type": "select",
"label": "运行模式",
"options": {
"单商品购买": "单商品购买",
"循环购买": "循环购买"
},
"validation": "required",
"help": "脚本点击聊天窗口最新的卡片,单商品:执行该商品购买完成后结束运行,循环购买:购买完成后继续点击最新卡片进行购买。"
},
{
"name": "text_word",
"type": "text",
"label": "关键词",
"validation": "required",
"help": "vx群名称或好友名称包含的唯一关键词,防止群消息混淆。"
},
{
"name": "text_password",
"type": "text",
"label": "支付密码",
"validation": "required",
"help": "支付密码,不需要脚本输入密码填0即可"
},
{
"name": "select_getshopfun",
"type": "select",
"label": "购买方式",
"options": {
"到店取": "到店取",
"送到家": "送到家",
"在线抽": "在线抽"
},
"validation": "required",
"help": "选择收货方式"
},
{
"name": "select_type",
"type": "select",
"label": "规格选择",
"options": {
"单个盲盒随机发货": "单个盲盒随机发货",
"整盒含个盲盒": "整盒含个盲盒"
},
"validation": "required",
"help": "整合抽取*代表多个"
},
{
"name": "text_number",
"type": "text",
"label": "数量",
"validation": "required",
"help": "购买数量"
},
{
"name": "text_timeoutcount",
"type": "text",
"label": "最大刷新次数",
"validation": "required",
"help": "刷新N次后仍然无法正常获取商品,结束或执行下一个商品,为0则无线刷取"
},
{
"name": "text_refush_timeout",
"type": "text",
"label": "单次刷新延时",
"validation": "required",
"help": "刷新后间隔多少秒执行下一刷新动作,单位为ms(1s=1000ms)"
}
] 用悬浮窗模式帮我把这个参数模式的数据在UI界面显示出来
继续补充,我需要完整的输入选择内容显示
继续推展,还有一点 <text>购买方式:</text>
<spinner id="select_getshopfun" entries={["到店取", "送到家", "在线抽"]} />
<text>规格选择:</text>
<spinner id="select_type" entries={["单个盲盒随机发货", "整盒含*个盲盒"]} />
<text>运行模式:</text>
<spinner id="select_runtype" entries={["单商品购买", "循环购买"]} /> ,还有这3个是下拉选择框内容,帮我完善
回答
在 Hamibot 中,你可以使用 dialogs.build
来创建一个悬浮窗界面,并将上述参数配置以表单的形式展示出来。以下是一个完整的示例脚本代码,它会弹出一个对话框,显示所有这些参数的设置:
// 文档地址 https://docs.hamibot.com/
var dialog = dialogs.build({
title: "参数设置",
positive: "确定",
negative: "取消",
items: [
"运行模式: 单商品购买 / 循环购买",
"关键词: vx群名称或好友名称包含的唯一关键词",
"支付密码: 输入支付密码(填0则不输入)",
"购买方式: 到店取 / 送到家 / 在线抽",
"规格选择: 单个盲盒随机发货 / 整盒含*个盲盒",
"数量: 购买数量",
"最大刷新次数: 刷新N次后结束或执行下一个",
"单次刷新延时: 刷新后等待时间(单位ms)"
],
itemsSelectMode: "select"
}).on("item_select", function (index, item, dialog) {
toast("你选择了第" + (index + 1) + "项:" + item);
}).show();
说明:
- items:将每个参数作为字符串数组的一项传入,用于展示。
- itemsSelectMode: "select":允许用户点击某一项进行交互。
- on("item_select"):当用户点击某一项时,会触发该事件并提示选中的内容。
如果你希望进一步编辑这些值,可以结合输入框 (dialogs.prompt
) 或自定义 UI 进行扩展。如果需要,我可以继续提供进阶版本。
补充回答 1
下面是一个完整的示例脚本,它使用 dialogs.build
构建一个悬浮窗 UI 界面,包含所有输入控件(下拉选择框、文本输入框等),并显示默认值和说明。
// 文档地址 https://docs.hamibot.com/
var config = {
select_runtype: "单商品购买",
text_word: "",
text_password: "",
select_getshopfun: "到店取",
select_type: "单个盲盒随机发货",
text_number: "1",
text_timeoutcount: "0",
text_refush_timeout: "3000"
};
var dialog = dialogs.build({
title: "参数设置",
wrapInScrollView: false,
customView: <vertical padding="16">
<text>运行模式:</text>
<spinner id="select_runtype" entries={["单商品购买", "循环购买"]} />
<text>关键词:</text>
<input id="text_word" hint="vx群名称或好友名称包含的唯一关键词" />
<text>支付密码:</text>
<input id="text_password" inputType="numberPassword" hint="支付密码,不需要脚本输入密码填0即可" />
<text>购买方式:</text>
<spinner id="select_getshopfun" entries={["到店取", "送到家", "在线抽"]} />
<text>规格选择:</text>
<spinner id="select_type" entries={["单个盲盒随机发货", "整盒含*个盲盒"]} />
<text>数量:</text>
<input id="text_number" inputType="number" hint="购买数量" />
<text>最大刷新次数:</text>
<input id="text_timeoutcount" inputType="number" hint="刷新N次后结束或执行下一个,为0则无限刷取" />
<text>单次刷新延时:</text>
<input id="text_refush_timeout" inputType="number" hint="刷新后等待时间(单位ms)" />
</vertical>
}).on("positive_click", function (dialog) {
// 获取用户输入的值
config.select_runtype = dialog.customView.select_runtype.getSelectedItem();
config.text_word = dialog.customView.text_word.getText().toString();
config.text_password = dialog.customView.text_password.getText().toString();
config.select_getshopfun = dialog.customView.select_getshopfun.getSelectedItem();
config.select_type = dialog.customView.select_type.getSelectedItem();
config.text_number = dialog.customView.text_number.getText().toString();
config.text_timeoutcount = dialog.customView.text_timeoutcount.getText().toString();
config.text_refush_timeout = dialog.customView.text_refush_timeout.getText().toString();
// 打印配置信息
log("运行模式:" + config.select_runtype);
log("关键词:" + config.text_word);
log("支付密码:" + config.text_password);
log("购买方式:" + config.select_getshopfun);
log("规格选择:" + config.select_type);
log("数量:" + config.text_number);
log("最大刷新次数:" + config.text_timeoutcount);
log("单次刷新延时:" + config.text_refush_timeout);
toast("配置已保存!");
}).show();
功能说明:
- 使用了
dialogs.build
创建一个带有自定义布局的对话框悬浮窗。 - 包含
spinner
(下拉选择框)、input
(输入框)等控件。 - 用户填写完成后点击【确定】按钮,会获取并打印所有字段的值。
- 你可以将
config
对象用于后续业务逻辑中的参数传递。
如果你需要进一步封装成函数或者持久化存储这些配置,请告诉我,我可以继续扩展。
补充回答 2
以下是你要求的完整悬浮窗 UI 界面脚本,包含全部字段,并按照你指定的内容完善了三个下拉选择框(运行模式、购买方式、规格选择)。
// 文档地址 https://docs.hamibot.com/
var config = {
select_runtype: "单商品购买",
text_word: "",
text_password: "",
select_getshopfun: "到店取",
select_type: "单个盲盒随机发货",
text_number: "1",
text_timeoutcount: "0",
text_refush_timeout: "3000"
};
var dialog = dialogs.build({
title: "参数设置界面",
wrapInScrollView: false,
customView: <vertical padding="16">
<!-- 运行模式 -->
<text>运行模式:</text>
<spinner id="select_runtype" entries={["单商品购买", "循环购买"]} />
<!-- 关键词 -->
<text>关键词:</text>
<input id="text_word" hint="vx群名称或好友名称包含的唯一关键词" />
<!-- 支付密码 -->
<text>支付密码:</text>
<input id="text_password" inputType="numberPassword" hint="支付密码,不需要脚本输入密码填0即可" />
<!-- 购买方式 -->
<text>购买方式:</text>
<spinner id="select_getshopfun" entries={["到店取", "送到家", "在线抽"]} />
<!-- 规格选择 -->
<text>规格选择:</text>
<spinner id="select_type" entries={["单个盲盒随机发货", "整盒含*个盲盒"]} />
<!-- 数量 -->
<text>数量:</text>
<input id="text_number" inputType="number" hint="购买数量" />
<!-- 最大刷新次数 -->
<text>最大刷新次数:</text>
<input id="text_timeoutcount" inputType="number" hint="刷新N次后结束或执行下一个,为0则无限刷取" />
<!-- 单次刷新延时 -->
<text>单次刷新延时:</text>
<input id="text_refush_timeout" inputType="number" hint="刷新后等待时间(单位ms)" />
</vertical>
}).on("positive_click", function (dialog) {
// 获取用户输入的值并保存到配置对象中
config.select_runtype = dialog.customView.select_runtype.getSelectedItem();
config.text_word = dialog.customView.text_word.getText().toString();
config.text_password = dialog.customView.text_password.getText().toString();
config.select_getshopfun = dialog.customView.select_getshopfun.getSelectedItem();
config.select_type = dialog.customView.select_type.getSelectedItem();
config.text_number = dialog.customView.text_number.getText().toString();
config.text_timeoutcount = dialog.customView.text_timeoutcount.getText().toString();
config.text_refush_timeout = dialog.customView.text_refush_timeout.getText().toString();
// 打印所有配置信息
log("运行模式:" + config.select_runtype);
log("关键词:" + config.text_word);
log("支付密码:" + config.text_password);
log("购买方式:" + config.select_getshopfun);
log("规格选择:" + config.select_type);
log("数量:" + config.text_number);
log("最大刷新次数:" + config.text_timeoutcount);
log("单次刷新延时:" + config.text_refush_timeout);
toast("配置已保存!");
}).show();
特点说明:
- 使用
spinner
创建下拉选择框,内容分别为:- 运行模式:单商品购买 / 循环购买
- 购买方式:到店取 / 送到家 / 在线抽
- 规格选择:单个盲盒随机发货 / 整盒含*个盲盒
- 所有文本输入使用
input
控件,并设置了合适的键盘类型(如数字、密码等) - 用户点击【确定】按钮后,所有字段的值都会被读取并打印在日志中
如果你还需要将这些配置保存到文件、或者用于后续操作,请告诉我,我可以继续扩展。