Commit 208a27d2 by 前端

https

1 parent 61234200
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2023-06-08 10:20:23 * @Date: 2023-06-08 10:20:23
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-23 09:44:52 * @LastEditTime: 2024-03-04 11:16:55
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\App.vue * @FilePath: \dj-scrm-wx-work-attachment-psd\src\App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -30,20 +30,6 @@ export default { ...@@ -30,20 +30,6 @@ export default {
data() { data() {
return { return {
entry: IS_PROD ? 'normal' : 'chat_attachment', entry: IS_PROD ? 'normal' : 'chat_attachment',
tabList: [
{
title: '卡券',
name: 'coupon',
active: require('@/assets/images/tabbar/coupon_active.png'),
inactive: require('@/assets/images/tabbar/coupon.png')
},
{
title: '活动',
name: 'activity',
active: require('@/assets/images/tabbar/activity_active.png'),
inactive: require('@/assets/images/tabbar/activity.png')
}
]
} }
}, },
watch: { watch: {
......
@import './normalize.scss'; @import "./normalize.scss";
@import './sprite.scss';
html, html,
body .app { body .app {
color: #333333; color: #333333;
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif; font-family: Arial, Helvetica, "STHeiti STXihei", "Microsoft YaHei", Tohoma, sans-serif;
background-color: #f7f7f7; background-color: #f7f7f7;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
height: 100%; height: 100%;
// overflow: hidden; // overflow: hidden;
--themeColor: #3975C6; --themeColor: #3975c6;
/* 兼容 IOS<11.2 先constant再env */ /* 兼容 IOS<11.2 先constant再env */
--constantSafeAreaInsetBottom: constant(safe-area-inset-bottom); --constantSafeAreaInsetBottom: constant(safe-area-inset-bottom);
/* 兼容 IOS>11.2 */ /* 兼容 IOS>11.2 */
...@@ -83,7 +82,7 @@ img { ...@@ -83,7 +82,7 @@ img {
transition: all 0.25s; transition: all 0.25s;
} }
.van-dropdown-menu__bar--opened~.arrow .sprite-icon, .van-dropdown-menu__bar--opened ~ .arrow .sprite-icon,
.van-dropdown-menu__title--active .icon-down { .van-dropdown-menu__title--active .icon-down {
transform: rotate(-180deg); transform: rotate(-180deg);
} }
...@@ -105,11 +104,11 @@ img { ...@@ -105,11 +104,11 @@ img {
.attachment { .attachment {
.van-dropdown-menu__bar { .van-dropdown-menu__bar {
.van-dropdown-menu__title { .van-dropdown-menu__title {
color: #5F5F5F !important; color: #5f5f5f !important;
font-size: 12px; font-size: 12px;
} }
.van-dropdown-menu__title--active { .van-dropdown-menu__title--active {
color: var(--themeColor) !important; color: var(--themeColor) !important;
} }
} }
}
\ No newline at end of file \ No newline at end of file
}
.sprite-icon { background-image: url(../images/sprite.png);background-size: 105px 90px;}
.icon-down { width: 12px; height: 12px; background-position: -26px -74px;}
.icon-eye { width: 13px; height: 8px; background-position: -48px -74px;}
.icon-gift-del { width: 18px; height: 18px; background-position: -84px -30px;}
.icon-grctx { width: 16px; height: 16px; background-position: 0px -74px;}
.icon-link { width: 32px; height: 32px; background-position: -42px 0px;}
.icon-menu-active { width: 22px; height: 20px; background-position: 0px -44px;}
.icon-menu { width: 22px; height: 20px; background-position: -32px -44px;}
.icon-pdf { width: 32px; height: 34px; background-position: 0px 0px;}
.icon-PYQ { width: 21px; height: 20px; background-position: -84px 0px;}
.icon-send { width: 10px; height: 10px; background-position: -64px -44px;}
\ No newline at end of file \ No newline at end of file
<template>
<van-popup
v-model="show"
position="bottom"
class="date-popup"
round
@close="close"
>
<div class="date-title flex">
时间选择
<i
class="van-icon van-icon-cross van-popup__close-icon van-popup__close-icon--top-right"
@click="close"
></i>
</div>
<div class="date-box">
<div class="date-subtitle">推送日期</div>
<div class="date-list flex">
<template v-for="(i,index) in dateList">
<div
:key="index"
:class="['item flex',{'active':index == dateIndex}]"
@click="chooseDate(index)"
>
{{ i }}
</div>
</template>
</div>
<div class="date-subtitle">自定义</div>
<van-calendar
ref="calendar"
class="calendar"
:poppable="false"
:show-confirm="false"
:show-title="false"
:show-subtitle="false"
type="range"
color="#3975C6"
:min-date="minDate"
:max-date="maxDate"
:allow-same-day="true"
:lazy-render="false"
row-height="48px"
@confirm="confirmCalendar"
/>
<van-button
block
round
color="#3975C6"
class="date-btn"
:disabled="!dateValue.startTime && !dateValue.endTime"
@click="confirmDate"
>确定</van-button>
</div>
</van-popup>
</template>
<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'
export default {
name: 'DatePopup',
props: {
value: Boolean
},
data () {
return {
show: false,
dateList: ['上月', '近三月', '近一年'],
dateValue: {
startTime: '',
endTime: ''
},
dateIndex: -1,
minDate: new Date('2023/01/01'),
maxDate: new Date(),
}
},
watch: {
value (n) {
this.show = n
}
},
mounted () {
},
methods: {
chooseDate (index) {
const monthNumber = {
0: 1,
1: 3,
2: 12
}[index]
let startTime = dayjs().subtract(monthNumber, 'month'),
endTime = dayjs()
if (index == 0) {
startTime = startTime.startOf('M')
endTime = dayjs(startTime).endOf('month')
}
this.dateIndex = index
this.setDateValue([startTime, endTime])
this.$refs.calendar.reset()
},
confirmCalendar (val) {
this.dateIndex = -1
this.setDateValue(val)
},
setDateValue ([startTime, endTime]) {
this.dateValue = {
startTime: `${dayjs(startTime).format('YYYY-MM-DD')} 00:00:00`,
endTime: `${dayjs(endTime).format('YYYY-MM-DD')} 23:59:59`
}
console.log(JSON.parse(JSON.stringify(this.dateValue)))
},
close () {
this.$emit('update:value', false)
},
confirmDate () {
let { dateValue } = this
this.$emit('confirm', dateValue)
this.close()
}
}
}
</script>
<style scoped lang='scss'>
.date-popup {
max-height: 95%;
/deep/.van-popup__close-icon {
z-index: 3;
margin-left: auto;
position: static;
}
/deep/.van-calendar__day {
font-size: 14px;
}
/deep/.van-calendar__month-title {
height: 32px;
line-height: 32px;
}
/deep/.van-calendar__bottom-info {
font-size: 8px;
bottom: 2px;
}
.date-title {
height: 44px;
padding: 0 16px;
font-weight: 500;
font-size: 16px;
color: #222222;
position: sticky;
background-color: #fff;
z-index: 2;
top: 0;
}
.date-box {
padding: 16px 16px calc(var(--constantSafeAreaInsetBottom) + 76px);
padding: 16px 16px calc(var(--envSafeAreaInsetBottom) + 76px);
.date-subtitle {
font-size: 14px;
color: #333333;
margin-bottom: 8px;
}
.date-list {
margin-bottom: 16px;
gap: 8px;
.item {
width: 80px;
height: 28px;
border: 1px solid #dadde0;
border-radius: 14px;
font-size: 14px;
color: #333333;
justify-content: center;
}
.active {
color: #3975c6;
background: #3975c61a;
border-color: #3975c61a;
}
}
.calendar {
height: 320px;
}
}
.date-btn {
position: fixed;
left: 16px;
bottom: calc(var(--constantSafeAreaInsetBottom) + 16px);
bottom: calc(var(--envSafeAreaInsetBottom) + 16px);
z-index: 2;
width: calc(100% - 32px);
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<form
:class="['search-box','flex',{'max':!showDropdown}]"
action=""
>
<van-search
ref="search"
v-model="searchValue"
:placeholder="placeholder"
@search="onEmit($event,'search')"
@clear="clear"
@focus="onEmit('','focus')"
:maxlength="maxlength"
/>
<template v-if="showDropdown">
<van-dropdown-menu active-color="#3975C6">
<van-dropdown-item
:options="option"
v-model="value"
@change="onEmit($event,'change')"
>
<template #title>
<div class="menu-title flex">
{{option[value].text}}
<div class="sprite-icon icon-down"></div>
</div>
</template>
</van-dropdown-item>
</van-dropdown-menu>
</template>
<template v-if="showMenu">
<dropdown-menu
@confirm="onEmit($event,'menuSelect')"
:single="single"
:title="title"
:data="option"
></dropdown-menu>
</template>
</form>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'SearchBox',
props: {
keyword: String,
index: {
type: Number,
default: 0
},
updata: {
type: Number,
default: new Date().getTime()
},
showDropdown: {
type: Boolean,
default: true
},
placeholder: String,
maxlength: {
type: Number,
default: 30
},
showMenu: Boolean,
option: {
type: Array,
default: () => []
},
single: Boolean,
title: String
},
data () {
return {
value: 0,
searchValue: ''
}
},
watch: {
'updata' (n) {
this.value = this.index
},
'keyword' (n) {
this.searchValue = n
}
},
methods: {
clear () {
let [input] = document.getElementsByClassName('van-field__control')
input.blur()
this.onEmit('', 'search')
},
onEmit (e, name) {
this.$emit(name, e)
}
}
}
</script>
<style lang='scss'>
.search-box {
height: 50px;
background: #fff;
box-shadow: 0px 1px 0px 0px #e9e9e9;
padding-right: 16px;
position: relative;
margin-bottom: 0;
.van-search {
width: 263px;
padding: 4.5px 8px;
height: 100%;
background: #fff;
.van-search__content {
background-color: #fff;
border: 1px solid #cdd1d4;
border-radius: 16px;
}
}
}
.max {
padding-right: 0;
.van-search {
width: 100%;
}
}
.van-icon-search:before {
color: #cdd1d4;
}
</style>
\ No newline at end of file \ No newline at end of file
import { merchantsApi } from '@/api'
export default {
data () {
return {
businessList: [
{
text: '全部',
value: '',
active: true
}
]
}
},
mounted () {
this.getBusinessType()
},
methods: {
getBusinessType () {
merchantsApi.getBusinessType().then(data => {
data && data.map(e => {
this.businessList.push({
text: e.dictLabel,
value: e.dictValue,
active: false
})
})
})
}
}
}
\ No newline at end of file \ No newline at end of file
import businessMixin from './businessMixin'
import shareMixin from './shareMixin'
import pageMixin from './pageMixin'
import psdMixin from './psdMixin'
export {
businessMixin,
shareMixin,
pageMixin,
psdMixin
}
\ No newline at end of file \ No newline at end of file
import { marketingApi } from '@/api'
export default {
data () {
return {
list: [],
total: 0,
flag: false,
businessText: '全部',
materialName: '',
sort: 0,
businessType: '',
groupId: '',
}
},
mounted () {
let { groupId } = this.getQuery()
if (groupId) {
this.groupId = groupId
return
}
if (this.$route.name != 'psd') {
this.init()
}
},
methods: {
init () {
this.showLoading()
this.getList()
},
search (e) {
this.materialName = e
this.clearData()
},
change (index) {
let { psdGroupList } = this
if (psdGroupList.length > 1) this.groupId = psdGroupList[index + 1].value
this.clearData()
},
menuSelect (e) {
this.groupId = e && e.length && e[0].value || ''
this.clearData()
},
clearData () {
this.flag = false
this.list = []
this.init()
},
changeSort (e) {
this.sort = e
this.clearData()
},
businessConfirm (chooseList) {
console.log(chooseList)
if (chooseList.length) {
let text = []
let businessType = []
chooseList.map(e => {
text.push(e.text)
businessType.push(e.value)
})
this.businessText = `${text.join(',').substring(0, 5)}...`
this.businessType = businessType.join(',')
} else {
this.businessType = ''
this.businessText = '全部'
}
this.clearData()
},
onReachBottom () {
this.$refs.scrollView.finished = true
},
sortList (data, attr) {
return data.sort((a, b) => b[attr] - a[attr])
},
getList () {
let { materialName, businessType, groupId, sort } = this
setTimeout(()=>{
marketingApi.getPsdList({ materialName, businessType, groupId }).then(data => {
console.log('素材列表', data)
if (sort != 0 && data && data.materialToCRpcResponses && data.materialToCRpcResponses.length) data.materialToCRpcResponses = this.sortList(data.materialToCRpcResponses, sort == 1 ? 'sendNum' : 'readNum')
this.list = data.materialToCRpcResponses || []
this.flag = true
this.hideLoading()
})
},500)
}
}
}
\ No newline at end of file \ No newline at end of file
import { marketingApi } from '@/api'
export default {
data () {
return {
option: [
{ text: '上传时间优先', value: 0 },
{ text: '发送次数优先', value: 1 },
{ text: '阅读数优先', value: 2 },
],
psdGroupList: [],
tab: [],
updata: new Date().getTime()
}
},
mounted () {
marketingApi.getPsdGroupList().then(data => {
console.log('素材组', data)
let psdGroupList = [{
text: '全部',
value: '',
active: true
}]
let tab = []
data && data.map(e => {
psdGroupList.push({
text: e.materialGroupName,
value: e.id,
active: false
})
tab.push(e.materialGroupName)
})
let { groupId } = this
if (groupId) {
psdGroupList.map(e =>{
if(e.value == groupId) e.active = true
else e.active = false
})
this.clearData()
}
this.psdGroupList = psdGroupList
if (this.$route.name == 'psd') {
this.tab = tab
this.change(0)
}
this.updata = new Date().getTime()
})
},
methods: {
}
}
\ No newline at end of file \ No newline at end of file
import { wxConfig, marketingApi } from '@/api'
// import { resolve } from 'core-js/fn/promise'
export default {
data () {
return {
entry: 'normal'
}
},
mounted () {
this.wxInit()
},
methods: {
wxInit () {
let _this = this
wxConfig.init(['getContext', 'shareAppMessage', 'sendChatMessage', 'shareToExternalMoments']).then(() => {
wxConfig.getContext().then(({ entry }) => {
_this.$parent.entry = entry
_this.entry = entry
})
})
},
shareToExternalMoments (i) {
this.sendMessage(i, true)
},
async sendMessage (i, isPyq) {
const { shopmall_appid, envVersion } = window.$fetchConfig
const path = 'pages/psdView/psdView'
const { merchantId, uuid, sapCode, userName } = this.getLocalStorage('dj_scrm_userInfo')
const { entry } = this
const { materialName, id, titleUrl, materialTitle, description, videoUrl, imageUrlList } = i
// let fisrtFrame = videoUrl && await this.getVideoFirstFrame(videoUrl)
const imgUrl = 'https://img01.glsx.com.cn/weapp/resource/scrm-mobile/test/test.jpg'
let frameUrl = (imageUrlList && imageUrlList.length) ? imageUrlList[0] : imgUrl
let query = `merchantId=${merchantId}&id=${id}&staffUuid=${uuid}&shareTime=${Date.now()}`
if (sapCode) query = `${query}&storeCode=${sapCode}`
if (isPyq) {
const data = {
path,
query: encodeURIComponent(query),
appId: shopmall_appid,
envVersion
}
let url = window.location.origin.replace('scrm', 'wechatlink')
wxConfig.shareToExternalMoments({
attachments: [
{
msgtype: 'link', // 消息类型,必填
link: {
title: materialTitle || `「${userName}」邀请您查看「${materialName}」`, // H5消息标题
imgUrl: titleUrl || frameUrl, // H5消息封面图片URL
url: `${url}?linkData=${encodeURIComponent(JSON.stringify(data))}` // H5消息页面url 必填
},
}
]
}).then(() => {
this.sendReadBuriedPoint({ id, merchantId, uuid })
this.hideLoading()
})
.catch(err => {
this.hideLoading()
})
} else {
wxConfig.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid,
envVersion
})
.then(link => {
// console.log('再次进来了吗')
// this.showLoading()
let params = {
link,
title: materialTitle || `「${userName}」邀请您查看「${materialName}」`,
desc: description || '',
imgUrl: titleUrl || frameUrl
}
// if (entry != 'normal') this.sendChatMessage(params, { id, merchantId, uuid })
// else this.shareAppMessage(params, { id, merchantId, uuid })
this.shareAppMessage(params, { id, merchantId, uuid })
// wxConfig.getContext().then((res) => {
// if (res.entry != 'normal'){
// let pdfParam = {
// msgtype: 'news',
// news: params,
// enterChat: false
// }
// if(i.materialType==1){
// this.sendChatMessage(pdfParam, { id, merchantId, uuid })
// }else{
// this.getParam(i, { id, merchantId, uuid })
// }
// }else{
// this.shareAppMessage(params, { id, merchantId, uuid })
// }
// })
})
}
},
sendReadBuriedPoint ({ id, merchantId, uuid }) {
marketingApi.sendReadBuriedPoint({
materialId: id,
type: 1,
merchantId,
staffUuid: uuid
})
},
getParam (item, sendParams) {
let str = decodeURIComponent(item.materialUrl)
let testReg = /\>(.*?)\<|img(.*?)src.*?(.jpg|.peg|.png|.gif|.webp|.pjp|.jfif|.pjpeg|.bmp|.dib)|video(.*?)src.*?(.ogm|.wmv|.asx|.mpg|.webm|.mp4|.ogv|.mpeg|.mov|.m4v|.avi)/g
let arr = str.match(testReg)
let imgLabelReg = /img(.*?)src.*?(.jpg|.peg|.png|.gif|.webp|.pjp|.jfif|.pjpeg|.bmp|.dib)/
let videoLabelReg = /video(.*?)src.*?(.ogm|.wmv|.asx|.mpg|.webm|.mp4|.ogv|.mpeg|.mov|.m4v|.avi)/
let imgLinkReg = /https?:\/\/(.*?)(.jpg|.peg|.png|.gif|.webp|.pjp|.jfif|.pjpeg|.bmp|.dib)/
let videoLinkReg = /https?:\/\/(.*?)(.ogm|.wmv|.asx|.mpg|.webm|.mp4|.ogv|.mpeg|.mov|.m4v|.avi)/
arr = arr.map(item => {
if (imgLabelReg.test(item)) {
if (item.match(imgLinkReg)) return item.match(imgLinkReg)[0]
} else if (videoLabelReg.test(item)) {
if (item.match(videoLinkReg)) return item.match(videoLinkReg)[0]
} else if (item && item.length > 2 && item != '><') {
return item.slice(1, -1) ? item.slice(1, -1).replaceAll('&amp;', '&').replaceAll('&gt;', '>').replaceAll('&lt;', '<') : ''
}
})
arr = arr.filter(item => item)
let newArr = []
arr.forEach((ele, id) => {
let mediaType = 5
let myParam = {}
// let fileReg = /^https?:\/\/[\s\S]+\./
if (!ele) return
if (imgLinkReg.test(ele) || videoLinkReg.test(ele)) {
let imgArr = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'pjp', 'jfif', 'pjpeg', 'bmp', 'dib']
let idx = ele.lastIndexOf('.')
if (idx > -1 && imgArr.includes(ele.slice(idx + 1))) {
mediaType = 3
} else {
mediaType = 4
}
myParam = this.uploadMaterial({ materialName: item.materialName, data: ele, mediaType }, mediaType)
} else {
myParam = this.getTextPromise(ele)
}
newArr.push(myParam)
});
Promise.allSettled(newArr).then(async res => {
for (let i = 0; i < res.length; i++) {
await this.sendChatMessage(res[i].value, sendParams)
}
})
},
getTextPromise (ele) {
return new Promise((resolve, reject) => {
resolve({
msgtype: 'text',
text: { content: ele },
enterChat: false
})
})
},
uploadMaterial (param, type) {
return new Promise((resolve, reject) => {
marketingApi.uploadMaterial(param).then(res => {
if (res?.mediaId) {
if (type == 1) {
resolve({
msgtype: 'file',
file: { mediaid: res.mediaId },
enterChat: false
})
} else if (type == 3) {
resolve({
msgtype: 'image',
image: { mediaid: res.mediaId },
enterChat: false
})
} else {
resolve({
msgtype: 'video',
video: { mediaid: res.mediaId },
enterChat: false
})
}
}
})
})
},
sendChatMessage (params, sendParams) {
return new Promise((resolve, reject) => {
this.showLoading()
wxConfig
.sendChatMessage(params)
.then(res => {
this.hideLoading()
this.sendReadBuriedPoint(sendParams)
resolve()
}).catch(err => {
this.hideLoading()
})
})
},
shareAppMessage (params, sendParams) {
wxConfig
.shareAppMessage(params)
.then(() => {
this.sendReadBuriedPoint(sendParams)
this.hideLoading()
})
.catch(() => {
this.hideLoading()
})
},
toUnicode (chineseStr = '') {
let unicodeStr = ''
for (let i = 0, iLength = chineseStr.length; i < iLength; i++) {
unicodeStr += '@' + chineseStr.charCodeAt(i).toString(16)
}
return unicodeStr
}
}
}
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-25 10:30:47 * @Date: 2024-02-25 10:30:47
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-29 22:05:50 * @LastEditTime: 2024-03-01 14:29:27
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\mixins\socket.js * @FilePath: \dj-scrm-wx-work-attachment-psd\src\mixins\socket.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
const Q_NUM = 9 const Q_NUM = 9
import { ROLE_LIST,AI_TYPE } from '@/utils/constants' import { ROLE_LIST, AI_TYPE } from '@/utils/constants'
export default { export default {
data() { data() {
return { return {
path: 'ws://192.168.3.191:7864/ws/1', path: 'wss://salesgpt.dev.glsx.com.cn/ws/1',
isSend: true, isSend: true,
timer_chat: null, timer_chat: null,
timer_jump: null, timer_jump: null,
...@@ -49,6 +49,10 @@ export default { ...@@ -49,6 +49,10 @@ export default {
}, },
getMessage: function (res) { getMessage: function (res) {
let msg = res.data let msg = res.data
if (this.summarize) {
this.summarize(msg)
return
}
if (msg == '<rdfast stop>') { if (msg == '<rdfast stop>') {
if (!this.timer_tip) if (!this.timer_tip)
this.timer_tip = setInterval(() => { this.timer_tip = setInterval(() => {
...@@ -60,16 +64,11 @@ export default { ...@@ -60,16 +64,11 @@ export default {
this.timer_tip = null this.timer_tip = null
} }
}, 100) }, 100)
if (this.endFun) this.endFun()
if (this.type != AI_TYPE.sparring_reply) { if (this.type != AI_TYPE.sparring_reply) {
this.isSend = true this.isSend = true
return return
} }
} }
if (this.summarize) {
this.summarize(msg)
return
}
if (this.type != AI_TYPE.sparring_reply) { if (this.type != AI_TYPE.sparring_reply) {
if (this.contentList.length == 1) { if (this.contentList.length == 1) {
this.contentList.push({ this.contentList.push({
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-24 13:35:26
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-24 13:49:11
* @FilePath: \vue-2.6\src\platforms\web\util\websocket.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
function initWebSocket(e) {
console.log(e)
const wsUri = 'ws://192.168.3.191:7864/ws/1'
this.socket = new WebSocket(wsUri) //这里面的this都指向vue
//连接成功
this.websock.onopen = websocketonopen
this.socket.onerror = webSocketOnError
this.socket.onmessage = webSocketOnMessage
this.socket.onclose = closeWebsocket
}
function webSocketOnError(e) {
console.log('WebSocket连接发生错误')
}
function webSocketOnMessage(e) {
const data = JSON.parse(e.data)
console.log(data)
}
function websocketonopen() {
//连接成功事件
websocketsend('发送数据')
//提示成功
console.log('连接成功', 3)
//开启心跳
this.start()
}
// 关闭websiocket
function closeWebsocket() {
console.log('连接已关闭...')
}
function close() {
this.socket.close() // 关闭 websocket
this.socket.onclose = function (e) {
console.log(e) //监听关闭事件
console.log('关闭')
}
}
function webSocketSend(agentData) {
this.socket.send(agentData)
}
export default {
initWebSocket,
close
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 09:47:18 * @Date: 2024-02-23 09:47:18
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-29 11:15:25 * @LastEditTime: 2024-03-01 17:41:15
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue * @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
<div class="card-desc">{{ item }}</div> <div class="card-desc">{{ item }}</div>
</div> </div>
</div> </div>
<div class="card-title">用车意向</div>
<div class="car-desc">{{ descList[identityIndex] || '正在努力加载...' }}</div>
<div class="card-title">你设定的身份</div>
<van-field v-model="identityValue" placeholder="请输入身份" class="car-input" />
<div class="popup-btn" @click="handleSure">确认</div> <div class="popup-btn" @click="handleSure">确认</div>
<!-- <div class="car-item" @click="handleSelectCar(item)" v-for="(item, index) in carList" :key="index"> <!-- <div class="car-item" @click="handleSelectCar(item)" v-for="(item, index) in carList" :key="index">
<div class="car-img"><img :src="item.url" /></div> <div class="car-img"><img :src="item.url" /></div>
...@@ -39,19 +44,61 @@ ...@@ -39,19 +44,61 @@
</template> </template>
<script> <script>
import { CAR_TYPE, CAR_SCENE, CAR_IDENTITY } from '@/utils/constants' import { CAR_TYPE, CAR_SCENE, CAR_IDENTITY } from '@/utils/constants'
import Socket from '@/mixins/socket'
export default { export default {
mixins: [Socket],
data() { data() {
return { return {
identityValue: '',
roleIndex: -1,
desc_d: '',
descList: [],
show: false, show: false,
roleMsg: '',
selectCar: {}, selectCar: {},
sceneList: CAR_SCENE, sceneList: CAR_SCENE,
identityList: CAR_IDENTITY, identityList: [],
sceneIndex: 0, sceneIndex: 0,
identityIndex: 0, identityIndex: 0,
carList: CAR_TYPE carList: CAR_TYPE
} }
}, },
methods: { methods: {
defaultFun() {
this.sendMessage(
JSON.stringify({
type: 'roles_generate',
question: '你是一名购车客户,请随机设定6个需要买车的角色,只需要输出他们的职业,每个职业不能超过6个字,输出格式如:家庭主妇、全职妈妈、上报族...'
})
)
},
summarize(msg) {
if (this.roleIndex > -1) {
if (msg == '<rdfast stop>') {
msg = ''
this.roleIndex++
}
this.$set(this.descList, this.roleIndex, this.descList[this.roleIndex] + msg)
return
}
if (msg == '<rdfast stop>') {
this.roleIndex++
const regex = /\d+\.\s(.+)/g
const matches = [...this.roleMsg.matchAll(regex)]
this.identityList = matches.length ? matches.map(match => match[1]) : this.roleMsg.replace(/\。/, '').split('、')
for (let i = 0; i < this.identityList.length; i++) {
this.descList.push('')
this.sendMessage(
JSON.stringify({
type: 'roles_generate_desc',
question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份描述你的用车意向,大约100字左右`
})
)
}
} else {
this.roleMsg += msg
}
},
handleSelectCar(item) { handleSelectCar(item) {
this.show = true this.show = true
this.selectCar = item this.selectCar = item
...@@ -60,13 +107,17 @@ export default { ...@@ -60,13 +107,17 @@ export default {
this.sceneIndex = item this.sceneIndex = item
}, },
handleSelectIdentity(item) { handleSelectIdentity(item) {
// if(this.roleIndex<=this.identityList.length) {
// return
// }
this.desc_d = ''
this.identityIndex = item this.identityIndex = item
}, },
handleSure() { handleSure() {
this.$router.push({ this.$router.push({
path: 'chat', path: 'chat',
query: { query: {
identity: this.identityList[this.identityIndex] identity: this.identityValue?this.identityValue:this.identityList[this.identityIndex]
} }
}) })
} }
...@@ -96,6 +147,18 @@ export default { ...@@ -96,6 +147,18 @@ export default {
} }
.card-title { .card-title {
padding-left: 20px; padding-left: 20px;
color: #333;
font-weight: 600;
}
.car-input {
margin: 10px 20px;
height: 40px;
border-radius: 4px;
width: calc(100% - 40px);
}
.car-desc {
padding: 10px 20px;
min-height: 150px
} }
.car-item { .car-item {
.car-img { .car-img {
......
...@@ -122,7 +122,7 @@ export default { ...@@ -122,7 +122,7 @@ export default {
car_type = CAR_TYPE_DESC.find(item => item.includes(type)) car_type = CAR_TYPE_DESC.find(item => item.includes(type))
this.car_tips = CAR_TIPS(identity) this.car_tips = CAR_TIPS(identity)
// this.title = `${type}` // this.title = `${type}`
this.title = `AI的身份是${identity}购买的意向车型是问界${CAR_TYPR[identity]}` this.title = `AI的身份是${identity}购买的意向车型是问界${['M5','M7','M9'][parseInt(Math.random()*100)%3]}`
// this.issuesList = TIP_LIST[CAR_TYPR[identity]] // this.issuesList = TIP_LIST[CAR_TYPR[identity]]
}, },
methods: { methods: {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 09:47:18 * @Date: 2024-02-23 09:47:18
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-27 16:00:41 * @LastEditTime: 2024-03-01 13:53:18
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue * @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -59,7 +59,6 @@ export default { ...@@ -59,7 +59,6 @@ export default {
resultAll: '', resultAll: '',
content: '', content: '',
advise: '', advise: '',
endStatus: true,
messageList: [], messageList: [],
timer: null, timer: null,
tabList: ['得分详情', '话术分析'], tabList: ['得分详情', '话术分析'],
...@@ -107,11 +106,9 @@ export default { ...@@ -107,11 +106,9 @@ export default {
}) })
) )
}, },
endFun() {
this.endStatus = true
},
//总结换行 //总结换行
summarize(msg) { summarize(msg) {
if(msg == '<rdfast stop>') return
this.resultAll += msg.replace(/\s/g, '') this.resultAll += msg.replace(/\s/g, '')
if (/\=\s*\d{1,3}分$/.test(this.resultAll)) { if (/\=\s*\d{1,3}分$/.test(this.resultAll)) {
this.advise += msg this.advise += msg
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!