B2B网络软件

标题: AIWROK软件苹果脚本案例1空白站位[Space]方法 [打印本页]

作者: YYPOST群发软件    时间: 昨天 08:46
标题: AIWROK软件苹果脚本案例1空白站位[Space]方法
AIWROK软件苹果脚本案例1空白站位[Space]方法
AIWROK软件苹果脚本案例1空白站位[Space]方法 B2B网络软件

AIWROK软件苹果脚本案例1空白站位[Space]方法 B2B网络软件

  1. // 🔨🍎UI-空白站位[Space]完整综合示例
  2. // 系统展示Space控件的所有功能和实际应用场景
  3. // 交流QQ群711841924

  4. printl("=== Space控件完整综合示例启动 ===");

  5. // 显示Toast提示
  6. function showToast(message) {
  7.     if (typeof toast !== 'undefined') {
  8.         // 检查toast是否为函数
  9.         if (typeof toast === 'function') {
  10.             toast(message);
  11.         } else if (toast && typeof toast.show === 'function') {
  12.             // 假设toast是一个对象,有show方法
  13.             toast.show(message);
  14.         } else {
  15.             printl("[Toast] " + message);
  16.         }
  17.     } else {
  18.         printl("[Toast] " + message);
  19.     }
  20. }

  21. // 日志记录
  22. function logInteraction(message) {
  23.     printl("[交互] " + message);
  24. }

  25. var vc = new IOSView();
  26. vc.show(function() {
  27.     printl("Space综合示例界面已加载");
  28.    
  29.     // 获取当前视图
  30.     var view = vc.getView();
  31.    
  32.     // 创建主容器
  33.     var mainContainer = new Vertical();
  34.     mainContainer.setSpacing(15);
  35.     mainContainer.setBackgroundColor(245, 245, 245);
  36.    
  37.     // 标题区域
  38.     var titleContainer = new Vertical();
  39.     titleContainer.setAlignment("fill");
  40.     titleContainer.setSpacing(5);
  41.     titleContainer.setBackgroundColor(0, 122, 255);
  42.    
  43.     var titleLabel = new Label();
  44.     titleLabel.setText("🔨 Space控件完整综合示例");
  45.     titleLabel.setFontSize(18.0);
  46.     titleLabel.setTextColor(255, 255, 255);
  47.     titleLabel.setTextAlignment("center");
  48.     titleLabel.setWidth(320); // 设置固定宽度以确保背景填充
  49.    
  50.     var subtitleLabel = new Label();
  51.     subtitleLabel.setText("空白站位控件的全方位应用");
  52.     subtitleLabel.setFontSize(12.0);
  53.     subtitleLabel.setTextColor(255, 255, 255);
  54.     subtitleLabel.setTextAlignment("center");
  55.     subtitleLabel.setWidth(320); // 设置固定宽度以确保背景填充
  56.    
  57.     titleContainer.addView(titleLabel);
  58.     titleContainer.addView(subtitleLabel);
  59.     mainContainer.addView(titleContainer);
  60.    
  61.     // Space核心方法演示区域
  62.     var coreDemoContainer = new Vertical();
  63.     coreDemoContainer.setBackgroundColor(255, 255, 255);
  64.     coreDemoContainer.setSpacing(15);
  65.    
  66.     var coreTitle = new Label();
  67.     coreTitle.setText("🎯 Space核心方法演示");
  68.     coreTitle.setFontSize(16.0);
  69.     coreTitle.setTextColor(0, 0, 0);
  70.     coreTitle.setTextAlignment("center");
  71.     coreDemoContainer.addView(coreTitle);
  72.    
  73.     // 方法1:setWidth设置宽度
  74.     var widthDemo = new Vertical();
  75.     widthDemo.setSpacing(8);
  76.    
  77.     var widthLabel = new Label();
  78.     widthLabel.setText("📏 setWidth - 设置宽度");
  79.     widthLabel.setFontSize(14.0);
  80.     widthLabel.setTextColor(0, 122, 255);
  81.     widthDemo.addView(widthLabel);
  82.    
  83.     var widthDesc = new Label();
  84.     widthDesc.setText("创建不同宽度的空白占位,用于水平布局调整");
  85.     widthDesc.setFontSize(12.0);
  86.     widthDesc.setTextColor(100, 100, 100);
  87.     widthDemo.addView(widthDesc);
  88.    
  89.     var widthContainer = new Horizontal();
  90.     widthContainer.setSpacing(5);
  91.     widthContainer.setBackgroundColor(240, 240, 240);
  92.    
  93.     var wLabel1 = new Label();
  94.     wLabel1.setText("左");
  95.     wLabel1.setFontSize(12.0);
  96.     wLabel1.setBackgroundColor(0, 122, 255);
  97.     wLabel1.setTextColor(255, 255, 255);
  98.    
  99.     var space1 = new Space();
  100.     space1.setWidth(30.0);
  101.     space1.setBackgroundColor(200, 200, 200);
  102.    
  103.     var wLabel2 = new Label();
  104.     wLabel2.setText("中");
  105.     wLabel2.setFontSize(12.0);
  106.     wLabel2.setBackgroundColor(52, 199, 89);
  107.     wLabel2.setTextColor(255, 255, 255);
  108.    
  109.     var space2 = new Space();
  110.     space2.setWidth(60.0);
  111.     space2.setBackgroundColor(200, 200, 200);
  112.    
  113.     var wLabel3 = new Label();
  114.     wLabel3.setText("右");
  115.     wLabel3.setFontSize(12.0);
  116.     wLabel3.setBackgroundColor(255, 149, 0);
  117.     wLabel3.setTextColor(255, 255, 255);
  118.    
  119.     widthContainer.addView(wLabel1);
  120.     widthContainer.addView(space1);
  121.     widthContainer.addView(wLabel2);
  122.     widthContainer.addView(space2);
  123.     widthContainer.addView(wLabel3);
  124.     widthDemo.addView(widthContainer);
  125.     coreDemoContainer.addView(widthDemo);
  126.    
  127.     // 分割线
  128.     var separator1 = new Space();
  129.     separator1.setHeight(10.0);
  130.     coreDemoContainer.addView(separator1);
  131.    
  132.     // 方法2:setHeight设置高度
  133.     var heightDemo = new Vertical();
  134.     heightDemo.setSpacing(8);
  135.    
  136.     var heightLabel = new Label();
  137.     heightLabel.setText("📏 setHeight - 设置高度");
  138.     heightLabel.setFontSize(14.0);
  139.     heightLabel.setTextColor(0, 122, 255);
  140.     heightDemo.addView(heightLabel);
  141.    
  142.     var heightDesc = new Label();
  143.     heightDesc.setText("创建不同高度的空白占位,用于垂直布局调整");
  144.     heightDesc.setFontSize(12.0);
  145.     heightDesc.setTextColor(100, 100, 100);
  146.     heightDemo.addView(heightDesc);
  147.    
  148.     var heightContainer = new Vertical();
  149.     heightContainer.setBackgroundColor(240, 240, 240);
  150.    
  151.     var hLabel1 = new Label();
  152.     hLabel1.setText("上");
  153.     hLabel1.setFontSize(12.0);
  154.     hLabel1.setBackgroundColor(0, 122, 255);
  155.     hLabel1.setTextColor(255, 255, 255);
  156.     hLabel1.setTextAlignment("center");
  157.    
  158.     var space3 = new Space();
  159.     space3.setHeight(20.0);
  160.     space3.setBackgroundColor(200, 200, 200);
  161.    
  162.     var hLabel2 = new Label();
  163.     hLabel2.setText("中");
  164.     hLabel2.setFontSize(12.0);
  165.     hLabel2.setBackgroundColor(52, 199, 89);
  166.     hLabel2.setTextColor(255, 255, 255);
  167.     hLabel2.setTextAlignment("center");
  168.    
  169.     var space4 = new Space();
  170.     space4.setHeight(40.0);
  171.     space4.setBackgroundColor(200, 200, 200);
  172.    
  173.     var hLabel3 = new Label();
  174.     hLabel3.setText("下");
  175.     hLabel3.setFontSize(12.0);
  176.     hLabel3.setBackgroundColor(255, 149, 0);
  177.     hLabel3.setTextColor(255, 255, 255);
  178.     hLabel3.setTextAlignment("center");
  179.    
  180.     heightContainer.addView(hLabel1);
  181.     heightContainer.addView(space3);
  182.     heightContainer.addView(hLabel2);
  183.     heightContainer.addView(space4);
  184.     heightContainer.addView(hLabel3);
  185.     heightDemo.addView(heightContainer);
  186.     coreDemoContainer.addView(heightDemo);
  187.    
  188.     // 分割线
  189.     var separator2 = new Space();
  190.     separator2.setHeight(10.0);
  191.     coreDemoContainer.addView(separator2);
  192.    
  193.     // 方法3:setBackgroundColor设置背景颜色
  194.     var colorDemo = new Vertical();
  195.     colorDemo.setSpacing(8);
  196.    
  197.     var colorLabel = new Label();
  198.     colorLabel.setText("🎨 setBackgroundColor - 设置背景颜色");
  199.     colorLabel.setFontSize(14.0);
  200.     colorLabel.setTextColor(0, 122, 255);
  201.     colorDemo.addView(colorLabel);
  202.    
  203.     var colorDesc = new Label();
  204.     colorDesc.setText("为空白占位设置背景颜色,用于视觉分隔或装饰");
  205.     colorDesc.setFontSize(12.0);
  206.     colorDesc.setTextColor(100, 100, 100);
  207.     colorDemo.addView(colorDesc);
  208.    
  209.     var colorContainer = new Horizontal();
  210.     colorContainer.setSpacing(10);
  211.    
  212.     var space5 = new Space();
  213.     space5.setWidth(50.0);
  214.     space5.setHeight(50.0);
  215.     space5.setBackgroundColor(255, 0, 0);
  216.    
  217.     var space6 = new Space();
  218.     space6.setWidth(50.0);
  219.     space6.setHeight(50.0);
  220.     space6.setBackgroundColor(0, 255, 0);
  221.    
  222.     var space7 = new Space();
  223.     space7.setWidth(50.0);
  224.     space7.setHeight(50.0);
  225.     space7.setBackgroundColor(0, 0, 255);
  226.    
  227.     var space8 = new Space();
  228.     space8.setWidth(50.0);
  229.     space8.setHeight(50.0);
  230.     space8.setBackgroundColor(255, 255, 0);
  231.    
  232.     colorContainer.addView(space5);
  233.     colorContainer.addView(space6);
  234.     colorContainer.addView(space7);
  235.     colorContainer.addView(space8);
  236.     colorDemo.addView(colorContainer);
  237.     coreDemoContainer.addView(colorDemo);
  238.    
  239.     mainContainer.addView(coreDemoContainer);
  240.    
  241.     // 实际应用场景
  242.     var applicationContainer = new Vertical();
  243.     applicationContainer.setBackgroundColor(255, 255, 255);
  244.     applicationContainer.setSpacing(15);
  245.    
  246.     var appTitle = new Label();
  247.     appTitle.setText("💼 Space实际应用场景");
  248.     appTitle.setFontSize(16.0);
  249.     appTitle.setTextColor(0, 0, 0);
  250.     appTitle.setTextAlignment("center");
  251.     applicationContainer.addView(appTitle);
  252.    
  253.     // 场景1:表单布局
  254.     var formContainer = new Vertical();
  255.     formContainer.setSpacing(10);
  256.    
  257.     var formTitle = new Label();
  258.     formTitle.setText("📋 表单布局示例");
  259.     formTitle.setFontSize(14.0);
  260.     formTitle.setTextColor(0, 122, 255);
  261.     formContainer.addView(formTitle);
  262.    
  263.     // 姓名输入行
  264.     var nameRow = new Horizontal();
  265.     nameRow.setSpacing(10);
  266.    
  267.     var nameLabel = new Label();
  268.     nameLabel.setText("姓名:");
  269.     nameLabel.setWidth(60);
  270.     nameLabel.setTextColor(0, 0, 0);
  271.    
  272.     var nameInput = new Label();
  273.     nameInput.setText("请输入姓名");
  274.     nameInput.setBackgroundColor(240, 240, 240);
  275.    
  276.     nameRow.addView(nameLabel);
  277.     nameRow.addView(nameInput);
  278.     formContainer.addView(nameRow);
  279.    
  280.     // 垂直间距
  281.     var formSpace1 = new Space();
  282.     formSpace1.setHeight(10.0);
  283.     formContainer.addView(formSpace1);
  284.    
  285.     // 年龄输入行
  286.     var ageRow = new Horizontal();
  287.     ageRow.setSpacing(10);
  288.    
  289.     var ageLabel = new Label();
  290.     ageLabel.setText("年龄:");
  291.     ageLabel.setWidth(60);
  292.     ageLabel.setTextColor(0, 0, 0);
  293.    
  294.     var ageInput = new Label();
  295.     ageInput.setText("请输入年龄");
  296.     ageInput.setBackgroundColor(240, 240, 240);
  297.    
  298.     ageRow.addView(ageLabel);
  299.     ageRow.addView(ageInput);
  300.     formContainer.addView(ageRow);
  301.    
  302.     // 垂直间距
  303.     var formSpace2 = new Space();
  304.     formSpace2.setHeight(10.0);
  305.     formContainer.addView(formSpace2);
  306.    
  307.     // 邮箱输入行
  308.     var emailRow = new Horizontal();
  309.     emailRow.setSpacing(10);
  310.    
  311.     var emailLabel = new Label();
  312.     emailLabel.setText("邮箱:");
  313.     emailLabel.setWidth(60);
  314.     emailLabel.setTextColor(0, 0, 0);
  315.    
  316.     var emailInput = new Label();
  317.     emailInput.setText("请输入邮箱");
  318.     emailInput.setBackgroundColor(240, 240, 240);
  319.    
  320.     emailRow.addView(emailLabel);
  321.     emailRow.addView(emailInput);
  322.     formContainer.addView(emailRow);
  323.    
  324.     applicationContainer.addView(formContainer);
  325.    
  326.     // 场景2:卡片布局
  327.     var cardContainer = new Vertical();
  328.     cardContainer.setSpacing(10);
  329.    
  330.     var cardTitle = new Label();
  331.     cardTitle.setText("📄 卡片布局示例");
  332.     cardTitle.setFontSize(14.0);
  333.     cardTitle.setTextColor(0, 122, 255);
  334.     cardContainer.addView(cardTitle);
  335.    
  336.     var card = new Vertical();
  337.     card.setBackgroundColor(255, 255, 255);
  338.     card.setSpacing(10);
  339.    
  340.     var cardHeader = new Horizontal();
  341.     cardHeader.setSpacing(10);
  342.    
  343.     var cardIcon = new Label();
  344.     cardIcon.setText("📱");
  345.     cardIcon.setFontSize(24.0);
  346.    
  347.     var cardInfo = new Vertical();
  348.     cardInfo.setSpacing(2);
  349.    
  350.     var cardName = new Label();
  351.     cardName.setText("产品名称");
  352.     cardName.setFontSize(16.0);
  353.     cardName.setTextColor(0, 0, 0);
  354.    
  355.     var cardDesc = new Label();
  356.     cardDesc.setText("这是一个产品描述");
  357.     cardDesc.setFontSize(12.0);
  358.     cardDesc.setTextColor(100, 100, 100);
  359.    
  360.     cardInfo.addView(cardName);
  361.     cardInfo.addView(cardDesc);
  362.     cardHeader.addView(cardIcon);
  363.     cardHeader.addView(cardInfo);
  364.     card.addView(cardHeader);
  365.    
  366.     // 卡片内容
  367.     var cardContent = new Label();
  368.     cardContent.setText("卡片内容区域,展示详细信息...");
  369.     cardContent.setFontSize(14.0);
  370.     cardContent.setTextColor(50, 50, 50);
  371.     card.addView(cardContent);
  372.    
  373.     // 卡片底部
  374.     var cardFooter = new Horizontal();
  375.     cardFooter.setSpacing(10);
  376.    
  377.     var priceLabel = new Label();
  378.     priceLabel.setText("¥99.00");
  379.     priceLabel.setFontSize(16.0);
  380.     priceLabel.setTextColor(255, 59, 48);
  381.    
  382.     var buyButton = new Button();
  383.     buyButton.setText("购买");
  384.     buyButton.setColor(0, 122, 255);
  385.     buyButton.setTextColor(255, 255, 255);
  386.     buyButton.setWidth(80);
  387.     buyButton.setHeight(30);
  388.    
  389.     // 使用Space创建间距
  390.     var footerSpace = new Space();
  391.    
  392.     cardFooter.addView(priceLabel);
  393.     cardFooter.addView(footerSpace);
  394.     cardFooter.addView(buyButton);
  395.     card.addView(cardFooter);
  396.    
  397.     cardContainer.addView(card);
  398.     applicationContainer.addView(cardContainer);
  399.    
  400.     // 场景3:导航栏布局
  401.     var navContainer = new Vertical();
  402.     navContainer.setSpacing(10);
  403.    
  404.     var navTitle = new Label();
  405.     navTitle.setText("🧭 导航栏布局示例");
  406.     navTitle.setFontSize(14.0);
  407.     navTitle.setTextColor(0, 122, 255);
  408.     navContainer.addView(navTitle);
  409.    
  410.     var navBar = new Horizontal();
  411.     navBar.setSpacing(10);
  412.     navBar.setBackgroundColor(240, 240, 240);
  413.    
  414.     var backButton = new Button();
  415.     backButton.setText("返回");
  416.     backButton.setColor(0, 122, 255);
  417.     backButton.setTextColor(255, 255, 255);
  418.     backButton.setWidth(80);
  419.     backButton.setHeight(30);
  420.    
  421.     var navSpace = new Space();
  422.    
  423.     var titleButton = new Button();
  424.     titleButton.setText("首页");
  425.     titleButton.setColor(52, 199, 89);
  426.     titleButton.setTextColor(255, 255, 255);
  427.     titleButton.setWidth(80);
  428.     titleButton.setHeight(30);
  429.    
  430.     var menuButton = new Button();
  431.     menuButton.setText("菜单");
  432.     menuButton.setColor(255, 149, 0);
  433.     menuButton.setTextColor(255, 255, 255);
  434.     menuButton.setWidth(80);
  435.     menuButton.setHeight(30);
  436.    
  437.     navBar.addView(backButton);
  438.     navBar.addView(navSpace);
  439.     navBar.addView(titleButton);
  440.     navBar.addView(menuButton);
  441.     navContainer.addView(navBar);
  442.     applicationContainer.addView(navContainer);
  443.    
  444.     mainContainer.addView(applicationContainer);
  445.    
  446.     // 交互功能演示
  447.     var interactionContainer = new Vertical();
  448.     interactionContainer.setBackgroundColor(236, 245, 255);
  449.     interactionContainer.setSpacing(15);
  450.    
  451.     var interactionTitle = new Label();
  452.     interactionTitle.setText("🔄 交互功能演示");
  453.     interactionTitle.setFontSize(16.0);
  454.     interactionTitle.setTextColor(0, 122, 255);
  455.     interactionContainer.addView(interactionTitle);
  456.    
  457.     var interactionDesc = new Label();
  458.     interactionDesc.setText("点击下方按钮体验Space控件的动态效果");
  459.     interactionDesc.setFontSize(12.0);
  460.     interactionDesc.setTextColor(100, 100, 100);
  461.     interactionContainer.addView(interactionDesc);
  462.    
  463.     var dynamicContainer = new Vertical();
  464.     dynamicContainer.setSpacing(10);
  465.    
  466.     var dynamicSpace = new Space();
  467.     dynamicSpace.setHeight(50.0);
  468.     dynamicSpace.setBackgroundColor(200, 200, 200);
  469.     dynamicContainer.addView(dynamicSpace);
  470.    
  471.     var controlButtons = new Horizontal();
  472.     controlButtons.setSpacing(10);
  473.     controlButtons.setAlignment("center");
  474.    
  475.     var increaseButton = new Button();
  476.     increaseButton.setText("增加高度");
  477.     increaseButton.setColor(0, 122, 255);
  478.     increaseButton.setTextColor(255, 255, 255);
  479.     increaseButton.setWidth(100);
  480.     increaseButton.setHeight(35);
  481.    
  482.     var decreaseButton = new Button();
  483.     decreaseButton.setText("减少高度");
  484.     decreaseButton.setColor(255, 59, 48);
  485.     decreaseButton.setTextColor(255, 255, 255);
  486.     decreaseButton.setWidth(100);
  487.     decreaseButton.setHeight(35);
  488.    
  489.     var changeColorButton = new Button();
  490.     changeColorButton.setText("改变颜色");
  491.     changeColorButton.setColor(52, 199, 89);
  492.     changeColorButton.setTextColor(255, 255, 255);
  493.     changeColorButton.setWidth(100);
  494.     changeColorButton.setHeight(35);
  495.    
  496.     controlButtons.addView(increaseButton);
  497.     controlButtons.addView(decreaseButton);
  498.     controlButtons.addView(changeColorButton);
  499.     dynamicContainer.addView(controlButtons);
  500.     interactionContainer.addView(dynamicContainer);
  501.     mainContainer.addView(interactionContainer);
  502.    
  503.     // 控件信息区域
  504.     var infoContainer = new Vertical();
  505.     infoContainer.setBackgroundColor(255, 255, 255);
  506.     infoContainer.setSpacing(8);
  507.    
  508.     var infoTitle = new Label();
  509.     infoTitle.setText("ℹ️ Space控件说明");
  510.     infoTitle.setFontSize(16.0);
  511.     infoTitle.setTextColor(0, 122, 255);
  512.     infoContainer.addView(infoTitle);
  513.    
  514.     var info1 = new Label();
  515.     info1.setText("• Space控件用于创建空白占位区域");
  516.     info1.setFontSize(12.0);
  517.     info1.setTextColor(52, 58, 64);
  518.     infoContainer.addView(info1);
  519.    
  520.     var info2 = new Label();
  521.     info2.setText("• 核心方法:setWidth()、setHeight()、setBackgroundColor()");
  522.     info2.setFontSize(12.0);
  523.     info2.setTextColor(52, 58, 64);
  524.     infoContainer.addView(info2);
  525.    
  526.     var info3 = new Label();
  527.     info3.setText("• 应用场景:布局间距、视觉分隔、响应式布局");
  528.     info3.setFontSize(12.0);
  529.     info3.setTextColor(52, 58, 64);
  530.     infoContainer.addView(info3);
  531.    
  532.     var info4 = new Label();
  533.     info4.setText("• 优势:轻量级、灵活、不占用系统资源");
  534.     info4.setFontSize(12.0);
  535.     info4.setTextColor(52, 58, 64);
  536.     infoContainer.addView(info4);
  537.    
  538.     mainContainer.addView(infoContainer);
  539.    
  540.     // 底部操作按钮
  541.     var bottomContainer = new Horizontal();
  542.     bottomContainer.setSpacing(10);
  543.     bottomContainer.setAlignment("center");
  544.    
  545.     var saveButton = new Button();
  546.     saveButton.setText("保存示例");
  547.     saveButton.setColor(52, 199, 89);
  548.     saveButton.setTextColor(255, 255, 255);
  549.     saveButton.setHeight(40);
  550.    
  551.     var resetButton = new Button();
  552.     resetButton.setText("重置示例");
  553.     resetButton.setColor(255, 149, 0);
  554.     resetButton.setTextColor(255, 255, 255);
  555.     resetButton.setHeight(40);
  556.    
  557.     var exitButton = new Button();
  558.     exitButton.setText("退出示例");
  559.     exitButton.setColor(255, 59, 48);
  560.     exitButton.setTextColor(255, 255, 255);
  561.     exitButton.setHeight(40);
  562.    
  563.     bottomContainer.addView(saveButton);
  564.     bottomContainer.addView(resetButton);
  565.     bottomContainer.addView(exitButton);
  566.     mainContainer.addView(bottomContainer);
  567.    
  568.     // 添加到主视图
  569.     view.addView(mainContainer);
  570.    
  571.     printl("Space综合示例界面构建完成");
  572.    
  573.     // 绑定事件处理
  574.     // 表单输入点击事件 - 注释掉Label的onClick事件,因为Label可能不支持此方法
  575.     /*
  576.     nameInput.onClick(function() {
  577.         nameInput.setText("张三");
  578.         nameInput.setBackgroundColor(200, 230, 255);
  579.         showToast("姓名已自动填充");
  580.         logInteraction("点击了姓名输入框,自动填充为'张三'");
  581.     });
  582.    
  583.     ageInput.onClick(function() {
  584.         ageInput.setText("25");
  585.         ageInput.setBackgroundColor(200, 230, 255);
  586.         showToast("年龄已自动填充");
  587.         logInteraction("点击了年龄输入框,自动填充为'25'");
  588.     });
  589.    
  590.     emailInput.onClick(function() {
  591.         emailInput.setText("zhangsan@example.com");
  592.         emailInput.setBackgroundColor(200, 230, 255);
  593.         showToast("邮箱已自动填充");
  594.         logInteraction("点击了邮箱输入框,自动填充为'zhangsan@example.com'");
  595.     });
  596.     */
  597.    
  598.     // 卡片购买按钮点击事件
  599.     buyButton.onClick(function() {
  600.         showToast("购买成功!");
  601.         logInteraction("点击了购买按钮");
  602.     });
  603.    
  604.     // 导航栏按钮点击事件
  605.     backButton.onClick(function() {
  606.         showToast("返回上一页");
  607.         logInteraction("点击了返回按钮");
  608.     });
  609.    
  610.     titleButton.onClick(function() {
  611.         showToast("跳转到首页");
  612.         logInteraction("点击了首页按钮");
  613.     });
  614.    
  615.     menuButton.onClick(function() {
  616.         showToast("打开菜单");
  617.         logInteraction("点击了菜单按钮");
  618.     });
  619.    
  620.     // 动态效果按钮点击事件
  621.     var currentHeight = 50;
  622.     increaseButton.onClick(function() {
  623.         currentHeight += 20;
  624.         dynamicSpace.setHeight(currentHeight);
  625.         showToast("Space高度增加到:" + currentHeight + "px");
  626.         logInteraction("点击了增加高度按钮,当前高度:" + currentHeight + "px");
  627.     });
  628.    
  629.     decreaseButton.onClick(function() {
  630.         if (currentHeight > 20) {
  631.             currentHeight -= 20;
  632.             dynamicSpace.setHeight(currentHeight);
  633.             showToast("Space高度减少到:" + currentHeight + "px");
  634.             logInteraction("点击了减少高度按钮,当前高度:" + currentHeight + "px");
  635.         } else {
  636.             showToast("高度已达到最小值");
  637.             logInteraction("点击了减少高度按钮,已达到最小值");
  638.         }
  639.     });
  640.    
  641.     var colors = [[255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0], [255, 0, 255], [0, 255, 255]];
  642.     var colorIndex = 0;
  643.     changeColorButton.onClick(function() {
  644.         colorIndex = (colorIndex + 1) % colors.length;
  645.         var color = colors[colorIndex];
  646.         dynamicSpace.setBackgroundColor(color[0], color[1], color[2]);
  647.         showToast("Space颜色已改变");
  648.         logInteraction("点击了改变颜色按钮,当前颜色:RGB(" + color[0] + "," + color[1] + "," + color[2] + ")");
  649.     });
  650.    
  651.     // 底部按钮点击事件
  652.     saveButton.onClick(function() {
  653.         showToast("示例已保存");
  654.         logInteraction("点击了保存示例按钮");
  655.     });
  656.    
  657.     resetButton.onClick(function() {
  658.         // 重置表单
  659.         nameInput.setText("请输入姓名");
  660.         nameInput.setBackgroundColor(240, 240, 240);
  661.         ageInput.setText("请输入年龄");
  662.         ageInput.setBackgroundColor(240, 240, 240);
  663.         emailInput.setText("请输入邮箱");
  664.         emailInput.setBackgroundColor(240, 240, 240);
  665.         
  666.         // 重置动态Space
  667.         currentHeight = 50;
  668.         dynamicSpace.setHeight(currentHeight);
  669.         dynamicSpace.setBackgroundColor(200, 200, 200);
  670.         colorIndex = 0;
  671.         
  672.         showToast("示例已重置");
  673.         logInteraction("点击了重置示例按钮");
  674.     });
  675.    
  676.     exitButton.onClick(function() {
  677.         showToast("退出示例");
  678.         logInteraction("点击了退出示例按钮");
  679.         vc.dismiss();
  680.     });
  681. });

  682. printl("Space控件完整综合示例已启动");
复制代码









欢迎光临 B2B网络软件 (http://bbs.niubt.cn/) Powered by Discuz! X3.2