var
r = http.get(
"https://wwth.lanzouw.com/b00u43sfg"
, {
headers: {
'User-Agent'
:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11'
}
});
var
htmlContent = r.body.string();
var
versionMatch = htmlContent.match(/<span id=
"filename"
>(.*?)<\/span>/);
var
versionNumber = versionMatch ? versionMatch[1].trim() :
"未知版本"
;
log(
"版本号 = "
+ versionNumber);
var
currentVersion =
"V1.0.0"
;
var
shouldShowMainPanel =
true
;
var
versionArray = versionNumber.split(
'-'
);
if
(!versionArray.includes(currentVersion)) {
shouldShowMainPanel =
false
;
dialogs.build({
title:
"版本更新"
,
content:
"发现新版本: "
+ versionArray[versionArray.length - 1],
positive:
"确定"
,
positiveColor:
"#007bff"
}).on(
"positive"
,
function
() {
app.openUrl(
"https://wwth.lanzouw.com/b00u43sfg"
);
exit();
}).show();
}
else
{
log(
"当前已是最新版本: "
+ currentVersion);
if
(currentVersion !== versionArray[versionArray.length - 1]) {
shouldShowMainPanel =
false
;
dialogs.build({
title:
"版本更新"
,
content:
"当前版本号: "
+ currentVersion +
"\n发现新版本: "
+ versionArray[versionArray.length - 1],
negative:
"取消"
,
positive:
"确定"
,
negativeColor:
"#FF4444"
,
positiveColor:
"#007bff"
}).on(
"negative"
,
function
() {
shouldShowMainPanel =
true
;
w.mainPanel.setVisibility(android.view.View.VISIBLE);
}).on(
"positive"
,
function
() {
app.openUrl(
"https://wwth.lanzouw.com/b00u43sfg"
);
exit();
}).show();
}
}
log(
"代码开始执行"
);
var
storage = storages.create(
"vehicle_commission_calculator"
);
var
taxCheckboxState = storage.get(
"taxCheckboxState"
,
true
);
var
textCheckboxState = storage.get(
"textCheckboxState"
,
true
);
var
backupCheckboxState = storage.get(
"backupCheckboxState"
,
true
);
var
w = floaty.window(
<frame gravity=
"right|top"
>
<vertical id=
"mainPanel"
gravity=
"right|top"
w=
"wrap_content"
h=
"wrap_content"
bg=
"#00000000"
>
<vertical id=
"expandPanel"
gravity=
"right|top"
w=
"200"
h=
"wrap_content"
bg=
"#FFFFFF"
visible=
"true"
alpha=
"0.9"
>
<horizontal gravity=
"left"
w=
"match_parent"
>
<text id=
"apptitle"
text=
"佣金计算器"
gravity=
"left"
w=
"wrap_content"
h=
"wrap_content"
padding=
"10"
alpha=
"0.8"
/>
<horizontal gravity=
"right|top"
w=
"match_parent"
>
<button id=
"minimizeBtn"
bg=
"#4CAF50"
radius=
"15"
w=
"30"
h=
"40"
text=
"—"
alpha=
"0.8"
/>
<button id=
"menuBtn"
bg=
"#2196F3"
radius=
"15"
w=
"30"
h=
"40"
text=
"☰"
alpha=
"0.8"
/>
<button id=
"closeBtn"
bg=
"#FF4444"
radius=
"15"
w=
"30"
h=
"40"
text=
"X"
alpha=
"0.8"
/>
</horizontal>
</horizontal>
<horizontal gravity=
"left"
w=
"match_parent"
>
<input id=
"input1"
hint=
"交强保费"
inputType=
"numberDecimal"
w=
"80"
h=
"wrap_content"
/>
<input id=
"input2"
hint=
"费用"
inputType=
"numberDecimal"
w=
"50"
h=
"wrap_content"
/>
<text id=
"jqyjText"
text=
"0.00"
w=
"wrap_content"
h=
"wrap_content"
padding=
"10"
/>
</horizontal>
<horizontal gravity=
"left"
w=
"match_parent"
>
<input id=
"input3"
hint=
"车船税费"
inputType=
"numberDecimal"
w=
"80"
h=
"wrap_content"
/>
<input id=
"input4"
hint=
"费用"
inputType=
"numberDecimal"
w=
"50"
h=
"wrap_content"
/>
<text id=
"syjyText"
text=
"0.00"
w=
"wrap_content"
h=
"wrap_content"
padding=
"10"
/>
</horizontal>
<horizontal gravity=
"left"
w=
"match_parent"
>
<input id=
"input5"
hint=
"商业保费"
inputType=
"numberDecimal"
w=
"80"
h=
"wrap_content"
/>
<input id=
"input6"
hint=
"费用"
inputType=
"numberDecimal"
w=
"50"
h=
"wrap_content"
/>
<text id=
"sybxjyText"
text=
"0.00"
w=
"wrap_content"
h=
"wrap_content"
padding=
"10"
/>
</horizontal>
<horizontal gravity=
"left"
w=
"match_parent"
>
<input id=
"input7"
hint=
"驾乘保费"
inputType=
"numberDecimal"
w=
"80"
h=
"wrap_content"
/>
<input id=
"input8"
hint=
"费用"
inputType=
"numberDecimal"
w=
"50"
h=
"wrap_content"
/>
<text id=
"jcyjText"
text=
"0.00"
w=
"wrap_content"
h=
"wrap_content"
padding=
"10"
/>
</horizontal>
<horizontal gravity=
"left"
w=
"match_parent"
>
<checkbox id=
"taxCheckbox"
text=
"除税"
checked=
"{{ taxCheckboxState }}"
/>
<checkbox id=
"textCheckbox"
text=
"文本"
checked=
"{{ textCheckboxState }}"
/>
<checkbox id=
"backupCheckbox"
text=
"清空"
checked=
"{{ backupCheckboxState }}"
/>
</horizontal>
<text id=
"summaryText"
text=
""
w=
"match_parent"
padding=
"10"
/>
<button id=
"getVehicleInfoBtn"
text=
"获取车辆信息"
w=
"match_parent"
h=
"wrap_content"
/>
<button id=
"selectPlanBtn"
text=
"选择费用套餐"
w=
"match_parent"
h=
"wrap_content"
/>
<button id=
"calculateBtn"
text=
"计算佣金"
w=
"match_parent"
h=
"wrap_content"
/>
</vertical>
<img id=
"iconBtn"
radius=
"20"
w=
"40"
h=
"40"
alpha=
"0.8"
visibility=
"gone"
src=
"@drawable/ic_exposure_black_48dp"
/>
</vertical>
</frame>
);
function
centerWindow() {
var
screenWidth = device.width;
var
screenHeight = device.height;
var
windowWidth = w.getWidth();
var
windowHeight = w.getHeight();
var
centerX = (screenWidth - windowWidth) / 4;
var
centerY = (screenHeight - windowHeight) / 4;
w.setPosition(centerX, centerY);
}
w.summaryText.setText(
"总保费: {总保费} 净: {净}\n佣金: {佣金}"
);
var
expandPanel = w.expandPanel;
var
closeBtn = w.closeBtn;
var
menuBtn = w.menuBtn;
var
minimizeBtn = w.minimizeBtn;
var
iconBtn = w.iconBtn;
var
apptitle = w.apptitle;
apptitle.click(
function
() {
w.setAdjustEnabled(!w.isAdjustEnabled());
});
if
(w.mainPanel.getVisibility() === android.view.View.GONE) {
w.mainPanel.setVisibility(android.view.View.VISIBLE);
log(
"确保悬浮窗可见"
);
}
var
inputs = [
w.input1, w.input2, w.input3, w.input4,
w.input5, w.input6, w.input7, w.input8
];
inputs.forEach(
function
(input) {
input.on(
"touch_down"
,
function
() {
w.requestFocus();
input.requestFocus();
});
});
minimizeBtn.click(
function
() {
if
(savedX === 0 && savedY === 0) {
var
screenWidth = device.width;
var
currentY = w.getY();
w.setPosition(screenWidth - w.getWidth() + 85, currentY);
}
if
(savedX !== 0 || savedY !== 0) {
w.setPosition(savedX, savedY);
log(
"悬浮窗移动到保存的位置"
);
}
expandPanel.setVisibility(android.view.View.GONE);
iconBtn.setVisibility(android.view.View.VISIBLE);
log(
"主界面设置为不可见,iconBtn显示"
);
w.disableFocus();
});
iconBtn.click(
function
() {
log(
"iconBtn clicked"
);
iconBtn.setVisibility(android.view.View.GONE);
expandPanel.setVisibility(android.view.View.VISIBLE);
centerWindow();
log(
"iconBtn隐藏,主界面显示"
);
w.disableFocus();
});
var
backupCheckbox = w.backupCheckbox;
var
taxCheckbox = w.taxCheckbox;
var
textCheckbox = w.textCheckbox;
function
saveCheckboxStates() {
storage.put(
"taxCheckboxState"
, taxCheckbox.isChecked());
storage.put(
"textCheckboxState"
, textCheckbox.isChecked());
storage.put(
"backupCheckboxState"
, backupCheckbox.isChecked());
}
backupCheckbox.click(
function
() {
backupCheckbox.setChecked(
true
);
saveCheckboxStates();
inputs.forEach(
function
(input) {
input.setText(
""
);
});
w.disableFocus();
w.summaryText.setText(
"总保费: {总保费} 净: {净}\n佣金: {佣金}"
);
w.jqyjText.setText(
"0.00"
);
w.syjyText.setText(
"0.00"
);
w.sybxjyText.setText(
"0.00"
);
w.jcyjText.setText(
"0.00"
);
});
taxCheckbox.click(
function
() {
saveCheckboxStates();
});
textCheckbox.click(
function
() {
saveCheckboxStates();
});
var
plateNumber =
""
;
var
ownerName =
""
;
var
insuredName =
""
;
function
clearInputsAndDisableFocus() {
w.input1.setText(
""
);
w.input3.setText(
""
);
w.input5.setText(
""
);
w.input7.setText(
""
);
w.disableFocus();
}
function
setTextToInputByLabel(labelText, inputField, containsLabel) {
threads.start(
function
() {
var
targetText = containsLabel ? textContains(labelText).findOne(500) : text(labelText).findOne(500);
if
(targetText) {
var
parent = targetText.parent();
if
(parent) {
var
targetValueText = parent.child(1);
if
(targetValueText) {
var
value = targetValueText.text();
log(labelText +
" 值: "
+ value);
var
numericValue = value.match(/\d+(\.\d+)?/);
if
(numericValue) {
value = numericValue[0];
}
else
{
value =
""
;
}
ui.run(
function
() {
inputField.setText(value);
});
}
}
}
});
}
function
fetchVehicleInfo(plateLabel, callback) {
threads.start(
function
() {
var
plateNumberText = text(plateLabel).findOne(500);
if
(plateNumberText) {
var
nextSibling = plateNumberText.nextSibling();
if
(nextSibling) {
var
childCount = nextSibling.childCount();
for
(
var
i = 0; i < childCount; i++) {
var
child = nextSibling.child(i);
if
(child) {
var
childText = child.text();
log(plateLabel +
" 后一个兄弟控件的子控件内容: "
+ childText);
callback(childText);
return
;
}
}
}
}
callback(
""
);
});
}
w.getVehicleInfoBtn.click(
function
() {
if
(!auto.service) {
toast(
"请先开启无障碍操作。选择[车险佣金计算器]"
,
'long'
);
app.startActivity({
action:
"android.settings.ACCESSIBILITY_SETTINGS"
});
return
;
}
clearInputsAndDisableFocus();
setTextToInputByLabel(
"交强险"
, w.input1);
setTextToInputByLabel(
"车船税"
, w.input3);
setTextToInputByLabel(
"商业险"
, w.input5,
true
);
setTextToInputByLabel(
"驾乘"
, w.input7,
true
);
fetchVehicleInfo(
"车牌号"
,
function
(childText) {
plateNumber = childText;
log(
"车牌号: "
+ plateNumber);
fetchVehicleInfo(
"车主姓名"
,
function
(childText) {
ownerName = childText;
log(
"车主姓名: "
+ ownerName);
fetchVehicleInfo(
"投保人姓名"
,
function
(childText) {
insuredName = childText;
log(
"投保人姓名: "
+ insuredName);
});
});
});
});
var
commissionPlans = storage.get(
"commissionPlans"
, [
"4/0/4/20/燃油车"
]);
function
saveCommissionPlans() {
storage.put(
"commissionPlans"
, commissionPlans);
}
w.selectPlanBtn.click(
function
() {
w.disableFocus();
minimizeBtn.callOnClick();
dialogs.select(
"请选择费用套餐"
, commissionPlans.map(plan => plan.split(
'/'
).slice(0, 4).join(
'/'
) + (plan.split(
'/'
).length > 4 ?
' ('
+ plan.split(
'/'
)[4] +
')'
:
''
)))
.then(i => {
if
(i == -1) {
iconBtn.callOnClick();
}
else
{
var
selectedPlan = commissionPlans[i];
log(
"被点击的套餐内容: "
+ selectedPlan);
iconBtn.callOnClick();
var
parts = selectedPlan.split(
'/'
);
if
(parts.length >= 4) {
w.input2.setText(parts[0]);
w.input4.setText(parts[1]);
w.input6.setText(parts[2]);
w.input8.setText(parts[3]);
}
else
{
toast(
"佣金套餐格式不正确"
);
}
saveCommissionPlans();
}
});
});
w.calculateBtn.click(
function
() {
w.disableFocus();
var
input1 = parseFloat(w.input1.getText()) || 0;
var
input2 = parseFloat(w.input2.getText()) || 0;
var
input3 = parseFloat(w.input3.getText()) || 0;
var
input4 = parseFloat(w.input4.getText()) || 0;
var
input5 = parseFloat(w.input5.getText()) || 0;
var
input6 = parseFloat(w.input6.getText()) || 0;
var
input7 = parseFloat(w.input7.getText()) || 0;
var
input8 = parseFloat(w.input8.getText()) || 0;
var
isTaxChecked = w.taxCheckbox.isChecked();
var
result1 = isTaxChecked ? (input1 / 1.06 * input2 / 100) : (input1 * input2 / 100);
w.jqyjText.setText(result1.toFixed(2));
var
result2 = input3 * input4 / 100;
w.syjyText.setText(result2.toFixed(2));
var
result3 = isTaxChecked ? (input5 / 1.06 * input6 / 100) : (input5 * input6 / 100);
w.sybxjyText.setText(result3.toFixed(2));
var
result4 = isTaxChecked ? (input7 / 1.06 * input8 / 100) : (input7 * input8 / 100);
w.jcyjText.setText(result4.toFixed(2));
var
totalPremium = input1 + input3 + input5 + input7;
var
totalCommission = result1 + result2 + result3 + result4;
var
netPremium = totalPremium - totalCommission;
var
summaryTextContent =
"总保费: "
+ totalPremium.toFixed(2) +
" 净: "
+ netPremium.toFixed(2) +
"\n佣金: "
+ totalCommission.toFixed(2);
w.summaryText.setText(summaryTextContent);
var
isTextChecked = w.textCheckbox.isChecked();
if
(isTextChecked) {
var
textContent =
""
;
if
(plateNumber) {
textContent +=
"车牌号: "
+ plateNumber +
"\n"
;
}
if
(ownerName) {
textContent +=
"车主: "
+ ownerName +
"\n"
;
}
if
(insuredName) {
textContent +=
"投保人: "
+ insuredName +
"\n"
;
}
if
(input1 === 0 && input3 === 0) {
}
else
if
(input1 === 0) {
textContent +=
"交: "
+ input3 +
"\n"
;
}
else
if
(input3 === 0) {
textContent +=
"交: "
+ input1 +
"\n"
;
}
else
{
textContent +=
"交: "
+ input1 +
"+"
+ input3 +
"\n"
;
}
if
(input5 === 0 && input7 === 0) {
}
else
if
(input5 === 0) {
textContent +=
"驾乘: "
+ input7 +
"\n"
;
}
else
if
(input7 === 0) {
textContent +=
"商: "
+ input5 +
"\n"
;
}
else
{
textContent +=
"商: "
+ input5 +
" 驾乘:"
+ input7 +
"\n"
;
}
var
variable1 = input1 === 0 ?
""
: input2 +
"/"
;
var
variable2 = (input3 === 0 || input4 === 0) ?
""
: input4 +
"/"
;
var
variable3 = input5 === 0 ?
""
: input6 +
"/"
;
var
variable4 = input7 === 0 ?
""
: input8 +
"/"
;
var
combinedVariables = variable1 + variable2 + variable3 + variable4;
if
(combinedVariables.endsWith(
"/"
)) {
combinedVariables = combinedVariables.slice(0, -1);
}
if
(input2 === 0 && input4 === 0 && input6 === 0 && input8 === 0) {
combinedVariables =
"零费"
;
}
textContent += summaryTextContent +
"\n"
;
textContent += combinedVariables;
setClip(textContent);
toast(
"已复制文本"
);
}
plateNumber =
""
;
ownerName =
""
;
insuredName =
""
;
});
var
savedX = 0;
var
savedY = 0;
iconBtn.setOnTouchListener(
function
(view, event) {
switch
(event.getAction()) {
case
event.ACTION_DOWN:
initialX = w.getX();
initialY = w.getY();
initialTouchX = event.getRawX();
initialTouchY = event.getRawY();
return
true
;
case
event.ACTION_MOVE:
var
x = initialX + (event.getRawX() - initialTouchX);
var
y = initialY + (event.getRawY() - initialTouchY);
w.setPosition(x, y);
savedX = x;
savedY = y;
return
true
;
case
event.ACTION_UP:
var
moveX = Math.abs(event.getRawX() - initialTouchX);
var
moveY = Math.abs(event.getRawY() - initialTouchY);
if
(moveX < 10 && moveY < 10) {
iconBtn.callOnClick();
}
else
{
var
screenWidth = device.width;
var
currentX = w.getX();
if
(savedX === 0 && savedY === 0) {
w.setPosition(screenWidth - w.getWidth() + 85, currentY);
savedX = screenWidth - w.getWidth() + 85;
savedY = currentY;
}
else
if
(currentX < screenWidth / 2) {
w.setPosition(0, w.getY());
savedX = 0;
savedY = w.getY();
}
else
{
w.setPosition(screenWidth - w.getWidth() + 85, w.getY());
savedX = screenWidth - w.getWidth() + 85;
savedY = w.getY();
}
}
return
true
;
}
return
false
;
});
closeBtn.click(
function
() {
w.disableFocus();
toast(
"退出软件"
);
exit();
});
menuBtn.click(
function
() {
w.disableFocus();
minimizeBtn.callOnClick();
dialogs.select(
"菜单"
, [
"新增佣金套餐"
,
"佣金套餐管理"
,
"分享给朋友"
,
"建议和意见"
,
"关于本软件"
])
.then(i => {
if
(i == -1) {
iconBtn.callOnClick();
}
else
if
(i == 0) {
rawInput(
"新增佣金套餐"
,
"4/0/4/20/备注"
)
.then(newPlan => {
if
(newPlan) {
var
parts = newPlan.split(
'/'
);
log(
"解析后的 parts 数组:"
, parts);
if
(parts.length < 4) {
log(
"parts 数组长度不足:"
, parts.length);
toast(
"佣金套餐格式不正确,必须包含至少4个成员"
);
}
else
{
var
plan = parts.slice(0, 4).join(
'/'
);
var
note = parts.slice(4).join(
'/'
);
var
fullPlan = note ? plan +
'/'
+ note : plan;
if
(commissionPlans.indexOf(fullPlan) >= 0) {
log(
"fullPlan 已存在:"
, fullPlan);
toast(
"该佣金套餐已存在"
);
}
else
{
commissionPlans.push(fullPlan);
alert(
"新增套餐: "
+ fullPlan);
saveCommissionPlans();
}
}
}
iconBtn.callOnClick();
});
}
else
if
(i == 1) {
rawInput(
"佣金套餐管理"
, commissionPlans.join(
", "
))
.then(updatedPlans => {
if
(updatedPlans) {
commissionPlans = updatedPlans.split(
','
).map(plan => plan.trim());
alert(
"佣金套餐已更新: "
+ commissionPlans.join(
", "
));
log(
"当前佣金套餐数组: "
+ commissionPlans.join(
", "
));
saveCommissionPlans();
}
iconBtn.callOnClick();
});
}
else
if
(i == 2) {
setClip(
"佣金计算零失误,支持将[车辆信息][保费信息][计算结果]复制到剪贴板,这个车险计算器太好用了!你也试试吧。https://wwth.lanzouw.com/b00u43sfg"
);
toast(
"已复制分享文本到剪贴板"
);
iconBtn.callOnClick();
}
else
if
(i == 3) {
app.openUrl(
"https://f.wps.cn/g/DciB0UPV"
);
iconBtn.callOnClick();
}
else
if
(i == 4) {
dialogs.build({
title:
"关于本软件"
,
content:
"纯属个人爱好,如有bug或建议,欢迎反馈。\n[获取车辆信息]\n目前仅支持以下APP:\n大家财险:畅销保/搭伙APP"
,
positive:
"确定"
,
positiveColor:
"#007bff"
}).on(
"positive"
,
function
() {
iconBtn.callOnClick();
}).show();
}
});
});
if
(!shouldShowMainPanel) {
w.mainPanel.setVisibility(android.view.View.GONE);
}
centerWindow();
setInterval(
function
() { }, 1000);