优化问题
This commit is contained in:
parent
f8b3520e5d
commit
2a48964efb
150
components/custom-back-header.vue
Normal file
150
components/custom-back-header.vue
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 自定义顶部返回栏 -->
|
||||||
|
<view class="custom-back-header" :style="headerStyle">
|
||||||
|
<!-- 返回按钮 -->
|
||||||
|
<view class="back-btn" @click="handleBack">
|
||||||
|
<slot name="icon">
|
||||||
|
<!-- 默认返回图标 -->
|
||||||
|
<view class="icon">←</view>
|
||||||
|
</slot>
|
||||||
|
<text v-if="showText" class="text">{{ backText }}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 标题插槽 -->
|
||||||
|
<view class="title">
|
||||||
|
<slot>{{ title }}</slot>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 右侧插槽 -->
|
||||||
|
<view class="right-slot">
|
||||||
|
<slot name="right"></slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
// 标题文字
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
// 是否显示返回文字
|
||||||
|
showText: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
// 返回按钮文字
|
||||||
|
backText: {
|
||||||
|
type: String,
|
||||||
|
default: '返回'
|
||||||
|
},
|
||||||
|
// 背景颜色
|
||||||
|
bgColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#ffffff'
|
||||||
|
},
|
||||||
|
// 文字颜色
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
default: '#333333'
|
||||||
|
},
|
||||||
|
// 是否沉浸式(占位)
|
||||||
|
immersive: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
// 指定返回目标路径
|
||||||
|
targetPath: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
headerStyle() {
|
||||||
|
return {
|
||||||
|
backgroundColor: this.bgColor,
|
||||||
|
color: this.color,
|
||||||
|
paddingTop: this.immersive ? 'var(--status-bar-height)' : '0'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleBack() {
|
||||||
|
if (this.$listeners.back) {
|
||||||
|
// 如果有自定义back事件则触发
|
||||||
|
this.$emit('back');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
|
||||||
|
// 指定目标页面返回
|
||||||
|
if (this.targetPath) {
|
||||||
|
const target = pages.find(page =>
|
||||||
|
page.route === this.targetPath.replace(/^\//, '')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (target) {
|
||||||
|
const delta = pages.length - pages.indexOf(target) - 1;
|
||||||
|
uni.navigateBack({ delta });
|
||||||
|
} else {
|
||||||
|
uni.redirectTo({ url: this.targetPath });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认返回逻辑
|
||||||
|
if (pages.length >= 2) {
|
||||||
|
uni.navigateBack();
|
||||||
|
} else {
|
||||||
|
uni.switchTab({ url: '/pages/index/index' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.custom-back-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 44px;
|
||||||
|
padding: 0 15px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 5px 10px 5px 0;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
font-size: 20px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: bold;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-slot {
|
||||||
|
min-width: 60px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -173,8 +173,9 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/meetingList/index",
|
"path": "pages/meetingList/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "近山社区",
|
"navigationStyle": "default",
|
||||||
"navigationStyle": "custom" // 隐藏原生导航栏
|
"navigationBarTitleText": "近山社区"
|
||||||
|
// "navigationStyle": "custom" // 隐藏原生导航栏
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 会议室详情
|
// 会议室详情
|
||||||
@ -206,18 +207,21 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/sign/sign",
|
"path": "pages/sign/sign",
|
||||||
"style": {
|
"style": {
|
||||||
|
"navigationStyle": "default",
|
||||||
"navigationBarTitleText": "电子签名"
|
"navigationBarTitleText": "电子签名"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/docList/index",
|
"path": "pages/docList/index",
|
||||||
"style": {
|
"style": {
|
||||||
|
"navigationStyle": "default",
|
||||||
"navigationBarTitleText": "文件下载"
|
"navigationBarTitleText": "文件下载"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"navigationBarBackgroundColor": "#F8F8F8",
|
"navigationBarBackgroundColor": "#F8F8F8",
|
||||||
"backgroundColor": "#F8F8F8"
|
"backgroundColor": "#F8F8F8"
|
||||||
|
|||||||
@ -84,18 +84,33 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 输入区域 -->
|
<!-- 输入区域 -->
|
||||||
<view class="chat-input">
|
<view class="chat-bottom">
|
||||||
<view class="" style="flex: 1;">
|
<view class="" style="padding: 10px;">
|
||||||
<input class="input-field" placeholder="输入消息..." v-model="inputMsg" @confirm="sendMessage"
|
<view class="aiTag" v-if="aiName==='生活咨询'" @click="sendMessageCeshi(0)">
|
||||||
confirm-type="send" />
|
最近雨季来了,家里总是很潮湿,有什么简单有效的除湿防霉小妙招吗?
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="width: 100px;">
|
<view class="aiTag" v-if="aiName==='穿搭顾问'" @click="sendMessageCeshi(1)">
|
||||||
<u-button type="primary" :disabled="!inputMsg.trim()||isAnswering" @click="sendMessage" shape="circle">
|
我下周要参加一个商务休闲风格的客户午餐会(夏天,户外庭院),男,身高175cm,体型偏瘦,肤色偏白,有什么搭配建议吗?
|
||||||
发送
|
</view>
|
||||||
</u-button>
|
<view class="aiTag" v-if="aiName==='膳食管家'" @click="sendMessageCeshi(2)">
|
||||||
|
我想开始减脂,能为我设计一份适合上班族、操作简单、营养均衡的晚餐食谱吗?
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="chat-input">
|
||||||
|
<view class="" style="flex: 1;">
|
||||||
|
<input class="input-field" placeholder="输入消息..." v-model="inputMsg" @confirm="sendMessage"
|
||||||
|
confirm-type="send" />
|
||||||
|
</view>
|
||||||
|
<view class="" style="width: 100px;">
|
||||||
|
<u-button type="primary" :disabled="!inputMsg.trim()||isAnswering" @click="sendMessage"
|
||||||
|
shape="circle">
|
||||||
|
发送
|
||||||
|
</u-button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -124,7 +139,14 @@
|
|||||||
serviceUrl: '',
|
serviceUrl: '',
|
||||||
currentAnswer: '',
|
currentAnswer: '',
|
||||||
isAnswering: false,
|
isAnswering: false,
|
||||||
isHandleClose:false
|
isHandleClose: false,
|
||||||
|
connectNum: 0,
|
||||||
|
aiName: '',
|
||||||
|
aiDefaultList: [
|
||||||
|
'最近雨季来了,家里总是很潮湿,有什么简单有效的除湿防霉小妙招吗?',
|
||||||
|
'我下周要参加一个商务休闲风格的客户午餐会(夏天,户外庭院),男,身高175cm,体型偏瘦,肤色偏白,有什么搭配建议吗?',
|
||||||
|
'我想开始减脂,能为我设计一份适合上班族、操作简单、营养均衡的晚餐食谱吗?'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -132,11 +154,11 @@
|
|||||||
this.serviceUrl = options.serviceUrl || '';
|
this.serviceUrl = options.serviceUrl || '';
|
||||||
this.apiKey = options.apiKey || '';
|
this.apiKey = options.apiKey || '';
|
||||||
this.botAvatar = options.icon || this.botAvatar;
|
this.botAvatar = options.icon || this.botAvatar;
|
||||||
|
this.aiName = options.name
|
||||||
const userInfo = wx.getStorageSync('userInfo') || {};
|
const userInfo = wx.getStorageSync('userInfo') || {};
|
||||||
this.userId = userInfo.id || Date.now().toString();
|
this.userId = userInfo.id || Date.now().toString();
|
||||||
this.userName = userInfo.name || '默认用户';
|
this.userName = userInfo.name || '默认用户';
|
||||||
this.userAvatar = userInfo.avatar?`${IMAGE_BASE_URL+userInfo.avatar}`:this.userAvatar;
|
this.userAvatar = userInfo.avatar ? `${IMAGE_BASE_URL+userInfo.avatar}` : this.userAvatar;
|
||||||
|
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title: options.name || 'AI助手'
|
title: options.name || 'AI助手'
|
||||||
@ -153,7 +175,7 @@
|
|||||||
// 初始化WebSocket连接
|
// 初始化WebSocket连接
|
||||||
initWebSocket() {
|
initWebSocket() {
|
||||||
if (this.isConnected) return;
|
if (this.isConnected) return;
|
||||||
|
console.log(WS_BASE_URL,'aiName===');
|
||||||
// 微信小程序中使用 wx.connectSocket
|
// 微信小程序中使用 wx.connectSocket
|
||||||
this.socketTask = wx.connectSocket({
|
this.socketTask = wx.connectSocket({
|
||||||
url: `${WS_BASE_URL}/api/v1/ws/ai?apiUrl=${encodeURIComponent(this.serviceUrl)}&apiToken=${this.apiKey}&userName=${this.userName}`,
|
url: `${WS_BASE_URL}/api/v1/ws/ai?apiUrl=${encodeURIComponent(this.serviceUrl)}&apiToken=${this.apiKey}&userName=${this.userName}`,
|
||||||
@ -170,17 +192,20 @@
|
|||||||
this.socketTask.onOpen(() => {
|
this.socketTask.onOpen(() => {
|
||||||
console.log('WebSocket连接已打开');
|
console.log('WebSocket连接已打开');
|
||||||
this.isConnected = true;
|
this.isConnected = true;
|
||||||
this.reconnectAttempts = 0;
|
// this.reconnectAttempts = 0;
|
||||||
const params = {
|
if (this.reconnectAttempts === 0) {
|
||||||
sender: 'bot',
|
const params = {
|
||||||
thinkContent: '',
|
sender: 'bot',
|
||||||
answerContent: '',
|
thinkContent: '',
|
||||||
type: 'normal',
|
answerContent: '',
|
||||||
isTyping: false,
|
type: 'normal',
|
||||||
showAnswer: '已连接,请输入您的问题',
|
isTyping: false,
|
||||||
answerType: 2
|
showAnswer: '已连接,请输入您的问题',
|
||||||
|
answerType: 2
|
||||||
|
}
|
||||||
|
this.addMessage(params);
|
||||||
}
|
}
|
||||||
this.addMessage(params);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socketTask.onMessage((res) => {
|
this.socketTask.onMessage((res) => {
|
||||||
@ -207,7 +232,7 @@
|
|||||||
this.socketTask.onClose(() => {
|
this.socketTask.onClose(() => {
|
||||||
console.log('WebSocket连接已关闭');
|
console.log('WebSocket连接已关闭');
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
if(!this.isHandleClose){
|
if (!this.isHandleClose) {
|
||||||
this.handleReconnect();
|
this.handleReconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -329,7 +354,9 @@
|
|||||||
if (lastMsg.answerContent.includes('outfit')) {
|
if (lastMsg.answerContent.includes('outfit')) {
|
||||||
const ls = lastMsg.answerContent.replace(/\n/g, '')
|
const ls = lastMsg.answerContent.replace(/\n/g, '')
|
||||||
try {
|
try {
|
||||||
|
console.log(lastMsg.answerContent)
|
||||||
const obj = JSON.parse(lastMsg.answerContent)
|
const obj = JSON.parse(lastMsg.answerContent)
|
||||||
|
console.log(obj)
|
||||||
lastMsg.answerContent = obj
|
lastMsg.answerContent = obj
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
lastMsg.answerContent = '哎呀,AI开小差了,请重新提问'
|
lastMsg.answerContent = '哎呀,AI开小差了,请重新提问'
|
||||||
@ -437,7 +464,54 @@
|
|||||||
|
|
||||||
this.inputMsg = '';
|
this.inputMsg = '';
|
||||||
},
|
},
|
||||||
|
sendMessageCeshi(index) {
|
||||||
|
const content = this.aiDefaultList[index];
|
||||||
|
if (!content || !this.isConnected) return;
|
||||||
|
const params = {
|
||||||
|
sender: 'me',
|
||||||
|
thinkContent: '',
|
||||||
|
answerContent: '',
|
||||||
|
type: 'normal',
|
||||||
|
isTyping: false,
|
||||||
|
showAnswer: content,
|
||||||
|
answerType: 2
|
||||||
|
}
|
||||||
|
this.addMessage(params);
|
||||||
|
this.isAnswering = true
|
||||||
|
// 微信小程序中使用 socketTask.send
|
||||||
|
this.socketTask.send({
|
||||||
|
data: content,
|
||||||
|
success: () => {
|
||||||
|
console.log('消息发送成功');
|
||||||
|
const params = {
|
||||||
|
sender: 'bot',
|
||||||
|
thinkContent: '思考中...',
|
||||||
|
answerContent: '',
|
||||||
|
type: 'normal',
|
||||||
|
isTyping: true,
|
||||||
|
showAnswer: '',
|
||||||
|
answerType: 2
|
||||||
|
}
|
||||||
|
// 添加机器人正在输入的提示
|
||||||
|
this.addMessage(params);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('消息发送失败', err);
|
||||||
|
const params = {
|
||||||
|
sender: 'bot',
|
||||||
|
thinkContent: '',
|
||||||
|
answerContent: '',
|
||||||
|
type: 'normal',
|
||||||
|
isTyping: true,
|
||||||
|
showAnswer: '消息发送失败,请重试',
|
||||||
|
answerType: 2
|
||||||
|
}
|
||||||
|
this.addMessage(params);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.inputMsg = '';
|
||||||
|
},
|
||||||
// 处理重连逻辑
|
// 处理重连逻辑
|
||||||
handleReconnect() {
|
handleReconnect() {
|
||||||
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
||||||
@ -466,14 +540,14 @@
|
|||||||
// 关闭WebSocket连接
|
// 关闭WebSocket连接
|
||||||
closeWebSocket() {
|
closeWebSocket() {
|
||||||
if (this.socketTask) {
|
if (this.socketTask) {
|
||||||
// 移除所有回调引用
|
// 移除所有回调引用
|
||||||
this.socketTask.onClose = null;
|
this.socketTask.onClose = null;
|
||||||
this.socketTask.onError = null;
|
this.socketTask.onError = null;
|
||||||
this.socketTask.onMessage = null;
|
this.socketTask.onMessage = null;
|
||||||
this.socketTask.close();
|
this.socketTask.close();
|
||||||
this.socketTask = null;
|
this.socketTask = null;
|
||||||
this.isHandleClose=true
|
this.isHandleClose = true
|
||||||
}
|
}
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -519,6 +593,14 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.aiTag {
|
||||||
|
padding: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
background: #f0f0f0;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
@ -544,13 +626,19 @@
|
|||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-input {
|
.chat-bottom {
|
||||||
display: flex;
|
|
||||||
padding: 10px;
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-top: 1px solid #ddd;
|
border-top: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-input {
|
||||||
|
background-color: white;
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
display: flex;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.input-field {
|
.input-field {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 8px 15px;
|
padding: 8px 15px;
|
||||||
|
|||||||
@ -50,6 +50,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goAiType(item) {
|
goAiType(item) {
|
||||||
|
console.log(item);
|
||||||
navigateTo({
|
navigateTo({
|
||||||
url: `/pages/chat/chatPage?serviceUrl=${item.serviceUrl}&apiKey=${item.apiKey}&id=${item.id}&name=${item.name}&icon=${item.icon}`
|
url: `/pages/chat/chatPage?serviceUrl=${item.serviceUrl}&apiKey=${item.apiKey}&id=${item.id}&name=${item.name}&icon=${item.icon}`
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="doc-page">
|
<view class="doc-page">
|
||||||
|
|
||||||
<view class="doc-content">
|
<view class="doc-content">
|
||||||
<view class="doc-file" v-for="item of docList" @click="downLoadFile(item)">
|
<view class="doc-file" v-for="item of docList" @click="downLoadFile(item)">
|
||||||
<image src="/static/imgs/word.png" alt="" srcset="" class="doc-img"/>
|
<image src="/static/imgs/word.png" alt="" srcset="" class="doc-img"/>
|
||||||
@ -37,6 +38,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
|
handleBack() {
|
||||||
|
// 固定跳转首页
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/meetingList/index`
|
||||||
|
})
|
||||||
|
},
|
||||||
async downLoadFile(fileUrl){
|
async downLoadFile(fileUrl){
|
||||||
const result = await downloadPdfFiles(fileUrl);
|
const result = await downloadPdfFiles(fileUrl);
|
||||||
if(result.success==true){
|
if(result.success==true){
|
||||||
@ -46,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
reback(){
|
reback(){
|
||||||
uni.redirectTo({
|
uni.reLaunch({
|
||||||
url: `/pages/meetingList/index`
|
url: `/pages/meetingList/index`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -84,4 +91,25 @@
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
.nav-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 15px;
|
||||||
|
// background-color: #fff;
|
||||||
|
border-bottom: 1px solid #f5f5f5;
|
||||||
|
margin-top: 84rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-title {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
// font-weight: bold;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -620,7 +620,7 @@
|
|||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
if (res.success == true) {
|
if (res.success == true) {
|
||||||
uni.navigateTo({
|
uni.redirectTo({
|
||||||
url: `/pages/docList/index?files=${JSON.stringify(res.data)}&&isSelfStudy=${this.isSelfStudy}`
|
url: `/pages/docList/index?files=${JSON.stringify(res.data)}&&isSelfStudy=${this.isSelfStudy}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- 自定义导航栏 -->
|
<!-- 自定义导航栏 -->
|
||||||
<view class="nav-bar">
|
<!-- <view class="nav-bar">
|
||||||
<view class="nav-left" @click="handleBack">
|
<view class="nav-left" @click="handleBack">
|
||||||
<u-icon name="arrow-left" size="44"></u-icon>
|
<u-icon name="arrow-left" size="44"></u-icon>
|
||||||
<!-- <text>返回</text> -->
|
<text>返回</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="nav-title">近山社区</text>
|
<text class="nav-title">近山社区</text>
|
||||||
</view>
|
</view> -->
|
||||||
|
|
||||||
<view v-if="tabsReady">
|
<view v-if="tabsReady">
|
||||||
<u-tabs :list="tabList" :current="currentTab" @change="handleTabChange" border="false"
|
<u-tabs :list="tabList" :current="currentTab" @change="handleTabChange" border="false"
|
||||||
@ -397,13 +397,13 @@
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
// background-color: #fff;
|
// background-color: #fff;
|
||||||
border-bottom: 1px solid #f5f5f5;
|
border-bottom: 1px solid #f5f5f5;
|
||||||
margin-top: 84rpx;
|
padding-top: 60rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-left {
|
.nav-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-right: 10px;
|
// margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-title {
|
.nav-title {
|
||||||
|
|||||||
@ -93,6 +93,7 @@
|
|||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
console.log('=====>',res)
|
||||||
resolve({
|
resolve({
|
||||||
longitude: res.longitude,
|
longitude: res.longitude,
|
||||||
latitude: res.latitude
|
latitude: res.latitude
|
||||||
|
|||||||
@ -4,6 +4,13 @@
|
|||||||
<!-- <view class="handRight">
|
<!-- <view class="handRight">
|
||||||
<view class="handTitle">请签名</view>
|
<view class="handTitle">请签名</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
|
<!-- <view class="nav-bar">
|
||||||
|
<view class="nav-left" @click="handleBack">
|
||||||
|
<u-icon name="arrow-left" size="44"></u-icon>
|
||||||
|
<text>返回</text>
|
||||||
|
</view>
|
||||||
|
<text class="nav-title">签名</text>
|
||||||
|
</view> -->
|
||||||
<view class="handCenter">
|
<view class="handCenter">
|
||||||
<canvas class="handWriting" :disable-scroll="true" @touchstart="uploadScaleStart"
|
<canvas class="handWriting" :disable-scroll="true" @touchstart="uploadScaleStart"
|
||||||
@touchmove="uploadScaleMove" @touchend="uploadScaleEnd" canvas-id="handWriting"></canvas>
|
@touchmove="uploadScaleMove" @touchend="uploadScaleEnd" canvas-id="handWriting"></canvas>
|
||||||
@ -39,11 +46,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { post } from "../../utils/request";
|
import {
|
||||||
import pickerColor from "./pickerColor.vue"
|
post
|
||||||
import {IMAGE_BASE_URL,BASE_URL} from '@/utils/config';
|
} from "../../utils/request";
|
||||||
import {downloadPdfFiles} from '@/utils/download.js'
|
import pickerColor from "./pickerColor.vue"
|
||||||
import instructionVue from '../../components/instruction.vue';
|
import {
|
||||||
|
IMAGE_BASE_URL,
|
||||||
|
BASE_URL
|
||||||
|
} from '@/utils/config';
|
||||||
|
import {
|
||||||
|
downloadPdfFiles
|
||||||
|
} from '@/utils/download.js'
|
||||||
|
import instructionVue from '../../components/instruction.vue';
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
pickerColor,
|
pickerColor,
|
||||||
@ -51,8 +65,8 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
readShow:false,
|
readShow: false,
|
||||||
hasReaded:true,
|
hasReaded: true,
|
||||||
showPickerColor: false,
|
showPickerColor: false,
|
||||||
ctx: '',
|
ctx: '',
|
||||||
canvasWidth: 0,
|
canvasWidth: 0,
|
||||||
@ -74,8 +88,8 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
},
|
},
|
||||||
toDataURL: void 0,
|
toDataURL: void 0,
|
||||||
requestAnimationFrame: void 0,
|
requestAnimationFrame: void 0,
|
||||||
applyInfo:null,
|
applyInfo: null,
|
||||||
isSelfStudy:true,
|
isSelfStudy: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: { //可用于修改的参数放在props里 也可单独放在外面做成组件调用 传值
|
props: { //可用于修改的参数放在props里 也可单独放在外面做成组件调用 传值
|
||||||
@ -109,14 +123,14 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
this.isSelfStudy=option.isSelfStudy
|
this.isSelfStudy = option.isSelfStudy
|
||||||
// 页面A设置参数
|
// 页面A设置参数
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
if(app.globalData.applyInfo){
|
if (app.globalData.applyInfo) {
|
||||||
this.applyInfo=app.globalData.applyInfo
|
this.applyInfo = app.globalData.applyInfo
|
||||||
}else{
|
} else {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/meetingList/index'
|
url: '/pages/meetingList/index'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.ctx = uni.createCanvasContext("handWriting");
|
this.ctx = uni.createCanvasContext("handWriting");
|
||||||
@ -130,12 +144,16 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
readChange(flag){
|
handleBack() {
|
||||||
this.hasReaded=flag
|
// 固定跳转首页
|
||||||
|
uni.navigateBack()
|
||||||
|
},
|
||||||
|
readChange(flag) {
|
||||||
|
this.hasReaded = flag
|
||||||
|
|
||||||
},
|
},
|
||||||
postApply(){
|
postApply() {
|
||||||
this.readShow=false
|
this.readShow = false
|
||||||
// 这里可以添加实际的API调用
|
// 这里可以添加实际的API调用
|
||||||
this.subCanvas()
|
this.subCanvas()
|
||||||
},
|
},
|
||||||
@ -430,141 +448,145 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
//完成
|
//完成
|
||||||
// 完成
|
// 完成
|
||||||
subCanvas() {
|
subCanvas() {
|
||||||
if (this.isEmpty()) {
|
if (this.isEmpty()) {
|
||||||
uni.showToast({
|
|
||||||
title: '没有任何绘制内容哦',
|
|
||||||
icon: 'none',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uni.showLoading({
|
|
||||||
title: '正在生成图片...'
|
|
||||||
});
|
|
||||||
|
|
||||||
uni.canvasToTempFilePath({
|
|
||||||
canvasId: 'handWriting',
|
|
||||||
fileType: 'png',
|
|
||||||
quality: 1,
|
|
||||||
success: async (res) => {
|
|
||||||
uni.hideLoading();
|
|
||||||
|
|
||||||
// 1. 保存到本地相册
|
|
||||||
try {
|
|
||||||
// await this.saveToAlbum(res.tempFilePath);
|
|
||||||
|
|
||||||
// 2. 上传到服务器
|
|
||||||
uni.showLoading({
|
|
||||||
title: '正在上传签名...'
|
|
||||||
});
|
|
||||||
|
|
||||||
const uploadRes = await this.uploadSignature(res.tempFilePath);
|
|
||||||
|
|
||||||
uni.hideLoading();
|
|
||||||
this.applyInfo.applySign=uploadRes
|
|
||||||
const response=await post('/api/v1/app_auth/metting-room/order/register', this.applyInfo)
|
|
||||||
console.log("===response", response)
|
|
||||||
if (!response || !response.success) {
|
|
||||||
throw new Error('会议室预定失败');
|
|
||||||
}
|
|
||||||
if(response.success==true){
|
|
||||||
uni.navigateTo({
|
|
||||||
url:`/pages/docList/index?files=${JSON.stringify(response.data)}&&isSelfStudy=${this.isSelfStudy}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '会议室预定成功!',
|
title: '没有任何绘制内容哦',
|
||||||
icon: 'success'
|
icon: 'none',
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// const result = await downloadPdfFiles(response);
|
uni.showLoading({
|
||||||
// console.log('下载结果:', result);
|
title: '正在生成图片...'
|
||||||
// if(result.success==true){
|
});
|
||||||
// uni.navigateTo({
|
|
||||||
// url: `/pages/meetingList/index`
|
uni.canvasToTempFilePath({
|
||||||
// });
|
canvasId: 'handWriting',
|
||||||
// }
|
fileType: 'png',
|
||||||
|
quality: 1,
|
||||||
|
success: async (res) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
// 1. 保存到本地相册
|
||||||
|
try {
|
||||||
|
// await this.saveToAlbum(res.tempFilePath);
|
||||||
|
|
||||||
|
// 2. 上传到服务器
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在上传签名...'
|
||||||
|
});
|
||||||
|
|
||||||
|
const uploadRes = await this.uploadSignature(res.tempFilePath);
|
||||||
|
|
||||||
|
uni.hideLoading();
|
||||||
|
this.applyInfo.applySign = uploadRes
|
||||||
|
const response = await post('/api/v1/app_auth/metting-room/order/register', this
|
||||||
|
.applyInfo)
|
||||||
|
console.log("===response", response)
|
||||||
|
if (!response || !response.success) {
|
||||||
|
throw new Error('会议室预定失败');
|
||||||
|
}
|
||||||
|
if (response.success == true) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/docList/index?files=${JSON.stringify(response.data)}&&isSelfStudy=${this.isSelfStudy}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
uni.showToast({
|
||||||
|
title: '会议室预定成功!',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
|
||||||
|
// const result = await downloadPdfFiles(response);
|
||||||
|
// console.log('下载结果:', result);
|
||||||
|
// if(result.success==true){
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: `/pages/meetingList/index`
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// 3. 可以通过回调或者事件将上传结果返回给父组件
|
// 3. 可以通过回调或者事件将上传结果返回给父组件
|
||||||
// this.$emit('upload-success', {
|
// this.$emit('upload-success', {
|
||||||
// tempFilePath: res.tempFilePath,
|
// tempFilePath: res.tempFilePath,
|
||||||
// serverPath: uploadRes // 假设服务器返回了图片地址
|
// serverPath: uploadRes // 假设服务器返回了图片地址
|
||||||
// });
|
// });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message || '上传失败',
|
title: error.message || '上传失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '生成图片失败',
|
title: '生成图片失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 保存到相册的方法
|
// 保存到相册的方法
|
||||||
saveToAlbum(tempFilePath) {
|
saveToAlbum(tempFilePath) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.saveImageToPhotosAlbum({
|
uni.saveImageToPhotosAlbum({
|
||||||
filePath: tempFilePath,
|
filePath: tempFilePath,
|
||||||
success: () => {
|
success: () => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '已保存到相册',
|
title: '已保存到相册',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
reject(new Error('保存到相册失败'));
|
reject(new Error('保存到相册失败'));
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 上传签名到服务器的方法
|
// 上传签名到服务器的方法
|
||||||
uploadSignature(tempFilePath) {
|
uploadSignature(tempFilePath) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 这里替换为你自己的上传接口
|
// 这里替换为你自己的上传接口
|
||||||
const uploadUrl = IMAGE_BASE_URL+'/api/v1/upload';
|
const uploadUrl = IMAGE_BASE_URL + '/api/v1/upload';
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: uploadUrl,
|
url: uploadUrl,
|
||||||
filePath: tempFilePath,
|
filePath: tempFilePath,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
// formData: {
|
// formData: {
|
||||||
// // 可以添加其他表单数据
|
// // 可以添加其他表单数据
|
||||||
// userId: '123', // 示例用户ID
|
// userId: '123', // 示例用户ID
|
||||||
// type: 'signature'
|
// type: 'signature'
|
||||||
// },
|
// },
|
||||||
success: (uploadRes) => {
|
success: (uploadRes) => {
|
||||||
console.log(uploadRes);
|
console.log(uploadRes);
|
||||||
console.log(JSON.parse(uploadRes.data))
|
console.log(JSON.parse(uploadRes.data))
|
||||||
try {
|
try {
|
||||||
const {success,data} = JSON.parse(uploadRes.data);
|
const {
|
||||||
if (success) {
|
success,
|
||||||
resolve(data); // 假设服务器返回了图片URL
|
data
|
||||||
} else {
|
} = JSON.parse(uploadRes.data);
|
||||||
reject(new Error(success || '上传失败'));
|
if (success) {
|
||||||
}
|
resolve(data); // 假设服务器返回了图片URL
|
||||||
} catch (e) {
|
} else {
|
||||||
reject(new Error('解析服务器响应失败'));
|
reject(new Error(success || '上传失败'));
|
||||||
}
|
}
|
||||||
},
|
} catch (e) {
|
||||||
fail: (err) => {
|
reject(new Error('解析服务器响应失败'));
|
||||||
reject(new Error('上传请求失败'));
|
}
|
||||||
console.error(err);
|
},
|
||||||
}
|
fail: (err) => {
|
||||||
});
|
reject(new Error('上传请求失败'));
|
||||||
});
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
//保存到相册
|
//保存到相册
|
||||||
saveCanvasAsImg() {
|
saveCanvasAsImg() {
|
||||||
@ -616,11 +638,31 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
flex-direction:column;
|
flex-direction: column;
|
||||||
/* justify-content: center; */
|
/* justify-content: center; */
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
|
.nav-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 15px;
|
||||||
|
// background-color: #fff;
|
||||||
|
border-bottom: 1px solid #f5f5f5;
|
||||||
|
padding-top: 60rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
/* margin-right: 10px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-title {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
// font-weight: bold;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.handWriting {
|
.handWriting {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
width: 95vw;
|
width: 95vw;
|
||||||
@ -657,7 +699,7 @@ import pickerColor from "./pickerColor.vue"
|
|||||||
display: flex;
|
display: flex;
|
||||||
/* flex-direction: column; */
|
/* flex-direction: column; */
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-content:center;
|
align-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
/* flex: 1; */
|
/* flex: 1; */
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
static/imgs/wechat.png
Normal file
BIN
static/imgs/wechat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@ -3,6 +3,7 @@
|
|||||||
export const BASE_URL = 'https://jinshan.nantong.info';
|
export const BASE_URL = 'https://jinshan.nantong.info';
|
||||||
export const IMAGE_BASE_URL = `https://jinshan.nantong.info`;
|
export const IMAGE_BASE_URL = `https://jinshan.nantong.info`;
|
||||||
export const WS_BASE_URL = `wss://jinshan.nantong.info`;
|
export const WS_BASE_URL = `wss://jinshan.nantong.info`;
|
||||||
|
// export const WS_BASE_URL = 'ws://10.10.1.6:8071';
|
||||||
|
|
||||||
|
|
||||||
// http://36.212.197.253:8071
|
// http://36.212.197.253:8071
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user