Compare commits

...

4 Commits

42 changed files with 250 additions and 49 deletions

View File

@ -292,7 +292,7 @@ function buildTransferTips(feePercent) {
return {
points: [
"只能转赠100的整数倍",
"只能转赠1的整数倍",
"凌晨00:00至02:00为系统维护时段不可赠送",
"转赠系统会扣除" + percentText + "%的手续费",
],

View File

@ -0,0 +1,97 @@
<template>
<input ref="InputRef" class="DecimalInput UI-FLEX-1 UI-P-L24 UI-FS28" type="text" inputmode="decimal"
:value="InnerValue" :placeholder="placeholder" :placeholder-style="placeholderStyle"
@input="HandleInput" />
</template>
<script>
import { limitDecimal } from '@/utils/index.js'
export default {
name: 'DecimalInput',
props: {
value: { type: [String, Number], default: '' },
digit: { type: Number, default: 2 },
allowNegative: { type: Boolean, default: false },
max: { type: [String, Number], default: null },
placeholder: { type: String, default: '' },
placeholderStyle: { type: String, default: '' }
},
data() {
return {
//
InnerValue: String(this.value === null || this.value === undefined ? '' : this.value)
}
},
watch: {
value(Val) {
const Str = String(Val === null || Val === undefined ? '' : Val)
if (Str !== this.InnerValue) {
this.InnerValue = Str
}
}
},
methods: {
/** 获取 uni-app input 组件内部的原生 input 节点 */
GetNativeInput(Target) {
if (Target && Target.tagName === 'INPUT') return Target
const ShadowInput = Target && Target.shadowRoot && typeof Target.shadowRoot.querySelector === 'function'
? Target.shadowRoot.querySelector('input')
: null
if (ShadowInput) return ShadowInput
const ChildInput = Target && typeof Target.querySelector === 'function'
? Target.querySelector('input')
: null
if (ChildInput) return ChildInput
const RootEl = this.$refs.InputRef && this.$refs.InputRef.$el
const RootInput = RootEl && typeof RootEl.querySelector === 'function'
? RootEl.querySelector('input')
: null
if (RootInput) return RootInput
// H5 input
const ActiveInput = typeof document !== 'undefined' ? document.activeElement : null
if (ActiveInput && ActiveInput.tagName === 'INPUT') return ActiveInput
return null
},
/** 输入时实时限制小数位数与最大值 */
HandleInput(e) {
const NativeInput = this.GetNativeInput(e && e.target)
const DetailValue = e && e.detail ? e.detail.value : undefined
let Value = String(
DetailValue !== undefined && DetailValue !== null
? DetailValue
: (NativeInput ? NativeInput.value : '')
)
//
Value = limitDecimal(Value, this.digit, this.allowNegative)
//
const Max = Number(this.max)
if (Value !== '' && this.max !== null && !isNaN(Number(Value)) && !isNaN(Max) && Number(Value) > Max) {
Value = String(Max)
}
this.InnerValue = Value
this.$emit('input', Value)
// uni-app H5 input uni-input valueSync
// Vue input
// patch nextTick input
this.$nextTick(() => {
const Target = this.GetNativeInput(e && e.target)
if (Target && Target.value !== Value) {
Target.value = Value
}
})
}
}
}
</script>
<style lang="scss" scoped>
.DecimalInput {
height: 100%;
}
</style>

View File

@ -1,6 +1,6 @@
{
"name" : "白马交易所",
"appid" : "__UNI__3EC3CC8",
"appid" : "__UNI__B250220",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",

View File

@ -15,7 +15,7 @@
</view>
<text class="hero-card__coin-text">BMT</text>
</view>
<text class="hero-card__label">可用BMT:</text>
<text class="hero-card__label">可用1BMT:</text>
<text class="hero-card__value asset-number-font">{{ displayBmt }}</text>
</view>
</view>
@ -78,12 +78,12 @@
</view>
<view class="form-input">
<input
<decimal-input
v-model="form.points"
class="form-input__field asset-number-font"
type="number"
:digit="0"
placeholder="请输入积分数量"
placeholder-class="form-input__placeholder"
placeholder-style="color: rgba(177, 187, 214, 0.42);"
/>
<text class="form-input__suffix">可用积分</text>
</view>
@ -156,6 +156,7 @@
<script>
import AssetConfirmPopup from "../../components/asset-confirm-popup.vue";
import AssetPageShell from "../../components/asset-page-shell.vue";
import DecimalInput from "../../components/DecimalInput/DecimalInput.vue";
import {
fetchBmtExchangeDetail,
submitAssetBmtExchange,
@ -165,6 +166,7 @@ export default {
components: {
AssetConfirmPopup,
AssetPageShell,
DecimalInput,
},
data() {
return {
@ -581,10 +583,6 @@ export default {
color: #ffffff;
}
.form-input__placeholder {
color: rgba(177, 187, 214, 0.42);
}
.form-input__suffix {
margin-left: 16rpx;
font-size: 22rpx;

View File

@ -16,22 +16,23 @@
summary.available
}}</text>
<!-- <text class="bmtr-hero__total asset-number-font">累计{{ summary.total }}</text> -->
<!-- <text class="bmtr-hero__total asset-number-font">仅米小嘉用户使用</text> -->
</view>
<!-- 设计图右侧的钱包插图替换 heroImage 为实际图片地址即可显示 -->
<image v-if="heroImage" class="bmtr-hero__image" :src="heroImage" mode="aspectFit"></image>
</view>
<view class="bmtr-address glass-panel" v-if="displayAddress">
<view class="bmtr-address glass-panel">
<view class="bmtr-address__head">
<image class="bmtr-address__icon" src="https://imgs.agrimedia.cn/bm-bmt/qianbao.png" mode="aspectFit"></image>
<text class="bmtr-address__title">白马提回地址</text>
</view>
<view class="bmtr-address__field">
<view class="bmtr-address__content">
<text class="bmtr-address__label">从交易所提回BMTR的地址</text>
<text class="bmtr-address__value asset-number-font">{{ displayAddress }}</text>
<text class="bmtr-address__label" v-if="displayAddress">从交易所提回BMTR的地址</text>
<text class="bmtr-address__value asset-number-font">{{ displayAddress || "请绑定手机号" }}</text>
</view>
<view class="bmtr-address__actions">
<view class="bmtr-address__actions" v-if="displayAddress">
<text class="bmtr-address__action" @click="toggleAddress">{{
isAddressVisible ? "隐藏" : "显示"
}}</text>
@ -98,6 +99,7 @@ export default {
}
return this.maskAddress(this.address);
},
showLoadMoreState() {
return this.records.length > 0;
@ -373,7 +375,7 @@ export default {
margin-top: 12rpx;
font-size: 28rpx;
font-weight: 600;
color: #35d9a0;
color: rgba(255, 97, 97, 1);
}
.bmtr-hero__image {

View File

@ -29,12 +29,12 @@
</view>
<view class="input-bar">
<input
<decimal-input
v-model="form.amount"
class="input-bar__field asset-number-font"
type="number"
:digit="0"
:placeholder="amountPlaceholder"
placeholder-class="input-bar__placeholder"
placeholder-style="color: rgba(170, 179, 204, 0.66);"
/>
<text class="input-bar__action" @click="fillAll">全部赠送</text>
</view>
@ -182,6 +182,7 @@
<script>
import AssetConfirmPopup from "../../components/asset-confirm-popup.vue";
import AssetPageShell from "../../components/asset-page-shell.vue";
import DecimalInput from "../../components/DecimalInput/DecimalInput.vue";
import {
fetchTransferDetail,
searchTransferUser,
@ -192,6 +193,7 @@ export default {
components: {
AssetConfirmPopup,
AssetPageShell,
DecimalInput,
},
data() {
return {
@ -255,7 +257,7 @@ export default {
}
return [
"只能转赠100的整数倍",
"只能转赠1的整数倍",
"凌晨0点-凌晨01点系统维护不可赠送",
"转赠系统会扣除" + this.feePercent + "%的手续费",
];
@ -276,9 +278,7 @@ export default {
return this.formatAmount(received, 2);
},
amountPlaceholder() {
return this.activeTab === "power"
? "请输入1的整数倍"
: "请输入100的整数倍";
return "请输入1的整数倍";
},
},
methods: {
@ -394,9 +394,9 @@ export default {
return;
}
if (this.activeTab === "points" && this.amountValue % 100 !== 0) {
if (this.activeTab === "points" && !Number.isInteger(this.amountValue)) {
uni.showToast({
title: "积分只能转赠100的整数倍",
title: "积分只能转赠1的整数倍",
icon: "none",
});
return;

View File

@ -7,7 +7,11 @@
<view class="home-wallet-btn__icon">
<image src="https://imgs.agrimedia.cn/bm-bmt/qianbao.png" mode="widthFix"></image>
</view>
<<<<<<< HEAD
<text class="home-wallet-btn__text">钱包</text>
=======
<text class="home-wallet-btn__text" style="margin-top: 4rpx;">钱包</text>
>>>>>>> dev_yk
</view>
</view>
@ -89,7 +93,7 @@
<view class="asset-mini-card__head">
<text class="asset-mini-card__label">{{ item.title }}</text>
</view>
<text class="asset-mini-card__value asset-number-font">{{ item.value }}</text>
<text class="asset-mini-card__value asset-number-font">{{ formatAssetValue(item.value) }}</text>
</view>
</view>
</view>
@ -129,6 +133,8 @@ import {
fetchAssetHome,
fetchCouponRedeemLinkData,
} from "../../api/assets";
import serviceConfig from "../../config/service";
import { truncateToTwo } from "../../utils/index.js";
export default {
data() {
@ -158,6 +164,9 @@ export default {
});
},
methods: {
formatAssetValue(value) {
return truncateToTwo(value);
},
async loadPage(options = {}) {
if (this.isFetchingHome) {
return;
@ -390,7 +399,7 @@ export default {
.home-wallet-btn {
justify-self: end;
display: flex;
// align-items: center;
align-items: center;
height: 52rpx;
color: rgba(229, 235, 255, 0.82);
padding-right: 10rpx;
@ -409,6 +418,7 @@ export default {
.home-wallet-btn__text {
font-size: 28rpx;
line-height: 1;
color: rgba(229, 235, 255, 0.82);
}

View File

@ -1,2 +1,6 @@
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>白马交易所</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
<<<<<<< HEAD
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/bmt/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/bmt/static/js/chunk-vendors.a58c62f3.js></script><script src=/bmt/static/js/index.6b0ea112.js></script></body></html>
=======
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/bmt/static/index.149e085d.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/bmt/static/js/chunk-vendors.e13b4a2c.js></script><script src=/bmt/static/js/index.5ae5da78.js></script></body></html>
>>>>>>> dev_yk

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

85
utils/index.js Normal file
View File

@ -0,0 +1,85 @@
/**
* 限制输入框中的小数位数
* @param {string} val - 输入值
* @param {number} digit - 小数位位数默认 2
* @param {boolean} allowNegative - 是否允许负数默认 false
* @returns {string}
*
* 示例
* limitDecimal('12.345', 2) // '12.34'
* limitDecimal('12..34', 2) // '12.34'
* limitDecimal('abc123.45', 2) // '123.45'
* limitDecimal('-12.34', 2, true) // '-12.34'
* limitDecimal('007.00', 2) // '7.00'
* limitDecimal('12.5', 0) // '12'digit 为 0 时小数点一并去除,仅保留整数)
*/
export function limitDecimal(val, digit = 2, allowNegative = false) {
if (!val && val !== "0") return "";
// 1. 过滤非法字符
let result = allowNegative
? String(val).replace(/[^\d.-]/g, "")
: String(val).replace(/[^\d.]/g, "");
// 2. 负号只能出现在开头
if (allowNegative) {
const hasMinus = result.indexOf("-") > -1;
result = result.replace(/-/g, "");
if (hasMinus && result) result = "-" + result;
}
// 3. 多个小数点只保留第一个
const parts = result.split(".");
if (parts.length > 2) {
result = parts[0] + "." + parts.slice(1).join("");
}
// 4. 限制小数位数digit 为 0 时去除小数点,仅保留整数)
if (result.includes(".") && digit >= 0) {
const [intPart, decPart] = result.split(".");
result = digit === 0 ? intPart : intPart + "." + decPart.slice(0, digit);
}
// 5. 处理前导零00、01 等
if (
result &&
!result.startsWith("-") &&
result.startsWith("0") &&
result.length > 1 &&
result[1] !== "."
) {
result = result.replace(/^0+/, "");
if (result === "") result = "0";
}
return result;
}
/**
* 数值展示格式化 0 时返回 "0.00" 0 时原样展示
* @param {number|string} num - 原始数值支持正负值
* @returns {string}
*
* 规则
* 1. 传入值为 0或空值非法值返回 "0.00"
* 2. 传入值不为 0无论正负原样返回该值的字符串形式不做任何截取
*
* 示例
* truncateToTwo(0) // '0.00'
* truncateToTwo('0.0000') // '0.00'
* truncateToTwo(null) // '0.00'
* truncateToTwo('11.0000') // '11.0000'
* truncateToTwo(11.2942) // '11.2942'
* truncateToTwo(-1.239) // '-1.239'
*/
export function truncateToTwo(num) {
const value = Number(num);
// 0、空值、非法值统一返回 0.00
if (!Number.isFinite(value) || value === 0) {
return "0.00";
}
return String(num);
}