B2B网络软件
标题:
H5任务脚本选择与执行中心
[打印本页]
作者:
YYPOST群发软件
时间:
2 小时前
标题:
H5任务脚本选择与执行中心
H5任务脚本选择与执行中心
3.png
(238.42 KB, 下载次数: 0)
下载附件
2 小时前
上传
1.png
(497.54 KB, 下载次数: 0)
下载附件
2 小时前
上传
//🍎交流QQ群711841924群一,苹果内测群,528816639
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>AIWROK 任务脚本选择与执行中心</title>
<style>
/* 基础样式重置 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background-color: #f5f5f5;
color: #333;
line-height: 1.6;
overflow-x: hidden;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* 手机容器 */
.mobile-container {
max-width: 414px;
margin: 0 auto;
background-color: white;
min-height: 100vh;
position: relative;
overflow: hidden;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}
/* 顶部导航栏 */
.top-nav {
display: flex;
background-color: white;
border-bottom: 1px solid #f0f0f0;
padding: 12px 0;
}
.top-nav-item {
flex: 1;
text-align: center;
font-size: 16px;
color: #333;
text-decoration: none;
padding: 8px 0;
}
.top-nav-item.active {
color: #2196f3;
font-weight: 600;
border-bottom: 2px solid #2196f3;
}
/* 主要内容区域 */
.content {
padding: 0;
padding-bottom: 80px;
}
/* 页面容器样式 */
.page {
display: none;
}
.page.active {
display: block;
}
/* 返回按钮 */
.back-button {
width: 100%;
height: 56px;
background-color: #ff0000;
color: white;
border: none;
border-radius: 0;
font-size: 18px;
font-weight: 600;
cursor: pointer;
margin-bottom: 0;
transition: all 0.3s ease;
transform: scale(1);
}
.back-button:active {
background-color: #cc0000;
transform: scale(0.95);
}
/* 选择列表 */
.select-list {
margin-bottom: 0;
padding: 0 16px;
}
/* 下拉选择框样式 */
.select-item {
margin-bottom: 12px;
padding: 12px 16px;
border-bottom: 1px solid #f0f0f0;
}
.select-item:last-child {
border-bottom: none;
}
.select-item select {
width: 100%;
height: 40px;
padding: 8px 12px;
font-size: 16px;
color: #333;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #fff;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-image: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpolyline points="6 9 12 15 18 9"%3E%3C/polyline%3E%3C/svg%3E');
background-repeat: no-repeat;
background-position: right 12px center;
background-size: 14px;
}
.select-item select:focus {
outline: none;
border-color: #ff0000;
box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.2);
}
/* 兼容旧的复选框样式 */
.checkbox-list {
margin-bottom: 0;
padding-left: 50px;
}
.checkbox-item {
display: flex;
align-items: center;
padding: 12px 16px;
border-bottom: 1px solid #f0f0f0;
}
.checkbox-item:last-child {
border-bottom: none;
}
.checkbox-item input[type="checkbox"] {
width: 20px;
height: 20px;
margin-right: 12px;
accent-color: #ff0000;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 1px solid #000;
border-radius: 2px;
background-color: #fff;
cursor: pointer;
position: relative;
}
.checkbox-item input[type="checkbox"]:checked {
background-color: #fff;
border-color: #000;
}
.checkbox-item input[type="checkbox"]:checked::after {
content: "✓";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #ff0000;
font-size: 14px;
font-weight: bold;
}
.checkbox-item label {
flex: 1;
font-size: 16px;
color: #333;
cursor: pointer;
}
/* 运行按钮 */
.run-button {
width: 100%;
height: 56px;
background-color: #1976d2;
color: white;
border: none;
border-radius: 0;
font-size: 18px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
margin-top: 20px;
position: relative;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.run-button:hover {
background-color: #1565c0;
box-shadow: 0 4px 8px rgba(25, 118, 210, 0.3);
transform: translateY(-2px);
}
.run-button:active {
background-color: #0d47a1;
transform: scale(0.98) translateY(0);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.run-button:disabled {
background-color: #90caf9;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
/* 波纹效果 */
.run-button::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.5);
transform: translate(-50%, -50%);
transition: width 0.6s ease, height 0.6s ease;
}
.run-button:active::before {
width: 300px;
height: 300px;
}
/* 加载动画 */
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.run-button.loading {
background-color: #1976d2;
}
.run-button.loading::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 24px;
height: 24px;
margin-top: -12px;
margin-left: -12px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
.run-button.loading span {
opacity: 0;
}
/* 响应式设计 */
@media (max-width: 375px) {
.mobile-container {
max-width: 100%;
}
}
/* 适配iOS设备的特殊优化 */
@supports (-webkit-touch-callout: none) {
/* 适配iOS底部安全区域 */
.content {
padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
}
/* 适配iOS顶部安全区域 */
.status-bar {
padding-top: env(safe-area-inset-top, 0);
height: calc(44px + env(safe-area-inset-top, 0));
}
}
</style>
</head>
<body>
<div class="mobile-container">
<!-- 顶部导航栏 -->
<div class="top-nav">
<a href="#" class="top-nav-item active">首页</a>
<a href="#" class="top-nav-item">第二页</a>
<a href="#" class="top-nav-item">第三页</a>
<a href="#" class="top-nav-item">第四页</a>
</div>
<!-- 结果显示区域 -->
<div id="resultDisplay" style="
background-color: #f5f5f5;
padding: 10px;
margin: 0 10px 10px;
border-radius: 8px;
font-size: 14px;
color: #333;
max-height: 150px;
overflow-y: auto;
border: 1px solid #e0e0e0;
">
<div style="font-weight: bold; margin-bottom: 5px;">交互结果:</div>
<div id="resultContent">初始化完成,等待交互...</div>
</div>
<!-- 主要内容区域 -->
<div class="content">
<!-- 首页内容 -->
<div id="page1" class="page active">
<!-- 返回按钮 -->
<button class="back-button" onclick="handleBackButton()">返回</button>
<!-- 下拉选择框 -->
<div class="select-list">
<div class="select-item">
<select id="page1-select" onchange="handleSelectChange(this)">
<option value="">请选择要执行的任务</option>
<option value="item1">抖音极速版</option>
<option value="item2">快手极速版</option>
<option value="item3">汽水音乐</option>
<option value="item4">番茄畅听音乐版</option>
<option value="item5">西瓜视频</option>
<option value="item6">番茄畅听</option>
<option value="item7">番茄小说</option>
<option value="item8">悟空浏览器</option>
<option value="item9">红果短剧</option>
<option value="item10">今日头条</option>
<option value="item11">今日头条极速版</option>
<option value="item12">喜番短剧</option>
<option value="item13">快手正式版</option>
<option value="item14">卸载APP</option>
<option value="item15">测试2</option>
</select>
</div>
</div>
<!-- 运行按钮 -->
<button class="run-button" onclick="handleRunButton(this)"><span>点击运行</span></button>
</div>
<!-- 第二页内容 -->
<div id="page2" class="page">
<!-- 返回按钮 -->
<button class="back-button" onclick="handleBackButton()">返回</button>
<!-- 下拉选择框 -->
<div class="select-list">
<div class="select-item">
<select id="page2-select" onchange="handleSelectChange(this)">
<option value="">请选择要执行的任务</option>
<option value="item21">喜番快手正式快手极速</option>
<option value="item22">抖音极速西瓜汽水</option>
<option value="item23">红果悟空番茄畅听音乐</option>
<option value="item24">番茄小说番茄畅听</option>
<option value="item25">抖音极速西瓜汽水新手模式</option>
<option value="item26">红果悟空番茄畅听音乐新手模式</option>
<option value="item27">番茄小说番茄畅听新手模式</option>
<option value="item28">喜番快手正式快手极速新手模式</option>
<option value="item29">喜番快手正式快手极速周期</option>
<option value="item30">抖音系周期任务</option>
<option value="item31">抖音系周期养号</option>
</select>
</div>
</div>
<!-- 运行按钮 -->
<button class="run-button" onclick="handleRunButton(this)"><span>点击运行</span></button>
</div>
<!-- 第三页内容 -->
<div id="page3" class="page">
<!-- 返回按钮 -->
<button class="back-button" onclick="handleBackButton()">返回</button>
<!-- 下拉选择框 -->
<div class="select-list">
<div class="select-item">
<select id="page3-select" onchange="handleSelectChange(this)">
<option value="">请选择要执行的任务</option>
<option value="item41">抖音系周期养号</option>
<option value="item42">抖音系周期任务</option>
<option value="item43">喜番快手正式快手极速周期</option>
<option value="item44">抖音系新手模式</option>
<option value="item45">快手系新手模式</option>
<option value="item46">番茄小说番茄畅听新手模式</option>
<option value="item47">红果悟空番茄畅听音乐新手模式</option>
<option value="item48">抖音极速西瓜汽水新手模式</option>
<option value="item49">快手系新手模式</option>
<option value="item50">番茄小说番茄畅听音乐</option>
<option value="item51">抖音极速西瓜汽水</option>
<option value="item52">喜番快手正式快手极速</option>
</select>
</div>
</div>
<!-- 运行按钮 -->
<button class="run-button" onclick="handleRunButton(this)"><span>点击运行</span></button>
</div>
<!-- 第四页内容(备用) -->
<div id="page4" class="page">
<!-- 返回按钮 -->
<button class="back-button" onclick="handleBackButton()">返回</button>
<!-- 下拉选择框 -->
<div class="select-list">
<div class="select-item">
<select id="page4-select" onchange="handleSelectChange(this)">
<option value="">请选择要执行的任务</option>
<option value="item61">备用任务1</option>
<option value="item62">备用任务2</option>
<option value="item63">备用任务3</option>
<option value="item64">备用任务4</option>
<option value="item65">备用任务5</option>
<option value="item66">备用任务6</option>
<option value="item67">备用任务7</option>
<option value="item68">备用任务8</option>
<option value="item69">备用任务9</option>
<option value="item70">备用任务10</option>
</select>
</div>
</div>
<!-- 运行按钮 -->
<button class="run-button" onclick="handleRunButton(this)"><span>点击运行</span></button>
</div>
</div>
</div>
<script>
// 先定义showResult函数,确保在window.at对象初始化时可用
function showResult(result) {
try {
var resultContent = document.getElementById('resultContent');
if (resultContent) {
var timestamp = new Date().toLocaleTimeString();
var newResult = '<div style="margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px dashed #ddd;"><strong>[' + timestamp + ']</strong> ' + result + '</div>';
resultContent.innerHTML = newResult + resultContent.innerHTML;
// 限制结果显示数量
var resultItems = resultContent.querySelectorAll('div');
if (resultItems.length > 10) {
for (var i = 10; i < resultItems.length; i++) {
resultItems[i].remove();
}
}
} else {
console.log('结果显示区域不可用,使用console.log输出:', result);
}
} catch (e) {
console.error('调用showResult失败:', e.message);
console.log('showResult错误日志:', result);
}
}
// 定义空的webjs函数,避免AIWROK内部调用时出现"is not a function"错误
function webjs() {
console.log('webjs函数被调用');
}
// 定义临时的printl函数,避免页面加载时出现"is not defined"错误
// 主脚本.js加载后会自动覆盖这个定义
function printl(message) {
try {
console.log('printl临时函数:', message);
showResult(message);
} catch (e) {
console.error('printl临时函数调用失败:', e.message);
}
}
// AIWROK原生环境交互对象 - 主通信接口
window.at = window.at || {};
// 初始化window.at对象的各种方法,确保与原生应用的交互能力
if (typeof window.at.callFunction === 'undefined') {
window.at.callFunction = function(functionName, params, callback) {
console.log('调用原生函数:', functionName, params);
showResult('调用原生函数: ' + functionName + ',参数: ' + JSON.stringify(params));
if (typeof callback === 'function') {
callback(JSON.stringify({result: '模拟返回结果', functionName: functionName}));
}
};
}
if (typeof window.at.runJs === 'undefined') {
window.at.runJs = function(jsCode, callback) {
console.log('运行原生JS代码:', jsCode);
showResult('运行原生JS代码: ' + jsCode.substring(0, 50) + (jsCode.length > 50 ? '...' : ''));
if (typeof callback === 'function') {
callback(JSON.stringify({result: 'JS代码执行成功', jsCode: jsCode}));
}
};
}
if (typeof window.at.setConfig === 'undefined') {
window.at.setConfig = function(key, value) {
console.log('设置配置:', key, '=', value);
showResult('设置配置: ' + key + ' = ' + value);
try {
localStorage.setItem(key, value);
showToast('配置已设置');
} catch (e) {
console.warn('localStorage不可用:', e.message);
if (!window._memoryStorage) {
window._memoryStorage = {};
}
window._memoryStorage[key] = value;
showToast('配置已记录');
}
};
}
if (typeof window.at.getConfig === 'undefined') {
window.at.getConfig = function(key, callback) {
var value = '未设置';
try {
value = localStorage.getItem(key) || '未设置';
} catch (e) {
console.warn('localStorage不可用:', e.message);
if (window._memoryStorage && window._memoryStorage[key] !== undefined) {
value = window._memoryStorage[key];
}
}
showResult('获取配置: ' + key + ' = ' + value);
if (typeof callback === 'function') {
callback(value);
}
};
}
if (typeof window.at.publicSet === 'undefined') {
window.at.publicSet = function(key, value) {
console.log('设置公共变量:', key, '=', value);
showResult('设置公共变量: ' + key + ' = ' + value);
window._publicData = window._publicData || {};
window._publicData[key] = value;
showToast('公共变量已设置');
};
}
if (typeof window.at.publicGet === 'undefined') {
window.at.publicGet = function(key, callback) {
var value = '未设置';
window._publicData = window._publicData || {};
if (window._publicData[key] !== undefined) {
value = window._publicData[key];
}
showResult('获取公共变量: ' + key + ' = ' + value);
if (typeof callback === 'function') {
callback(value);
}
};
}
if (typeof window.at.getRootPath === 'undefined') {
window.at.getRootPath = function(callback) {
var path = '模拟根路径: /sdcard/AIWROK/';
showResult('获取根路径: ' + path);
if (typeof callback === 'function') {
callback(path);
}
};
}
if (typeof window.at.getResourcesPath === 'undefined') {
window.at.getResourcesPath = function(callback) {
var path = '模拟资源路径: /sdcard/AIWROK/resources/';
showResult('获取资源路径: ' + path);
if (typeof callback === 'function') {
callback(path);
}
};
}
// 添加JsWebView类,支持new JsWebView().close()方式关闭界面
if (typeof JsWebView === 'undefined') {
function JsWebView() {
// JsWebView构造函数
}
JsWebView.prototype.close = function() {
console.log('使用JsWebView.close()关闭界面');
showToast('关闭界面');
try {
// 调用原生的dismiss方法
if (window.at && typeof window.at.callFunction === 'function') {
window.at.callFunction('dismiss', {}, function(result) {
console.log('关闭界面结果:', result);
});
}
// 模拟关闭界面的视觉效果
var mobileContainer = document.querySelector('.mobile-container');
if (mobileContainer) {
mobileContainer.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
mobileContainer.style.opacity = '0';
mobileContainer.style.transform = 'translateY(20px)';
// 动画结束后隐藏元素
setTimeout(function() {
mobileContainer.style.display = 'none';
}, 500);
}
} catch (e) {
console.error('调用JsWebView.close()失败:', e.message);
}
};
}
// 模拟AIWROK原生环境的交互方法(兼容旧代码)
// 在实际环境中,这些方法由原生应用提供
if (typeof setConfig === 'undefined') {
function setConfig(key, value) {
try {
if (window.at && typeof window.at.setConfig === 'function') {
// 先保存到本地存储作为备份
try {
localStorage.setItem(key, value);
} catch (localStorageError) {
console.warn('localStorage不可用:', localStorageError.message);
}
// 调用原生方法并处理可能的异常
try {
window.at.setConfig(key, value);
showToast('配置设置成功');
} catch (nativeError) {
console.error('原生setConfig方法执行失败:', nativeError.message);
showToast('配置已保存到本地');
}
} else {
console.error('window.at.setConfig 方法不可用,使用本地存储');
showToast('设置配置: ' + key + ' = ' + value);
showResult('设置配置: ' + key + ' = ' + value);
// 尝试使用本地存储作为备选
try {
localStorage.setItem(key, value);
} catch (e) {
console.warn('localStorage不可用:', e.message);
}
}
} catch (e) {
console.error('调用setConfig失败:', e.message);
showToast('配置保存成功');
}
}
}
if (typeof getConfig === 'undefined') {
function getConfig(key, callback) {
try {
if (window.at && typeof window.at.getConfig === 'function') {
window.at.getConfig(key, callback);
} else {
console.error('window.at.getConfig 方法不可用,使用本地存储');
var value = '未设置';
// 尝试从本地存储获取
try {
value = localStorage.getItem(key) || '未设置';
} catch (e) {
console.warn('localStorage不可用:', e.message);
}
showResult('获取配置: ' + key + ' = ' + value);
if (typeof callback === 'function') {
callback(value);
}
}
} catch (e) {
console.error('调用getConfig失败:', e.message);
if (typeof callback === 'function') {
callback('获取失败');
}
}
}
}
// 完全移除toast模拟,避免与原生toast对象冲突
// 统一使用showToast函数进行提示
if (typeof printl === 'undefined') {
function printl(message) {
try {
console.log('原生日志:', message);
// 尝试调用原生printl函数
if (window.at && typeof window.at.callFunction === 'function') {
window.at.callFunction('printl', {message: message});
} else {
console.error('window.at.callFunction 方法不可用,无法调用原生printl');
}
// 在H5页面上显示日志
if (typeof showResult === 'function') {
showResult(message);
}
} catch (e) {
console.error('调用printl失败:', e.message);
// 确保日志至少在控制台输出
console.log('printl错误日志:', message);
}
}
}
if (typeof dismiss === 'undefined') {
function dismiss() {
console.log('关闭界面');
showToast('关闭界面操作');
window.at.callFunction('dismiss', {}, function(result) {
console.log('关闭界面结果:', result);
});
// 模拟关闭界面的视觉效果
var mobileContainer = document.querySelector('.mobile-container');
if (mobileContainer) {
mobileContainer.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
mobileContainer.style.opacity = '0';
mobileContainer.style.transform = 'translateY(20px)';
// 动画结束后隐藏元素
setTimeout(function() {
mobileContainer.style.display = 'none';
}, 500);
}
}
}
// 添加runJS函数,用于运行原生JS代码
if (typeof runJS === 'undefined') {
function runJS(func) {
try {
// 获取完整的函数代码字符串
var jsCode = func.toString();
// 显示执行状态
showToast('正在执行脚本...');
console.log('执行JS代码:', jsCode);
if (window.at && typeof window.at.runJs === 'function') {
// 调用原生方法,与h5Demo.html保持一致
window.at.runJs(jsCode);
showToast('脚本执行成功');
showResult('已执行APP JS代码');
} else {
console.error('window.at.runJs 方法不可用,尝试直接执行');
// 直接在本地执行函数
func();
showToast('脚本本地执行成功');
showResult('脚本本地执行成功');
}
} catch (e) {
console.error('调用runJS失败:', e.message);
console.error('错误堆栈:', e.stack);
showToast('脚本执行失败');
showResult('脚本执行失败: ' + e.message);
}
}
}
// 添加runJSFile函数,用于运行原生JS文件
if (typeof runJSFile === 'undefined') {
function runJSFile(filePath) {
try {
if (window.at && typeof window.at.runJsFile === 'function') {
window.at.runJsFile(filePath);
showToast('运行JS文件成功');
showResult('已执行APP JS文件: ' + filePath);
} else {
console.error('window.at.runJsFile 方法不可用,无法运行JS文件');
showToast('运行JS文件失败: ' + filePath);
showResult('运行JS文件失败: ' + filePath);
}
} catch (e) {
console.error('调用runJSFile失败:', e.message);
showToast('运行JS文件失败');
showResult('运行JS文件失败: ' + e.message);
}
}
}
// 添加callAppMain函数,用于调用原生应用主函数
if (typeof callAppMain === 'undefined') {
function callAppMain(funcName, params, callback) {
try {
if (window.at && typeof window.at.callFunction === 'function') {
// 调用原生方法并处理可能的异常
try {
window.at.callFunction(funcName, params, callback);
showToast('调用成功');
} catch (nativeError) {
console.error('原生callFunction方法执行失败:', nativeError.message);
showToast('功能已执行');
}
} else {
console.error('window.at.callFunction 方法不可用,尝试本地处理');
showToast('功能已执行');
showResult('功能已在本地环境处理');
if (typeof callback === 'function') {
callback(JSON.stringify({result: '功能已处理', message: '本地环境执行'}));
}
}
} catch (e) {
console.error('调用callAppMain失败:', e.message);
showToast('功能已执行');
if (typeof callback === 'function') {
callback(JSON.stringify({result: '功能已处理', message: '已忽略兼容性警告'}));
}
}
}
}
// 添加runAppJs函数,用于运行原生JS代码
if (typeof runAppJs === 'undefined') {
function runAppJs() {
try {
window.at.runJs(function() {
printl("H5触发APP执行JS代码");
// 这里可以执行任何APP端的JS代码
}.toString());
showResult("已执行APP JS代码");
} catch (e) {
showResult("执行APP JS代码失败: " + e);
}
}
}
// 自定义Toast提示
function showToast(message) {
var toast = document.getElementById('custom-toast');
if (!toast) {
toast = document.createElement('div');
toast.id = 'custom-toast';
toast.style.cssText =
'position: fixed;' +
'top: 50%;' +
'left: 50%;' +
'transform: translate(-50%, -50%);' +
'background: rgba(0, 0, 0, 0.7);' +
'color: white;' +
'padding: 12px 24px;' +
'border-radius: 8px;' +
'font-size: 14px;' +
'z-index: 9999;' +
'opacity: 0;' +
'transition: opacity 0.3s ease, transform 0.3s ease;' +
'transform: translate(-50%, -50%) scale(0.9);';
document.body.appendChild(toast);
}
if (toast.timer) {
clearTimeout(toast.timer);
}
toast.textContent = message;
toast.style.opacity = '1';
toast.style.transform = 'translate(-50%, -50%) scale(1)';
toast.timer = setTimeout(function() {
toast.style.opacity = '0';
toast.style.transform = 'translate(-50%, -50%) scale(0.9)';
}, 2000);
}
// 显示交互结果的函数已在页面顶部定义
// 保存用户操作到配置
function saveUserAction(action, value) {
var timestamp = new Date().toISOString();
printl('保存用户操作:' + action + ' 时间戳:' + timestamp);
setConfig('last_' + action, timestamp);
if (value) {
setConfig(action, value);
}
}
// 添加按钮点击反馈
function addButtonFeedback() {
var buttons = document.querySelectorAll('.back-button, .run-button');
for (var i = 0; i < buttons.length; i++) {
(function(button) {
button.addEventListener('mousedown', function() {
this.style.transform = 'scale(0.95)';
});
button.addEventListener('mouseup', function() {
this.style.transform = 'scale(1)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'scale(1)';
});
})(buttons[i]);
}
}
// AIWROK标准的返回按钮点击处理
function handleBackButton() {
printl('返回按钮被点击');
saveUserAction('back_button_click');
// 如果当前是第一页,关闭界面
if (currentPageId === 1) {
showToast('关闭界面');
dismiss();
} else {
// 从历史记录中移除当前页面
pageHistory.pop();
// 获取上一页的ID
var previousPageId = pageHistory[pageHistory.length - 1];
// 隐藏所有页面
var pages = document.querySelectorAll('.page');
for (var i = 0; i < pages.length; i++) {
pages[i].classList.remove('active');
}
// 显示上一页
var previousPage = document.getElementById('page' + previousPageId);
if (previousPage) {
previousPage.classList.add('active');
}
// 更新导航栏状态
var navItems = document.querySelectorAll('.top-nav-item');
for (var j = 0; j < navItems.length; j++) {
navItems[j].classList.remove('active');
}
navItems[previousPageId - 1].classList.add('active');
// 更新当前页面ID
currentPageId = previousPageId;
showToast('返回上一页');
printl('返回到页面: ' + previousPageId);
}
}
// AIWROK标准的运行按钮点击处理
function handleRunButton(button) {
// 如果按钮已经处于加载状态,不执行任何操作
if (button.classList.contains('loading')) {
return;
}
printl('运行按钮被点击');
saveUserAction('run_button_click');
// 添加加载状态
button.classList.add('loading');
button.disabled = true;
showToast('开始执行任务');
// 根据当前页面执行对应的脚本
var selectedItems = [];
// 获取当前页面的下拉选择框
var currentPage = document.getElementById('page' + currentPageId);
var selectBox = currentPage.querySelector('select');
// 检查是否有选中的值
if (selectBox && selectBox.value) {
var itemId = selectBox.value;
var label = selectBox.options[selectBox.selectedIndex].text;
printl('执行脚本: ' + label);
selectedItems.push(label);
// 根据不同页面和选择项执行不同的函数
if (currentPageId === 1) {
// 第一页脚本
switch (itemId) {
case 'item1': runJS(function() { 抖音极速(); }); break;
case 'item2': runJS(function() { 快手极速(); }); break;
case 'item3': runJS(function() { 汽水音乐(); }); break;
case 'item4': runJS(function() { 番茄畅听音乐(); }); break;
case 'item5': runJS(function() { 西瓜视频(); }); break;
case 'item6': runJS(function() { 番茄畅听(); }); break;
case 'item7': runJS(function() { 番茄小说(); }); break;
case 'item8': runJS(function() { 悟空浏览器(); }); break;
case 'item9': runJS(function() { 红果短剧(); }); break;
case 'item10': runJS(function() { 头条广告单版(); }); break;
case 'item11': runJS(function() { 头条极速广告单版(); }); break;
case 'item12': runJS(function() { 喜番短剧(); }); break;
case 'item13': runJS(function() { 快手正式(); }); break;
case 'item14': runJS(function() { 苹果删除APP(); }); break;
case 'item15': runJS(function() { 测试函数2(); printl('测试2脚本已启动'); }); break;
}
} else if (currentPageId === 2) {
// 第二页脚本
switch (itemId) {
case 'item21': runJS(function() { 喜番快手正式快手极速(); printl('喜番极速快手正式快手混跑脚本已启动'); }); break;
case 'item22': runJS(function() { 抖音极速西瓜汽水(); printl('极速抖音混跑脚本已启动'); }); break;
case 'item23': runJS(function() { 红果悟空番茄畅听音乐(); printl('红果混跑脚本已启动'); }); break;
case 'item24': runJS(function() { 番茄小说番茄畅听(); printl('番茄小说混跑脚本已启动'); }); break;
case 'item25': runJS(function() { 抖音极速西瓜汽水新手(); printl('西瓜视频脚本已启动'); }); break;
case 'item26': runJS(function() { 红果悟空番茄畅听音乐新手(); printl('番茄畅听脚本已启动'); }); break;
case 'item27': runJS(function() { 番茄小说番茄畅听新手(); printl('番茄小说脚本已启动'); }); break;
case 'item28': runJS(function() { 喜番快手正式快手极速新手模式(); printl('喜番快手正式快手极速新手模式已启动'); }); break;
case 'item29': runJS(function() { 喜番快手正式快手极速周期(); }); break;
case 'item30': runJS(function() { 抖音系周期做任务(); }); break;
case 'item31': runJS(function() { 抖音系周期养号(); }); break;
}
} else if (currentPageId === 3) {
// 第三页脚本
switch (itemId) {
case 'item41': runJS(function() { 抖音系周期养号(); printl('抖音系周期养号脚本已启动'); }); break;
case 'item42': runJS(function() { 抖音系周期做任务(); printl('抖音系周期任务脚本已启动'); }); break;
case 'item43': runJS(function() { 喜番快手正式快手极速周期(); printl('喜番快手正式快手极速周期脚本已启动'); }); break;
case 'item44': runJS(function() { 抖音系新手模式(); printl('抖音系新手模式脚本已启动'); }); break;
case 'item45': runJS(function() { 快手系新手模式(); printl('快手系新手模式脚本已启动'); }); break;
case 'item46': runJS(function() { 番茄小说番茄畅听新手(); printl('番茄小说番茄畅听新手模式脚本已启动'); }); break;
case 'item47': runJS(function() { 红果悟空番茄畅听音乐新手(); printl('红果悟空番茄畅听音乐新手模式脚本已启动'); }); break;
case 'item48': runJS(function() { 抖音极速西瓜汽水新手(); printl('抖音极速西瓜汽水新手模式脚本已启动'); }); break;
case 'item49': runJS(function() { 快手系新手模式(); printl('快手系新手模式脚本已启动'); }); break;
case 'item50': runJS(function() { 番茄小说番茄畅听(); printl('番茄小说番茄畅听音乐脚本已启动'); }); break;
case 'item51': runJS(function() { 抖音极速西瓜汽水(); printl('抖音极速西瓜汽水脚本已启动'); }); break;
case 'item52': runJS(function() { 喜番快手正式快手极速(); printl('喜番快手正式快手极速脚本已启动'); }); break;
}
} else if (currentPageId === 4) {
// 第四页备用脚本
switch (itemId) {
case 'item61': runJS(function() { 备用任务1(); printl('备用任务1脚本已启动'); }); break;
case 'item62': runJS(function() { 备用任务2(); printl('备用任务2脚本已启动'); }); break;
case 'item63': runJS(function() { 备用任务3(); printl('备用任务3脚本已启动'); }); break;
case 'item64': runJS(function() { 备用任务4(); printl('备用任务4脚本已启动'); }); break;
case 'item65': runJS(function() { 备用任务5(); printl('备用任务5脚本已启动'); }); break;
case 'item66': runJS(function() { 备用任务6(); printl('备用任务6脚本已启动'); }); break;
case 'item67': runJS(function() { 备用任务7(); printl('备用任务7脚本已启动'); }); break;
case 'item68': runJS(function() { 备用任务8(); printl('备用任务8脚本已启动'); }); break;
case 'item69': runJS(function() { 备用任务9(); printl('备用任务9脚本已启动'); }); break;
case 'item70': runJS(function() { 备用任务10(); printl('备用任务10脚本已启动'); }); break;
}
}
}
// 如果没有选中任何任务
if (selectedItems.length === 0) {
showToast('请先选择要执行的任务');
}
// 模拟任务执行过程
setTimeout(function() {
// 移除加载状态
button.classList.remove('loading');
button.disabled = false;
// 显示执行完成提示
if (selectedItems.length > 0) {
showToast('任务执行完成');
// 添加返回桌面功能,但保持H5界面打开以继续运行脚本
try {
window.at.runJs(function() {
printl("H5触发APP返回桌面");
auto.home(); // 返回桌面
}.toString());
showResult("已触发APP返回桌面");
} catch (e) {
showResult("返回桌面失败: " + e);
}
}
}, 2000);
}
// 页面历史记录,用于实现返回功能
var pageHistory = [1]; // 初始页面是第一页
var currentPageId = 1;
// AIWROK标准的选择框变化处理
function handleSelectChange(select) {
var selectedValue = select.value;
var selectedText = select.options[select.selectedIndex].text;
if (selectedValue) {
printl('选中: ' + selectedText);
saveUserAction('select_' + select.id, selectedValue);
} else {
printl('未选择任何任务');
saveUserAction('select_' + select.id, '');
}
}
// 保持兼容旧的复选框变化处理函数
function handleCheckboxChange(checkbox) {
try {
var label = checkbox.nextElementSibling;
if (checkbox.checked) {
label.style.color = '#d32f2f';
label.style.fontWeight = '600';
printl('选中: ' + label.textContent);
saveUserAction('checkbox_' + checkbox.id, 'checked');
} else {
label.style.color = '#333';
label.style.fontWeight = 'normal';
printl('取消选中: ' + label.textContent);
saveUserAction('checkbox_' + checkbox.id, 'unchecked');
}
} catch (e) {
console.error('handleCheckboxChange错误:', e.message);
}
}
// 页面切换函数
function switchPage(pageId) {
// 如果是当前页面,不进行切换
if (currentPageId === pageId) {
return;
}
// 隐藏所有页面
var pages = document.querySelectorAll('.page');
for (var i = 0; i < pages.length; i++) {
pages[i].classList.remove('active');
}
// 显示选中的页面
var selectedPage = document.getElementById('page' + pageId);
if (selectedPage) {
selectedPage.classList.add('active');
}
// 更新导航栏状态
var navItems = document.querySelectorAll('.top-nav-item');
for (var j = 0; j < navItems.length; j++) {
navItems[j].classList.remove('active');
}
navItems[pageId - 1].classList.add('active');
// 记录页面历史
pageHistory.push(pageId);
currentPageId = pageId;
printl('切换到页面: ' + pageId);
}
// 页面加载完成后初始化
window.onload = function() {
printl('页面加载完成');
// 执行APP JS文件,与h5Demo.html保持一致
if (window.at && typeof window.at.runJsFile === 'function') {
window.at.runJsFile("主脚本.js");
printl('已执行APP JS文件: 主脚本.js');
} else {
printl('runJsFile方法不可用,尝试使用script标签加载');
// 使用script标签加载主脚本
var scriptTag = document.createElement('script');
scriptTag.src = '主脚本.js';
scriptTag.onload = function() {
printl('主脚本.js已通过script标签加载完成');
};
scriptTag.onerror = function() {
printl('主脚本.js加载失败');
};
document.body.appendChild(scriptTag);
}
// 为导航栏添加点击事件
var navItems = document.querySelectorAll('.top-nav-item');
for (var i = 0; i < navItems.length; i++) {
(function(index) {
navItems[index].addEventListener('click', function(e) {
e.preventDefault();
switchPage(index + 1);
});
})(i);
}
// 添加按钮点击反馈
addButtonFeedback();
printl('初始化完成,所有交互功能已就绪');
};
</script>
</body>
</html>
复制代码
欢迎光临 B2B网络软件 (http://bbs.niubt.cn/)
Powered by Discuz! X3.2