alipay-emulator/pages/other/splash/splash.vue

940 lines
32 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="container">
<!-- 自定义头部导航栏 -->
<ZdyNavbar @right-click="edit" isRightButton rightButtonText="编辑" :title="data.navbar.title"
:bgColor="data.navbar.bgColor" :isBack="true" />
<image :src="data.code" mode="widthFix" style="width: 100vw;" @click="previewImage"></image>
<view class="footer-box">
<view class="btn" v-for="(item, index) in data.typeList" :key="index" :class="{ active: data.type == index }"
@click="setType(index)">
样式{{index+1}}
</view>
</view>
<view class="button-container">
<button class="btn-save-image" @click="saveImage">保存图片</button>
</view>
<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" hidden
v-if="data.bgImage&&data.type==0" :css="`width:${data.width}px;height:${data.width / 4 * 3}px;`">
<l-painter-view
:css="`position: relative;width:${data.width}px;height:${data.width / 4 * 3}px;background-image: url('${data.bgImage}');`">
<!-- 头部年月 -->
<l-painter-view :css="`position: absolute;left:480px;top:336px;`">
<l-painter-text :css="data.textCssTime" :text="data.form.year" />
</l-painter-view>
<l-painter-view :css="`position: absolute;left:544px;top:336px;`">
<l-painter-text :css="data.textCssTime" :text="data.form.month" />
</l-painter-view>
<!-- 岗位 -->
<l-painter-view :css="`position: absolute;left:158px;top:445px;`">
<l-painter-text :css="data.textCss" :text="data.form.work" />
</l-painter-view>
<!-- 姓名 -->
<l-painter-view :css="`position: absolute;left:213px;top:445px;`">
<l-painter-text :css="data.textCss" :text="data.form.name" />
</l-painter-view>
<!-- 基本工资 -->
<l-painter-view :css="`position: absolute;left:268px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money1 + ''" />
</l-painter-view>
<!-- 绩效工资 -->
<l-painter-view :css="`position: absolute;left:314px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money2 + ''" />
</l-painter-view>
<!-- 全勤工资 -->
<l-painter-view :css="`position: absolute;left:358px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money3 + ''" />
</l-painter-view>
<!-- 其他奖金 -->
<l-painter-view :css="`position: absolute;left:404px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money4 + ''" />
</l-painter-view>
<!-- 合计 -->
<l-painter-view :css="`position: absolute;left:454px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money5 + ''" />
</l-painter-view>
<!-- 社保缴纳 -->
<l-painter-view :css="`position: absolute;left:504px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money6 + ''" />
</l-painter-view>
<!-- 个税缴纳 -->
<l-painter-view :css="`position: absolute;left:554px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money7 + ''" />
</l-painter-view>
<!-- 考勤扣款 -->
<l-painter-view :css="`position: absolute;left:598px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money8 + ''" />
</l-painter-view>
<!-- 其他扣款 -->
<l-painter-view :css="`position: absolute;left:640px;top:445px;`">
<l-painter-text :css="data.textCssMoney" :text="data.form.money9 + ''" />
</l-painter-view>
<!-- 合计 -->
<l-painter-view :css="`position: absolute;left:688px;top:445px;`">
<l-painter-text :css="data.textCss" :text="data.form.money10 + ''" />
</l-painter-view>
<!-- 实发工资 -->
<l-painter-view :css="`position: absolute;left:734px;top:445px;`">
<l-painter-text :css="data.textCss" :text="data.form.money11 + ''" />
</l-painter-view>
<l-painter-view v-if="$isVip()" :css="`position: absolute;right:20px;bottom:20px;`">
<l-painter-image src="/static/image/other/shuiying.png" css="width: 170rpx; height: 50rpx;" />
</l-painter-view>
</l-painter-view>
</l-painter>
<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" hidden v-else-if="data.type==1"
:css="`width:375px;height:1150px;`">
<l-painter-view :css="`position: relative;width:375px;height:1150px;background-color:#F6F8FA;`">
<!-- 头部 -->
<l-painter-view
css="background-color:#EFEFEF;height:44px;display:flex;justify-content: space-between;align-items: center;padding:0 12px;">
<l-painter-image src="/static/image/close.png" css="width: 24px; height: 24px;" />
<l-painter-text text="工资条详情" />
<l-painter-image src="/static/image/more.png" css="width: 24px; height: 24px;" />
</l-painter-view>
<l-painter-view css="padding:12px 18px;">
<l-painter-view css="background-color:#FFFFFF;padding:12px;border-radius: 6px 6px 6px 6px;">
<l-painter-view css="display: flex; flex-direction: column;align-items: center;margin-top:23px;">
<l-painter-text css="font-size:24px;color:#373737;font-weight: bold;" :text="formatMoney(data.form.money11)" />
<l-painter-text css="font-size:12px;color:#767676;" text="实发工资" />
<l-painter-image src="/static/image/other/salary/dashed.png"
css="margin-top:24px;width:100%; height: 2px;" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:12px;">
<l-painter-text css="font-size:14px;color:#373737;" text="姓名" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.name + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="任职部门" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.department + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="职务" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.work + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="专员薪酬标准" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.salaryStandard + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="应出勤天数" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.shouldWorkDays + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="事假" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.personalLeave + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="病假" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.sickLeave + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="实出勤天数" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.actualWorkDays + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="补贴" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.subsidy + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="绩效" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.performance + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="应发合计" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.money5 + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="个人社保代扣" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.money6 + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="个人公积金代扣" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.housingFund + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="个人所得税代扣" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.money7 + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="应扣事假" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.deductPersonalLeave + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="应扣病假" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.deductSickLeave + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="其他扣款" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.money9 + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="应扣合计" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.money10 + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="实发工资" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.money11 + ''" />
</l-painter-view>
<l-painter-view css="display:flex;justify-content: space-between;padding:0 24px;margin-top:22px;">
<l-painter-text css="font-size:14px;color:#373737;" text="备注" />
<l-painter-text css="font-size:14px;color:#373737;" :text="data.form.remark + ''" />
</l-painter-view>
<l-painter-view css="margin-top:24px;">
<l-painter-image src="/static/image/other/salary/dashed.png" css="width:100%; height: 2px;" />
</l-painter-view>
<l-painter-view css="margin-top:60px;display:flex;justify-content: space-between;align-items: center;">
<l-painter-view css="width: 143px;height: 38px;border-radius: 4px 4px 4px 4px;border: 1px solid #3B9BDF;background-color:#3B9BDF;display:flex;justify-content: center;align-items: center;">
<l-painter-text css="font-size:14px;color:#ffffff;" text="签名确认" />
</l-painter-view>
<l-painter-view css="width: 143px;height: 38px;border-radius: 4px 4px 4px 4px;border: 1px solid #3B9BDF;display:flex;justify-content: center;align-items: center;">
<l-painter-text css="font-size:14px;color:#3B9BDF;" text="对工资有疑问" />
</l-painter-view>
</l-painter-view>
</l-painter-view>
</l-painter-view>
<l-painter-view v-if="$isVip()" :css="`position: absolute;right:20px;bottom:20px;`">
<l-painter-image src="/static/image/other/shuiying.png" css="width: 170rpx; height: 50rpx;" />
</l-painter-view>
</l-painter-view>
</l-painter>
<!-- 编辑弹窗 -->
<view v-if="showEditPopup" class="popup-overlay">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">编辑工资条</text>
<text class="popup-close" @click="closeEditPopup">×</text>
</view>
<view class="popup-body">
<!-- 样式1编辑表单 -->
<template v-if="data.type == 0">
<view class="form-row">
<text class="form-label">岗位:</text>
<input class="form-input" v-model="editForm.work" type="text" />
</view>
<view class="form-row">
<text class="form-label">姓名:</text>
<input class="form-input" v-model="editForm.name" type="text" />
</view>
<view class="form-row">
<text class="form-label">年月:</text>
<input class="form-input" v-model="editForm.year" type="number" style="width: 100px;" />
<text class="form-separator">-</text>
<input class="form-input" v-model="editForm.month" type="number" style="width: 100px;" />
</view>
<view class="form-section">
<text class="section-title">收入部分</text>
<view class="form-row">
<text class="form-label">基本工资:</text>
<input class="form-input" v-model.number="editForm.money1" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">绩效工资:</text>
<input class="form-input" v-model.number="editForm.money2" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">全勤工资:</text>
<input class="form-input" v-model.number="editForm.money3" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">其他奖金:</text>
<input class="form-input" v-model.number="editForm.money4" type="number" @input="calculateValues" />
</view>
<view class="form-row form-total">
<text class="form-label">合计:</text>
<input class="form-input form-total-input" v-model.number="editForm.money5" type="number" disabled />
</view>
</view>
<view class="form-section">
<text class="section-title">扣款部分</text>
<view class="form-row">
<text class="form-label">社保缴纳:</text>
<input class="form-input" v-model.number="editForm.money6" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">个税缴纳:</text>
<input class="form-input" v-model.number="editForm.money7" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">考勤扣款:</text>
<input class="form-input" v-model.number="editForm.money8" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">其他扣款:</text>
<input class="form-input" v-model.number="editForm.money9" type="number" @input="calculateValues" />
</view>
<view class="form-row form-total">
<text class="form-label">合计:</text>
<input class="form-input form-total-input" v-model.number="editForm.money10" type="number" disabled />
</view>
</view>
<view class="form-row form-total">
<text class="form-label">实发工资:</text>
<input class="form-input form-total-input" v-model.number="editForm.money11" type="number" disabled />
</view>
</template>
<!-- 样式2编辑表单 -->
<template v-else>
<view class="form-row">
<text class="form-label">姓名:</text>
<input class="form-input" v-model="editForm.name" type="text" />
</view>
<view class="form-row">
<text class="form-label">任职部门:</text>
<input class="form-input" v-model="editForm.department" type="text" />
</view>
<view class="form-row">
<text class="form-label">职务:</text>
<input class="form-input" v-model="editForm.work" type="text" />
</view>
<view class="form-row">
<text class="form-label">专员薪酬标准:</text>
<input class="form-input" v-model.number="editForm.salaryStandard" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">应出勤天数:</text>
<input class="form-input" v-model.number="editForm.shouldWorkDays" type="number" />
</view>
<view class="form-row">
<text class="form-label">事假:</text>
<input class="form-input" v-model.number="editForm.personalLeave" type="number" />
</view>
<view class="form-row">
<text class="form-label">病假:</text>
<input class="form-input" v-model.number="editForm.sickLeave" type="number" />
</view>
<view class="form-row">
<text class="form-label">实出勤天数:</text>
<input class="form-input" v-model.number="editForm.actualWorkDays" type="number" />
</view>
<view class="form-section">
<text class="section-title">收入部分</text>
<view class="form-row">
<text class="form-label">补贴:</text>
<input class="form-input" v-model.number="editForm.subsidy" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">绩效:</text>
<input class="form-input" v-model.number="editForm.performance" type="number" @input="calculateValues" />
</view>
<view class="form-row form-total">
<text class="form-label">应发合计:</text>
<input class="form-input form-total-input" v-model.number="editForm.money5" type="number" disabled />
</view>
</view>
<view class="form-section">
<text class="section-title">扣款部分</text>
<view class="form-row">
<text class="form-label">个人社保代扣:</text>
<input class="form-input" v-model.number="editForm.money6" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">个人公积金代扣:</text>
<input class="form-input" v-model.number="editForm.housingFund" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">个人所得税代扣:</text>
<input class="form-input" v-model.number="editForm.money7" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">应扣事假:</text>
<input class="form-input" v-model.number="editForm.deductPersonalLeave" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">应扣病假:</text>
<input class="form-input" v-model.number="editForm.deductSickLeave" type="number" @input="calculateValues" />
</view>
<view class="form-row">
<text class="form-label">其他扣款:</text>
<input class="form-input" v-model.number="editForm.money9" type="number" @input="calculateValues" />
</view>
<view class="form-row form-total">
<text class="form-label">应扣合计:</text>
<input class="form-input form-total-input" v-model.number="editForm.money10" type="number" disabled />
</view>
</view>
<view class="form-row form-total">
<text class="form-label">实发工资:</text>
<input class="form-input form-total-input" v-model.number="editForm.money11" type="number" disabled />
</view>
<view class="form-row">
<text class="form-label">备注:</text>
<input class="form-input" v-model="editForm.remark" type="text" />
</view>
</template>
</view>
<view class="popup-footer">
<button class="btn-cancel" @click="closeEditPopup">取消</button>
<button class="btn-save" @click="saveEditForm">保存</button>
</view>
</view>
</view>
<!-- 水印 -->
<view v-if="$isVip()">
<liu-drag-button :canDocking="false" @clickBtn="$goRechargePage('watermark', 'uni_alipay_other_gongzhitiao')">
<c-lottie ref="cLottieRef" :src='$watermark()' width="94px" height='74px' :loop="true"></c-lottie>
</liu-drag-button>
</view>
</view>
</template>
<script setup>
// 自定义头部
import ZdyNavbar from "@/components/nav-bar/nav-bar.vue"
import {
imgLocal
} from '@/utils/common.js';
import {
ref,
reactive,
watch,
nextTick,
getCurrentInstance
} from "vue";
import {
onLoad,
onShow,
onReady,
onPullDownRefresh,
onReachBottom
} from "@dcloudio/uni-app";
const {
appContext,
proxy
} = getCurrentInstance();
function defaultForm(type) {
const forms = {
0: {
work: "销售",
name: '小明',
money1: 5000,
money2: 1000,
money3: 1000,
money4: 1000,
money5: 8000,
money6: 512,
money7: 12,
money8: 0,
money9: 0,
money10: 524,
money11: 7476,
year: 2026,
month: 1,
},
1: {
name: '校长',
department: '市场推广部',
work: '推广专员',
salaryStandard: 7500,
shouldWorkDays: 22,
personalLeave: 0,
sickLeave: 0,
actualWorkDays: 22,
subsidy: 500,
performance: 1000,
money5: 9000,
money6: 512,
housingFund: 300,
money7: 120,
deductPersonalLeave: 0,
deductSickLeave: 0,
money9: 0,
money10: 932,
money11: 8068,
remark: '餐饮饭卡补贴200元',
}
}
return forms[type] || forms[0]
}
function mergeForm(raw, type) {
return Object.assign(defaultForm(type), raw && typeof raw === 'object' ? raw : {})
}
function formatMoney(val) {
const num = Number(val) || 0
return '¥' + num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
const data = reactive({
navbar: {
title: "工资条",
bgColor: '#EDEDED',
},
type: 0,
bgImage: '',
width: 375,
height: 495,
code: '',
form: mergeForm(null, 0),
textCss: ' letter-spacing: 10px;font-family: "SimHei", "Microsoft YaHei", sans-serif;width:50px;text-align: center;color:#505156;transform: scale(0.4);font-size:26rpx;font-weight: bold; mix-blend-mode: overlay;',
textCssMoney: 'font-family: "SimHei", "Microsoft YaHei", sans-serif;width:50px;text-align: center;color:#505156;transform: scale(0.4);font-size:12px;font-weight: bold; mix-blend-mode: overlay;',
textCssTime: 'font-family: "SimHei", "Microsoft YaHei", sans-serif;width:50px;text-align: center;color:#505156;transform: scale(0.4);font-size:18px;font-weight: bold; mix-blend-mode: overlay;',
typeList: ['样式1', '样式2']
})
// 弹窗相关
const showEditPopup = ref(false);
const editForm = ref({});
function setType(index) {
uni.setStorageSync("salary" + data.type, data.form)
uni.showLoading({
title: "生成中"
})
data.type = index
data.form = mergeForm(uni.getStorageSync("salary" + data.type), data.type)
}
//
function successImage(e) {
data.code = e
}
function progress(e) {
if (e < 0.03) {
uni.showLoading({
title: "生成中"
})
}
if (e == 1) {
uni.hideLoading()
}
// console.log(e)
}
// 打开编辑弹窗
function edit() {
editForm.value = mergeForm(JSON.parse(JSON.stringify(data.form)), data.type)
calculateValues()
showEditPopup.value = true
}
// 关闭编辑弹窗
function closeEditPopup() {
showEditPopup.value = false;
}
// 保存编辑表单
function saveEditForm() {
calculateValues()
uni.showLoading({
title: "生成中"
})
data.form = mergeForm(editForm.value, data.type)
uni.setStorageSync("salary" + data.type, data.form)
showEditPopup.value = false
}
// 计算值
function calculateValues() {
if (data.type === 0) {
editForm.value.money5 = (editForm.value.money1 || 0) + (editForm.value.money2 || 0) + (editForm.value.money3 ||
0) + (editForm.value.money4 || 0)
editForm.value.money10 = (editForm.value.money6 || 0) + (editForm.value.money7 || 0) + (editForm.value.money8 ||
0) + (editForm.value.money9 || 0)
editForm.value.money11 = editForm.value.money5 - editForm.value.money10
} else {
editForm.value.money5 = (editForm.value.salaryStandard || 0) + (editForm.value.subsidy || 0) + (editForm.value
.performance || 0)
editForm.value.money10 = (editForm.value.money6 || 0) + (editForm.value.housingFund || 0) + (editForm.value
.money7 || 0) + (editForm.value.deductPersonalLeave || 0) + (editForm.value.deductSickLeave || 0) + (
editForm.value.money9 || 0)
editForm.value.money11 = editForm.value.money5 - editForm.value.money10
}
}
// 预览图片
function previewImage() {
if (data.code) {
uni.previewImage({
urls: [data.code],
current: 0
});
}
}
// 保存图片
function saveImage() {
if (data.code) {
console.log(data.code)
uni.showLoading({
title: '保存中...'
});
try {
// 检查是否为base64格式
if (data.code.startsWith('data:image')) {
// 处理base64格式图片
console.log('开始处理base64图片');
uni.base64ToTempFile({
base64: data.code.split(',')[1], // 去除base64前缀
success: (res) => {
console.log('base64转换成功', res);
if (res.tempFilePath) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
console.log('保存图片成功');
uni.hideLoading();
uni.showToast({
title: '保存成功',
icon: 'success'
});
},
fail: (err) => {
console.log('保存图片失败', err);
uni.hideLoading();
uni.showToast({
title: '保存失败',
icon: 'none'
});
}
});
} else {
console.log('base64转换失败无临时文件路径');
uni.hideLoading();
uni.showToast({
title: '转换失败',
icon: 'none'
});
}
},
fail: (err) => {
console.log('base64转换失败', err);
uni.hideLoading();
uni.showToast({
title: '转换失败',
icon: 'none'
});
}
});
} else if (data.code.startsWith('_') || data.code.includes('temp') || data.code.includes('cache') || data
.code.includes('_doc') || data.code.includes('_tmp')) {
// 处理本地临时文件
console.log('开始处理本地临时文件');
uni.saveImageToPhotosAlbum({
filePath: data.code,
success: () => {
console.log('保存本地文件成功');
uni.hideLoading();
uni.showToast({
title: '保存成功',
icon: 'success'
});
},
fail: (err) => {
console.log('保存本地文件失败', err);
uni.hideLoading();
uni.showToast({
title: '保存失败',
icon: 'none'
});
}
});
} else {
// 处理网络图片
console.log('开始处理网络图片');
uni.downloadFile({
url: data.code,
success: (res) => {
console.log('下载图片成功', res);
if (res.statusCode === 200 && res.tempFilePath) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
console.log('保存图片成功');
uni.hideLoading();
uni.showToast({
title: '保存成功',
icon: 'success'
});
},
fail: (err) => {
console.log('保存图片失败', err);
uni.hideLoading();
uni.showToast({
title: '保存失败',
icon: 'none'
});
}
});
} else {
console.log('下载图片失败,状态码:', res.statusCode);
uni.hideLoading();
uni.showToast({
title: '下载失败',
icon: 'none'
});
}
},
fail: (err) => {
console.log('下载图片失败', err);
uni.hideLoading();
uni.showToast({
title: '下载失败',
icon: 'none'
});
}
});
}
} catch (error) {
console.log('保存图片异常', error);
uni.hideLoading();
uni.showToast({
title: '保存失败',
icon: 'none'
});
}
} else {
uni.showToast({
title: '暂无图片可保存',
icon: 'none'
});
}
}
onLoad(async (option) => {
// 进入工资单页面埋点
proxy.$apiUserEvent('all', {
type: 'event',
key: 'paystub',
prefix: '.uni.other.',
value: "工资单"
})
data.bgImage = await imgLocal.getLocalImage('other/gzd.png');
data.form = mergeForm(uni.getStorageSync("salary" + data.type), data.type)
})
onReady(() => {
})
onShow(() => {})
onPullDownRefresh(() => {
setTimeout(() => {
uni.stopPullDownRefresh();
}, 1000);
})
onReachBottom(() => {
})
</script>
<style lang="scss" scoped>
* {
box-sizing: content-box;
}
.aadadad {
text-align: center;
}
.heiti {
font-family: "SimHei", "Microsoft YaHei", sans-serif;
}
/* 弹窗样式 */
.popup-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.popup-content {
background-color: #fff;
border-radius: 10px;
width: 90%;
max-width: 500px;
max-height: 80vh;
overflow-y: auto;
}
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx;
border-bottom: 1rpx solid #eee;
}
.popup-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.popup-close {
font-size: 48rpx;
color: #999;
cursor: pointer;
}
.popup-body {
padding: 20rpx;
height:60vh;
overflow-y: scroll;
}
.form-section {
margin-bottom: 30rpx;
padding: 20rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
}
.section-title {
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
display: block;
}
.form-row {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.form-label {
width: 200rpx;
font-size: 26rpx;
color: #333;
}
.form-input {
flex: 1;
padding: 15rpx;
border: 1rpx solid #ddd;
border-radius: 4rpx;
font-size: 26rpx;
}
.form-separator {
margin: 0 10rpx;
font-size: 26rpx;
color: #333;
}
.form-total {
margin-top: 10rpx;
padding-top: 10rpx;
border-top: 1rpx dashed #ddd;
}
.form-total-input {
background-color: #f9f9f9;
color: #ff6b35;
font-weight: bold;
}
.popup-footer {
display: flex;
justify-content: space-between;
padding: 20rpx;
border-top: 1rpx solid #eee;
}
.btn-cancel,
.btn-save {
width: calc(48% - 40rpx);
padding: 20rpx;
border-radius: 4rpx;
font-size: 28rpx;
}
.btn-cancel {
background-color: #f5f5f5;
color: #333;
// border: 1rpx solid #ddd;
}
.btn-save {
background-color: #187AFF;
color: #fff;
border: none;
}
/* 保存图片按钮 */
.button-container {
display: flex;
justify-content: center;
position: fixed;
left: 0;
bottom: 86px;
width: 100vw;
display: flex;
justify-content: center;
padding-bottom: constant(safe-area-inset-bottom); // 兼容 IOS<11.2
padding-bottom: env(safe-area-inset-bottom); // 兼容 IOS>11.2
}
.btn-save-image {
background: linear-gradient(90deg, #187AFF 0%, #3295FC 100%);
color: #fff;
border: none;
padding: 18rpx 60rpx;
border-radius: 40rpx;
font-size: 26rpx;
font-weight: bold;
box-shadow: 0 3rpx 10rpx rgba(7, 66, 193, 0.3);
transition: all 0.3s ease;
text-align: center;
min-width: 160rpx;
}
.btn-save-image:hover {
transform: translateY(-2rpx);
box-shadow: 0 4rpx 12rpx rgba(7, 72, 193, 0.4);
}
.btn-save-image:active {
transform: translateY(0);
box-shadow: 0 2rpx 6rpx rgba(7, 140, 193, 0.3);
}
.footer-box {
position: fixed;
left: 0;
bottom: 16px;
width: 100vw;
display: flex;
justify-content: center;
padding-bottom: constant(safe-area-inset-bottom); // 兼容 IOS<11.2
padding-bottom: env(safe-area-inset-bottom); // 兼容 IOS>11.2
.btn {
font-size: 18px;
color: #767676;
width: 180rpx;
height: 80rpx;
line-height: 80rpx;
background: #FFFFFF;
border-radius: 8px 8px 8px 8px;
background: #FFFFFF;
text-align: center;
margin: 0 24rpx;
border: 2px solid #FFFFFF;
color: #767676;
}
.active {
color: #1777FF;
border: 2px solid #1777FF;
}
}
</style>