This commit is contained in:
hezhidong
2025-04-18 18:01:03 +08:00
parent 9103270895
commit 44cba1950d
10 changed files with 1327 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": {
"mini-smooth-signature": "^1.2.3"
}
}
+44 -1
View File
@@ -1,8 +1,23 @@
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
// 示例模版页面
// {
// "path": "pages/index/index",
// "style": {
// // 顶部标题字
// "navigationBarTitleText": "uni-app",
// // 开启下拉加载
// "enablePullDownRefresh": true,
// // 下拉的距离触发下拉事件
// "pull-distance": 50,
// // 设置背景颜色
// "backgroundColor": "#ffffff",
// // 上拉触底的距离
// "onReachBottomDistance": 100
// }
// },
{
"path": "pages/index/index",
"path": "pages/homePage/homePage",
"style": {
// 顶部标题字
"navigationBarTitleText": "uni-app",
@@ -16,6 +31,34 @@
"onReachBottomDistance": 100
}
}
,{
"path" : "pages/attendanceManagement/attendanceManagement",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/salaryDetails/salaryDetails",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/sign/sign",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"subPackages": [
{
@@ -0,0 +1,469 @@
<template>
<view class="attendance-page">
<!-- 月份选择 -->
<view class="month-selector" @click="showDatePicker">
<view class="combination">
<text class="current-month"
>{{ selectedYear }}{{
selectedMonth < 10 ? "0" + selectedMonth : selectedMonth
}}</text
>
<image class="arrow" src="/static/arr.png" mode="aspectFit"></image>
</view>
<text class="month-text">月度</text>
</view>
<!-- 打卡统计 -->
<view class="stat-section">
<view class="section-title">打卡统计</view>
<view class="stat-grid">
<view class="stat-item">
<text class="label">迟到</text>
<text class="value red-text">4</text>
</view>
<view class="stat-item">
<text class="label">严重迟到</text>
<text class="value red-text">3</text>
</view>
<view class="stat-item">
<text class="label">旷工迟到</text>
<text class="value">0</text>
</view>
<view class="stat-item">
<text class="label">早退</text>
<text class="value red-text">1</text>
</view>
<view class="stat-item">
<text class="label">未打卡</text>
<text class="value red-text">2</text>
</view>
</view>
</view>
<!-- 请假统计 -->
<view class="stat-section">
<view class="section-title">请假统计</view>
<view class="stat-grid">
<view class="stat-item">
<text class="label">事假</text>
<text class="value red-text">4</text>
</view>
<view class="stat-item">
<text class="label">病假</text>
<text class="value red-text">3</text>
</view>
<view class="stat-item">
<text class="label">婚假</text>
<text class="value">0</text>
</view>
<view class="stat-item">
<text class="label">产假</text>
<text class="value red-text">1</text>
</view>
<view class="stat-item">
<text class="label">陪产假</text>
<text class="value red-text">2</text>
</view>
<view class="stat-item">
<text class="label">丧假</text>
<text class="value red-text">2</text>
</view>
</view>
</view>
<!-- 加班调休统计 -->
<view class="stat-section">
<view class="section-title">加班调休统计</view>
<view class="stat-grid">
<view class="stat-item">
<text class="label">节假日加班</text>
<text class="value red-text">4</text>
</view>
<view class="stat-item">
<text class="label">休息日加班</text>
<text class="value red-text">3</text>
</view>
<view class="stat-item">
<text class="label">工作日加班</text>
<text class="value">0</text>
</view>
<view class="stat-item">
<text class="label">调休</text>
<text class="value red-text">1</text>
</view>
</view>
</view>
<!-- 底部说明 -->
<view class="bottom-tips">说明请核实当月考勤记录确认无误请签字确认</view>
<!-- 员工签字 -->
<view class="sign">
<view class="sign-tit">
员工签字
<text>/保留员工签字</text>
</view>
<view class="signatureVersion"></view>
</view>
<!-- 签字确认按钮 -->
<view class="confirm-btn" @click="goSignIt"><text>签字确认</text></view>
<!-- 日期选择模态框 -->
<view class="date-picker-modal" v-if="showModal" @click.stop="closeDatePicker">
<view class="modal-content" @click.stop>
<view class="modal-title">{{
currentStep === "year" ? "选择年份" : "选择月份"
}}</view>
<!-- 年份选择 -->
<view class="year-grid" v-if="currentStep === 'year'">
<view
v-for="year in availableYears"
:key="year"
class="year-item"
:class="{ active: tempSelectedYear === year }"
@click="selectYear(year)"
>
<view class="year-circle">
<text>{{ year }}</text>
</view>
</view>
</view>
<!-- 月份选择 -->
<view class="month-grid" v-if="currentStep === 'month'">
<view
v-for="month in months"
:key="month"
class="month-item"
:class="{ active: tempSelectedMonth === month }"
@click="selectMonth(month)"
>
<view class="month-circle">
<text
>{{ tempSelectedYear }}{{ month < 10 ? "0" + month : month }}</text
>
</view>
</view>
</view>
<!-- 底部按钮 -->
<view class="modal-footer" v-if="currentStep === 'month'">
<view class="back-btn" @click="backToYearSelect">返回年份选择</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
return {
showModal: false,
currentYear,
selectedYear: currentYear,
selectedMonth: currentDate.getMonth() + 1,
months: Array.from({ length: 12 }, (_, i) => i + 1),
currentStep: "year", // 'year' 或 'month'
tempSelectedYear: currentYear,
tempSelectedMonth: currentDate.getMonth() + 1,
availableYears: Array.from({ length: 7 }, (_, i) => currentYear - 3 + i),
};
},
created() {
this.$setNavigationBar("考勤管理");
},
methods: {
showDatePicker() {
this.showModal = true;
this.currentStep = "year";
this.tempSelectedYear = this.selectedYear;
this.tempSelectedMonth = this.selectedMonth;
},
closeDatePicker() {
this.showModal = false;
this.currentStep = "year";
},
selectYear(year) {
this.tempSelectedYear = year;
this.currentStep = "month";
},
selectMonth(month) {
this.tempSelectedMonth = month;
this.selectedYear = this.tempSelectedYear;
this.selectedMonth = month;
this.showModal = false;
this.currentStep = "year";
this.$emit("dateSelected", {
year: this.selectedYear,
month: this.selectedMonth,
});
console.log("选择月份触发");
},
backToYearSelect() {
this.currentStep = "year";
},
goSignIt(){
this.$navTo('/pages/sign/sign');
}
},
};
</script>
<style lang="scss" scoped>
.attendance-page {
min-height: 100vh;
background-color: #f8f9fa;
padding: 0 30rpx 0 30rpx;
.month-selector {
padding: 0 28rpx 0 10rpx;
display: flex;
align-items: center;
margin: 40rpx 0;
justify-content: space-between;
.combination {
height: 40rpx;
line-height: 40rpx;
display: flex;
align-content: center;
.current-month {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
color: #4b5563;
}
.arrow {
transform: rotate(90deg);
width: 40rpx;
height: 40rpx;
}
}
.month-text {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
color: #2b5ce4;
}
}
.stat-section {
background: #fff;
border-radius: 12rpx;
padding: 35rpx 40rpx;
margin-bottom: 20rpx;
.section-title {
font-size: 32rpx;
color: #111827;
}
.stat-grid {
margin-top: 40rpx;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 40rpx 90rpx;
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
.label {
font-size: 28rpx;
color: #4b5563;
margin-bottom: 15rpx;
}
.value {
font-size: 32rpx;
color: #666;
&.red-text {
color: #ff4d4f;
}
}
}
}
}
.bottom-tips {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #b9b9c2;
}
.sign {
margin-top: 32rpx;
margin-bottom: 180rpx;
.sign-tit {
margin-bottom: 32rpx;
margin-left: 8rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 700;
font-size: 28rpx;
color: #000000;
text {
padding-left: 16rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #b9b9c2;
}
}
.signatureVersion {
width: 690rpx;
height: 280rpx;
background: #ffffff;
border-radius: 20rpx;
}
}
.confirm-btn {
position: fixed;
bottom: 45rpx;
left: 20rpx;
right: 20rpx;
height: 78rpx;
background: #ffffff;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 30rpx;
color: #0078ff;
font-size: 32rpx;
border: 2rpx solid #0078ff;
}
.date-picker-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
.modal-content {
width: 690rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 40rpx 30rpx;
.modal-title {
font-size: 32rpx;
color: #111827;
text-align: center;
margin-bottom: 40rpx;
font-weight: 500;
}
.year-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
padding: 0 20rpx;
.year-item {
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
.year-circle {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8rpx;
border: 2rpx solid #e5e7eb;
text {
font-size: 28rpx;
color: #4b5563;
}
}
&.active {
.year-circle {
background: #eef2ff;
border-color: #2b5ce4;
text {
color: #2b5ce4;
}
}
}
}
}
.month-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
padding: 0 20rpx;
.month-item {
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
.month-circle {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8rpx;
border: 2rpx solid #e5e7eb;
text {
font-size: 28rpx;
color: #4b5563;
}
}
&.active {
.month-circle {
background: #eef2ff;
border-color: #2b5ce4;
text {
color: #2b5ce4;
}
}
}
}
}
.modal-footer {
margin-top: 30rpx;
display: flex;
justify-content: center;
.back-btn {
padding: 20rpx 40rpx;
font-size: 28rpx;
color: #2b5ce4;
background: #eef2ff;
border-radius: 8rpx;
}
}
}
}
}
</style>
+331
View File
@@ -0,0 +1,331 @@
<template>
<view class="home-page">
<!-- 考勤管理部分 -->
<view class="section attendance">
<view class="section-header">
<view class="left">
<image class="icon" src="/static/WorkAtt.png" mode="aspectFit"></image>
<text>考勤管理</text>
</view>
<view class="right"><text class="blue-text">月度考勤</text></view>
</view>
<view class="section-content" style="display: flex; justify-content: space-between; align-items: center">
<text class="title">{{ selectedYear }}{{ selectedMonth < 10 ? '0' + selectedMonth : selectedMonth }}月考勤统计</text>
<view class="combination" @click="viewDetails">
<text class="detail">查看详情</text>
<image class="icon" src="/static/arr.png" mode="aspectFit"></image>
</view>
</view>
</view>
<!-- 工资条部分 -->
<view class="section salary">
<view class="section-header">
<view class="left">
<image class="icon" src="/static/money.png" mode="aspectFit"></image>
<text>工资条</text>
</view>
<view class="right" @click="showDatePicker">
<text>{{ selectedYear }}{{ selectedMonth < 10 ? '0' + selectedMonth : selectedMonth }}</text>
<image class="arrow" src="/static/arr.png" mode="aspectFit"></image>
</view>
</view>
<view class="section-content">
<text class="title">{{ selectedYear }}{{ selectedMonth < 10 ? '0' + selectedMonth : selectedMonth }}月工资条</text>
<view class="warning">
<text class="warning-icon"></text>
<text class="watext">工资表为系统自动生成如有疑问请联系财务部门</text>
</view>
</view>
<view class="view-details" @click="viewSalaryDetails"><text>查看明细</text></view>
</view>
<!-- 日期选择模态框 -->
<view class="date-picker-modal" v-if="showModal" @click.stop="closeDatePicker">
<view class="modal-content" @click.stop>
<view class="modal-title">{{ currentStep === 'year' ? '选择年份' : '选择月份' }}</view>
<!-- 年份选择 -->
<view class="year-grid" v-if="currentStep === 'year'">
<view v-for="year in availableYears" :key="year" class="year-item" :class="{ active: tempSelectedYear === year }" @click="selectYear(year)">
<view class="year-circle">
<text>{{ year }}</text>
</view>
</view>
</view>
<!-- 月份选择 -->
<view class="month-grid" v-if="currentStep === 'month'">
<view v-for="month in months" :key="month" class="month-item" :class="{ active: tempSelectedMonth === month }" @click="selectMonth(month)">
<view class="month-circle">
<text>{{ tempSelectedYear }}{{ month < 10 ? '0' + month : month }}</text>
</view>
</view>
</view>
<!-- 底部按钮 -->
<view class="modal-footer" v-if="currentStep === 'month'"><view class="back-btn" @click="backToYearSelect">返回年份选择</view></view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
return {
showModal: false,
currentYear,
selectedYear: currentYear,
selectedMonth: currentDate.getMonth() + 1,
months: Array.from({ length: 12 }, (_, i) => i + 1),
currentStep: 'year',
tempSelectedYear: currentYear,
tempSelectedMonth: currentDate.getMonth() + 1,
availableYears: Array.from({ length: 7 }, (_, i) => currentYear - 3 + i)
};
},
created() {
this.$setNavigationBar('人资系统');
},
methods: {
showDatePicker() {
this.showModal = true;
this.currentStep = 'year';
this.tempSelectedYear = this.selectedYear;
this.tempSelectedMonth = this.selectedMonth;
},
closeDatePicker() {
this.showModal = false;
this.currentStep = 'year';
},
selectYear(year) {
this.tempSelectedYear = year;
this.currentStep = 'month';
},
selectMonth(month) {
this.tempSelectedMonth = month;
this.selectedYear = this.tempSelectedYear;
this.selectedMonth = month;
this.showModal = false;
this.currentStep = 'year';
this.$emit('dateSelected', {
year: this.selectedYear,
month: this.selectedMonth
});
console.log('选择月份触发');
},
backToYearSelect() {
this.currentStep = 'year';
},
viewDetails() {
this.$navTo('/pages/attendanceManagement/attendanceManagement');
},
viewSalaryDetails(){
this.$navTo('/pages/salaryDetails/salaryDetails');
}
}
};
</script>
<style lang="scss" scoped>
.home-page {
overflow: hidden;
min-height: 100vh;
background-color: #f8f9fa;
padding: 0 30rpx;
.section {
background: #fff;
border-radius: 20rpx;
margin-top: 24rpx;
padding: 30rpx;
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.left {
display: flex;
align-items: center;
.icon {
width: 48rpx;
height: 48rpx;
margin-right: 10rpx;
}
text {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 36rpx;
color: #111827;
}
}
.right {
display: flex;
align-items: center;
color: #666;
font-size: 28rpx;
.blue-text {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
color: #2b5ce4;
}
.arrow {
transform: rotate(90deg);
width: 40rpx;
height: 40rpx;
}
}
}
.section-content {
margin-top: 35rpx;
.title {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 30rpx;
color: #4b5563;
}
.combination {
display: flex;
align-items: center;
}
.detail {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
color: #4b5563;
}
.icon {
width: 40rpx;
height: 40rpx;
}
.warning {
margin-top: 10rpx;
display: flex;
align-items: center;
color: #ff6b01;
font-size: 28rpx;
.warning-icon {
margin-right: 10rpx;
}
.watext {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #b9b9c2;
}
}
}
}
.view-details {
font-family: Source Han Sans CN, Source Han Sans CN;
margin-top: 42rpx;
height: 78rpx;
background: #0078ff;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 30rpx;
}
.date-picker-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
.modal-content {
width: 690rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 40rpx 30rpx;
.modal-title {
font-size: 32rpx;
color: #111827;
text-align: center;
margin-bottom: 40rpx;
font-weight: 500;
}
.year-grid,
.month-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
padding: 0 20rpx;
.year-item,
.month-item {
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
.year-circle,
.month-circle {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8rpx;
border: 2rpx solid #e5e7eb;
text {
font-size: 28rpx;
color: #4b5563;
}
}
&.active {
.year-circle,
.month-circle {
background: #eef2ff;
border-color: #2b5ce4;
text {
color: #2b5ce4;
}
}
}
}
}
.modal-footer {
margin-top: 30rpx;
display: flex;
justify-content: center;
.back-btn {
padding: 20rpx 40rpx;
font-size: 28rpx;
color: #2b5ce4;
background: #eef2ff;
border-radius: 8rpx;
}
}
}
}
}
</style>
+1 -5
View File
@@ -8,12 +8,8 @@
<Inputli @click="onClickName" v-model="form.sex" />
<Selectli v-model="form.sex" label="性123别" :array="sexArr" />
<Dateli v-model="form.startTime" />
<button @click="onClickSave">提交</button>
<button @click="onClickSave">提交1</button>
</view>
</view>
</template>
+260
View File
@@ -0,0 +1,260 @@
<template>
<view class="salary-details">
<!-- 顶部蓝色卡片 -->
<view class="salary-card">
<text class="date">2025年04月实发工资</text>
<text class="amount">3000.00</text>
<text class="tips">感谢您为公司的付出辛苦了</text>
</view>
<!-- 收入项目 -->
<view class="salary-section">
<view class="section-title">收入项目</view>
<view class="salary-items">
<view class="item">
<text class="label">基本工资</text>
<text class="value">2500</text>
</view>
<view class="item">
<text class="label">年度绩效奖金</text>
<text class="value">500</text>
</view>
<view class="item">
<text class="label">月度绩效奖金</text>
<text class="value">500</text>
</view>
<view class="item">
<text class="label">其他奖金</text>
<text class="value">1000</text>
</view>
<view class="item">
<text class="label">总经理补贴</text>
<text class="value">0</text>
</view>
<view class="item">
<text class="label">交通补贴</text>
<text class="value">50</text>
</view>
<view class="item">
<text class="label">其他补贴</text>
<text class="value">0</text>
</view>
<view class="item">
<text class="label">工龄工资</text>
<text class="value">50</text>
</view>
<view class="item">
<text class="label">加班工资</text>
<text class="value">0</text>
</view>
<view class="item total">
<text class="label">应发小计</text>
<text class="value highlight">5000</text>
</view>
</view>
</view>
<!-- 扣除项目 -->
<view class="salary-section">
<view class="section-title">扣除项目</view>
<view class="salary-items">
<view class="item">
<text class="label">年度绩效奖金</text>
<text class="value">2500</text>
</view>
<view class="item">
<text class="label">月度绩效奖金</text>
<text class="value">500</text>
</view>
<view class="item">
<text class="label">事假</text>
<text class="value">500</text>
</view>
<view class="item">
<text class="label">病假</text>
<text class="value">1000</text>
</view>
<view class="item">
<text class="label">婚假丧假陪产假</text>
<text class="value">0</text>
</view>
<view class="item">
<text class="label">迟到早退</text>
<text class="value">50</text>
</view>
<view class="item">
<text class="label">签到签退</text>
<text class="value">0</text>
</view>
<view class="item">
<text class="label">缺卡</text>
<text class="value">50</text>
</view>
<view class="item">
<text class="label">旷工</text>
<text class="value">0</text>
</view>
<view class="item">
<text class="label">违纪</text>
<text class="value">0</text>
</view>
</view>
</view>
<!-- 福利 -->
<view class="salary-section">
<view class="section-title">福利</view>
<view class="salary-items">
<view class="item">
<text class="label">基本养老</text>
<text class="value">2500</text>
</view>
<view class="item">
<text class="label">失业保险</text>
<text class="value">500</text>
</view>
<view class="item">
<text class="label">基本医疗</text>
<text class="value">500</text>
</view>
<view class="item">
<text class="label">大额医疗</text>
<text class="value">1000</text>
</view>
<view class="item">
<text class="label">住房公积金</text>
<text class="value">0</text>
</view>
</view>
</view>
<!-- 其他 -->
<view class="salary-section">
<view class="section-title">其他</view>
<view class="salary-items">
<view class="item">
<text class="label">其他扣款</text>
<text class="value">2500</text>
</view>
<view class="item">
<text class="label">个税</text>
<text class="value">500</text>
</view>
<view class="item total">
<text class="label">扣款小计</text>
<text class="value highlight red">2000</text>
</view>
</view>
</view>
<!-- 备注 -->
<view class="salary-section"><view>备注</view></view>
</view>
</template>
<script>
export default {
data() {
return {};
},
created() {
this.$setNavigationBar('工资条');
}
};
</script>
<style lang="scss" scoped>
.salary-details {
min-height: 100vh;
background-color: #f8f9fa;
padding-bottom: 40rpx;
.salary-card {
margin: 0 auto;
box-sizing: border-box;
width: 690rpx;
height: 326rpx;
margin-top: 30rpx;
background: #0078ff;
padding: 54rpx 30rpx 42rpx 30rpx;
display: flex;
flex-direction: column;
align-items: center;
color: #ffffff;
border-radius: 20rpx;
.date {
font-size: 32rpx;
margin-bottom: 20rpx;
}
.amount {
font-size: 72rpx;
font-weight: 500;
margin-bottom: 30rpx;
}
.tips {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.6);
}
}
.salary-section {
background: #ffffff;
margin: 20rpx 30rpx 0;
border-radius: 12rpx;
padding: 30rpx;
.section-title {
font-size: 32rpx;
color: #111827;
font-weight: 500;
margin-bottom: 30rpx;
}
.salary-items {
.item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30rpx;
&:last-child {
margin-bottom: 0;
}
.label {
font-size: 28rpx;
color: #4b5563;
}
.value {
font-size: 28rpx;
color: #4b5563;
}
&.total {
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 2rpx solid #e5e7eb;
.label {
font-weight: 500;
}
.value.highlight {
font-weight: 700;
font-size: 32rpx;
color: #0078ff;
&.red {
color: #ff4d4f;
}
}
}
}
}
}
}
</style>
+216
View File
@@ -0,0 +1,216 @@
<template>
<view class="sing-box">
<view class="canvas-box">
<canvas
:width="width * scale"
:height="height * scale"
:style="{ width: width, height: height }"
:disable-scroll="true"
canvas-id="cansignature"
id="cansignature"
@touchstart="handleTouchStart"
@touchMove="handleTouchMove"
@touchCancel="handleTouchEnd"
@touchEnd="handleTouchEnd"
></canvas>
</view>
<view class="tips">请在空白区域内横向签字</view>
<view class="button-box">
<view @click="onClickClear" class="clear-button">清空</view>
<view @click="onClickAffirm" class="affirm-button">确认</view>
</view>
</view>
</template>
<script>
import Signature from 'mini-smooth-signature';
import baseUrl from '@/api/baseUrl.js';
import { signatureOfMeetingMinutesApi } from '@/api/create.js';
export default {
data() {
return {
signature: '',
width: '',
height: '',
scale: 1,
imgurl: '',
};
},
onLoad(obj) {
this.$setNavigationBar('手写签名');
this.initSignature();
dd.getSystemInfo({
success: res => {
// console.log(res)
this.width = res.windowWidth;
this.height = res.windowHeight;
}
});
},
methods: {
// 点击清除
onClickClear() {
setTimeout(() => {
this.initSignature();
}, 10);
},
// 点击确认
onClickAffirm() {
uni.showLoading({ title: '提交中', mask: true });
this.signature.getImagePath().then(res => {
var pages = getCurrentPages();
var previousPage = pages[pages.length - 2];
uni.uploadFile({
url: baseUrl + '/file/upload',
fileName: 'file',
header: {
Authorization: JSON.parse(uni.getStorageSync('token'))
},
fileType: 'image', // 必填
filePath: res,
success: async res => {
let data = JSON.parse(res.data);
if (data.code == 200) {
uni.hideLoading();
// 把值给前一个页面中的data
// previousPage.$vm.signatureAddress = data.data
console.log(data, '地址');
let obj = {
id: '',
meetingMinutesSign: ''
};
obj.id = this.meetingId;
obj.meetingMinutesSign = data.data;
let signRes = await signatureOfMeetingMinutesApi(obj);
if (signRes.code == 200) {
uni.showToast({
title: '签字成功',
duration: 2000
});
} else {
uni.showToast({
title: '服务器错误,有结果!'
});
}
uni.navigateBack();
} else {
uni.showToast({ title: data.msg, icon: 'error' });
}
},
fail: err => {
uni.showToast({ title: err, icon: 'error' });
}
});
});
},
// 初始化
initSignature() {
const ctx = uni.createCanvasContext('cansignature');
const _this = this;
this.signature = new Signature(ctx, {
width: _this.width,
height: _this.height,
scale: 1,
color: '#000000',
bgColor: '#ffffff',
getImagePath: () => {
return new Promise(resolve => {
ctx.toTempFilePath({
success: res => resolve(res.filePath)
});
});
},
toDataURL: function(res) {
return this;
}
});
},
// 绑定touchstart事件
handleTouchStart(e) {
const pos = e.touches[0];
this.signature.onDrawStart(pos.x, pos.y);
},
// 绑定touchmove事件
handleTouchMove(e) {
const pos = e.touches[0];
this.signature.onDrawMove(pos.x, pos.y);
},
// 绑定touchend/touchcancel事件
handleTouchEnd() {
this.signature.onDrawEnd();
}
}
};
</script>
<style lang="scss" scoped>
.sing-box {
width: 100vw;
height: 100vh;
// border-bottom: 2rpx dashed rgba(94,110,254,0.20);
padding: 0 0rpx 0 0;
box-sizing: border-box;
display: flex;
overflow: hidden;
.tips {
position: fixed;
right: 0;
top: 0;
z-index: 100000000000;
// top: 200rpx;
font-size: 26rpx;
font-family: Source Han Sans CN, Source Han Sans CN-Regular;
font-weight: 400;
text-align: LEFT;
color: #b9b9c2;
line-height: 40rpx;
transform: rotateZ(90deg) translateX(60%) translateY(-250%);
}
.label {
width: 150rpx;
color: #002567;
font-size: 28rpx;
line-height: 70rpx;
font-weight: 500;
}
.canvas-box {
position: relative;
z-index: 0;
width: 100%;
height: 100%;
}
.button-box {
position: fixed;
left: 0;
bottom: 0;
z-index: 10000;
display: flex;
transform: rotate(90deg) translateX(-50%) translateY(80%);
.clear-button {
width: 142rpx;
height: 80rpx;
line-height: 80rpx;
background: #ffffff;
border: 2rpx solid #2976ff;
color: #2976ff;
font-size: 24rpx;
border-radius: 10rpx;
text-align: center;
box-sizing: border-box;
margin-right: 18rpx;
}
.affirm-button {
width: 142rpx;
height: 80rpx;
line-height: 80rpx;
background: #2976ff;
border-radius: 10rpx;
text-align: center;
color: #ffffff;
font-size: 24rpx;
}
}
}
</style>
Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB