fix: H5多项优化-返回按钮/布局/弹窗/兼容性/BASE_URL统一
This commit is contained in:
parent
b693ecd247
commit
6a12162705
|
|
@ -202,6 +202,7 @@ function onSubmit() {
|
|||
|
||||
.scroll-area {
|
||||
flex: 1;
|
||||
width: 90%;
|
||||
max-height: 60vh;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -17,7 +17,11 @@
|
|||
"delay" : 0
|
||||
},
|
||||
/* 模块配置 */
|
||||
"modules" : {},
|
||||
"modules" : {
|
||||
"Barcode" : {},
|
||||
"Geolocation" : {},
|
||||
"Camera" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
|
|
@ -45,7 +49,14 @@
|
|||
"dSYMs" : false
|
||||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {},
|
||||
"sdkConfigs" : {
|
||||
"geolocation" : {
|
||||
"system" : {
|
||||
"__platform__" : [ "ios", "android" ]
|
||||
}
|
||||
},
|
||||
"share" : {}
|
||||
},
|
||||
"icons" : {
|
||||
"android" : {
|
||||
"hdpi" : ""
|
||||
|
|
|
|||
|
|
@ -1,86 +1,145 @@
|
|||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/start/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/login/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/home/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "", "enablePullDownRefresh": true }
|
||||
},
|
||||
{
|
||||
"path": "pages/region/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/room/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "", "enablePullDownRefresh": true }
|
||||
},
|
||||
{
|
||||
"path": "pages/rack/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "", "enablePullDownRefresh": true }
|
||||
},
|
||||
{
|
||||
"path": "pages/rack-detail/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/search/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/settings/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/change-password/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/portal/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/checkin/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/trunk/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/cable/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/fault-list/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/fault-detail/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/fault-add/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/trunk-search/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
},
|
||||
{
|
||||
"path": "pages/route-plan/index",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "" }
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "绥时录",
|
||||
"navigationBarBackgroundColor": "#1A73EC",
|
||||
"backgroundColor": "#F5F5F5"
|
||||
}
|
||||
}
|
||||
"pages": [{
|
||||
"path": "pages/start/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/route-plan/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/home/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/region/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/room/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/rack/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/rack-detail/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/search/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/settings/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/change-password/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/portal/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/checkin/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/trunk/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cable/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/fault-list/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/fault-detail/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/fault-add/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/trunk-search/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "绥时录",
|
||||
"navigationBarBackgroundColor": "#1A73EC",
|
||||
"backgroundColor": "#F5F5F5"
|
||||
}
|
||||
}
|
||||
|
|
@ -34,17 +34,21 @@
|
|||
</view>
|
||||
|
||||
<!-- 光缆列表 -->
|
||||
<scroll-view class="cable-list" scroll-y>
|
||||
<scroll-view class="cable-list" scroll-y v-if="cableList.length > 0">
|
||||
<view
|
||||
class="cable-card"
|
||||
v-for="item in cableList"
|
||||
:key="item.id"
|
||||
@click="goFaultList(item)"
|
||||
>
|
||||
<view class="cable-image" />
|
||||
<text class="cable-name">{{ item.cableName }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" v-else-if="loaded">
|
||||
<text class="empty-text">暂无光缆数据</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -58,12 +62,14 @@ const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
|||
const cableList = ref([])
|
||||
const deptId = ref('')
|
||||
const keyword = ref('')
|
||||
const loaded = ref(false)
|
||||
|
||||
async function loadCableList() {
|
||||
const res = await getCableList(deptId.value)
|
||||
if (res.code === 200) {
|
||||
cableList.value = res.data || []
|
||||
if (res.code === 200 && res.data) {
|
||||
cableList.value = res.data.result || []
|
||||
}
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
|
|
@ -189,28 +195,30 @@ onPullDownRefresh(() => {
|
|||
|
||||
.cable-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: 0 24rpx 20rpx;
|
||||
padding: 24rpx;
|
||||
padding: 28rpx 24rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
border: 1rpx solid #E8E8E8;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.cable-image {
|
||||
width: 100%;
|
||||
height: 160rpx;
|
||||
background: #F0F0F0;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.cable-name {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -159,6 +159,24 @@ function takePhoto() {
|
|||
}
|
||||
|
||||
function getLocation() {
|
||||
// #ifdef H5
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(pos) => {
|
||||
form.latitude = pos.coords.latitude
|
||||
form.longitude = pos.coords.longitude
|
||||
uni.showToast({ title: '获取成功', icon: 'success' })
|
||||
},
|
||||
() => {
|
||||
uni.showToast({ title: '获取位置失败,请检查浏览器定位权限', icon: 'none' })
|
||||
},
|
||||
{ enableHighAccuracy: true, timeout: 10000 }
|
||||
)
|
||||
} else {
|
||||
uni.showToast({ title: '当前浏览器不支持定位', icon: 'none' })
|
||||
}
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
success(res) {
|
||||
|
|
@ -170,6 +188,7 @@ function getLocation() {
|
|||
uni.showToast({ title: '获取位置失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
|
|
@ -177,6 +196,10 @@ async function handleSubmit() {
|
|||
uni.showToast({ title: '请至少拍摄一张照片', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!cableId.value) {
|
||||
uni.showToast({ title: '所属光缆信息缺失,无法提交', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
if (submitting.value) return
|
||||
submitting.value = true
|
||||
|
|
@ -421,6 +444,7 @@ onLoad((options) => {
|
|||
padding: 24rpx;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
|
|
|
|||
|
|
@ -8,17 +8,25 @@
|
|||
<view class="nav-bar-inner">
|
||||
<image
|
||||
class="nav-icon"
|
||||
src="/static/images/ic_refresh.png"
|
||||
src="/static/images/ic_back.png"
|
||||
mode="aspectFit"
|
||||
@click="handleRefresh"
|
||||
@click="goBack"
|
||||
/>
|
||||
<text class="nav-title">公司列表</text>
|
||||
<image
|
||||
class="nav-icon"
|
||||
src="/static/images/ic_set.png"
|
||||
mode="aspectFit"
|
||||
@click="goSettings"
|
||||
/>
|
||||
<view class="nav-right">
|
||||
<image
|
||||
class="nav-icon"
|
||||
src="/static/images/ic_refresh.png"
|
||||
mode="aspectFit"
|
||||
@click="handleRefresh"
|
||||
/>
|
||||
<image
|
||||
class="nav-icon nav-icon-ml"
|
||||
src="/static/images/ic_set.png"
|
||||
mode="aspectFit"
|
||||
@click="goSettings"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
@ -90,6 +98,15 @@ function handleRefresh() {
|
|||
loadCompanyList()
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.navigateBack({
|
||||
fail() {
|
||||
// H5下navigateBack失败时(如页面栈只有一层),回到portal
|
||||
uni.reLaunch({ url: '/pages/portal/index' })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSearch() {
|
||||
uni.navigateTo({ url: '/pages/search/index' })
|
||||
}
|
||||
|
|
@ -153,6 +170,15 @@ onPullDownRefresh(() => {
|
|||
height: 44rpx;
|
||||
}
|
||||
|
||||
.nav-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-icon-ml {
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
:key="item.code"
|
||||
@click="handleModuleClick(item)"
|
||||
>
|
||||
<image class="module-image" :src="item.icon" mode="aspectFit" />
|
||||
<text class="module-name">{{ item.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -136,23 +135,16 @@ onLoad(() => {
|
|||
|
||||
.module-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 32rpx;
|
||||
height: 160rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.module-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.module-name {
|
||||
font-size: 30rpx;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ onLoad(() => {
|
|||
checkPermission().then((res) => {
|
||||
if (res.code === 200) {
|
||||
store.isPermission = true
|
||||
uni.reLaunch({ url: '/pages/home/index' })
|
||||
uni.reLaunch({ url: '/pages/portal/index' })
|
||||
} else if (res.code === 403) {
|
||||
store.isPermission = false
|
||||
uni.reLaunch({ url: '/pages/home/index' })
|
||||
uni.reLaunch({ url: '/pages/portal/index' })
|
||||
} else if (res.code === 401) {
|
||||
uni.reLaunch({ url: '/pages/login/index' })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
:key="item.id"
|
||||
@click="goCableFaultList(item)"
|
||||
>
|
||||
<view class="cable-image" />
|
||||
<text class="cable-name">{{ item.cableName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -188,29 +187,19 @@ onLoad((options) => {
|
|||
/* 光缆卡片 — 复用 cable 页样式 */
|
||||
.cable-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: 0 24rpx 20rpx;
|
||||
padding: 24rpx;
|
||||
padding: 28rpx 24rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
border: 1rpx solid #E8E8E8;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.cable-image {
|
||||
width: 100%;
|
||||
height: 160rpx;
|
||||
background: #F0F0F0;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.cable-name {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 故障卡片 — 复用 fault-list 页样式 */
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
:key="item.deptId"
|
||||
@click="goCable(item)"
|
||||
>
|
||||
<view class="company-image" />
|
||||
<text class="company-name">{{ item.deptName }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
|
@ -134,28 +133,18 @@ onPullDownRefresh(() => {
|
|||
|
||||
.company-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: 0 24rpx 20rpx;
|
||||
padding: 24rpx;
|
||||
padding: 28rpx 24rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
border: 1rpx solid #E8E8E8;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.company-image {
|
||||
width: 100%;
|
||||
height: 160rpx;
|
||||
background: #F0F0F0;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.company-name {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import store from '@/store'
|
|||
|
||||
// const BASE_URL = 'http://49.233.115.141:11082'
|
||||
// const BASE_URL = 'http://115.190.188.216:2861'
|
||||
const BASE_URL = 'https://api.wux.shhmkjgs.cn'
|
||||
export const BASE_URL = 'https://api.wux.shhmkjgs.cn'
|
||||
const TIMEOUT = 20000
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { get } from './api'
|
||||
import { get, BASE_URL } from './api'
|
||||
import store from '@/store'
|
||||
|
||||
const BASE_URL = 'http://49.233.115.141:11082'
|
||||
|
||||
export const getCableList = (deptId) =>
|
||||
get('/business/OdfCables/list', { deptId })
|
||||
|
||||
|
|
|
|||
|
|
@ -2,54 +2,37 @@
|
|||
* 在照片左下角叠加水印文字
|
||||
* @param {string} imagePath - 原始图片路径
|
||||
* @param {string} text - 水印文字(如 "2025/06/15 12:00 张三")
|
||||
* @returns {Promise<string>} 带水印的临时文件路径
|
||||
* @returns {Promise<string>} 带水印的临时文件路径(H5 返回 base64 dataURL)
|
||||
*/
|
||||
export function addWatermark(imagePath, text) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// #ifdef APP-PLUS
|
||||
uni.getImageInfo({
|
||||
src: imagePath,
|
||||
success(imgInfo) {
|
||||
const canvasId = 'watermarkCanvas'
|
||||
const width = imgInfo.width
|
||||
const height = imgInfo.height
|
||||
|
||||
// 使用 OffscreenCanvas(APP-PLUS 和 H5 均支持)
|
||||
// #ifdef APP-PLUS
|
||||
const bitmap = new plus.nativeObj.Bitmap('watermark')
|
||||
bitmap.load(imagePath, () => {
|
||||
const canvas = new plus.nativeObj.View('watermarkView', {
|
||||
left: '0px', top: '0px',
|
||||
width: width + 'px', height: height + 'px'
|
||||
})
|
||||
|
||||
// 绘制原图
|
||||
canvas.drawBitmap(bitmap, {}, { left: '0px', top: '0px', width: width + 'px', height: height + 'px' })
|
||||
|
||||
// 水印参数
|
||||
const fontSize = Math.max(Math.floor(width * 0.03), 14)
|
||||
const padding = Math.floor(fontSize * 0.8)
|
||||
const textX = padding
|
||||
const textY = height - padding
|
||||
|
||||
// 绘制半透明背景
|
||||
const bgHeight = fontSize + padding * 2
|
||||
canvas.drawRect(
|
||||
{ color: 'rgba(0,0,0,0.4)' },
|
||||
{ left: '0px', top: (height - bgHeight) + 'px', width: width + 'px', height: bgHeight + 'px' }
|
||||
)
|
||||
|
||||
// 绘制水印文字
|
||||
canvas.drawText(text, {
|
||||
left: textX + 'px',
|
||||
top: (height - bgHeight + padding) + 'px',
|
||||
width: (width - textX * 2) + 'px',
|
||||
height: fontSize + 'px'
|
||||
}, {
|
||||
size: fontSize + 'px',
|
||||
color: '#ffffff'
|
||||
})
|
||||
|
||||
// 导出
|
||||
}, { size: fontSize + 'px', color: '#ffffff' })
|
||||
const tempPath = `_doc/watermark_${Date.now()}.jpg`
|
||||
canvas.toBitmap(tempPath, {}, () => {
|
||||
bitmap.clear()
|
||||
|
|
@ -58,51 +41,41 @@ export function addWatermark(imagePath, text) {
|
|||
bitmap.clear()
|
||||
reject(err)
|
||||
})
|
||||
}, (err) => {
|
||||
reject(err)
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
// H5 / 小程序端使用 Canvas 2D
|
||||
const canvas = uni.createOffscreenCanvas({ type: '2d', width, height })
|
||||
const ctx = canvas.getContext('2d')
|
||||
const img = canvas.createImage()
|
||||
|
||||
img.onload = () => {
|
||||
// 绘制原图
|
||||
ctx.drawImage(img, 0, 0, width, height)
|
||||
|
||||
// 水印参数
|
||||
const fontSize = Math.max(Math.floor(width * 0.03), 14)
|
||||
const padding = Math.floor(fontSize * 0.8)
|
||||
|
||||
// 绘制半透明背景
|
||||
const bgHeight = fontSize + padding * 2
|
||||
ctx.fillStyle = 'rgba(0,0,0,0.4)'
|
||||
ctx.fillRect(0, height - bgHeight, width, bgHeight)
|
||||
|
||||
// 绘制水印文字
|
||||
ctx.fillStyle = '#ffffff'
|
||||
ctx.font = `${fontSize}px sans-serif`
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.fillText(text, padding, height - bgHeight / 2)
|
||||
|
||||
// 导出为临时文件
|
||||
const tempFilePath = canvas.toDataURL('image/jpeg', 0.9)
|
||||
resolve(tempFilePath)
|
||||
}
|
||||
|
||||
img.onerror = (err) => {
|
||||
reject(err || new Error('图片加载失败'))
|
||||
}
|
||||
|
||||
img.src = imagePath
|
||||
// #endif
|
||||
}, (err) => reject(err))
|
||||
},
|
||||
fail(err) {
|
||||
reject(err)
|
||||
}
|
||||
fail: reject
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
const img = new Image()
|
||||
img.crossOrigin = 'anonymous'
|
||||
img.onload = () => {
|
||||
const width = img.naturalWidth
|
||||
const height = img.naturalHeight
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = width
|
||||
canvas.height = height
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.drawImage(img, 0, 0, width, height)
|
||||
const fontSize = Math.max(Math.floor(width * 0.03), 14)
|
||||
const padding = Math.floor(fontSize * 0.8)
|
||||
const bgHeight = fontSize + padding * 2
|
||||
ctx.fillStyle = 'rgba(0,0,0,0.4)'
|
||||
ctx.fillRect(0, height - bgHeight, width, bgHeight)
|
||||
ctx.fillStyle = '#ffffff'
|
||||
ctx.font = `${fontSize}px sans-serif`
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.fillText(text, padding, height - bgHeight / 2)
|
||||
resolve(canvas.toDataURL('image/jpeg', 0.9))
|
||||
}
|
||||
img.onerror = (err) => reject(err || new Error('图片加载失败'))
|
||||
img.src = imagePath
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ
|
||||
// 小程序端:跳过水印,直接返回原图
|
||||
// resolve(imagePath)
|
||||
// #endif
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,12 +145,29 @@ function loadData() {
|
|||
}
|
||||
}
|
||||
|
||||
// 从部门树中查找部门名称
|
||||
function findDeptName(deptId, nodes) {
|
||||
for (const node of nodes) {
|
||||
if (node.id === deptId) return node.label
|
||||
if (node.children && node.children.length > 0) {
|
||||
const found = findDeptName(deptId, node.children)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
function submitForm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
submitLoading.value = true
|
||||
|
||||
// 根据选中的 deptId 填充 deptName
|
||||
if (form.value.deptId) {
|
||||
form.value.deptName = findDeptName(form.value.deptId, deptOptions.value) || ''
|
||||
}
|
||||
|
||||
if (isEdit.value) {
|
||||
updateOdfCables(form.value)
|
||||
.then((res) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user