Commit 43352ba2ba9ad5696a4507f8c0d390eff6212029
1 parent
f9b345a2
数字处理
Showing
2 changed files
with
27 additions
and
6 deletions
src/components/base/AccountNum.vue
| 1 | 1 | <template> |
| 2 | 2 | <div class="total-wrap"> |
| 3 | 3 | <span>总计</span> |
| 4 | - <div class="total-main"> | |
| 5 | - <div class="eleNumBg" v-for="item in total" :key="item"> | |
| 4 | + <div class="total-main" > | |
| 5 | + <div v-for="item in total" :key="item" :class="item !==',' ? 'eleNumBg':'noeleNumBg'" > | |
| 6 | 6 | {{item}} |
| 7 | 7 | </div> |
| 8 | 8 | </div> |
| ... | ... | @@ -15,8 +15,7 @@ export default { |
| 15 | 15 | name: 'AccountNum', |
| 16 | 16 | data(){ |
| 17 | 17 | return { |
| 18 | - total: formaterTotal('219706'), | |
| 19 | - msg:'123' | |
| 18 | + total: formaterTotal(219706) | |
| 20 | 19 | } |
| 21 | 20 | } |
| 22 | 21 | } |
| ... | ... | @@ -45,5 +44,15 @@ export default { |
| 45 | 44 | background: url("../../images/content/numBg.svg") no-repeat; |
| 46 | 45 | background-size: 100% 100%; |
| 47 | 46 | } |
| 47 | + .noeleNumBg{ | |
| 48 | + width: 10px; | |
| 49 | + height: 30px; | |
| 50 | + display: inline-block; | |
| 51 | + margin-left: 5px; | |
| 52 | + line-height: 30px; | |
| 53 | + font-size: 22px; | |
| 54 | + font-weight: 600; | |
| 55 | + text-align: center; | |
| 56 | + } | |
| 48 | 57 | } |
| 49 | 58 | </style> | ... | ... |
src/utils/formate.js
| ... | ... | @@ -3,7 +3,7 @@ function formateday() { |
| 3 | 3 | let str = '' |
| 4 | 4 | let year = date.getFullYear() |
| 5 | 5 | let month = date.getMonth()+1<10? "0"+ (date.getMonth()+1) : date.getMonth()+1 |
| 6 | - let day = date.getDate()<10 ? "0"+date.getDate() : date.getDate | |
| 6 | + let day = date.getDate()<10 ? "0"+date.getDate() : date.getDate() | |
| 7 | 7 | str = year +"-"+ month +"-"+ day |
| 8 | 8 | return str |
| 9 | 9 | } |
| ... | ... | @@ -20,7 +20,19 @@ function formateTime() { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | function formaterTotal(val) { |
| 23 | - return val.split('') | |
| 23 | + // return val.split('') | |
| 24 | + let str = val.toString() | |
| 25 | + let newStr = '' | |
| 26 | + let count = 0 | |
| 27 | + for(let i=str.length-1;i>=0;i--){ | |
| 28 | + if(count % 3 == 0 && count!= 0){ | |
| 29 | + newStr = str.charAt(i)+","+newStr | |
| 30 | + }else{ | |
| 31 | + newStr = str.charAt(i)+newStr | |
| 32 | + } | |
| 33 | + count++ | |
| 34 | + } | |
| 35 | + return newStr.split("") | |
| 24 | 36 | } |
| 25 | 37 | |
| 26 | 38 | export { formateday, formateTime, formaterTotal } | ... | ... |