Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
account-book
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘文虎
account-book
Commits
e4d9cb82
Commit
e4d9cb82
authored
Jul 11, 2022
by
Facius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 计算器修改
parent
aa0f436a
Pipeline
#2757
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
20 deletions
+41
-20
index.vue
components/calculator/index.vue
+41
-20
No files found.
components/calculator/index.vue
View file @
e4d9cb82
...
...
@@ -14,7 +14,7 @@
<!-- 小程序使用请改成 :key="ix" -->
<view
class=
"calculator-button-left-aview dot-view"
v-for=
"(item, ix) in calculatorButBList"
:key=
"ix"
>
<view
class=
"calculator-button-left-a2 dot-view"
></view>
<view
class=
"calculator-button-left-a dot-view"
@
tap=
"numTap
B
(item)"
>
<view
class=
"calculator-button-left-a dot-view"
@
tap=
"numTap
A
(item)"
>
<text
class=
"calculator-button-left-a1"
>
{{
item
}}
</text>
</view>
</view>
...
...
@@ -78,8 +78,9 @@ export default {
},
methods
:
{
handleClickSure
()
{
console
.
log
(
'-----sure-----'
,
this
.
sureText
)
this
.
$emit
(
'sure'
,
this
.
sureText
);
var
text
=
(
Math
.
trunc
(
this
.
sureText
*
100
)
/
100
).
toFixed
(
2
)
console
.
log
(
'-----sure-----'
,
this
.
sureText
,
text
)
this
.
$emit
(
'sure'
,
text
);
},
textChange
(
text
)
{
console
.
log
(
'top:'
,
'|'
+
this
.
topText
+
'|'
)
...
...
@@ -134,43 +135,63 @@ export default {
// 1-9输入判断
numTapA
(
item
)
{
// this.showSure = false
if
(
this
.
bottomText
.
length
==
1
&&
this
.
bottomText
==
0
)
{
if
(
this
.
bottomText
.
length
==
1
&&
this
.
bottomText
==
0
&&
!
this
.
topText
&&
item
==
0
)
{
return
;
}
if
(
this
.
bottomText
.
length
==
1
&&
this
.
bottomText
==
0
&&
!
this
.
topText
)
{
this
.
bottomText
=
''
;
}
if
(
this
.
bottomText
==
'Infinity'
||
this
.
bottomText
==
'NaN'
)
{
this
.
bottomText
=
''
;
}
this
.
bottomText
+=
item
;
var
text
=
this
.
bottomText
var
array
=
this
.
bottomText
.
split
(
'.'
)
console
.
log
(
'----()-----'
,
array
,
array
.
length
,
array
[
array
.
length
-
1
],
array
[
array
.
length
-
1
].
length
)
if
(
array
.
length
>
1
&&
array
[
array
.
length
-
1
].
length
>=
2
)
{
// bottomText超过两个小数点不处理
return
}
var
text
=
this
.
bottomText
+
item
if
(
this
.
topText
)
{
let
numList
=
[
'7'
,
'8'
,
'9'
,
'4'
,
'5'
,
'6'
,
'1'
,
'2'
,
'3'
,
'0'
,
'.'
];
let
lastT
=
this
.
topText
.
slice
(
-
1
);
if
(
numList
.
includes
(
lastT
))
{
var
arr
=
this
.
topText
.
split
(
' '
)
var
a
=
arr
[
arr
.
length
-
1
].
split
(
'.'
)
if
(
a
.
length
>
1
&&
a
[
a
.
length
-
1
].
length
+
this
.
bottomText
.
length
>=
2
)
{
// topText和bottomText超过两个小数点不处理
return
}
this
.
bottomText
=
text
text
=
String
(
this
.
topText
)
+
String
(
this
.
bottomText
)
}
else
{
this
.
bottomText
=
text
text
=
this
.
topText
+
' '
+
this
.
bottomText
}
}
else
{
this
.
bottomText
=
text
}
// else {
// this.showSure = true
// }
this
.
textChange
(
text
)
},
// 0,00输入判断
numTapB
(
item
)
{
if
(
this
.
bottomText
.
length
==
1
&&
this
.
bottomText
==
0
)
{
return
;
}
if
(
item
==
'00'
&&
this
.
bottomText
==
''
)
{
return
;
}
if
(
this
.
bottomText
==
'Infinity'
||
this
.
bottomText
==
'NaN'
)
{
this
.
bottomText
=
''
;
}
this
.
bottomText
+=
item
;
this
.
textChange
(
this
.
bottomText
)
},
// numTapB(item) {
// if (this.bottomText.length == 1 && this.bottomText == 0) {
// return;
// }
// // if (item == '00' && this.bottomText == '') {
// // return;
// // }
// if (this.bottomText == 'Infinity' || this.bottomText == 'NaN') {
// this.bottomText = '';
// }
// this.bottomText += item;
// this.textChange(this.bottomText)
// },
// .输入判断
numTapC
()
{
// this.showSure = false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment