工商银行优化
This commit is contained in:
parent
906293b350
commit
d047299489
|
|
@ -26,12 +26,10 @@
|
||||||
</NavBar>
|
</NavBar>
|
||||||
|
|
||||||
<view v-if="!selectedImage" :style="{'height':$systemInfo.statusBarHeight*2+88+'rpx'}">
|
<view v-if="!selectedImage" :style="{'height':$systemInfo.statusBarHeight*2+88+'rpx'}">
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="group_48164">
|
<view class="group_48164">
|
||||||
<view class="rectangle_23292">
|
<view class="rectangle_23292">
|
||||||
<image class="group_48163" src="/static/image/other/bank/gsyh/mrzh.png" />
|
<image class="group_48163" src="/static/image/other/bank/gsyh/mrzh.png" />
|
||||||
|
|
||||||
<view class="flexcontainer_1">
|
<view class="flexcontainer_1">
|
||||||
<view class="rectangle_23290">
|
<view class="rectangle_23290">
|
||||||
<image class="f0763869907c4a2a56d1061936006358" src="/static/image/other/bank/gsyh/gsyh.png" />
|
<image class="f0763869907c4a2a56d1061936006358" src="/static/image/other/bank/gsyh/gsyh.png" />
|
||||||
|
|
@ -41,7 +39,8 @@
|
||||||
<view class="text_3">
|
<view class="text_3">
|
||||||
{{maskCardNumber(data.form.cardNumber)}}
|
{{maskCardNumber(data.form.cardNumber)}}
|
||||||
<view
|
<view
|
||||||
style="color:#3E82BD;margin-left: 52rpx;text-align: center;font-size: 22rpx; width: 52rpx;height: 32rpx;background: #F3F6FB;border-radius: 2px 2px 2px 2px;" @click="data.isShow=true">查看</view>
|
style="color:#3E82BD;margin-left: 52rpx;text-align: center;font-size: 22rpx; width: 52rpx;height: 32rpx;background: #F3F6FB;border-radius: 2px 2px 2px 2px;"
|
||||||
|
@click="data.isShow=true">查看</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -57,37 +56,31 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="!selectedImage" class="image-box" @touchstart="handleTouchStart" @touchend="handleTouchEnd">
|
<view v-if="!selectedImage" class="image-box" @touchstart="handleTouchStart" @touchend="handleTouchEnd">
|
||||||
<image class="group_48140_3x" :src="data.bannerImage || '/static/image/other/bank/gsyh/gnimg.png'" mode="aspectFill" />
|
<image class="group_48140_3x" :src="data.bannerImage || '/static/image/other/bank/gsyh/gnimg.png'"
|
||||||
<!-- <view class="image-tip">
|
mode="aspectFill" />
|
||||||
<text>长按替换真实截图</text>
|
|
||||||
</view> -->
|
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="scroll-image-box flex-1">
|
<view v-else class="scroll-image-box flex-1">
|
||||||
<scroll-view class="image-box h100" style="width: 100%;height: 182px;" scroll-y :show-scrollbar="false"
|
<scroll-view class="image-box h100" style="width: 100%;height: 182px;" scroll-y :show-scrollbar="false"
|
||||||
@scroll="onImageScroll">
|
@scroll="onImageScroll">
|
||||||
<image class="crop-image-target" style="width:100%;" :src="selectedImage" mode="widthFix"></image>
|
<image class="crop-image-target" style="width:100%;" :src="selectedImage" mode="widthFix"></image>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<view class="dashed-line-box">
|
<view class="dashed-line-box">
|
||||||
<view class="dashed-line-text">我是分割线</view>
|
<view class="dashed-line-text">我是分割线</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<canvas canvas-id="crop-canvas"
|
<canvas canvas-id="crop-canvas"
|
||||||
style="position: fixed; left: -9999px; width: 750rpx; height: 100vh; pointer-events: none;"></canvas>
|
style="position: fixed; left: -9999px; width: 750rpx; height: 100vh; pointer-events: none;"></canvas>
|
||||||
|
|
||||||
<!-- 蒙层 -->
|
<!-- 蒙层 -->
|
||||||
<view v-if="showMask" class="mask" @click="closeMask">
|
<view v-if="showMask" class="mask" @click="closeMask">
|
||||||
<image class="mask-icon" src="/static/image/common/mask-icon.png" mode="widthFix">
|
<image class="mask-icon" src="/static/image/common/mask-icon.png" mode="widthFix"></image>
|
||||||
</image>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 卡号信息弹窗 -->
|
<!-- 卡号信息弹窗 -->
|
||||||
<view class="dask" v-if="data.isShow">
|
<view class="dask" v-if="data.isShow">
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="title">
|
<view class="title">完整卡号</view>
|
||||||
完整卡号
|
<view class="dec">{{addSpaceEveryFourChars(data.form.cardNumber)}}</view>
|
||||||
</view>
|
|
||||||
<view class="dec">
|
|
||||||
{{addSpaceEveryFourChars(data.form.cardNumber)}}
|
|
||||||
</view>
|
|
||||||
<view class="btnbox">
|
<view class="btnbox">
|
||||||
<view class="btn" @click="data.isShow=false">取消</view>
|
<view class="btn" @click="data.isShow=false">取消</view>
|
||||||
<view class="btn btns" @click="data.isShow=false">复制卡号</view>
|
<view class="btn btns" @click="data.isShow=false">复制卡号</view>
|
||||||
|
|
@ -100,7 +93,6 @@
|
||||||
<text class="text_7">限额</text>
|
<text class="text_7">限额</text>
|
||||||
<image class="group_48165" src="/static/image/other/bank/gsyh/titleIcon.png" />
|
<image class="group_48165" src="/static/image/other/bank/gsyh/titleIcon.png" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="panel_limits" @click="openEditDialog">
|
<view class="panel_limits" @click="openEditDialog">
|
||||||
<view class="flexcontainer_4">
|
<view class="flexcontainer_4">
|
||||||
<view class="flexcontainer_5">
|
<view class="flexcontainer_5">
|
||||||
|
|
@ -108,22 +100,16 @@
|
||||||
<text class="text_9">日累积{{data.form.dayLimit}}</text>
|
<text class="text_9">日累积{{data.form.dayLimit}}</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="text_10">{{data.form.dayRemain}}</text>
|
<text class="text_10">{{data.form.dayRemain}}</text>
|
||||||
<view class="line">
|
<view class="line"></view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="flexcontainer_6">
|
<view class="flexcontainer_6">
|
||||||
<view class="flexcontainer_7">
|
<view class="flexcontainer_7">
|
||||||
<text class="text_11">当月剩余额度(元)</text>
|
<text class="text_11">当月剩余额度(元)</text>
|
||||||
<text class="text_12">日累积{{data.form.monthLimit}}</text>
|
<text class="text_12">日累积{{data.form.monthLimit}}</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="text_13">{{data.form.monthRemain}}</text>
|
<text class="text_13">{{data.form.monthRemain}}</text>
|
||||||
<view class="line">
|
<view class="line"></view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="flexcontainer_8">
|
<view class="flexcontainer_8">
|
||||||
<view class="flexcontainer_9">
|
<view class="flexcontainer_9">
|
||||||
<text class="text_14">当年剩余额度(元)</text>
|
<text class="text_14">当年剩余额度(元)</text>
|
||||||
|
|
@ -144,14 +130,12 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13989" @click="openEditDialog">
|
<view class="group_13989" @click="openEditDialog">
|
||||||
<view class="rectangle_23294_1">
|
<view class="rectangle_23294_1">
|
||||||
<text class="text_19">启用日期</text>
|
<text class="text_19">启用日期</text>
|
||||||
<text class="text_20">{{data.form.startDate}}</text>
|
<text class="text_20">{{data.form.startDate}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13990" @click="openEditDialog">
|
<view class="group_13990" @click="openEditDialog">
|
||||||
<view class="rectangle_23294_2">
|
<view class="rectangle_23294_2">
|
||||||
<view class="rightInfo">
|
<view class="rightInfo">
|
||||||
|
|
@ -161,7 +145,6 @@
|
||||||
<text class="text_22">{{data.form.endDate}}</text>
|
<text class="text_22">{{data.form.endDate}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13991" @click="openEditDialog">
|
<view class="group_13991" @click="openEditDialog">
|
||||||
<view class="rectangle_23294_3">
|
<view class="rectangle_23294_3">
|
||||||
<text class="text_23">设置别名</text>
|
<text class="text_23">设置别名</text>
|
||||||
|
|
@ -171,28 +154,24 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13992">
|
<view class="group_13992">
|
||||||
<view class="rectangle_23294_4">
|
<view class="rectangle_23294_4">
|
||||||
<text class="text_25">账户互转</text>
|
<text class="text_25">账户互转</text>
|
||||||
<image class="group_13987_2" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
<image class="group_13987_2" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13993">
|
<view class="group_13993">
|
||||||
<view class="rectangle_23294_5">
|
<view class="rectangle_23294_5">
|
||||||
<text class="text_26">当面收款</text>
|
<text class="text_26">当面收款</text>
|
||||||
<image class="group_13987_3" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
<image class="group_13987_3" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13994">
|
<view class="group_13994">
|
||||||
<view class="rectangle_23294_6">
|
<view class="rectangle_23294_6">
|
||||||
<text class="text_27">绑手机号</text>
|
<text class="text_27">绑手机号</text>
|
||||||
<image class="group_13987_4" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
<image class="group_13987_4" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="group_13994_1">
|
<view class="group_13994_1">
|
||||||
|
|
@ -205,9 +184,7 @@
|
||||||
<image class="group_13987_6" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
<image class="group_13987_6" src="/static/image/other/bank/gsyh/rightIcon.png" />
|
||||||
</view>
|
</view>
|
||||||
<image class="dee351fc65540488ca79ac78c10072f2" src="/static/image/other/bank/gsyh/bottomImg.png" />
|
<image class="dee351fc65540488ca79ac78c10072f2" src="/static/image/other/bank/gsyh/bottomImg.png" />
|
||||||
<view class="footer">
|
<view class="footer"></view>
|
||||||
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 编辑弹窗 -->
|
<!-- 编辑弹窗 -->
|
||||||
<view v-if="editDialog.show" class="editDialog">
|
<view v-if="editDialog.show" class="editDialog">
|
||||||
|
|
@ -218,7 +195,12 @@
|
||||||
<view class="editDialog_body">
|
<view class="editDialog_body">
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>余额</text>
|
<text>余额</text>
|
||||||
<input v-model="editDialog.data.balance" type="digit" placeholder="请输入余额" />
|
<input
|
||||||
|
:value="editDialog.data.balance"
|
||||||
|
@input="(e) => onNumberInputRaw('balance', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="请输入余额"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>卡类型</text>
|
<text>卡类型</text>
|
||||||
|
|
@ -230,27 +212,57 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>当日额度上限</text>
|
<text>当日额度上限</text>
|
||||||
<input :value="editDialog.data.dayLimit" @input="(e) => onNumberInput('dayLimit', e.detail.value)" placeholder="如: 50,000.00" />
|
<input
|
||||||
|
:value="editDialog.data.dayLimit"
|
||||||
|
@input="(e) => onNumberInputRaw('dayLimit', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="如: 50000"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>当日剩余额度</text>
|
<text>当日剩余额度</text>
|
||||||
<input :value="editDialog.data.dayRemain" @input="(e) => onNumberInput('dayRemain', e.detail.value)" placeholder="如: 50,000.00" />
|
<input
|
||||||
|
:value="editDialog.data.dayRemain"
|
||||||
|
@input="(e) => onNumberInputRaw('dayRemain', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="如: 50000"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>当月额度上限</text>
|
<text>当月额度上限</text>
|
||||||
<input :value="editDialog.data.monthLimit" @input="(e) => onNumberInput('monthLimit', e.detail.value)" placeholder="如: 500,000.00" />
|
<input
|
||||||
|
:value="editDialog.data.monthLimit"
|
||||||
|
@input="(e) => onNumberInputRaw('monthLimit', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="如: 500000"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>当月剩余额度</text>
|
<text>当月剩余额度</text>
|
||||||
<input :value="editDialog.data.monthRemain" @input="(e) => onNumberInput('monthRemain', e.detail.value)" placeholder="如: 500,000.00" />
|
<input
|
||||||
|
:value="editDialog.data.monthRemain"
|
||||||
|
@input="(e) => onNumberInputRaw('monthRemain', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="如: 500000"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>当年额度上限</text>
|
<text>当年额度上限</text>
|
||||||
<input :value="editDialog.data.yearLimit" @input="(e) => onNumberInput('yearLimit', e.detail.value)" placeholder="如: 2,500,000.00" />
|
<input
|
||||||
|
:value="editDialog.data.yearLimit"
|
||||||
|
@input="(e) => onNumberInputRaw('yearLimit', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="如: 2500000"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>当年剩余额度</text>
|
<text>当年剩余额度</text>
|
||||||
<input :value="editDialog.data.yearRemain" @input="(e) => onNumberInput('yearRemain', e.detail.value)" placeholder="如: 2,500,000.00" />
|
<input
|
||||||
|
:value="editDialog.data.yearRemain"
|
||||||
|
@input="(e) => onNumberInputRaw('yearRemain', e.detail.value)"
|
||||||
|
type="digit"
|
||||||
|
placeholder="如: 2500000"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="formItem">
|
<view class="formItem">
|
||||||
<text>基本账户</text>
|
<text>基本账户</text>
|
||||||
|
|
@ -277,6 +289,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, onMounted, ref, getCurrentInstance } from 'vue';
|
import { reactive, onMounted, ref, getCurrentInstance } from 'vue';
|
||||||
import NavBar from '@/components/nav-bar/nav-bar'
|
import NavBar from '@/components/nav-bar/nav-bar'
|
||||||
|
|
@ -284,6 +297,7 @@ import NavBar from '@/components/nav-bar/nav-bar'
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
const CACHE_KEY = 'gsyh_account_info';
|
const CACHE_KEY = 'gsyh_account_info';
|
||||||
const BANNER_IMAGE_KEY = 'gsyh_banner_image';
|
const BANNER_IMAGE_KEY = 'gsyh_banner_image';
|
||||||
|
const FONT_KEY = 'gsyh_font_path'; // 修复:统一字体缓存key
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
form: {
|
form: {
|
||||||
|
|
@ -317,17 +331,13 @@ const editDialog = reactive({
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadCache();
|
loadCache();
|
||||||
// 加载保存的banner图片
|
|
||||||
const savedBanner = uni.getStorageSync(BANNER_IMAGE_KEY);
|
const savedBanner = uni.getStorageSync(BANNER_IMAGE_KEY);
|
||||||
if (savedBanner) {
|
if (savedBanner) {
|
||||||
data.bannerImage = savedBanner;
|
data.bannerImage = savedBanner;
|
||||||
}
|
}
|
||||||
const config = uni.getStorageSync('config')
|
|
||||||
console.log("---config---", config);
|
|
||||||
const font = config.config['client.uniapp.font']
|
|
||||||
|
|
||||||
console.log("字体地址信息", font.bank);
|
const config = uni.getStorageSync('config');
|
||||||
// Font loading logic
|
const font = config.config['client.uniapp.font'];
|
||||||
const fontUrl = font.bank;
|
const fontUrl = font.bank;
|
||||||
const fontName = 'zsyhFt';
|
const fontName = 'zsyhFt';
|
||||||
|
|
||||||
|
|
@ -345,13 +355,12 @@ onMounted(() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
// H5 环境直接从 URL 加载字体
|
|
||||||
loadFont(fontUrl);
|
loadFont(fontUrl);
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
// 非 H5 环境使用下载和保存逻辑
|
// 修复:读取和保存都用同一个 FONT_KEY
|
||||||
const savedFontPath = uni.getStorageSync(' ');
|
const savedFontPath = uni.getStorageSync(FONT_KEY);
|
||||||
if (savedFontPath) {
|
if (savedFontPath) {
|
||||||
loadFont(savedFontPath);
|
loadFont(savedFontPath);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -362,14 +371,10 @@ onMounted(() => {
|
||||||
uni.saveFile({
|
uni.saveFile({
|
||||||
tempFilePath: res.tempFilePath,
|
tempFilePath: res.tempFilePath,
|
||||||
success: (saveRes) => {
|
success: (saveRes) => {
|
||||||
const savedPath = saveRes.savedFilePath;
|
uni.setStorageSync(FONT_KEY, saveRes.savedFilePath); // 修复:用统一key保存
|
||||||
uni.setStorageSync('certificate2_font_path', savedPath);
|
loadFont(saveRes.savedFilePath);
|
||||||
console.log("字体保存路径", savedPath);
|
|
||||||
loadFont(savedPath);
|
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: () => {
|
||||||
console.error('保存文件失败', err);
|
|
||||||
// Fallback: 尝试加载临时路径
|
|
||||||
loadFont(res.tempFilePath);
|
loadFont(res.tempFilePath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -382,9 +387,11 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
});
|
});
|
||||||
function back(){
|
|
||||||
uni.navigateBack()
|
function back() {
|
||||||
|
uni.navigateBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCache() {
|
function loadCache() {
|
||||||
const cache = uni.getStorageSync(CACHE_KEY);
|
const cache = uni.getStorageSync(CACHE_KEY);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
|
|
@ -396,13 +403,32 @@ function saveCache() {
|
||||||
uni.setStorageSync(CACHE_KEY, data.form);
|
uni.setStorageSync(CACHE_KEY, data.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 需要格式化显示的数字字段
|
||||||
|
const NUMBER_FIELDS = ['balance', 'dayLimit', 'dayRemain', 'monthLimit', 'monthRemain', 'yearLimit', 'yearRemain'];
|
||||||
|
|
||||||
|
// 格式化值 → 纯数字字符串(用于输入框)
|
||||||
|
function toRawNumber(val) {
|
||||||
|
if (!val && val !== 0) return '';
|
||||||
|
return String(val).replace(/[^\d.]/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
function openEditDialog() {
|
function openEditDialog() {
|
||||||
editDialog.data = JSON.parse(JSON.stringify(data.form));
|
const raw = JSON.parse(JSON.stringify(data.form));
|
||||||
|
// 打开弹窗时把格式化值还原成纯数字,方便用户直接输入
|
||||||
|
NUMBER_FIELDS.forEach(field => {
|
||||||
|
raw[field] = toRawNumber(raw[field]);
|
||||||
|
});
|
||||||
|
editDialog.data = raw;
|
||||||
editDialog.show = true;
|
editDialog.show = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveEdit() {
|
function saveEdit() {
|
||||||
data.form = { ...data.form, ...editDialog.data };
|
const saved = { ...editDialog.data };
|
||||||
|
// 保存时格式化数字字段,用于页面显示
|
||||||
|
NUMBER_FIELDS.forEach(field => {
|
||||||
|
saved[field] = formatNumber(saved[field]);
|
||||||
|
});
|
||||||
|
data.form = { ...data.form, ...saved };
|
||||||
saveCache();
|
saveCache();
|
||||||
editDialog.show = false;
|
editDialog.show = false;
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
@ -422,36 +448,8 @@ function addSpaceEveryFourChars(str) {
|
||||||
return str.replace(/(.{4})/g, '$1 ').trim();
|
return str.replace(/(.{4})/g, '$1 ').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyAll() {
|
|
||||||
const text = `户 名: ${data.form.name}\n卡 号: ${addSpaceEveryFourChars(data.form.cardNumber)}\n开户行: ${data.form.bankName}`;
|
|
||||||
uni.setClipboardData({
|
|
||||||
data: text,
|
|
||||||
success: () => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '复制成功',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
data.isShow = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyCardNumber() {
|
|
||||||
uni.setClipboardData({
|
|
||||||
data: data.form.cardNumber,
|
|
||||||
success: () => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '复制成功',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
data.isShow = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 长按事件处理
|
// 长按事件处理
|
||||||
const handleTouchStart = (e) => {
|
const handleTouchStart = (e) => {
|
||||||
// 兼容iOS上滑HOME条
|
|
||||||
const systemInfo = uni.getSystemInfoSync();
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
if (systemInfo.platform === 'ios' && systemInfo.safeAreaInsets?.bottom) {
|
if (systemInfo.platform === 'ios' && systemInfo.safeAreaInsets?.bottom) {
|
||||||
const clientY = e.touches[0].clientY;
|
const clientY = e.touches[0].clientY;
|
||||||
|
|
@ -460,7 +458,6 @@ const handleTouchStart = (e) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
longPressTimer = setTimeout(() => {
|
longPressTimer = setTimeout(() => {
|
||||||
uni.vibrateShort();
|
uni.vibrateShort();
|
||||||
chooseImage();
|
chooseImage();
|
||||||
|
|
@ -474,128 +471,86 @@ const handleTouchEnd = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 选择图片
|
|
||||||
const chooseImage = () => {
|
const chooseImage = () => {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
sourceType: ['album'],
|
sourceType: ['album'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
selectedImage.value = res.tempFilePaths[0]
|
selectedImage.value = res.tempFilePaths[0];
|
||||||
data.showMask = true
|
data.showMask = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 关闭蒙层
|
|
||||||
const closeMask = () => {
|
const closeMask = () => {
|
||||||
data.showMask = false
|
data.showMask = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 图片滚动监听
|
|
||||||
const onImageScroll = (e) => {
|
const onImageScroll = (e) => {
|
||||||
scrollTop.value = e.detail.scrollTop;
|
scrollTop.value = e.detail.scrollTop;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 确认裁剪
|
|
||||||
const confirmImage = () => {
|
const confirmImage = () => {
|
||||||
uni.showLoading({
|
uni.showLoading({ title: '处理中...' });
|
||||||
title: '处理中...'
|
const query = uni.createSelectorQuery().in(instance);
|
||||||
})
|
query.select('.image-box').boundingClientRect();
|
||||||
const query = uni.createSelectorQuery().in(instance)
|
query.select('.crop-image-target').boundingClientRect();
|
||||||
|
|
||||||
// 获取容器和图片信息
|
|
||||||
query.select('.image-box').boundingClientRect()
|
|
||||||
query.select('.crop-image-target').boundingClientRect()
|
|
||||||
query.exec(res => {
|
query.exec(res => {
|
||||||
if (!res[0] || !res[1]) {
|
if (!res[0] || !res[1]) {
|
||||||
uni.hideLoading()
|
uni.hideLoading();
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
const container = res[0];
|
||||||
console.log('rects', res)
|
const image = res[1];
|
||||||
const container = res[0] // 容器
|
|
||||||
const image = res[1] // 图片实际渲染尺寸
|
|
||||||
|
|
||||||
// 获取图片原始尺寸
|
|
||||||
uni.getImageInfo({
|
uni.getImageInfo({
|
||||||
src: selectedImage.value,
|
src: selectedImage.value,
|
||||||
success: (imgInfo) => {
|
success: (imgInfo) => {
|
||||||
const scale = imgInfo.width / image.width // 图片 原始宽 / 渲染宽
|
const scale = imgInfo.width / image.width;
|
||||||
const sTop = scrollTop.value * scale // 原始图上的裁切起始Y
|
const sTop = scrollTop.value * scale;
|
||||||
const sHeight = container.height * scale // 原始图上的裁切高度
|
const sHeight = container.height * scale;
|
||||||
|
const sWidth = imgInfo.width;
|
||||||
// 因为是 widthFix,宽度就是原始图宽度(或裁切全宽)
|
const canvasW = container.width;
|
||||||
const sWidth = imgInfo.width
|
const canvasH = container.height;
|
||||||
|
const ctx = uni.createCanvasContext('crop-canvas', instance);
|
||||||
// 设置画布尺寸 (使用像素值)
|
ctx.clearRect(0, 0, canvasW, canvasH);
|
||||||
const canvasW = container.width
|
ctx.drawImage(imgInfo.path, 0, sTop, sWidth, sHeight, 0, 0, canvasW, canvasH);
|
||||||
const canvasH = container.height
|
|
||||||
|
|
||||||
const ctx = uni.createCanvasContext('crop-canvas', instance)
|
|
||||||
|
|
||||||
// 清除画布
|
|
||||||
ctx.clearRect(0, 0, canvasW, canvasH)
|
|
||||||
|
|
||||||
// 绘制
|
|
||||||
ctx.drawImage(
|
|
||||||
imgInfo.path,
|
|
||||||
0, sTop, sWidth, sHeight, // 源图裁剪区域
|
|
||||||
0, 0, canvasW, canvasH // 画布绘制区域
|
|
||||||
)
|
|
||||||
ctx.draw(false, () => {
|
ctx.draw(false, () => {
|
||||||
uni.canvasToTempFilePath({
|
uni.canvasToTempFilePath({
|
||||||
canvasId: 'crop-canvas',
|
canvasId: 'crop-canvas',
|
||||||
width: canvasW,
|
width: canvasW,
|
||||||
height: canvasH,
|
height: canvasH,
|
||||||
destWidth: sWidth, // 使用原图实际宽度,保持原图清晰度
|
destWidth: sWidth,
|
||||||
destHeight: sHeight, // 使用原图实际高度,保持原图清晰度
|
destHeight: sHeight,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('crop success (temp)', res.tempFilePath)
|
|
||||||
|
|
||||||
// 将临时路径保存为永久路径
|
|
||||||
uni.saveFile({
|
uni.saveFile({
|
||||||
tempFilePath: res.tempFilePath,
|
tempFilePath: res.tempFilePath,
|
||||||
success: (saveRes) => {
|
success: (saveRes) => {
|
||||||
console.log('save success (saved)', saveRes.savedFilePath)
|
data.bannerImage = saveRes.savedFilePath;
|
||||||
data.bannerImage = saveRes.savedFilePath
|
selectedImage.value = '';
|
||||||
selectedImage.value = '' // 隐藏编辑模式
|
uni.setStorageSync(BANNER_IMAGE_KEY, data.bannerImage);
|
||||||
// 保存到缓存
|
uni.hideLoading();
|
||||||
uni.setStorageSync(BANNER_IMAGE_KEY, data.bannerImage)
|
|
||||||
uni.hideLoading()
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('saveFile fail', err)
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: '保存失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.error(err)
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: '裁剪失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, instance)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
uni.hideLoading()
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({ title: '保存失败', icon: 'none' });
|
||||||
title: '图片加载失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '裁剪失败', icon: 'none' });
|
||||||
|
}
|
||||||
|
}, instance);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '图片加载失败', icon: 'none' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 关闭图片编辑
|
|
||||||
const closeImageEdit = () => {
|
const closeImageEdit = () => {
|
||||||
selectedImage.value = '';
|
selectedImage.value = '';
|
||||||
};
|
};
|
||||||
|
|
@ -603,34 +558,31 @@ const closeImageEdit = () => {
|
||||||
// 格式化数字,保留两位小数并添加千分位逗号
|
// 格式化数字,保留两位小数并添加千分位逗号
|
||||||
function formatNumber(num) {
|
function formatNumber(num) {
|
||||||
if (!num && num !== 0) return '';
|
if (!num && num !== 0) return '';
|
||||||
// 移除所有非数字和小数点
|
|
||||||
let cleanNum = String(num).replace(/[^\d.]/g, '');
|
let cleanNum = String(num).replace(/[^\d.]/g, '');
|
||||||
// 确保只有一个小数点
|
|
||||||
const parts = cleanNum.split('.');
|
const parts = cleanNum.split('.');
|
||||||
if (parts.length > 2) {
|
if (parts.length > 2) {
|
||||||
cleanNum = parts[0] + '.' + parts.slice(1).join('');
|
cleanNum = parts[0] + '.' + parts.slice(1).join('');
|
||||||
}
|
}
|
||||||
// 转换为数字
|
|
||||||
let number = parseFloat(cleanNum);
|
let number = parseFloat(cleanNum);
|
||||||
if (isNaN(number)) return '';
|
if (isNaN(number)) return '';
|
||||||
// 保留两位小数
|
|
||||||
number = Math.round(number * 100) / 100;
|
number = Math.round(number * 100) / 100;
|
||||||
// 添加千分位逗号
|
|
||||||
return number.toLocaleString('en-US', {
|
return number.toLocaleString('en-US', {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2
|
maximumFractionDigits: 2
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理输入事件
|
// 输入时只更新原始值,不做任何格式化
|
||||||
function onNumberInput(field, value) {
|
function onNumberInputRaw(field, value) {
|
||||||
editDialog.data[field] = formatNumber(value);
|
editDialog.data[field] = value;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" >
|
|
||||||
page{
|
<style lang="scss">
|
||||||
|
page {
|
||||||
background: #F8F8F8;
|
background: #F8F8F8;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
@ -651,6 +603,8 @@ function onNumberInput(field, value) {
|
||||||
width: 750rpx;
|
width: 750rpx;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -690,11 +644,6 @@ function onNumberInput(field, value) {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rectangle_18503 {
|
|
||||||
width: 240rpx;
|
|
||||||
height: 88rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text_1 {
|
.text_1 {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #617280;
|
color: #617280;
|
||||||
|
|
@ -705,7 +654,8 @@ function onNumberInput(field, value) {
|
||||||
width: 240rpx;
|
width: 240rpx;
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row; justify-content: flex-end;
|
flex-direction: row;
|
||||||
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -716,11 +666,6 @@ function onNumberInput(field, value) {
|
||||||
margin-left: 28rpx;
|
margin-left: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.div_1 {
|
|
||||||
width: 754rpx;
|
|
||||||
height: 2rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== card ===== */
|
/* ===== card ===== */
|
||||||
.group_48164 {
|
.group_48164 {
|
||||||
width: 692rpx;
|
width: 692rpx;
|
||||||
|
|
@ -735,12 +680,11 @@ function onNumberInput(field, value) {
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.1);
|
box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.1);
|
||||||
padding: 40rpx 40rpx 20rpx 40rpx ;
|
padding: 40rpx 40rpx 20rpx 40rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.group_48163 {
|
.group_48163 {
|
||||||
|
|
@ -776,13 +720,6 @@ function onNumberInput(field, value) {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group_48162 {
|
|
||||||
width: 52rpx;
|
|
||||||
height: 32rpx;
|
|
||||||
margin-left: 20rpx;
|
|
||||||
margin-top: 46rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rectangle_23290 {
|
.rectangle_23290 {
|
||||||
width: 108rpx;
|
width: 108rpx;
|
||||||
height: 78rpx;
|
height: 78rpx;
|
||||||
|
|
@ -877,7 +814,8 @@ function onNumberInput(field, value) {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 0 26rpx 0 26rpx;
|
margin: 0 26rpx 0 26rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
.line{
|
|
||||||
|
.line {
|
||||||
width: calc(100%);
|
width: calc(100%);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 1rpx;
|
height: 1rpx;
|
||||||
|
|
@ -886,13 +824,13 @@ function onNumberInput(field, value) {
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexcontainer_5,
|
.flexcontainer_5,
|
||||||
.flexcontainer_7,
|
.flexcontainer_7,
|
||||||
.flexcontainer_9 {
|
.flexcontainer_9 {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.text_8,
|
.text_8,
|
||||||
|
|
@ -917,14 +855,6 @@ function onNumberInput(field, value) {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分割线 */
|
|
||||||
.div_2,
|
|
||||||
.div_3 {
|
|
||||||
width: 694rpx;
|
|
||||||
height: 2rpx;
|
|
||||||
margin-left: 28rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== list ===== */
|
/* ===== list ===== */
|
||||||
.panel_limits_1 {
|
.panel_limits_1 {
|
||||||
width: 750rpx;
|
width: 750rpx;
|
||||||
|
|
@ -946,20 +876,27 @@ function onNumberInput(field, value) {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1rpx solid #eee;
|
border-bottom: 1rpx solid #eee;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
.rightInfo{
|
|
||||||
|
.rightInfo {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.text_20,.text_22{
|
|
||||||
|
.text_20,
|
||||||
|
.text_22 {
|
||||||
margin-right: 28rpx;
|
margin-right: 28rpx;
|
||||||
}
|
}
|
||||||
.text_18,.text_24{
|
|
||||||
|
.text_18,
|
||||||
|
.text_24 {
|
||||||
margin-right: 28rpx;
|
margin-right: 28rpx;
|
||||||
}
|
}
|
||||||
.text_24{
|
|
||||||
|
.text_24 {
|
||||||
color: #AAAAAA;
|
color: #AAAAAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text_17,
|
.text_17,
|
||||||
.text_19,
|
.text_19,
|
||||||
.text_21,
|
.text_21,
|
||||||
|
|
@ -1013,16 +950,12 @@ function onNumberInput(field, value) {
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
}
|
}
|
||||||
.footer{
|
|
||||||
|
.footer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
}
|
}
|
||||||
.home {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 图片编辑样式 */
|
/* 图片编辑样式 */
|
||||||
.image-box {
|
.image-box {
|
||||||
|
|
@ -1032,20 +965,6 @@ function onNumberInput(field, value) {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-tip {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 20rpx;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
background-color: rgba(0, 0, 0, 0.5);
|
|
||||||
padding: 10rpx 20rpx;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.scroll-image-box {
|
.scroll-image-box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
|
@ -1120,8 +1039,6 @@ function onNumberInput(field, value) {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
@ -1159,7 +1076,6 @@ function onNumberInput(field, value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
.btns {
|
.btns {
|
||||||
/* border-left: 1rpx solid #F2F2F2; */
|
|
||||||
color: #DA1C01;
|
color: #DA1C01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1205,7 +1121,9 @@ function onNumberInput(field, value) {
|
||||||
.editDialog_body {
|
.editDialog_body {
|
||||||
padding: 20rpx 30rpx;
|
padding: 20rpx 30rpx;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
max-height: 60vh;
|
max-height: 60vh;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.formItem {
|
.formItem {
|
||||||
|
|
@ -1255,10 +1173,11 @@ function onNumberInput(field, value) {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.text_6,
|
.text_6,
|
||||||
.text_10,
|
.text_10,
|
||||||
.text_13,
|
.text_13,
|
||||||
.text_16{
|
.text_16 {
|
||||||
font-family:"zsyhFt";
|
font-family: "zsyhFt";
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue