From 811cb1715c4939d01fc3b4cd6854e4c2d856374b Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Sun, 17 Aug 2025 15:37:13 +0100 Subject: [PATCH] scanner: support start button customize --- scanner/pages/index/index.js | 29 +++++++++++++++++++++++++++++ scanner/pages/index/index.wxml | 2 +- scanner/project.private.config.json | 4 ++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/scanner/pages/index/index.js b/scanner/pages/index/index.js index 2027a5b..15fdb4d 100644 --- a/scanner/pages/index/index.js +++ b/scanner/pages/index/index.js @@ -17,6 +17,8 @@ Page({ userInfo: {}, content: {}, background_style: '', + scan_button_text: '开启AI验证', + scan_button_style: '', }, goto_link(e) { var link = e.currentTarget.dataset.link; @@ -42,6 +44,7 @@ Page({ this.patch_url([c.video]); this.patch_url(c.icons); this.patch_url(c.static); + this.gen_scan_button_props(c); return c; }, load_content(tenant_id, code) { @@ -129,6 +132,32 @@ Page({ }); }, + gen_scan_button_props: function(content) { + var scan_button = content.scan_button; + var text = '开启AI验证'; + var style = ''; + + if (scan_button) { + if (scan_button.text) { + text = scan_button.text; + } + + var styles = []; + if (scan_button.color) { + styles.push('background-color: ' + scan_button.color); + } + if (scan_button.text_color) { + styles.push('color: ' + scan_button.text_color); + } + style = styles.join('; '); + } + + this.setData({ + scan_button_text: text, + scan_button_style: style, + }); + }, + gen_background_style: function(content) { var bg = content.background; var ret = ''; diff --git a/scanner/pages/index/index.wxml b/scanner/pages/index/index.wxml index a40535c..b9cfa8a 100644 --- a/scanner/pages/index/index.wxml +++ b/scanner/pages/index/index.wxml @@ -23,7 +23,7 @@ loading... {{ item.title }} - +