This commit is contained in:
xyc 2025-07-11 13:16:08 +08:00
parent 2b6351037d
commit 288deaa2ee
7 changed files with 803 additions and 254 deletions

View File

@ -4,9 +4,11 @@
<view class="content">
<view class="authentication_top">
<image class="image3" style="width: 100%;margin-top: 50%;" v-if="PreviewContract" :src="contractImg" mode="widthFix"></image>
<image class="image3" style="width: 100%;margin-top: 50%;" v-if="PreviewContract" :src="contractImg"
mode="widthFix"></image>
<!-- 创建合成画布 -->
<view class="bgCoverBox" v-if="publish"><canvas :style="{width:height +'px',height:width +'px'}" canvas-id="mycontract" class="canvsborder2"></canvas></view>
<view class="bgCoverBox" v-if="publish"><canvas :style="{width:height +'px',height:width +'px'}"
canvas-id="mycontract" class="canvsborder2"></canvas></view>
<!-- 创建合成画布 -->
</view>
<!-- <view class="authentication_bottom" v-if="NavAutograph" style="background:#ffe9e9" @click="agreeSign">
@ -16,46 +18,47 @@
<button style="color:#f00">我已阅读上述内容下一步>></button>
</view>
<view class="authentication_fun" v-if="Navpreservation" style="background:#fff; ">
<button style="color:#fd972e;" @click="SigningCompleted">签署完成去提交>></button>
<button style="color:#fd972e;" @click="SigningCompleted">签署完成去提交>></button>
</view>
<!-- 填写信息 -->
<view class="inforMation" v-if="Mation == true">
<view class="in-input" @click="show = true">
<view class="in-left">请选择车辆</view>
<view class="in-right" >
<view class="in-right">
<text>{{showtext}}</text>
</view>
</view>
<view class="in-box" >
<view class="in-box">
<view class="in-input">
<view class="in-left">请选择人</view>
<view class="in-right">
<input type="text" v-model="showtext1" @input="getcarlist" @blur="getcarlist" @confirm="getcarlist" placeholder="输入姓名/手机号">
</view>
<view class="in-left">请选择人</view>
<view class="in-right">
<input type="text" v-model="showtext1" @input="getcarlist" @blur="getcarlist"
@confirm="getcarlist" placeholder="输入姓名/手机号">
</view>
</view>
<scroll-view class="l-bai" scroll-y="true">
<view class="renname" v-for="(item,index) in columns1" :key="index">
<view class="dix">
<view class="ming">{{item.nickname}}</view>
<view class="tel">{{item.mobile}}</view>
</view>
<view class="anniux" @click="getren(item.id,item.nickname)">
<text>选择</text>
</view>
</view>
<view class="lanzi" v-if="columns1" @click="jja">
<view class="renname" v-for="(item,index) in columns1" :key="index">
<view class="dix">
<view class="ming">{{item.nickname}}</view>
<view class="tel">{{item.mobile}}</view>
</view>
<view class="anniux" @click="getren(item.id,item.nickname)">
<text>选择</text>
</view>
</view>
<view class="lanzi" v-if="columns1" @click="jja">
<text>点击加载更多</text>
</view>
<view class="lanzi" v-else >
<view class="lanzi" v-else>
<text>暂无信息</text>
</view>
</scroll-view>
</view>
<view class="anniu" @click="getsignature()">
<text>下一步</text>
@ -76,14 +79,16 @@
</view>
</view>
<u-picker :show="show" :columns="columns" keyName="carBrand" @confirm="confirm1" @cancel="close1"></u-picker>
<!-- 签字弹窗 end -->
</view>
</template>
<script>
import request from '../../utils/request'
import { getToken } from '@/utils/auth'
import request from '../../utils/newRequest'
import {
getToken
} from '@/utils/auth'
import config from '@/config'
var x = 20;
var y = 20;
@ -97,20 +102,20 @@
data() {
return {
status: 'loadmore',
searchValue:'',
wtr:'',
sfz:'',
position:'',
carNum:'',
phone:'',
cbgs:'',
kcyPhone:'',
lc:'',
rs:'',
sjqk:'',
jbr:'',
signImage:'',
Mation:false,
searchValue: '',
wtr: '',
sfz: '',
position: '',
carNum: '',
phone: '',
cbgs: '',
kcyPhone: '',
lc: '',
rs: '',
sjqk: '',
jbr: '',
signImage: '',
Mation: false,
contractImg: '../../static/images/ppg.jpg', //
ctx: '', //
points: [], //,
@ -118,19 +123,19 @@
height: 0,
autographStatus: false,
publish: false,
PreviewContract:true,
PreviewContract: true,
NavAutograph: true,
Navpreservation:false,
Navpreservation: false,
show: false,
showtext:'请选择',
showtext: '请选择',
columns: [],
show1: false,
showtext1:'',
showtext1: '',
columns1: null,
wtrId:'',
carnum:'',
pageSize:5,
pageNum:1,
wtrId: '',
carnum: '',
pageSize: 5,
pageNum: 1,
}
},
onLoad(option) {
@ -145,7 +150,7 @@
this.ctx.lineJoin = 'round';
uni.getSystemInfo({
success: function(res) {
that.width = res.windowWidth * 0.8;
that.height = res.windowHeight * 0.85;
}
@ -156,86 +161,86 @@
this.getcarlist()
uni.getStorage({
key: 'autograph_key',
success: function (res) {
if( res.data !== '' ){
success: function(res) {
if (res.data !== '') {
t.contractImg = res.data
t.PreviewContract = true;
t.publish = false;
t.NavAutograph = false
}
}
});
},
});
},
methods: {
jja(){
jja() {
let that = this
this.pageSize ++
this.pageSize++
that.getcarlist()
console.log(this.pageSize);
},
async getcarlist(){
async getcarlist() {
let resc = await request({
url: '/appInspection/userOwn/getCars',
url: '/app-api/appInspection/userOwn/getCars',
method: 'get',
})
console.log(resc);
this.columns.push(resc.data)
this.columns.push(resc.data)
let data = {
searchValue:this.showtext1,
pageNum: this.pageNum,//
pageSize: this.pageSize,//
searchValue: this.showtext1,
pageNum: this.pageNum, //
pageSize: this.pageSize, //
}
let res = await request({
url: '/appInspection/userOwn/getDbList',
url: '/app-api/appInspection/userOwn/getDbList',
method: 'get',
params: data
})
console.log(res);
this.columns1 = res.rows
},
close1(){
close1() {
this.show = false
},
confirm1(e){
confirm1(e) {
this.showtext = e.value[0].carBrand
this.carnum = e.value[0].carNo
console.log(e);
this.show = false
},
close2(){
close2() {
this.show1 = false
},
confirm2(e){
confirm2(e) {
this.showtext1 = e.value[0].nickname
this.wtrId = e.value[0].id
console.log(e);
this.show1 = false
},
getren(ids,names){
getren(ids, names) {
this.showtext1 = names
this.wtrId = ids
},
agreeSign() {
this.Mation = true
this.Mation = true
},
getsignature(){
if(this.wtrId == '' || this.carnum == ''){
uni.showToast({
title:'以上均为必填!!!',
icon:'none'
})
return
}
this.autographStatus = true;
getsignature() {
if (this.wtrId == '' || this.carnum == '') {
uni.showToast({
title: '以上均为必填!!!',
icon: 'none'
})
return
}
this.autographStatus = true;
},
//
@ -264,7 +269,7 @@
};
this.points.push(movePoint); //
let len = this.points.length;
if (len >= 2) {
if (len >= 2) {
this.draw(); //
}
tempPoint.push(movePoint);
@ -279,7 +284,7 @@
# 2.为保证笔迹连续每次从路径集合中区两个点作为起点moveTo和终点(lineTo)
# 3.将上一次的终点作为下一次绘制的起点即清除第一个点
************************************************ */
draw: function() {
let point1 = this.points[0];
let point2 = this.points[1];
@ -301,7 +306,7 @@
that.ctx.draw(true);
tempPoint = [];
},
//
async handleConfirm() {
const t = this;
@ -319,7 +324,7 @@
uni.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function(res) {
console.log('点击确认返回',res);
console.log('点击确认返回', res);
// t.objectURLToBlob(res)
let tempPath = res.tempFilePath;
const ctx = uni.createCanvasContext('camCacnvs', that);
@ -333,100 +338,100 @@
uni.hideLoading();
//
},
async shangchuang(imgs){
async shangchuang(imgs) {
uni.showLoading({
title: '加载中'
});
const resx = await request({
method:'post',
url:'/system/history/jcWts',
data:{
wtrId:this.wtrId,
carnum:this.carnum,
signImage:imgs
method: 'post',
url: '/system/history/jcWts',
data: {
wtrId: this.wtrId,
carnum: this.carnum,
signImage: imgs
}
})
console.log('成功',resx);
if(resx.code == 200){
console.log('成功', resx);
if (resx.code == 200) {
uni.hideLoading();
uni.showToast({
title:'提交成功',
icon:'none',
title: '提交成功',
icon: 'none',
duration: 2000
})
setTimeout(() => {
uni.navigateBack()
}, 2000);
}
if(resx.code != 200){
if (resx.code != 200) {
uni.hideLoading();
uni.showToast({
title:'网络不佳 请稍后在试'+resx.code,
icon:'none',
title: '网络不佳 请稍后在试' + resx.code,
icon: 'none',
duration: 2000
})
setTimeout(() => {
uni.navigateBack()
}, 2000);
}
},
urlTobase64(url) {
uni.getFileSystemManager().readFile({
filePath:url,
encoding:'base64',
success:res=>{
let base64 = 'data:image/jpeg;base64,' + res.data; //
console.log(base64,"base64")
this.shangchuang(base64)
// upFile({
// 'base64': base64
// }).then(res2 => {
// console.log(res2.data.url, "res2res2res2res2")
// })
}
})
},
objectURLToBlob(url) {
// console.log(url.tempFilePath,'121212')
uni.request({
url: url.tempFilePath,
method: "GET",
responseType: "arraybuffer",
success: (ress) => {
console.log(ress);
const base64 = uni.arrayBufferToBase64(ress.data)
// console.log('data:image/png;base64,'+ base64,'signFile')
let imgs ='data:image/png;base64,'+ base64
console.log('转换base格式后',imgs);
// this.shangchuang(imgs)
// upFile({
// 'base64': imgs
// }).then(res2 => {
// console.log(res2, "res2res2res2res2")
// })
// //
},
fail: (res) => {
console.log(res)
}
});
urlTobase64(url) {
uni.getFileSystemManager().readFile({
filePath: url,
encoding: 'base64',
success: res => {
let base64 = 'data:image/jpeg;base64,' + res.data; //
console.log(base64, "base64")
this.shangchuang(base64)
// upFile({
// 'base64': base64
// }).then(res2 => {
// console.log(res2.data.url, "res2res2res2res2")
// })
}
})
},
preservationImg(){
objectURLToBlob(url) {
// console.log(url.tempFilePath,'121212')
uni.request({
url: url.tempFilePath,
method: "GET",
responseType: "arraybuffer",
success: (ress) => {
console.log(ress);
const base64 = uni.arrayBufferToBase64(ress.data)
// console.log('data:image/png;base64,'+ base64,'signFile')
let imgs = 'data:image/png;base64,' + base64
console.log('转换base格式后', imgs);
// this.shangchuang(imgs)
// upFile({
// 'base64': imgs
// }).then(res2 => {
// console.log(res2, "res2res2res2res2")
// })
// //
},
fail: (res) => {
console.log(res)
}
});
},
preservationImg() {
const t = this;
uni.downloadFile({
url: t.contractImg,
@ -459,49 +464,51 @@
}
});
},
SigningCompleted(){
SigningCompleted() {
uni.showToast({
title:'您发起了提交',
icon:'none'
title: '您发起了提交',
icon: 'none'
})
const t = this;
let ImgType = t.contractImg.split(".")
uni.getFileSystemManager().readFile({
filePath: t.contractImg,
encoding: 'base64',
success: async(res) =>{
t.contractImg = 'data:image/png;base64,' + res.data;
uni.showLoading ({
title: '提交中',
});
console.log(res.data)
return
const result = await t.$req("/user/upload/img",{
uid: t.user.uid,
type: ImgType[1],
img: res.data,
place: 'sign',
})
let rd = result.data
// console.log(rd)
if(rd.code == 0){
let data = rd.data
t.contractImg = data.url;
uni.hideLoading();
uni.setStorage({
key: 'autograph_key',
data: t.contractImg,
success: function () {
console.log("签字",'success');
}
});
uni.navigateBack({ delta: 1 }); //
}
}
})
filePath: t.contractImg,
encoding: 'base64',
success: async (res) => {
t.contractImg = 'data:image/png;base64,' + res.data;
uni.showLoading({
title: '提交中',
});
console.log(res.data)
return
const result = await t.$req("/user/upload/img", {
uid: t.user.uid,
type: ImgType[1],
img: res.data,
place: 'sign',
})
let rd = result.data
// console.log(rd)
if (rd.code == 0) {
let data = rd.data
t.contractImg = data.url;
uni.hideLoading();
uni.setStorage({
key: 'autograph_key',
data: t.contractImg,
success: function() {
console.log("签字", 'success');
}
});
uni.navigateBack({
delta: 1
}); //
}
}
})
},
ReSign:function(){
ReSign: function() {
// console.log(this.ctx)
this.autographStatus = true
}
@ -509,8 +516,8 @@
}
</script>
<style>
.lanzi{
margin-top:20px ;
.lanzi {
margin-top: 20px;
width: 100%;
display: flex;
align-items: center;
@ -519,28 +526,32 @@
font-weight: 400;
color: #0D2E8D;
}
.l-bai{
.l-bai {
width: 100%;
height: 220px;
box-sizing: border-box;
padding: 15px;
background: #FFFFFF;
border-radius: 5px;
white-space: nowrap;
overflow: hidden;
border-radius: 5px;
white-space: nowrap;
overflow: hidden;
}
.ming{
.ming {
font-size: 16px;
font-weight: 400;
color: #333333;
margin-right: 10px;
}
.tel{
.tel {
font-size: 16px;
font-weight: 400;
color: #999999;
}
.renname{
.renname {
width: 100%;
display: flex;
align-items: center;
@ -548,12 +559,14 @@
box-sizing: border-box;
padding: 10px;
}
.dix{
.dix {
display: flex;
align-items: center;
}
.anniux{
.anniux {
width: 55px;
height: 25px;
display: flex;
@ -564,44 +577,208 @@
border-radius: 50px;
font-size: 15px;
}
.image3 {
.image3 {}
.in-box {
background-color: white;
width: 100%;
border-bottom: 1px solid #E8E8E8;
box-sizing: border-box;
}
.in-box{
background-color: white;
width: 100%;
border-bottom: 1px solid #E8E8E8;
box-sizing: border-box;
}
.anniu{ width: 95%; height: 40px; margin: 0 auto; border-radius: 50px; display: flex; justify-content: center; align-items: center; color: #333333;
background: #0D2E8D; margin-top: 10px; color: white;}
.inforMation{width:100%; height: 100%; box-sizing: border-box; padding-top: 88px; background:#F6F6F6;position:fixed;top:0;left:0;right:0;
box-sizing: border-box; }
.in-input{background-color: white; width: 100%;border-bottom: 1px solid #E8E8E8; display: flex; justify-content: space-between;
align-items: center; box-sizing: border-box;padding: 20px;}
.in-left{font-size: 16px;font-weight: bold;color: #333333;}
.in-right{font-size: 16px;font-weight: 400;color: #C2C2C2; text-align: right;}
.authentication_top{width:100%;height:90%;position:fixed;top:0;left:0;right:0;margin:auto;overflow-y:scroll;padding-bottom:40rpx}
.authentication_top image{width:100%;display:inline-block}
.authentication_bottom{width:100%;height:10%;position:fixed;bottom:0;left:0;right:0;margin:auto;display:flex;flex-direction:column;justify-content:center;align-items:center;background:#ffe9e9}
.authentication_bottom button{background:0 0;border:none;font-size:15px;color:red;width:100%;text-align:center}
.authentication_bottom button:after{display:none}
.authentication_fun{width:100%;height:10%;position:fixed;bottom:30rpx;left:0;right:0;margin:auto;display:flex;flex-direction:row;justify-content:center;align-items:center;background:#ffe9e9;padding:0 3%;width:90%;border-radius:50px;box-shadow:0 3px 13px rgba(0,0,0,.2);border:4px solid #fd972e;box-sizing:border-box}
.authentication_fun button{border:none;font-size:15px;background:0 0;width:100%;text-align:center}
.authentication_fun button:after{display:none}
.signMask{width:100%;height:100%;background:#fff;position:fixed;top:0;bottom:0;left:0;right:0;flex-direction:row}
.sign-box,.signMask{margin:auto;display:flex}
.sign-box{width:80%;height:90%;flex-direction:column;text-align:center}
.sigh-btns,.sign-view{height:100%}
.sigh-btns{margin:auto;display:flex;flex-direction:column;justify-content:space-around}
.btn{margin:auto;padding:8rpx 40rpx;font-size:14px;transform:rotate(90deg);border:1rpx solid grey}
.mycanvas{margin:auto 0rpx;background-color:#ececec}
.canvsborder{border:1rpx solid #333;position:fixed;top:0;left:10000rpx}
.bgCoverBox{width:100%;height:auto}
.canvsborder2{height:700px!important}
</style>
.anniu {
width: 95%;
height: 40px;
margin: 0 auto;
border-radius: 50px;
display: flex;
justify-content: center;
align-items: center;
color: #333333;
background: #0D2E8D;
margin-top: 10px;
color: white;
}
.inforMation {
width: 100%;
height: 100%;
box-sizing: border-box;
padding-top: 88px;
background: #F6F6F6;
position: fixed;
top: 0;
left: 0;
right: 0;
box-sizing: border-box;
}
.in-input {
background-color: white;
width: 100%;
border-bottom: 1px solid #E8E8E8;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 20px;
}
.in-left {
font-size: 16px;
font-weight: bold;
color: #333333;
}
.in-right {
font-size: 16px;
font-weight: 400;
color: #C2C2C2;
text-align: right;
}
.authentication_top {
width: 100%;
height: 90%;
position: fixed;
top: 0;
left: 0;
right: 0;
margin: auto;
overflow-y: scroll;
padding-bottom: 40rpx
}
.authentication_top image {
width: 100%;
display: inline-block
}
.authentication_bottom {
width: 100%;
height: 10%;
position: fixed;
bottom: 0;
left: 0;
right: 0;
margin: auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #ffe9e9
}
.authentication_bottom button {
background: 0 0;
border: none;
font-size: 15px;
color: red;
width: 100%;
text-align: center
}
.authentication_bottom button:after {
display: none
}
.authentication_fun {
width: 100%;
height: 10%;
position: fixed;
bottom: 30rpx;
left: 0;
right: 0;
margin: auto;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background: #ffe9e9;
padding: 0 3%;
width: 90%;
border-radius: 50px;
box-shadow: 0 3px 13px rgba(0, 0, 0, .2);
border: 4px solid #fd972e;
box-sizing: border-box
}
.authentication_fun button {
border: none;
font-size: 15px;
background: 0 0;
width: 100%;
text-align: center
}
.authentication_fun button:after {
display: none
}
.signMask {
width: 100%;
height: 100%;
background: #fff;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
flex-direction: row
}
.sign-box,
.signMask {
margin: auto;
display: flex
}
.sign-box {
width: 80%;
height: 90%;
flex-direction: column;
text-align: center
}
.sigh-btns,
.sign-view {
height: 100%
}
.sigh-btns {
margin: auto;
display: flex;
flex-direction: column;
justify-content: space-around
}
.btn {
margin: auto;
padding: 8rpx 40rpx;
font-size: 14px;
transform: rotate(90deg);
border: 1rpx solid grey
}
.mycanvas {
margin: auto 0rpx;
background-color: #ececec
}
.canvsborder {
border: 1rpx solid #333;
position: fixed;
top: 0;
left: 10000rpx
}
.bgCoverBox {
width: 100%;
height: auto
}
.canvsborder2 {
height: 700px !important
}
</style>

View File

@ -377,11 +377,11 @@
fang() {
console.log("1212")
uni.openLocation({
latitude: this.obj.latitude,
longitude: this.obj.longitude,
latitude: this.obj.lat,
longitude: this.obj.lgt,
success: function() {
console.log('success');
}
},
});
},
async getindex() {

View File

@ -503,6 +503,7 @@
}
})
//
console.log(res);
if (res.data) {
data.businessChannelId = res.data.business.id

View File

@ -257,7 +257,12 @@
} from '@/utils/auth'
import config from '@/config'
import tabBar from '../../components/detection/tabBar.vue'
import newRequest from "@/utils/newRequest";
import newRequest from "@/utils/newRequest";
import {
toast,
showConfirm,
tansParams
} from '@/utils/common'
export default {
data() {
return {
@ -345,11 +350,12 @@
// 退
outoflogin() {
uni.clearStorageSync();
uni.reLaunch({
uni.navigateTo({
url: '/pages/detection/detection'
})
},
async getmy() {
console.log(getToken(), 111);
if (!getToken()) {
return
}
@ -369,16 +375,46 @@
console.log('车辆信息', this.carobj);
},
goorder(id) {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/detection/my-order?id=' + id
})
},
goreservation() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/detection/my-reservation'
})
},
goshang() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/ruzhu/ruzhu'
})
@ -389,23 +425,63 @@
})
},
gowei() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/contract/contract'
})
},
//
gocollect() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/detection/my-collect'
})
},
gocarinfo(id) {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/detection/my-carinfo?id=' + id
})
},
//
gousers() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
console.log('11');
uni.navigateTo({
url: '/pages/detection/my-user'
@ -413,6 +489,16 @@
},
//
gosfz() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
if (this.userinfo.idCard != null) {
uni.showToast({
title: '已上传身份证'
@ -425,6 +511,16 @@
},
//
goyhq() {
if (!getToken()) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
}
uni.navigateTo({
url: '/pages/detection/my-coupon'
})

View File

@ -0,0 +1,181 @@
<template>
<view class="container">
<VNavigationBar titleColor="rgba(0,0,0,0.9)" backgroundColor="#fff" title="通知公告详情"></VNavigationBar>
<view class="body">
<view class="header">
<view class="title line-clamp-3">{{ noticeDetails.title }}</view>
<view class="time" v-if="noticeDetails.updateTime">{{ getCurrentDateTime(noticeDetails.updateTime) }}
</view>
</view>
<view class="content">
<u-parse :content="noticeDetails.content"></u-parse>
<!-- <u-parse :content="test"></u-parse> -->
</view>
</view>
</view>
</template>
<script>
import {
getJSONData
} from "@/utils/auth";
import VNavigationBar from '@/components/tabBar/VNavigationBar.vue'
import request from '@/utils/request.js'
import newRequest from "@/utils/newRequest";
export default {
name: "content",
components: {
VNavigationBar
},
filters: {
formatRichText(html) {
const nodes = parser.getRichTextJson(html)
return nodes.children
}
},
data() {
return {
richTextHtml: '',
toUrl: null,
noticeId: null,
noticeDetails: [],
};
},
onLoad(data) {
console.log('data', data.id)
this.noticeId = data.id
this.getNoticeById()
},
methods: {
getNoticeById() {
newRequest({
url: '/app-api/base/notice/get',
method: 'GET',
params: {
id: this.noticeId
}
}).then(res => {
this.noticeDetails = res.data
})
},
//
getCurrentDateTime() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
// return now;
},
}
}
</script>
<style scoped lang="scss">
.container {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #ffffff;
.body {
flex: 1;
padding: 24rpx 32rpx;
overflow-y: auto;
box-sizing: border-box;
.header {
margin-bottom: 40rpx;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.title {
font-size: 36rpx;
font-weight: 600;
color: #333333;
line-height: 1.5;
margin-bottom: 16rpx;
word-break: break-word;
white-space: normal;
}
.time {
font-size: 24rpx;
color: #999999;
}
}
.content {
font-size: 30rpx;
color: #333333;
line-height: 1.8;
/* 图片样式增强 */
img {
max-width: 100% !important;
/* 确保图片不超过容器宽度 */
height: auto !important;
/* 保持图片原始比例 */
display: block;
/* 改为块级元素避免间隙 */
margin: 32rpx auto;
/* 增加上下边距 */
border-radius: 12rpx;
/* 圆角效果 */
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
/* 轻微阴影提升层次感 */
background-color: #f8f8f8;
/* 加载时的背景色 */
}
/* 图片点击预览(可选) */
img {
cursor: pointer;
transition: transform 0.2s;
}
img:active {
transform: scale(0.98);
}
/* 其他富文本元素样式 */
p {
margin: 24rpx 0;
word-break: break-word;
}
h1,
h2,
h3 {
margin: 32rpx 0 24rpx;
font-weight: 600;
}
a {
color: #2979ff;
text-decoration: none;
}
table {
width: 100%;
border-collapse: collapse;
margin: 24rpx 0;
font-size: 28rpx;
}
th,
td {
border: 1rpx solid #e0e0e0;
padding: 16rpx;
text-align: left;
}
}
}
}
</style>

View File

@ -46,12 +46,9 @@ const request = config => {
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
console.log('跳转');
uni.reLaunch({
uni.navigateTo({
url: '/pages/login/login'
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')

97
utils/utils.js Normal file
View File

@ -0,0 +1,97 @@
import request from "./request";
import {
setStorageWithExpiry,
getStorageWithExpiry
} from './auth'
export async function getDictDataByType(type) {
let data = getStorageWithExpiry(type);
if (data === null || data === undefined) {
try {
const response = await request({
url: '/app-api/system/dict-data/type',
method: 'get',
params: {type}
});
data = response.data;
setStorageWithExpiry(type, data, 3600); // 存储数据并设置过期时间
} catch (error) {
console.error("请求字典数据时出现了异常:", error);
throw error; // 确保错误能够被外部捕获
}
}
return data;
}
export function formatDate(timestamp) {
// 将时间戳转换为Date对象
const date = new Date(timestamp);
// 获取年月日时分秒
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
// 组合成日期时间字符串
return `${year}-${month}-${day}`;
}
export function formatDateChinese(timestamp) {
// 将时间戳转换为Date对象
const date = new Date(timestamp);
// 获取年月日时分秒
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
// 组合成日期时间字符串
return `${year}${month}${day}`;
}
export function formatDateTimeToMinute(timestamp) {
// 将时间戳转换为 Date 对象
const date = new Date(timestamp);
// 获取年月日时分
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
// 组合成日期时间字符串格式yyyy-MM-dd hh:mm
return `${year}-${month}-${day} ${hours}:${minutes}`;
}
export function formatTimestamp(timestamp) {
// 将时间戳转换为Date对象
const date = new Date(timestamp);
// 获取年月日时分秒
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
// 组合成日期时间字符串
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
export function getWXStatusHeight() {
// #ifdef MP-WEIXIN
// 获取距上
const barTop = wx.getSystemInfoSync().statusBarHeight
// 获取胶囊按钮位置信息
const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
// 获取导航栏高度
const barHeight = menuButtonInfo.height + (menuButtonInfo.top - barTop) * 2
let barWidth = menuButtonInfo.width
console.log('menuButtonInfo', menuButtonInfo)
let barLeftPosition = 375 - menuButtonInfo.right + menuButtonInfo.width
let menuButtonLeft = menuButtonInfo.left
let menuButtonRight = menuButtonInfo.right
return {
barHeight,
barTop,
barWidth,
barLeftPosition,
menuButtonLeft,
menuButtonRight
}
// #endif
}