2025.03.15 工作代码提交
This commit is contained in:
parent
fdee18b7f8
commit
cc9578f3eb
|
@ -130,6 +130,7 @@ export const news = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param.data,
|
data: param.data,
|
||||||
query: param.query,
|
query: param.query,
|
||||||
|
load: true,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ export const news = {
|
||||||
url: `/user/getRedPacketInfo`,
|
url: `/user/getRedPacketInfo`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
query: param.query,
|
query: param.query,
|
||||||
load: 1,
|
load: true,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -150,6 +151,7 @@ export const news = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param.data,
|
data: param.data,
|
||||||
query: param.query,
|
query: param.query,
|
||||||
|
load: true,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ const config = {
|
||||||
// #endif
|
// #endif
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
host: 'http://91f.xyz:8080',
|
host: 'http://91f.xyz:8080',
|
||||||
// host: 'http://762c9b48.r24.cpolar.top',
|
|
||||||
// #endif
|
// #endif
|
||||||
// 是否vivo显示
|
// 是否vivo显示
|
||||||
showVivo: true,
|
showVivo: true,
|
||||||
|
|
|
@ -134,7 +134,7 @@ const util = {
|
||||||
reject(res)
|
reject(res)
|
||||||
},
|
},
|
||||||
complete(rs) {
|
complete(rs) {
|
||||||
console.log('upload complete', rs)
|
// console.log('upload complete', rs)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -213,7 +213,7 @@ const util = {
|
||||||
responseType: params.responseType || 'text',
|
responseType: params.responseType || 'text',
|
||||||
// 请求成功返回
|
// 请求成功返回
|
||||||
success: res => {
|
success: res => {
|
||||||
// console.log('request success', url, res, params.data ? params.data : '')
|
console.log('request success', url, res, params.data ? params.data : '')
|
||||||
// 关闭加载效果
|
// 关闭加载效果
|
||||||
if (params.load) {
|
if (params.load) {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
@ -602,6 +602,7 @@ const util = {
|
||||||
count: obj.type == 1 ? 1 : count - obj.value.length,
|
count: obj.type == 1 ? 1 : count - obj.value.length,
|
||||||
sourceType: obj.sourceType || ['album', 'camera'],
|
sourceType: obj.sourceType || ['album', 'camera'],
|
||||||
success: (rs) => {
|
success: (rs) => {
|
||||||
|
console.log('rs', rs)
|
||||||
// 遍历图片返回列表
|
// 遍历图片返回列表
|
||||||
rs.tempFiles.forEach(item => {
|
rs.tempFiles.forEach(item => {
|
||||||
// 限制大小
|
// 限制大小
|
||||||
|
@ -615,6 +616,7 @@ const util = {
|
||||||
file: item.path,
|
file: item.path,
|
||||||
mode: 'img',
|
mode: 'img',
|
||||||
success(res) {
|
success(res) {
|
||||||
|
console.log('upload res', res)
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.getImageInfo({
|
uni.getImageInfo({
|
||||||
src: item.path,
|
src: item.path,
|
||||||
|
@ -625,6 +627,7 @@ const util = {
|
||||||
width: imageInfo.width,
|
width: imageInfo.width,
|
||||||
height: imageInfo
|
height: imageInfo
|
||||||
.height,
|
.height,
|
||||||
|
size: item.size,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -114,8 +114,11 @@
|
||||||
res.forEach(item => {
|
res.forEach(item => {
|
||||||
let obj = {}
|
let obj = {}
|
||||||
obj.type = item.type;
|
obj.type = item.type;
|
||||||
obj.chatText = item.lastMessage.messageForShow;
|
// 处理最近一条消息
|
||||||
|
obj.chatText = item.lastMessage.messageForShow
|
||||||
|
if (obj.chatText == "[自定义消息]") obj.chatText = item.lastMessage.payload.description || '[自定义消息]'
|
||||||
obj.MsgTime = handleDate(item.lastMessage.lastTime);
|
obj.MsgTime = handleDate(item.lastMessage.lastTime);
|
||||||
|
//
|
||||||
obj.unreadCount = item.unreadCount;
|
obj.unreadCount = item.unreadCount;
|
||||||
|
|
||||||
if (item.type == 'C2C') {
|
if (item.type == 'C2C') {
|
||||||
|
|
|
@ -149,24 +149,28 @@
|
||||||
uni.offKeyboardHeightChange(() => {})
|
uni.offKeyboardHeightChange(() => {})
|
||||||
// #endif
|
// #endif
|
||||||
videoContext.value.stop()
|
videoContext.value.stop()
|
||||||
|
// 移除监听消息
|
||||||
|
removeListener()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 开启监听消息
|
// 开启监听消息
|
||||||
function addListener() {
|
function addListener() {
|
||||||
let onMessageReceived = function(event) {
|
let onMessageReceived = function(event) {
|
||||||
console.log('TencentCloudChat.EVENT.MESSAGE_RECEIVED', event)
|
console.log('TencentCloudChat.EVENT.MESSAGE_RECEIVED', event)
|
||||||
setTimeout(() => {
|
//
|
||||||
// 获取历史记录
|
list.messageList.push(...event.data)
|
||||||
getHistory({
|
|
||||||
msgId: '',
|
|
||||||
limit: 1,
|
|
||||||
})
|
|
||||||
}, 200)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.$chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, onMessageReceived);
|
uni.$chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, onMessageReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除监听消息
|
||||||
|
function removeListener() {
|
||||||
|
let onMessageReceived = function(event) {}
|
||||||
|
|
||||||
|
uni.$chat.off(TencentCloudChat.EVENT.MESSAGE_RECEIVED, onMessageReceived);
|
||||||
|
}
|
||||||
|
|
||||||
// 监听内容滚动
|
// 监听内容滚动
|
||||||
function onContentScroll(ev) {
|
function onContentScroll(ev) {
|
||||||
if (ev.scrollTop == 50) getMoreHistroy()
|
if (ev.scrollTop == 50) getMoreHistroy()
|
||||||
|
@ -177,18 +181,26 @@
|
||||||
|
|
||||||
// 点击发送
|
// 点击发送
|
||||||
function handleSend() {
|
function handleSend() {
|
||||||
|
//
|
||||||
|
if (!content.value) {
|
||||||
|
util.alert('消息不能为空')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 取消聚焦
|
||||||
inputFocus.value = false
|
inputFocus.value = false
|
||||||
|
|
||||||
|
// 创建文本消息
|
||||||
|
let message = uni.$chat.createTextMessage({
|
||||||
|
to: msg.id,
|
||||||
|
conversationType: msg.type,
|
||||||
|
payload: {
|
||||||
|
text: content.value
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
sendMsg({
|
sendMsg({
|
||||||
query: {
|
message,
|
||||||
formId: userinfo.value.id,
|
|
||||||
toUserId: msg.id,
|
|
||||||
msgType: TencentCloudChat.TYPES.MSG_TEXT,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
text: content.value
|
|
||||||
},
|
|
||||||
success: () => {
|
success: () => {
|
||||||
// 清空已发送的消息
|
// 清空已发送的消息
|
||||||
content.value = ''
|
content.value = ''
|
||||||
|
@ -202,7 +214,9 @@
|
||||||
* @param {Object} message 消息对象
|
* @param {Object} message 消息对象
|
||||||
*/
|
*/
|
||||||
function handlePlusSend(message) {
|
function handlePlusSend(message) {
|
||||||
sendMsg(message)
|
sendMsg({
|
||||||
|
message
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -210,22 +224,13 @@
|
||||||
* @param {Object} param
|
* @param {Object} param
|
||||||
*/
|
*/
|
||||||
function sendMsg(param) {
|
function sendMsg(param) {
|
||||||
//
|
console.log('sendMsg', param.message)
|
||||||
let request = api.news.sendUserMsg
|
|
||||||
//
|
|
||||||
if (msg.type == 'GROUP') request = api.news.sendGroupMsg
|
|
||||||
// if (msg.isCustomer) request = api.news.sendCusomterService
|
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
request({
|
uni.$chat.sendMessage(param.message).then((rs) => {
|
||||||
query: param.query,
|
console.log('send success', rs)
|
||||||
data: param.data,
|
if (rs.code == 0) {
|
||||||
}).then((rs) => {
|
//
|
||||||
if (rs.code == 200) {
|
list.messageList.push(rs.data.message)
|
||||||
// getHistory({
|
|
||||||
// msgId: '',
|
|
||||||
// limit: 1,
|
|
||||||
// })
|
|
||||||
param.success ? param.success() : ''
|
param.success ? param.success() : ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -240,14 +245,14 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开红包详情
|
* 打开红包详情
|
||||||
* @param {Object} ev
|
* @param {Object} event 默认事件
|
||||||
*/
|
*/
|
||||||
function handleRedPacket(ev) {
|
function handleRedPacket(event) {
|
||||||
messageItem.value = ev
|
console.log('event', event)
|
||||||
api.news.getRedPacketInfo({
|
api.news.getRedPacketInfo({
|
||||||
query: {
|
query: {
|
||||||
// 红包id
|
// 红包id
|
||||||
redPacketId: ev.callbackData.callback_json[0].businessId
|
redPacketId: event.formatData.id,
|
||||||
}
|
}
|
||||||
}).then(rs => {
|
}).then(rs => {
|
||||||
if (rs.code == 200) {
|
if (rs.code == 200) {
|
||||||
|
@ -310,10 +315,9 @@
|
||||||
|
|
||||||
// 获取更多消息记录
|
// 获取更多消息记录
|
||||||
function getMoreHistroy() {
|
function getMoreHistroy() {
|
||||||
// 获取第一条消息记录
|
// if(list.isCompleted) return
|
||||||
if (list.total <= list.data.length) return
|
|
||||||
getHistory({
|
getHistory({
|
||||||
msgId: list.data[0].id
|
msgId: list.messageList[0].ID
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,15 +562,15 @@
|
||||||
|
|
||||||
<view class="tool bfff" id="tool">
|
<view class="tool bfff" id="tool">
|
||||||
<view class="tool-group">
|
<view class="tool-group">
|
||||||
|
<!-- 摁住说话 -->
|
||||||
<!-- 语音 -->
|
<!-- 语音 -->
|
||||||
<image src="/static/news-voice.png" mode="widthFix" class="thumb" @click="handleTool('voice')"></image>
|
<image src="/static/news-voice.png" mode="widthFix" class="thumb" @click="handleTool('voice')"></image>
|
||||||
<!-- 摁住说话 -->
|
|
||||||
<template v-if="toolStatus == 'voice'">
|
<template v-if="toolStatus == 'voice'">
|
||||||
<JyVoice @send="voiceSend" :msg="msg" />
|
<JyVoice @send="voiceSend" :msg="msg" />
|
||||||
</template>
|
</template>
|
||||||
<!-- 输入框 -->
|
<!-- 输入框 -->
|
||||||
<template v-if="toolStatus != 'voice'">
|
<template v-if="toolStatus != 'voice'">
|
||||||
<uni-easyinput @focus="onFocus" type="text" v-model="content" :clearable="false" class="input"
|
<uni-easyinput @focus="onFocus" type="text" v-model.trim="content" :clearable="false" class="input"
|
||||||
:adjust-position="false" @keyboardheightchange="keyboardheightchange" placeholder="请输入你的问题"
|
:adjust-position="false" @keyboardheightchange="keyboardheightchange" placeholder="请输入你的问题"
|
||||||
confirmType="发送" :focus="inputFocus" />
|
confirmType="发送" :focus="inputFocus" />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
computed,
|
computed,
|
||||||
defineEmits,
|
defineEmits,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
// 工具库
|
||||||
|
import util from '@/common/js/util';
|
||||||
|
|
||||||
import NewsAudio from '@/static/audio.png'
|
import NewsAudio from '@/static/audio.png'
|
||||||
import JyCommodityInformation from '@/components/public/jy-commodity-information'
|
import JyCommodityInformation from '@/components/public/jy-commodity-information'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -30,7 +33,11 @@
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const emit = defineEmits(['openRedBag', 'viewVideo'])
|
const emit = defineEmits(['openRedBag', 'viewVideo'])
|
||||||
// 格式化
|
// 格式化
|
||||||
const formatData = computed(() => props.item)
|
const formatData = computed(() => {
|
||||||
|
let result = props.item.payload.data || ''
|
||||||
|
if (result) result = JSON.parse(result)
|
||||||
|
return result
|
||||||
|
})
|
||||||
//音频
|
//音频
|
||||||
const innerAudioContext = uni.createInnerAudioContext();
|
const innerAudioContext = uni.createInnerAudioContext();
|
||||||
// 播放语音
|
// 播放语音
|
||||||
|
@ -41,10 +48,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 用户信息
|
// 用户信息
|
||||||
const userinfo = computed(() => {
|
const userinfo = computed(() => store.state.userinfo)
|
||||||
let result = store.state.userinfo
|
|
||||||
return result
|
|
||||||
})
|
|
||||||
|
|
||||||
// 拨打电话
|
// 拨打电话
|
||||||
function handleCall() {
|
function handleCall() {
|
||||||
|
@ -58,20 +62,34 @@
|
||||||
|
|
||||||
// 开红包
|
// 开红包
|
||||||
function handleOpenRedBag() {
|
function handleOpenRedBag() {
|
||||||
emit('openRedBag', props.item)
|
emit('openRedBag', {
|
||||||
|
item: props.item,
|
||||||
|
formatData: formatData.value,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 看视频
|
// 看视频
|
||||||
function handleViewVideo(item) {
|
function handleViewVideo(item) {
|
||||||
emit('viewVideo', item)
|
emit('viewVideo', item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看图片
|
||||||
|
* @param {Object} urls 图片路径数组
|
||||||
|
*/
|
||||||
|
function handleViewImage(urls) {
|
||||||
|
uni.previewImage({
|
||||||
|
urls,
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="content pr">
|
<view class="content pr">
|
||||||
<!-- 图片 -->
|
<!-- 图片 -->
|
||||||
<template v-if="item.type === TencentCloudChat.TYPES.MSG_IMAGE">
|
<template v-if="item.type === TencentCloudChat.TYPES.MSG_IMAGE">
|
||||||
<image class="br10" :src="formatData.MsgContent.ImageInfoArray[0].URL" mode="widthFix" />
|
<image class="br10" :src="item.payload.imageInfoArray[0].imageUrl" mode="widthFix"
|
||||||
|
@click="util.view_imgs([item.payload.imageInfoArray[0].imageUrl],0)" />
|
||||||
</template>
|
</template>
|
||||||
<!-- 文字 -->
|
<!-- 文字 -->
|
||||||
<template v-else-if="item.type === TencentCloudChat.TYPES.MSG_TEXT">
|
<template v-else-if="item.type === TencentCloudChat.TYPES.MSG_TEXT">
|
||||||
|
@ -140,12 +158,12 @@
|
||||||
<!-- 红包 -->
|
<!-- 红包 -->
|
||||||
<view class="redPacket br10" :class="{'disabled': 0}" @click="handleOpenRedBag">
|
<view class="redPacket br10" :class="{'disabled': 0}" @click="handleOpenRedBag">
|
||||||
<view class="df aic">
|
<view class="df aic">
|
||||||
<image class="img fs0 mr10" src="/static/image/pages/news/group/create.png" />
|
<image class="img fs0 mr10" src="/static/image/red-envelope.png" />
|
||||||
<view class="red-packet-text cfff">{{ formatData.data.blessing }}</view>
|
<view class="red-packet-text cfff">{{ formatData.blessing }}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 分割线 -->
|
<!-- 分割线 -->
|
||||||
<view class="line"></view>
|
<view class="line"></view>
|
||||||
<view class="f20" style="color:#FBD3A4">{{ formatData.data.payType == 1 ? '余额红包' : '积分红包' }}
|
<view class="f20" style="color:#FBD3A4">{{ formatData.redPacketType == 1 ? '余额红包' : '积分红包' }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const getHistoryMsg = async (option) => {
|
||||||
nextReqMessageID: option.nextReqMessageID,
|
nextReqMessageID: option.nextReqMessageID,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('options', options);
|
console.log('getHistoryMsg', options);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.$chat.getMessageList(options).then((res) => {
|
uni.$chat.getMessageList(options).then((res) => {
|
||||||
resolve(res)
|
resolve(res)
|
||||||
|
|
|
@ -1,37 +1,40 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
// + 页面
|
// + 页面
|
||||||
// 腾讯云聊天
|
// 腾讯云聊天
|
||||||
import TencentCloudChat from '@tencentcloud/chat';
|
import TencentCloudChat from '@tencentcloud/chat';
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
reactive,
|
reactive,
|
||||||
nextTick,
|
nextTick,
|
||||||
computed,
|
computed,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import {
|
import {
|
||||||
screenHeight
|
screenHeight
|
||||||
} from '@/components/public/Mixins'
|
} from '@/components/public/Mixins'
|
||||||
import JyCommodityInformation from '@/components/public/jy-commodity-information'
|
import JyCommodityInformation from '@/components/public/jy-commodity-information'
|
||||||
// api
|
// api
|
||||||
import api from '@/api/index.js'
|
import api from '@/api/index.js'
|
||||||
// 工具库
|
// 工具库
|
||||||
import util from '@/common/js/util.js'
|
import util from '@/common/js/util.js'
|
||||||
import { inject } from 'vue'
|
import {
|
||||||
|
inject
|
||||||
|
} from 'vue'
|
||||||
|
|
||||||
const { checkLink } = inject('util');
|
const {
|
||||||
//
|
checkLink
|
||||||
const props = defineProps({
|
} = inject('util');
|
||||||
msg: {
|
//
|
||||||
type: Object,
|
const props = defineProps({
|
||||||
},
|
msg: {
|
||||||
})
|
type: Object,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// 调用父级方法
|
// 调用父级方法
|
||||||
const emit = defineEmits(['plusClick', 'send'])
|
const emit = defineEmits(['plusClick', 'send'])
|
||||||
// 加号菜单
|
// 加号菜单
|
||||||
const plusList = computed(() => {
|
const plusList = computed(() => {
|
||||||
let result = [
|
let result = [{
|
||||||
{
|
|
||||||
type: 'picture.png',
|
type: 'picture.png',
|
||||||
label: '照片',
|
label: '照片',
|
||||||
value: 'chooseImage',
|
value: 'chooseImage',
|
||||||
|
@ -43,202 +46,184 @@ const plusList = computed(() => {
|
||||||
type: 'pages/news/group/create.png',
|
type: 'pages/news/group/create.png',
|
||||||
label: '红包',
|
label: '红包',
|
||||||
value: 'redEnvelope',
|
value: 'redEnvelope',
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
|
|
||||||
const isCustomer = props.msg.isCustomer;
|
const isCustomer = props.msg.isCustomer;
|
||||||
|
|
||||||
// 单聊
|
// 单聊
|
||||||
if (props.msg.type == 'C2C' && !isCustomer) result.push({
|
if (props.msg.type == 'C2C' && !isCustomer) result.push({
|
||||||
type: 'news-voice.png',
|
type: 'news-voice.png',
|
||||||
label: '音视频',
|
label: '音视频',
|
||||||
value: 'voice'
|
value: 'voice'
|
||||||
|
})
|
||||||
|
// 客服
|
||||||
|
if (isCustomer) result.unshift({
|
||||||
|
type: 'order.png',
|
||||||
|
label: '订单',
|
||||||
|
value: 'chooseOrder',
|
||||||
|
}, {
|
||||||
|
type: 'shop.png',
|
||||||
|
label: '商品',
|
||||||
|
value: 'chooseShop',
|
||||||
|
})
|
||||||
|
return result
|
||||||
})
|
})
|
||||||
// 客服
|
|
||||||
if (isCustomer) result.unshift({
|
const popupRef = ref(null)
|
||||||
type: 'order.png',
|
const popupRE = ref(null)
|
||||||
label: '订单',
|
const formData = reactive({
|
||||||
value: 'chooseOrder',
|
name: ''
|
||||||
}, {
|
|
||||||
type: 'shop.png',
|
|
||||||
label: '商品',
|
|
||||||
value: 'chooseShop',
|
|
||||||
})
|
})
|
||||||
return result
|
const popupData = reactive({
|
||||||
})
|
show: false,
|
||||||
|
title: '选择订单'
|
||||||
const popupRef = ref(null)
|
|
||||||
const popupRE = ref(null)
|
|
||||||
const formData = reactive({
|
|
||||||
name: ''
|
|
||||||
})
|
|
||||||
const popupData = reactive({
|
|
||||||
show: false,
|
|
||||||
title: '选择订单'
|
|
||||||
})
|
|
||||||
|
|
||||||
// 订单列表
|
|
||||||
const list = reactive([])
|
|
||||||
|
|
||||||
// 加号方法对象
|
|
||||||
const plusClickObj = {
|
|
||||||
voice: () => {
|
|
||||||
// 菜单
|
|
||||||
const menu = [{
|
|
||||||
name: '语音通话',
|
|
||||||
type: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
nanme: '视频通话',
|
|
||||||
type: 2,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
uni.showActionSheet({
|
|
||||||
itemList: ['语音通话', '视频通话'],
|
|
||||||
success: rs => {
|
|
||||||
uni.$TUICallKit.call({
|
|
||||||
userID: props.msg.id,
|
|
||||||
callMediaType: menu[rs.tapIndex].type,
|
|
||||||
// callParams: {
|
|
||||||
// roomID: 234,
|
|
||||||
// strRoomID: '2323423',
|
|
||||||
// timeout: 30
|
|
||||||
// },
|
|
||||||
}, res => {
|
|
||||||
console.log('[TUICallKit] call params: ', JSON.stringify(res));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
// 选择订单
|
|
||||||
chooseOrder: () => {
|
|
||||||
let param = {
|
|
||||||
pageSize: 10,
|
|
||||||
pageNum: 1,
|
|
||||||
merId: props.msg.id,
|
|
||||||
}
|
|
||||||
api.shop.getShopOrderList(param).then(rs => {
|
|
||||||
if (rs.code == 200) {
|
|
||||||
list.length = 0
|
|
||||||
list.push(...rs.rows.map(item => {
|
|
||||||
// 状态
|
|
||||||
item.status = Number(item.status)
|
|
||||||
// 编辑订单状态文字
|
|
||||||
item.status_text = {
|
|
||||||
'0': '待支付',
|
|
||||||
'1': '待发货',
|
|
||||||
'4': '待收货',
|
|
||||||
'5': '已收货',
|
|
||||||
'6': '已完成',
|
|
||||||
'9': '已取消',
|
|
||||||
}[item.status]
|
|
||||||
return item
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
nextTick().then(() => {
|
|
||||||
popupRef.value.open()
|
|
||||||
});
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
util.alert({
|
|
||||||
content: rs.msg,
|
|
||||||
showCancel: false,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
// 选择商品
|
|
||||||
chooseShop: () => {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/news/goodsList/index?merId=${props.msg.id}`
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 发送红包
|
|
||||||
redEnvelope() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: util.setUrl('/pages/news/redPacket', {
|
|
||||||
// 聊天对象
|
|
||||||
msgId: props.msg.id,
|
|
||||||
// 发送方式
|
|
||||||
sendType: {
|
|
||||||
'C2C': 1,
|
|
||||||
'GROUP': 2,
|
|
||||||
}[props.msg.type],
|
|
||||||
num: props.msg.num,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
// popupRE.value.open()
|
|
||||||
},
|
|
||||||
|
|
||||||
//拍照
|
|
||||||
takePhoto: () => {
|
|
||||||
console.log('takePhoto')
|
|
||||||
sendMsgImg({
|
|
||||||
sourceType: ['album'],
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
//选择图片
|
|
||||||
chooseImage: () => {
|
|
||||||
console.log('chooseImage')
|
|
||||||
sendMsgImg({
|
|
||||||
sourceType: ['album'],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送图片消息
|
|
||||||
function sendMsgImg(option) {
|
|
||||||
util.upload_image({
|
|
||||||
count: 1,
|
|
||||||
type: 1,
|
|
||||||
success: rs => {
|
|
||||||
emit('send', {
|
|
||||||
query: {
|
|
||||||
toUserId: props.msg.id,
|
|
||||||
msgType: TencentCloudChat.TYPES.MSG_IMAGE,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
imgUrl: rs.value
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return
|
|
||||||
// 选择图片
|
// 订单列表
|
||||||
uni.chooseImage({
|
const list = reactive([])
|
||||||
count: 1,
|
|
||||||
sourceType: option.sourceType, // 从相册选择
|
// 加号方法对象
|
||||||
success: (res) => {
|
const plusClickObj = {
|
||||||
let message = uni.$chat.createImageMessage({
|
voice: () => {
|
||||||
to: props.msg.id,
|
// 菜单
|
||||||
conversationType: props.msg.type,
|
const menu = [{
|
||||||
payload: {
|
name: '语音通话',
|
||||||
file: res
|
type: 1,
|
||||||
},
|
},
|
||||||
onProgress: function (event) {
|
{
|
||||||
console.log('file uploading:', event)
|
nanme: '视频通话',
|
||||||
|
type: 2,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
uni.showActionSheet({
|
||||||
|
itemList: ['语音通话', '视频通话'],
|
||||||
|
success: rs => {
|
||||||
|
uni.$TUICallKit.call({
|
||||||
|
userID: props.msg.id,
|
||||||
|
callMediaType: menu[rs.tapIndex].type,
|
||||||
|
// callParams: {
|
||||||
|
// roomID: 234,
|
||||||
|
// strRoomID: '2323423',
|
||||||
|
// timeout: 30
|
||||||
|
// },
|
||||||
|
}, res => {
|
||||||
|
console.log('[TUICallKit] call params: ', JSON.stringify(res));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return
|
},
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 咨询订单
|
// 选择订单
|
||||||
const consult = (content) => {
|
chooseOrder: () => {
|
||||||
let obj = {
|
let param = {
|
||||||
content,
|
pageSize: 10,
|
||||||
type: 'order'
|
pageNum: 1,
|
||||||
|
merId: props.msg.id,
|
||||||
|
}
|
||||||
|
api.shop.getShopOrderList(param).then(rs => {
|
||||||
|
if (rs.code == 200) {
|
||||||
|
list.length = 0
|
||||||
|
list.push(...rs.rows.map(item => {
|
||||||
|
// 状态
|
||||||
|
item.status = Number(item.status)
|
||||||
|
// 编辑订单状态文字
|
||||||
|
item.status_text = {
|
||||||
|
'0': '待支付',
|
||||||
|
'1': '待发货',
|
||||||
|
'4': '待收货',
|
||||||
|
'5': '已收货',
|
||||||
|
'6': '已完成',
|
||||||
|
'9': '已取消',
|
||||||
|
} [item.status]
|
||||||
|
return item
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
nextTick().then(() => {
|
||||||
|
popupRef.value.open()
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
util.alert({
|
||||||
|
content: rs.msg,
|
||||||
|
showCancel: false,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
// 选择商品
|
||||||
|
chooseShop: () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/news/goodsList/index?merId=${props.msg.id}`
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 发送红包
|
||||||
|
redEnvelope() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: util.setUrl('/pages/news/redPacket', {
|
||||||
|
// 聊天对象
|
||||||
|
msgId: props.msg.id,
|
||||||
|
// 发送方式
|
||||||
|
sendType: {
|
||||||
|
'C2C': 1,
|
||||||
|
'GROUP': 2,
|
||||||
|
} [props.msg.type],
|
||||||
|
num: props.msg.num,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// popupRE.value.open()
|
||||||
|
},
|
||||||
|
|
||||||
|
//拍照
|
||||||
|
takePhoto: () => {
|
||||||
|
console.log('takePhoto')
|
||||||
|
sendMsgImg({
|
||||||
|
sourceType: ['camera'],
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
//选择图片
|
||||||
|
chooseImage: () => {
|
||||||
|
console.log('chooseImage')
|
||||||
|
sendMsgImg({
|
||||||
|
sourceType: ['album'],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送图片消息
|
||||||
|
function sendMsgImg(option) {
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 8,
|
||||||
|
sourceType: option.sourceType,
|
||||||
|
success: res => {
|
||||||
|
console.log('res', res)
|
||||||
|
// 创建图片消息
|
||||||
|
let message = uni.$chat.createImageMessage({
|
||||||
|
to: props.msg.id,
|
||||||
|
conversationType: props.msg.type,
|
||||||
|
payload: {
|
||||||
|
file: res,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
emit('send', message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 咨询订单
|
||||||
|
const consult = (content) => {
|
||||||
|
let obj = {
|
||||||
|
content,
|
||||||
|
type: 'order'
|
||||||
|
}
|
||||||
|
popupRef.value.close()
|
||||||
}
|
}
|
||||||
popupRef.value.close()
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -280,65 +265,65 @@ const consult = (content) => {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.NewsPlus {
|
.NewsPlus {
|
||||||
// 一行四个
|
// 一行四个
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
grid-gap: 20rpx;
|
grid-gap: 20rpx;
|
||||||
|
|
||||||
.imageBox {
|
.imageBox {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.jy-popup {
|
.jy-popup {
|
||||||
width: 100%;
|
|
||||||
border-radius: 20px 20px 0px 0px;
|
|
||||||
|
|
||||||
.title {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
border-radius: 20px 20px 0px 0px;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
padding: 20rpx 0;
|
|
||||||
// 底部边框显示
|
|
||||||
color: #3D3D3D;
|
|
||||||
font-size: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-btn {
|
.title {
|
||||||
position: absolute;
|
width: 100%;
|
||||||
top: 40rpx;
|
display: flex;
|
||||||
right: 40rpx;
|
justify-content: center;
|
||||||
height: 52rpx;
|
align-items: center;
|
||||||
line-height: 52rpx;
|
padding: 20rpx 0;
|
||||||
width: 52rpx;
|
// 底部边框显示
|
||||||
background: #D8D8D8;
|
color: #3D3D3D;
|
||||||
color: #999999;
|
font-size: 32rpx;
|
||||||
font-size: 30rpx;
|
}
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
transform: translate(50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-view {
|
.close-btn {
|
||||||
// 只显示上下边框不显示左右
|
position: absolute;
|
||||||
border-top: 1px solid #E5E5E5;
|
top: 40rpx;
|
||||||
border-bottom: 1px solid #E5E5E5;
|
right: 40rpx;
|
||||||
padding: 20rpx;
|
height: 52rpx;
|
||||||
}
|
line-height: 52rpx;
|
||||||
|
width: 52rpx;
|
||||||
|
background: #D8D8D8;
|
||||||
|
color: #999999;
|
||||||
|
font-size: 30rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
transform: translate(50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
.easyinput {
|
.input-view {
|
||||||
flex: 1;
|
// 只显示上下边框不显示左右
|
||||||
}
|
border-top: 1px solid #E5E5E5;
|
||||||
|
border-bottom: 1px solid #E5E5E5;
|
||||||
|
padding: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.time {
|
.easyinput {
|
||||||
padding: 24rpx 20rpx 0 20rpx;
|
flex: 1;
|
||||||
font-size: 22rpx;
|
}
|
||||||
color: #3D3D3D;
|
|
||||||
|
.time {
|
||||||
|
padding: 24rpx 20rpx 0 20rpx;
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #3D3D3D;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
|
@ -16,274 +16,274 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
defineEmits
|
defineEmits
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
// 腾讯云聊天
|
// 腾讯云聊天
|
||||||
import TencentCloudChat from '@tencentcloud/chat';
|
import TencentCloudChat from '@tencentcloud/chat';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
msg: {
|
msg: {
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['send'])
|
const emit = defineEmits(['send'])
|
||||||
//录音
|
//录音
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
const recorderManager = uni.getRecorderManager();
|
const recorderManager = uni.getRecorderManager();
|
||||||
// #endif
|
// #endif
|
||||||
// 录音时长
|
// 录音时长
|
||||||
const voiceLength = ref(0);
|
const voiceLength = ref(0);
|
||||||
// 录音定时器
|
// 录音定时器
|
||||||
const voiceTimer = ref(null);
|
const voiceTimer = ref(null);
|
||||||
// 录音文本
|
// 录音文本
|
||||||
const voiceText = ref('按住 说话');
|
const voiceText = ref('按住 说话');
|
||||||
// 录音提示
|
// 录音提示
|
||||||
const voiceTis = ref('手指上滑 取消发送');
|
const voiceTis = ref('手指上滑 取消发送');
|
||||||
// 录音图标显示
|
// 录音图标显示
|
||||||
const voiceFlg = ref(false);
|
const voiceFlg = ref(false);
|
||||||
// 录音开始Y坐标
|
// 录音开始Y坐标
|
||||||
const voicePageY = ref(0);
|
const voicePageY = ref(0);
|
||||||
// 录音结束
|
// 录音结束
|
||||||
const voiceStop = ref(false);
|
const voiceStop = ref(false);
|
||||||
const str = '';
|
const str = '';
|
||||||
// 录音相关
|
// 录音相关
|
||||||
const sv = {
|
const sv = {
|
||||||
// 按下触发
|
// 按下触发
|
||||||
touchstartVoice: (e) => {
|
touchstartVoice: (e) => {
|
||||||
voicePageY.value = (e.changedTouches[0].pageY).toFixed(2);
|
voicePageY.value = (e.changedTouches[0].pageY).toFixed(2);
|
||||||
recorderManager.start({
|
recorderManager.start({
|
||||||
duration: 60000, // 录音的时长,单位 ms,最大值 600000(10 分钟)
|
duration: 60000, // 录音的时长,单位 ms,最大值 600000(10 分钟)
|
||||||
sampleRate: 44100, // 采样率
|
sampleRate: 44100, // 采样率
|
||||||
numberOfChannels: 1, // 录音通道数
|
numberOfChannels: 1, // 录音通道数
|
||||||
encodeBitRate: 192000, // 编码码率
|
encodeBitRate: 192000, // 编码码率
|
||||||
format: "mp3"
|
format: "mp3"
|
||||||
});
|
});
|
||||||
voiceLength.value = 0;
|
voiceLength.value = 0;
|
||||||
voiceFlg.value = true
|
voiceFlg.value = true
|
||||||
console.log('recorder start success');
|
console.log('recorder start success');
|
||||||
//录音开始,
|
//录音开始,
|
||||||
voiceTimer.value = setInterval(() => {
|
voiceTimer.value = setInterval(() => {
|
||||||
voiceLength.value += 0.1;
|
voiceLength.value += 0.1;
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
console.log('touchstartVoice', voicePageY.value);
|
console.log('touchstartVoice', voicePageY.value);
|
||||||
},
|
},
|
||||||
// 滑动触发
|
// 滑动触发
|
||||||
touchmoveVoice: (e) => {
|
touchmoveVoice: (e) => {
|
||||||
// 没有展示UI不触发
|
// 没有展示UI不触发
|
||||||
if (!voiceFlg.value) {
|
if (!voiceFlg.value) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
let numTemp = voicePageY.value - ((e.changedTouches[0].pageY).toFixed(2));
|
|
||||||
if (numTemp >= 60) {
|
|
||||||
console.log('取消发送');
|
|
||||||
voiceStop.value = true
|
|
||||||
voiceTis.value = '松开手指 取消发送'
|
|
||||||
} else {
|
|
||||||
console.log('继续发送');
|
|
||||||
voiceStop.value = false
|
|
||||||
voiceTis.value = '手指上滑 取消发送'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 松开触发
|
|
||||||
touchendVoice: () => {
|
|
||||||
// 没有展示UI不触发
|
|
||||||
if (!voiceFlg.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
clearInterval(voiceTimer.value);
|
|
||||||
voiceText.value = '按住 说话'
|
|
||||||
voiceTis.value = "手指上滑 取消发送"
|
|
||||||
console.log('touchendVoice');
|
|
||||||
sv.stop();
|
|
||||||
},
|
|
||||||
// 打断触发
|
|
||||||
touchcancelVoice: () => {
|
|
||||||
clearInterval(voiceTimer.value);
|
|
||||||
// 关闭UI
|
|
||||||
voiceText.value = '按住 说话'
|
|
||||||
voiceTis.value = "手指上滑 取消发送"
|
|
||||||
// 不发送语音
|
|
||||||
voiceStop.value = true
|
|
||||||
console.log('touchcancelVoice');
|
|
||||||
sv.stop();
|
|
||||||
},
|
|
||||||
stop: () => {
|
|
||||||
voiceTimer.value = null;
|
|
||||||
voiceFlg.value = false
|
|
||||||
recorderManager.stop(); // 录音结束
|
|
||||||
console.log('录音结束');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
// 监听录音停止事件
|
|
||||||
recorderManager.onStop((res) => {
|
|
||||||
// 被打断等情况不发送
|
|
||||||
if (voiceStop.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 正常情况
|
|
||||||
if (voiceStop.value) {
|
|
||||||
uni.showToast({
|
|
||||||
icon: "none",
|
|
||||||
title: "取消发送",
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (voiceLength.value < 1) {
|
|
||||||
uni.showToast({
|
|
||||||
icon: "none",
|
|
||||||
title: "语音时长过短",
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (voiceLength.value > 60) {
|
|
||||||
uni.showToast({
|
|
||||||
icon: "none",
|
|
||||||
title: "语音时长过长",
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log('file', res)
|
|
||||||
|
|
||||||
try {
|
|
||||||
let message = uni.$chat.createAudioMessage({
|
|
||||||
to: props.msg.id,
|
|
||||||
conversationType: props.msg.type,
|
|
||||||
payload: {
|
|
||||||
file: res
|
|
||||||
},
|
|
||||||
// 音频上传进度回调
|
|
||||||
onProgress: function (event) {
|
|
||||||
console.log('file uploading:', event)
|
|
||||||
}
|
}
|
||||||
})
|
let numTemp = voicePageY.value - ((e.changedTouches[0].pageY).toFixed(2));
|
||||||
|
if (numTemp >= 60) {
|
||||||
let obj = {
|
console.log('取消发送');
|
||||||
query: {
|
voiceStop.value = true
|
||||||
toUserId: message.to,
|
voiceTis.value = '松开手指 取消发送'
|
||||||
formId: message.from,
|
} else {
|
||||||
msgType: message.type,
|
console.log('继续发送');
|
||||||
},
|
voiceStop.value = false
|
||||||
data: message
|
voiceTis.value = '手指上滑 取消发送'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 松开触发
|
||||||
|
touchendVoice: () => {
|
||||||
|
// 没有展示UI不触发
|
||||||
|
if (!voiceFlg.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearInterval(voiceTimer.value);
|
||||||
|
voiceText.value = '按住 说话'
|
||||||
|
voiceTis.value = "手指上滑 取消发送"
|
||||||
|
console.log('touchendVoice');
|
||||||
|
sv.stop();
|
||||||
|
},
|
||||||
|
// 打断触发
|
||||||
|
touchcancelVoice: () => {
|
||||||
|
clearInterval(voiceTimer.value);
|
||||||
|
// 关闭UI
|
||||||
|
voiceText.value = '按住 说话'
|
||||||
|
voiceTis.value = "手指上滑 取消发送"
|
||||||
|
// 不发送语音
|
||||||
|
voiceStop.value = true
|
||||||
|
console.log('touchcancelVoice');
|
||||||
|
sv.stop();
|
||||||
|
},
|
||||||
|
stop: () => {
|
||||||
|
voiceTimer.value = null;
|
||||||
|
voiceFlg.value = false
|
||||||
|
recorderManager.stop(); // 录音结束
|
||||||
|
console.log('录音结束');
|
||||||
}
|
}
|
||||||
emit('send', obj)
|
};
|
||||||
} catch (e) {
|
// #ifdef APP-PLUS
|
||||||
console.log('message catch', e)
|
// 监听录音停止事件
|
||||||
}
|
recorderManager.onStop((res) => {
|
||||||
//
|
// 被打断等情况不发送
|
||||||
|
if (voiceStop.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 正常情况
|
||||||
|
if (voiceStop.value) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: "none",
|
||||||
|
title: "取消发送",
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (voiceLength.value < 1) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: "none",
|
||||||
|
title: "语音时长过短",
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (voiceLength.value > 60) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: "none",
|
||||||
|
title: "语音时长过长",
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log('file', res)
|
||||||
|
|
||||||
})
|
try {
|
||||||
// #endif
|
let message = uni.$chat.createAudioMessage({
|
||||||
|
to: props.msg.id,
|
||||||
|
conversationType: props.msg.type,
|
||||||
|
payload: {
|
||||||
|
file: res
|
||||||
|
},
|
||||||
|
// 音频上传进度回调
|
||||||
|
onProgress: function(event) {
|
||||||
|
console.log('file uploading:', event)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let obj = {
|
||||||
|
query: {
|
||||||
|
toUserId: message.to,
|
||||||
|
formId: message.from,
|
||||||
|
msgType: message.type,
|
||||||
|
},
|
||||||
|
data: message
|
||||||
|
}
|
||||||
|
emit('send', obj)
|
||||||
|
} catch (e) {
|
||||||
|
console.log('message catch', e)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.voice_box {
|
.voice_box {
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
margin: 0 20rpx;
|
margin: 0 20rpx;
|
||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.record {
|
|
||||||
width: 40vw;
|
|
||||||
height: 40vw;
|
|
||||||
position: fixed;
|
|
||||||
top: 55%;
|
|
||||||
left: 30%;
|
|
||||||
background-color: rgba(0, 0, 0, .6);
|
|
||||||
border-radius: 20rpx;
|
|
||||||
|
|
||||||
.ing {
|
|
||||||
width: 100%;
|
|
||||||
height: 30vw;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
// 模拟录音音效动画
|
|
||||||
@keyframes volatility {
|
|
||||||
0% {
|
|
||||||
background-position: 0% 130%;
|
|
||||||
}
|
|
||||||
|
|
||||||
20% {
|
|
||||||
background-position: 0% 150%;
|
|
||||||
}
|
|
||||||
|
|
||||||
30% {
|
|
||||||
background-position: 0% 155%;
|
|
||||||
}
|
|
||||||
|
|
||||||
40% {
|
|
||||||
background-position: 0% 150%;
|
|
||||||
}
|
|
||||||
|
|
||||||
50% {
|
|
||||||
background-position: 0% 145%;
|
|
||||||
}
|
|
||||||
|
|
||||||
70% {
|
|
||||||
background-position: 0% 150%;
|
|
||||||
}
|
|
||||||
|
|
||||||
80% {
|
|
||||||
background-position: 0% 155%;
|
|
||||||
}
|
|
||||||
|
|
||||||
90% {
|
|
||||||
background-position: 0% 140%;
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
background-position: 0% 135%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
background-image: linear-gradient(to bottom, #f09b37, #fff 50%);
|
|
||||||
background-size: 100% 200%;
|
|
||||||
animation: volatility 1.5s ease-in-out -1.5s infinite alternate;
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
font-size: 150rpx;
|
|
||||||
color: #f09b37;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel {
|
.hidden {
|
||||||
width: 100%;
|
display: none !important;
|
||||||
height: 30vw;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
color: #fff;
|
|
||||||
font-size: 150rpx;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tis {
|
.record {
|
||||||
width: 100%;
|
width: 40vw;
|
||||||
height: 10vw;
|
height: 40vw;
|
||||||
display: flex;
|
position: fixed;
|
||||||
justify-content: center;
|
top: 55%;
|
||||||
font-size: 28rpx;
|
left: 30%;
|
||||||
color: #fff;
|
background-color: rgba(0, 0, 0, .6);
|
||||||
|
border-radius: 20rpx;
|
||||||
|
|
||||||
&.change {
|
.ing {
|
||||||
|
width: 100%;
|
||||||
|
height: 30vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
// 模拟录音音效动画
|
||||||
|
@keyframes volatility {
|
||||||
|
0% {
|
||||||
|
background-position: 0% 130%;
|
||||||
|
}
|
||||||
|
|
||||||
|
20% {
|
||||||
|
background-position: 0% 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
30% {
|
||||||
|
background-position: 0% 155%;
|
||||||
|
}
|
||||||
|
|
||||||
|
40% {
|
||||||
|
background-position: 0% 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
background-position: 0% 145%;
|
||||||
|
}
|
||||||
|
|
||||||
|
70% {
|
||||||
|
background-position: 0% 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
80% {
|
||||||
|
background-position: 0% 155%;
|
||||||
|
}
|
||||||
|
|
||||||
|
90% {
|
||||||
|
background-position: 0% 140%;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
background-position: 0% 135%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
background-image: linear-gradient(to bottom, #f09b37, #fff 50%);
|
||||||
|
background-size: 100% 200%;
|
||||||
|
animation: volatility 1.5s ease-in-out -1.5s infinite alternate;
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
font-size: 150rpx;
|
||||||
color: #f09b37;
|
color: #f09b37;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel {
|
||||||
|
width: 100%;
|
||||||
|
height: 30vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
color: #fff;
|
||||||
|
font-size: 150rpx;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.tis {
|
||||||
|
width: 100%;
|
||||||
|
height: 10vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
&.change {
|
||||||
|
color: #f09b37;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
|
@ -4,7 +4,6 @@ import {
|
||||||
import uni from '@dcloudio/vite-plugin-uni';
|
import uni from '@dcloudio/vite-plugin-uni';
|
||||||
|
|
||||||
let target = 'http://91f.xyz:8080'
|
let target = 'http://91f.xyz:8080'
|
||||||
// let target = 'http://762c9b48.r24.cpolar.top'
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [uni()],
|
plugins: [uni()],
|
||||||
|
|
Loading…
Reference in New Issue