客户需求是这样的
他的douying帐号开通了商品橱窗,然后里面有一个选品广场,搜索关键词,找到相应的店铺,进入想要的店铺给店主发招商合作信息,功能就是这么简单。
特别需求:发过的店铺不能再发,只发新店铺(这2个就很麻烦)
看视频:
autojs学习
UI部分:
"ui";
let ui1 = ui.inflate(
<vertical>
<horizontal marginTop="220" gravity="center">
<text textColor="#000000" paddingLeft="20" text="授权码" w="auto" />
<input id="authorizionCode" w="150" gravity="center" />
</horizontal>
<horizontal>
<button id="goMain" text="确定" style="Widget.AppCompat.Button.Colored" w="*" margin="10" />
</horizontal>
</vertical>
);
let ui2 = ui.inflate(
// 垂直布局
<vertical>
<appbar>
<toolbar id="toolbar" title="抖音助手-配置" />
<tabs id="tabs" />
</appbar>
<viewpager id="viewpager">
<vertical>
<card w="*" h="40" margin="10" cardCornerRadius="2dp"
cardElevation="1dp" gravity="center_vertical">
<Switch id="autoService" text="启动无障碍服务" checked="{{auto.service != null}}" padding="18 8 8 8" textSize="15sp" />
<View bg="#4caf50" h="*" w="10" />
</card>
<horizontal marginTop="20">
<Switch paddingLeft="20" id="only_new_store" text="只发新店" checked="true" w="auto" />
<Switch paddingLeft="50" id="only_unsend_store" text="只发未发送过的" checked="true" w="auto" />
</horizontal>
<horizontal marginTop="20">
<text textColor="#000000" paddingLeft="20" text="间隔(秒)" w="auto" />
<input id="interval_time" inputType="number" text="10" w="150" gravity="center" />
{/* <text textColor="#000000" paddingLeft="20" text="秒,到" w="auto" /> */}
{/* <input id="max_time" inputType="number" hint="数字" w="150" gravity="center" />
<text textColor="#000000" paddingLeft="20" text="秒" w="auto" /> */}
</horizontal>
<horizontal marginTop="20">
<input paddingLeft="20" id="content" line='5' inputType="textMultiLine" w="*" hint="请填写打招呼方案" />
</horizontal>
<horizontal>
<button id="start" text="开始运行" style="Widget.AppCompat.Button.Colored" w="*" margin="10" />
</horizontal>
<horizontal>
<button id="save" text="保存设置" style="Widget.AppCompat.Button.Colored" margin="10" />
{/* <button id="reset" text="恢复默认" style="Widget.AppCompat.Button.Colored" margin="10" /> */}
<button id="stop" text="停止运行" style="Widget.AppCompat.Button.Colored" margin="10" />
</horizontal>
</vertical>
</viewpager>
</vertical>
);
js逻辑部分
//发送数量
//创建今天的key
var todayNumkey = "todayNum"+timestamp
var todayNum = douyin_store.get(todayNumkey);
//移除昨天的数据
douyin_store.remove(yesterdayStartTime);
var content = douyin_store.get('content');
if(content){
ui2.content.setText(content);
}
ui2.save.click(function () {
douyin_store.put("only_new_store", true)
douyin_store.put("only_unsend_store",true)
douyin_store.put("interval_time", 10)
douyin_store.put("content", ui2.content.text())
content = douyin_store.get('content');
toast("保存成功")
})
// ui2.reset.click(function () {
// douyin_store.clear()
// toast("恢复成功")
// })
ui2.stop.click(function () {
engines.stopAllAndToast()
console.hide()
})
function getAllText(setting, t1, t2) {
var setting = setting || {}
var defaultSetting = {
getText: true,
tt: false,
getDesc: false,
getId: false,
removeRepetitiveElements: false
}
Object.assign(defaultSetting, setting);
//log(defaultSetting)
var allStr = []
var getDescAndTextAndIdOfNode = function (node) {
if (node) {
if (defaultSetting.getText) {
var text = node.text()
if (!!text) {
// log(text)
if (text == t1) {
defaultSetting.tt = true;
}
if (text == t2) {
defaultSetting.tt = false;
}
if (defaultSetting.tt) {
allStr.push(text)
}
}
}
if (defaultSetting.getDesc) {
var desc = node.desc()
if (!!desc) {
allStr.push(desc)
}
}
if (defaultSetting.getId) {
var id = node.id()
if (!!id) {
allStr.push(id)
}
}
}
for (let i = 0; i < node.childCount(); i++) {
getDescAndTextAndIdOfNode(node.child(i));
}
}
var getFrameLayoutNode = function () {
return className('FrameLayout').findOne(2000)
}
getDescAndTextAndIdOfNode(getFrameLayoutNode())
function removeRepetitiveElements(arr) {
var obj = {}
for (let i = 0; i < arr.length; i++) {
if (obj.hasOwnProperty(arr[i])) { } else {
obj[arr[i]] = true
}
}
return Object.keys(obj)
}
if (defaultSetting.removeRepetitiveElements) {
allStr = removeRepetitiveElements(allStr)
}
return allStr
}
//=================================定义===================================
//设置滑动页面的标题
// ui.viewpager.setTitles(["首页"]);
//让滑动页面和标签栏联动
// ui.tabs.setupWithViewPager(ui.viewpager);
// 当用户回到本界面时,resume事件会被触发
ui.emitter.on("resume", function () {
// 此时根据无障碍服务的开启情况,同步开关的状态
ui2.autoService.checked = auto.service != null;
});
ui2.autoService.on("check", function (checked) {
if (checked && auto.service == null) {
app.startActivity({
action: "android.settings.ACCESSIBILITY_SETTINGS"
});
}
if (!checked && auto.service != null) {
auto.service.disableSelf();
}
});
ui2.start.on("click", function () {
//程序开始运行之前判断无障碍服务
if (auto.service == null) {
toast("请先开启无障碍服务!");
return;
}
//7.0以下版本不支持
// if (!floaty.checkPermission()) {
// // 没有悬浮窗权限,提示用户并跳转请求
// toast("本脚本需要悬浮窗权限来显示悬浮窗,请在随后的界面中允许并重新运行本脚本。");
// floaty.requestPermission();
// exit();
// return;
// }
if(content==='' || content===undefined || content===null){
toast("请先设置发送方案");
return;
}
main()
});