用css绘制收银键盘

最近需求说需要自己弄个收银键盘,于是乎直接上手搓

主要基于Vue3写的,主要是CSS

<template><view class="container"><view class="info"><image class="img" src="" mode=""></image><text class="name">达达</text></view><view class="inputBox"><view class="concent flex flex_just_sb flex_items_c"><view class="insideBox"><text class="title">付款金额</text><view class="price"><text class="value">¥</text><text class="number">{{payMuch}}</text></view></view></view></view><div class="btn"><view class="btn_box"><view class="line_one"><button @click="_handleKeyPress('1')" type="primary">1</button><button @click="_handleKeyPress('2')" type="primary">2</button><button @click="_handleKeyPress('3')" type="primary">3</button><button @click="_handleKeyPress('D')" type="primary">清除</button></view><view class="btn_bottom"><view class="line_two"><view class="line-left"><view class="line_box"><view class="line_two"><button @click="_handleKeyPress('4')" type="primary">4</button><button @click="_handleKeyPress('5')" type="primary">5</button><button @click="_handleKeyPress('6')" type="primary">6</button></view><view class="line_three"><button @click="_handleKeyPress('7')" type="primary">7</button><button @click="_handleKeyPress('8')" type="primary">8</button><button @click="_handleKeyPress('9')" type="primary">9</button></view><view class="line_four"><button type="primary"></button><button @click="_handleKeyPress('0')" type="primary">0</button><button @click="_handleKeyPress('.')" type="primary">.</button></view></view></view><view class="line-right"><button type="primary" @click="_handleKeyPress('S')">优惠<br />买单</button></view></view></view></view></div></view>
</template><script setup>import {reactive,ref} from 'vue';import {preferentialPay} from '@/api/store'import {onLoad,onShow} from '@dcloudio/uni-app'const payMuch = ref('0')const payPrice = ref(0)const confirmOrderStatus = ref(false)const isdisabled = ref(false)//处理按键function _handleKeyPress(num) {//不同按键处理逻辑// -1 代表无效按键,直接返回if (num == -1) return false;switch (String(num)) {//小数点case ".":_handleDecimalPoint();break;//删除键case "D":_handleDeleteKey();break;//确认键case "S":_handleConfirmKey();break;default:_handleNumberKey(num);break;}}//处理数字function _handleNumberKey(num) {let S = payMuch.value;//如果有小数点且小数点位数不小于2if (S.indexOf(".") > -1 && S.substring(S.indexOf(".") + 1).length < 2) payMuch.value = S + num;//没有小数点if (!(S.indexOf(".") > -1)) {//如果第一位是0,只能输入小数点if (num == 0 && S.length == 0) payMuch.value = "0.";else {if (S.length && Number(S.charAt(0)) === 0) {payMuch.value = num;return;}payMuch.value = S + num;}}}function _handleConfirmKey() {let S = payMuch.value;//未输入if (!S.length || Number(S) === 0) {showTotal("您目前未输入!");return false;}//将 8. 这种转换成 8.00if (S.indexOf(".") > -1 && S.indexOf(".") === S.length - 1) S = Number(S.substring(0, S.length - 1)).toFixed(2);//保留两位S = Number(S).toFixed(2);confirmOrder();}//处理小数点函数function _handleDecimalPoint() {//如果包含小数点,直接返回if (payMuch.value.indexOf(".") > -1) return false;//如果小数点是第一位,补0if (!payMuch.value.length) payMuch.value = "0.";//如果不是,添加一个小数点else payMuch.value = payMuch.value + ".";}//处理删除键function _handleDeleteKey() {let S = payMuch.value;//如果没有输入,直接返回if (S.length <= 1) return (payMuch.value = "0");//否则删除最后一个payMuch.value = S.substring(0, S.length - 1);}async function toPayMethods(){const {data,result,msg} = await preferentialPay({// 处理你需要处理的支付逻辑})}function showTotal(e) {uni.showToast({title: e,icon: 'none',duration: 2000,mask: true})}function confirmOrder() {var val = payMuch.value;if (val && val > 0) {payPrice.value = val;toPayMethods();confirmOrderStatus.value = true;isdisabled.value = true;} else {showTotal('请输入正确的付款金额!')confirmOrderStatus.value = false;isdisabled.value = false;}}
</script><style lang="scss" scoped>.container {.info {display: flex;align-items: center;justify-content: center;padding-top: 40upx;.img {background: greenyellow;width: 80upx;height: 80upx;border-radius: 50%;}.name {font-weight: bold;font-size: 32upx;color: #323233;line-height: 48upx;padding-left: 20upx;}}.inputBox {// margin-top: 20upx;width: 90vw;min-height: 100upx;background: #fff;border: 0.0625upx solid #999;// border-radius: 0.375rem;margin: 40upx auto;padding: 0 12upx;line-height: 100upx;.concent {.insideBox {display: flex;align-items: center;justify-content: space-between;width: 100%;.title {// display: flex;width: 160upx;font-weight: 500;font-size: 40upx;color: #323233;line-height: 36upx;text-align: right;opacity: 0.6;}.price {display: flex;align-items: flex-end;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;.value {font-weight: 500;font-size: 30upx;color: #323233;text-align: left;}.number {font-weight: 500;font-size: 48upx;color: #323233;text-align: left;&:last-child {white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 450upx;}}}}}}.btn {background: #fff;position: fixed;bottom: 0;.btn_box {border-top: solid 0.0625rem #ccc;.line_one {display: flex;button {width: 5.8125rem;// height: 3.75rem;font-size: 2rem;background: none;color: #333;border-radius: 0;padding: 0;border: none;border-right: solid 0.0625rem #ccc;}button:last-child {border-right: none;}}.btn_bottom {.line_two {display: flex;.line-left {.line_box {.line_two {display: flex;border-top: solid 0.0625rem #ccc;button {width: 5.8rem;// height: 3.75rem;font-size: 2rem;background: none;color: #333;border-radius: 0;padding: 0;border: none;border-right: solid 0.0625rem #ccc;}button:last-child {border-right: none;}}.line_three {border-top: solid 0.0625rem #ccc;display: flex;button {width: 5.8rem;// height: 3.75rem;font-size: 2rem;background: none;color: #333;border-radius: 0;padding: 0;border: none;border-right: solid 0.0625rem #ccc;}button:last-child {border-right: none;}}.line_four {display: flex;border-top: solid 0.0625rem #ccc;button {width: 5.8rem;// height: 3.75rem;font-size: 2rem;background: none;color: #333;border-radius: 0;padding: 0;border: none;border-right: solid 0.0625rem #ccc;}button:last-child {border-right: none;}}}}.line-right {button {width: 6rem;height: 100%;padding: 0;border-radius: 0;font-size: 1.375rem;line-height: 6.375rem;}}}}}}}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/36473.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C# | 超简单CSV表格读写操作(轻松将数据保存到CSV,并支持读取还原)

C# | 超简单CSV表格读写操作&#xff08;轻松将数据保存到CSV&#xff0c;并支持读取还原&#xff09; 文章目录 C# | 超简单CSV表格读写操作&#xff08;轻松将数据保存到CSV&#xff0c;并支持读取还原&#xff09;一、上位机开发中的CSV应用背景二、CSV读写实战教学1. 基本对…

14:00面试,15:00就出来了,问的问题过于变态了。。。

从小厂出来&#xff0c;没想到在另一家公司又寄了。 到这家公司开始上班&#xff0c;加班是每天必不可少的&#xff0c;看在钱给的比较多的份上&#xff0c;就不太计较了。没想到3月一纸通知&#xff0c;所有人不准加班&#xff0c;加班费不仅没有了&#xff0c;薪资还要降40%…

友思特应用 | 行业首创:基于深度学习视觉平台的AI驱动轮胎检测自动化

导读 全球领先的轮胎制造商 NEXEN TIRE 在其轮胎生产检测过程中使用了基于友思特伙伴Neurocle开发的AI深度学习视觉平台&#xff0c;实现缺陷检测率高达99.96%&#xff0c;是该行业首个使用AI平台技术推动缺陷检测自动化流程的企业。 将AI应用从轮胎开发扩展到制造过程 2024年…

09 python函数(上)

一、函数的介绍 什么是函数&#xff1f; 函数的诞生为了解决两个问题&#xff1a;可读性、重复性。使用函数可以将一些代码放在一起成为一个功能&#xff0c;方便调用&#xff0c;出现了函数也方便用户阅读代码。 函数是组织好的&#xff0c;可重复使用的&#xff0c;用来实现…

Androidstudio出现警告warning:意外的元素

这些警告信息通常与 Android SDK 或系统镜像的配置文件有关&#xff0c;可能是由于 SDK 工具或系统镜像的版本不兼容或配置文件格式发生了变化。以下是解决这些警告的步骤&#xff1a; 1. 更新 Android SDK 工具 确保你使用的是最新版本的 Android SDK 工具&#xff1a; 打开…

性能调优疑难问题解决-completablefuture造成oom

一 案例 1.1 背景描述 对公交易服务使用了热点资源组件&#xff0c;出现了在高并发下触发线程池资源耗尽&#xff0c;任务堆积&#xff1b;出现内存oom。 1.2 模拟场景 public class OrderSystemCrash {// 模拟高并发场景public static void main(String[] args) {for (int…

HW华为流程管理体系精髓提炼华为流程运营体系(124页PPT)(文末有下载方式)

资料解读&#xff1a;HW华为流程管理体系精髓提炼华为流程运营体系&#xff08;124页PPT&#xff09; 详细资料请看本解读文章的最后内容。 华为作为全球领先的科技公司&#xff0c;其流程管理体系的构建与运营是其成功的关键之一。本文将从华为流程管理体系的核心理念、构建…

Python的内置函数 - min()

知识点1 在 Python 中&#xff0c;min() 和 max() 是两个非常实用的内置函数&#xff0c;分别用于找出可迭代对象中的最小值和最大值。 基本语法 min(iterable, *[, key, default]) min(arg1, arg2, *args, *[, key]) iterable&#xff1a;可迭代对象&#xff0c;如列表list…

【企业微信自建应用-前端篇】企业微信自建应用开发流程详细介绍

前言 最近接到需求&#xff0c;需要我在企业微信端自建一个应用&#xff0c;用来接受PC端派发的工单&#xff0c;告警&#xff0c;公告等内容。 这里写一个帖子汇总一下我经历的全流程开发&#xff0c;当然这是基础的流程啊。因为功能要求也不高。后面如果开发更多的东西再补充…

从毛坯房到梦想智家一步到位?三问赵瑞海读懂“曲美整家”

一年之计在于春&#xff0c;阳春三月&#xff0c;万物复苏&#xff01;在这充满生机的时节&#xff0c;众多家居企业也争先创新、变革&#xff01;走过32个春秋的知名家居品牌曲美家居也再一次破局、创变&#xff01;3月15日&#xff0c;“曲美家居 整家焕新发布会”在曲美家居…

【IDEA中配置Maven国内镜像源】

1. 为什么需要配置国内镜像源&#xff1f; 首先&#xff0c;Maven本身的工作原理是通过从仓库中下载依赖包。而这些依赖通常来自于 Maven中央仓库&#xff08;位于国外&#xff09;&#xff0c;由于网络原因&#xff0c;我们在国内访问这些远程仓库的速度比较慢&#xff0c;甚至…

蓝桥杯嵌入式赛道复习笔记4(TIM输出PWM,TIM输入捕获)

原理介绍 高级定时器 PWM计算 假如要得到输出频率为1000HZ 输入捕获的计算 实战练习 cubeMX的配置 TIM2的配置 TIM17的配置 同时输入捕获模式要开启中断模式 将NVIC Setting中的中段配置为enable 代码展示 main.c 中断配置

Linux驱动开发进阶 - 文件系统

文章目录 1、前言2、学习目标3、VFS虚拟文件系统3.1、超级块&#xff08;Super Block&#xff09;3.2、dentry3.3、inode3.4、file 4、文件系统的挂载5、文件系统的注册5.1、文件系统的注册过程5.1.2、定义文件系统类型5.1.3、注册文件系统5.1.4、注销文件系统 5.2、文件系统的…

WEB攻防-PHP反序列化-字符串逃逸

目录 前置知识 字符串逃逸-减少 字符串逃逸-增多 前置知识 1.PHP 在反序列化时&#xff0c;语法是以 ; 作为字段的分隔&#xff0c;以 } 作为结尾&#xff0c;在结束符}之后的任何内容不会影响反序列化的后的结果 class people{ public $namelili; public $age20; } var_du…

蓝桥杯真题——洛谷Day13 找规律(修建灌木)、字符串(乘法表)、队列(球票)

目录 找规律 P8781 [蓝桥杯 2022 省 B] 修剪灌木 字符串 P8723 [蓝桥杯 2020 省 AB3] 乘法表 队列 P8641 [蓝桥杯 2016 国 C] 赢球票 找规律 P8781 [蓝桥杯 2022 省 B] 修剪灌木 思路&#xff1a;对某个特定的点来说有向前和向后的情况&#xff0c;即有向前再返回到该位置…

C语言内存函数

一、memcpy使用和模拟实现 函数原型: void * memcpy ( void * destination, const void * source, size_t num ); dest指向目标内存区域的指针&#xff0c;即数据要复制的地方。sour指向内存区域的指针&#xff0c;即数据要复制的地方。num要复制的字节数。 memcpy函数会将s…

Springboot项目打包成war包

1、首先创建一个springboot工程&#xff0c;然后我们改造启动类如&#xff1a; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuil…

【大模型基础_毛玉仁】3.3 思维链

目录 3.3 思维链3.3.1 思维链提示的定义3.3.2 按部就班1&#xff09;Zero-Shot CoT2&#xff09;Auto-CoT 3.3.3 三思后行1&#xff09;思维树&#xff08;Tree of Thoughts, ToT&#xff09;2&#xff09;思维图&#xff08;Graph of Thoughts, GoT&#xff09; 3.3.4 集思广益…

虚拟电商-延迟任务系统的微服务改造(二)

一、微服务注册中心Consul 编写完延迟任务系统的web层接口&#xff0c;也就是说可以基于http协议来访问延迟系统&#xff0c;接下来要将延迟任务改造成一个服务。首要考虑的问题就是服务的注册与发现&#xff0c;服务的注册与发现都离不开服务的注册中心&#xff0c;本项目选取…

场景题:如何设计一个抢红包随机算法

面试官&#xff1a;咱来写个算法题吧 设计一个抢红包的随机算法&#xff0c;比如一个人在群里发了100块钱的红包&#xff0c;群里有10个人一起来抢红包&#xff0c;每人抢到的金额随机分配。 1.所有人抢到的金额之和要等于红包金额&#xff0c;不能多也不能少。 2.每个人至少抢…