此模板是参照爱奇艺支付模板
使用 自定义控件 降低代码重复率
有支付宝支付功能
有弹窗模板 仿toast弹窗
/*
* @Author: 造雾者
* @QQ: 1340468168@qq.com
* @Version: Auto.Js Pro
* @LastEditors: 造雾者
* @Date: 2024-09-28 22:27:06
* @Description: 支付UI界面
* 此模板是参照爱奇艺支付模板
* 使用 自定义控件 降低代码重复率
* 有支付宝支付功能 是我自己本人的接口
* 有弹窗模板 仿toast弹窗
*/
"ui";
importClass("androidx.drawerlayout.widget.DrawerLayout")
importClass(android.view.WindowManager);
importClass(android.view.View);
importClass(android.graphics.Color)
importClass(android.app.AlertDialog)
importClass(java.io.FileOutputStream);
importClass(java.io.File);
importClass(java.lang.Runnable);
importClass(android.animation.ObjectAnimator)
importClass(android.animation.PropertyValuesHolder)
importClass(android.animation.ValueAnimator)
importClass(android.animation.AnimatorSet)
importClass(android.view.animation.AccelerateInterpolator)
importClass(android.view.animation.TranslateAnimation)
importClass(android.animation.ObjectAnimator)
importClass(android.animation.TimeInterpolator)
importClass(android.os.Bundle)
importClass(android.view.Window)
importClass(android.view.animation.AccelerateDecelerateInterpolator)
importClass(android.view.animation.AccelerateInterpolator)
importClass(android.view.animation.AnticipateInterpolator)
importClass(android.view.animation.AnticipateOvershootInterpolator)
importClass(android.view.animation.BounceInterpolator)
importClass(android.view.animation.CycleInterpolator)
importClass(android.view.animation.DecelerateInterpolator)
importClass(android.view.animation.LinearInterpolator)
importClass(android.view.animation.OvershootInterpolator)
importClass(android.view.animation.PathInterpolator)
importClass(android.widget.Button)
importClass(android.widget.ImageView)
importClass(android.widget.TextView)
//用户信息
user = {
name: "造雾者",
id: "ZWZ000",
phone: "Q:1340468168",
time_off: "2024-09-27",
}
//套餐信息
payName = "黄金VIP套餐"
//IMG图片数据
img_zfb = "http://gdown.baidu.com/img/0/512_512/4bfcfd18afa6dc68ef84b00302344dbd.png";
img_wx = "https://16570095.s21i.faiusr.com/4/ABUIABAEGAAgh9i35gUogKLn1wUwgAQ4gAQ.png";
img_user = "https://i.postimg.cc/cHPFcdtk/cutcamera1727446757784.png"
const animation_time = 500 //动画时间
//任务栏透明
var window = activity.getWindow();
var decorView = window.getDecorView();
var option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
window.setStatusBarColor(Color.TRANSPARENT);
//确认支付按钮 背景和文字color
pay_bnt = {
s: {
bg: "#e3e3e3",
color: "#ffffff"
},
c: {
bg: "#f2c186",
color: "#6b4128"
}
}
var MyColor = "#3d3d3f" //主题色
const log_back = "@drawable/ic_chevron_left_black_48dp" //返回按钮
var v_meal_bg = []; //套餐view信息
var v_pay_radio = []; //支付方式 单选框值
var order = {};
var remind = {};
//订单支付信息
var data = {
name: user.name,
id: user.id,
goods: payName,
money: "",
pay: "",
date: "",
}
//自定义控件 充值套餐
var setMealLayout = (function() {
util.extend(setMealLayout, ui.Widget);
function setMealLayout() {
ui.Widget.call(this);
this.defineAttr("title", (view, attr, value, defineSetter) => {
view._title_bg.attr("visibility", "visible");
view._title_text.setText(value);
})
this.defineAttr("month", (view, attr, value, defineSetter) => {
view._month.setText(value);
});
this.defineAttr("money", (view, attr, value, defineSetter) => {
view._money.setText(value);
});
this.defineAttr("subtitle", (view, attr, value, defineSetter) => {
view._subtitle.attr("visibility", "visible");
view._subtitle.setText(value);
});
this.defineAttr("remind", (view, attr, value, defineSetter) => {
view._remind_bg.attr("visibility", "visible");
view._remind.setText(value);
});
this.defineAttr("onClick", (view, name, defaultGetter) => {
return this._onClick;
}, (view, name, value, defaultSetter) => {
v_meal_bg[v_meal_bg.length] = view
this._onClick = value;
});
};
setMealLayout.prototype.render = function() {
return (
<frame h="*" w="*" marginRight="10" >
<card
id="_title_bg"
w="auto" h="14"
cardCornerRadius="5dp"
cardBackgroundColor="#3b3b3b"
gravity="center"
foreground="?selectableItemBackground"
visibility="invisible"
>
<text id="_title_text" text="0" margin="5 0 5 0" textSize="10" textStyle="bold" textColor="#dbbb88" />
</card>
<vertical id="_bg" h="*" w="*" marginTop="7" bg="#e3e3e3" >
<vertical id="_bg_1" w="*" h="*" margin="1" bg="#ffffff" gravity="center_horizontal">
<text id="_month" w="auto" text="0个月" marginTop="10" textStyle="bold" textSize="22" />
<horizontal w="auto" h="auto" >
<text text="¥" textColor="#a37655" />
<text id="_money" text="0.00" textColor="#a37655" textSize="32" textStyle="bold" typeface="serif" />
</horizontal>
<text id="_subtitle" w="auto" text="0" textSize="10" visibility="invisible" />
<card id="_remind_bg"
w="auto" h="auto"
marginTop="5" marginBottom="15"
cardCornerRadius="6"
cardBackgroundColor="#dcbb86"
gravity="center"
foreground="?selectableItemBackground"
visibility="invisible" >
<horizontal margin="2 0 2 0">
<img w="10" h="10" margin="5 2 3 0" src="@drawable/ic_thumb_up_black_48dp" tint="#ffffff" />
<text id="_remind" text="0" margin="0 0 5 0" textSize="10" textStyle="bold" textColor="#ffffff" />
</horizontal>
</card>
</vertical>
</vertical>
</frame>
);
};
setMealLayout.prototype.onViewCreated = function(view) {
view.on("click", () => {
if (this._onClick) {
for (let i = 0; i != v_meal_bg.length; i++) {
v_meal_bg[i]._bg.attr("bg", "#e3e3e3");
v_meal_bg[i]._bg_1.attr("alpha", "1");
}
ui.money.setText(view._money.text())
ui.money_s.setText("你已选择" + ui.money_name.text() + view._month.text() + "套餐")
data.money = parseInt(view._month.text())