Commit 5e0a2993 by 前端

fixed

1 parent f5670085
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-26 14:09:59
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-13 15:36:30
* @FilePath: \salesgpt-project\src\api\ssoApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const url = '/rop-scrm-sso/router' const url = '/rop-scrm-sso/router'
const returnAll = true const returnAll = true
export default { export default {
/**OAuth2授权登陆 */ /**OAuth2授权登陆 */
login(data) { login(data) {
// data.method = 'scrm.api.sso.ww.oauth.login'
data.method = 'scrm.api.sso.weapp.login.by.wechat'
data.productCode = 'PC00025'
return window.$HTTP({
url,
data,
returnAll
})
},
/**企微 OAuth2授权登陆 */
wwLogin(data) {
data.method = 'scrm.api.sso.ww.oauth.login' data.method = 'scrm.api.sso.ww.oauth.login'
data.productCode = 'PC00025' data.productCode = 'PC00025'
return window.$HTTP({ return window.$HTTP({
...@@ -20,4 +39,4 @@ export default { ...@@ -20,4 +39,4 @@ export default {
returnAll returnAll
}) })
} }
}
\ No newline at end of file \ No newline at end of file
}
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-03-13 17:42:28
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-13 17:42:36
* @FilePath: \salesgpt-project\src\directive\press.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const press = {
bind: function (el, binding, vNode) {
console.log(el, binding, vNode)
// el就是dom
if (typeof binding.value !== 'function') {
throw 'callback must be a function'
}
// 定义变量
let pressTimer = null
// 创建计时器( 2秒后执行函数 )
let start = e => {
if (e.type === 'click' && e.button !== 0) {
return
}
if (pressTimer === null) {
pressTimer = setTimeout(() => {
handler()
}, 2000)
}
}
// 取消计时器
let cancel = e => {
console.log(e)
if (pressTimer !== null) {
clearTimeout(pressTimer)
pressTimer = null
}
}
// 运行函数
const handler = e => {
binding.value(e)
}
// 添加事件监听器
el.addEventListener('mousedown', start)
el.addEventListener('touchstart', start)
// 取消计时器
el.addEventListener('click', cancel)
el.addEventListener('mouseout', cancel)
el.addEventListener('touchend', cancel)
el.addEventListener('touchcancel', cancel)
},
// 当传进来的值更新的时候触发
componentUpdated(el, { value }) {
el.$value = value
},
// 指令与元素解绑的时候,移除事件绑定
unbind(el) {
el.removeEventListener('click', el.handler)
}
}
export default press
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: limin * @Author: limin
* @Date: 2021-06-07 14:12:32 * @Date: 2021-06-07 14:12:32
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-05 15:08:11 * @LastEditTime: 2024-03-22 17:28:33
*/ */
// 兼容 IE // 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill // https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
...@@ -16,6 +16,7 @@ import router from './router' ...@@ -16,6 +16,7 @@ import router from './router'
import store from './store' import store from './store'
import api from './api' import api from './api'
import { fetchConfig, cfg } from '@/config' import { fetchConfig, cfg } from '@/config'
import press from '@/directive/press'
import '@/assets/css/index.scss' import '@/assets/css/index.scss'
import { bus, tools, store as local, util } from './utils' import { bus, tools, store as local, util } from './utils'
import './utils/util' import './utils/util'
...@@ -23,6 +24,7 @@ import 'components' ...@@ -23,6 +24,7 @@ import 'components'
// import websocket from './utils/websocket' // import websocket from './utils/websocket'
import { components } from '@/plugins/vant' import { components } from '@/plugins/vant'
components.forEach(component => Vue.use(component)) components.forEach(component => Vue.use(component))
Vue.directive('press', press)
Vue.prototype.api = api Vue.prototype.api = api
Vue.prototype.bus = bus Vue.prototype.bus = bus
Vue.prototype.tools = tools Vue.prototype.tools = tools
...@@ -38,7 +40,30 @@ Vue.prototype.to = function (name, params) { ...@@ -38,7 +40,30 @@ Vue.prototype.to = function (name, params) {
// 移动端适配 rem // 移动端适配 rem
// import 'lib-flexible/flexible.js' // import 'lib-flexible/flexible.js'
import VConsole from 'vconsole' import VConsole from 'vconsole'
const ua = navigator.userAgent.toLowerCase()
let body = document.getElementsByTagName('head')[0],
WXJDK = document.createElement('script'),
WWJDK = document.createElement('script'),
ISWXWORK = false,
IsIOS = /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent),
ISMiniprogram = window.__wxjs_environment === 'miniprogram'
WXJDK.src = '//res.wx.qq.com/open/js/jweixin-1.6.0.js'
if (Boolean(ua.match(/MicroMessenger/i)) && Boolean(ua.match(/wxwork/i))) {
//是否企微
WXJDK.src = '//res.wx.qq.com/open/js/jweixin-1.2.0.js'
WWJDK.src = '//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js'
ISWXWORK = true
}
window.$ISWXWORK = ISWXWORK
util.setLocalStorage('is_wxwork', ISWXWORK)
Vue.prototype.ISWXWORK = ISWXWORK
Vue.prototype.ISMOBILE = util.isMobileDevice()
body.appendChild(WXJDK)
if (WWJDK.src) body.appendChild(WWJDK)
window.$IsIOS = IsIOS
Vue.prototype.IsIOS = IsIOS
window.$ISMiniprogram = ISMiniprogram
Vue.prototype.ISMiniprogram = ISMiniprogram
const isMock = ['prod', 'production'].includes(process.env.NODE_ENV) const isMock = ['prod', 'production'].includes(process.env.NODE_ENV)
fetchConfig().then(res => { fetchConfig().then(res => {
console.log(res) console.log(res)
...@@ -54,6 +79,7 @@ fetchConfig().then(res => { ...@@ -54,6 +79,7 @@ fetchConfig().then(res => {
// util.clearSessionId() // util.clearSessionId()
// store.dispatch('navigation') // store.dispatch('navigation')
// } // }
// store.dispatch('navigation')
store.dispatch('registerHttp') store.dispatch('registerHttp')
window.vm = new Vue({ window.vm = new Vue({
el: '#app', el: '#app',
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-03-18 16:22:13
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-18 16:22:38
* @FilePath: \salesgpt-project\src\mixins\iat.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const APPID = '12fdb6e3'
const API_SECRET = 'ZjEyYTI4YjY3NmZiYzVjYThhNWY4NmU3'
const API_KEY = 'b26af0899897ba7890c2bcccdb72b558'
export default {
data() {
return {}
}
}
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-25 10:30:47
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-22 10:14:33
* @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
*/
const Q_NUM = 9
import { ROLE_LIST, AI_TYPE } from '@/utils/constants'
export default {
data() {
return {
path: window.$fetchConfig.baseURL + (Math.random() + '').slice(2),
isShow: true,
noSendMsg: '',
isSend: true,
timer_chat: null,
timer_jump: null,
messageAll: [],
issue: '',
contentList: [],
deleteArr: [],
socket: ''
}
},
mounted() {
// 初始化
this.init()
},
methods: {
init: function (msg) {
this.noSendMsg = msg
this.socket = new WebSocket(this.path)
// 监听socket连接
this.socket.onopen = this.open
// 监听socket错误信息
this.socket.onerror = this.error
// 监听socket消息
this.socket.onmessage = this.getMessage
this.socket.onclose = this.close
},
open: function () {
console.log('socket连接成功')
if (this.defaultFun && !this.noSendMsg) {
this.defaultFun()
}
if (this.noSendMsg) {
this.socket.send(this.noSendMsg)
}
},
error: function () {
console.log('连接错误')
},
getMessage: function (res) {
this.isShow = false
let msg = res.data
if (msg == '<rdfast stop>') {
if (!this.timer_tip)
this.timer_tip = setInterval(() => {
if (this.type == AI_TYPE.sparring_sales && this.messageAll.length == 0) {
this.getIssuesList()
}
if (this.messageAll.length == 0) {
clearInterval(this.timer_tip)
this.timer_tip = null
}
}, 100)
if (this.type != AI_TYPE.sparring_reply_sales) {
this.isSend = true
return
}
}
if (this.type != AI_TYPE.sparring_reply_sales) {
this.messageAll.push(msg)
if (!this.timer_chat)
this.timer_chat = setInterval(() => {
const len = this.contentList.length - 1
const i = this.messageAll.shift()
if (this.messageAll.length == 0) {
clearInterval(this.timer_chat)
this.timer_chat = null
}
this.contentList[len].content += i
}, 50)
this.toBottom()
} else {
this.setTips(msg)
}
},
// 发送消息给被连接的服务端
/**
* type 有三个值:
summarize 表示总结
sparring 表示对练
chat 表示问答
*/
sendMessage: function (params) {
if (this.socket.readyState == WebSocket.OPEN) {
this.socket.send(params)
} else {
this.init(params)
}
},
pushMsg(type, history, question_d = '') {
if (type != AI_TYPE.sparring_reply_sales)
this.contentList.push({
contentType: 2,
content: this.issue
})
let question = this.issue
this.type = type
if (question_d) {
for (let i = 0; i < 2; i++) {
this.sendMessage(
JSON.stringify({
type,
question: question_d,
history: JSON.stringify([...history])
})
)
}
} else {
for (let i = 0; i < 2; i++) {
this.sendMessage(
JSON.stringify({
type,
question: question + ',你的回复不超过80个字',
history: JSON.stringify([i % 2 == 0 ? { role: ROLE_LIST.system, content: '以正常客户的口吻回复' } : { role: ROLE_LIST.system, content: '以刁钻客户的口吻回复' }, ...history])
})
)
}
}
if (type != AI_TYPE.sparring_reply_sales)
this.$nextTick(() => {
this.contentList.push({
contentType: 1,
content: ''
})
})
this.toBottom()
this.isSend = false
this.issue = ''
},
close() {
console.log('关闭')
// if (this.socket.readyState != WebSocket.OPEN) this.init(true)
},
toBottom() {
this.$nextTick(() => {
this.$refs.contentView.scrollTop = 999999999
})
}
},
beforeDestroy() {
// 销毁监听
this.close()
clearInterval(this.timer_jump)
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @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-03-06 16:14:05 * @LastEditTime: 2024-03-07 10:48:47
* @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
*/ */
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-03-13 15:37:58
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-28 10:52:38
* @FilePath: \salesgpt-project\src\mixins\speech.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { wxConfig } from '@/api'
export default {
data() {
return {
timeOut: null,
isListening: false
}
},
async mounted() {
await wxConfig.init(['startRecord', 'stopRecord', 'onVoiceRecordEnd', 'translateVoice'])
this.onVoiceRecordEnd()
},
beforeDestroy() {
clearTimeout(this.timeOut)
},
methods: {
// 手指按下事件
gotouchstart() {
window.isClick = true
clearTimeout(this.timeOut)
this.timeOut = setTimeout(() => {
this.startRecord()
window.isClick = false
}, 1000)
},
gotouchend() {
this.endRecord()
clearTimeout(this.timeOut)
},
//手释放,如果在500毫秒内就释放,则取消长按事件,此时可以执行onclick应该执行的事件
// gotouchend() {
// if (window.isClick) {
// console.log('在这里执行点击事件')
// }
// },
//如果手指有移动,则取消所有事件,此时说明用户只是要移动而不是长按
gotouchmove() {
console.log('手指移动了')
window.isClick = false
},
onVoiceRecordEnd() {
const _this = this
wx.onVoiceRecordEnd({
//录音时间超过一分钟没有停止的时候会执行 complete 回调
complete(res) {
console.log(res)
_this.translateVoice(res.localId)
}
})
},
translateVoice(localId) {
const _this = this
wx.translateVoice({
localId, // 需要识别的音频的本地Id,由录音相关接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success(res) {
console.log(res)
_this.isListening = false
let result = res.translateResult
result = result.substring(0, result.length - 1)
_this.send(result)
}
})
},
startRecord() {
this.isListening = true
wx.startRecord()
},
endRecord() {
const _this = this
wx.stopRecord({
success(res) {
console.log(res)
_this.translateVoice(res.localId)
}
})
}
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-26 14:10:00 * @Date: 2024-02-26 14:10:00
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-27 14:23:49 * @LastEditTime: 2024-03-07 10:24:02
* @FilePath: \salesgpt-project\src\router\routes.js * @FilePath: \salesgpt-project\src\router\routes.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
*/ */
...@@ -12,6 +12,12 @@ const pages = { ...@@ -12,6 +12,12 @@ const pages = {
name: 'chat' name: 'chat'
}, },
{ {
name: 'sales'
},
{
name: 'salesChat'
},
{
name: 'questions' name: 'questions'
}, },
{ {
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* @version: * @version:
* @Author: limin * @Author: limin
* @Date: 2021-06-07 14:12:32 * @Date: 2021-06-07 14:12:32
* @LastEditors: limin * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2021-07-06 12:02:21 * @LastEditTime: 2024-03-13 15:26:35
*/ */
import { ssoApi } from '@/api' import { ssoApi } from '@/api'
import { store, util } from 'utils' import { store, util } from 'utils'
...@@ -53,106 +53,130 @@ const actions = { ...@@ -53,106 +53,130 @@ const actions = {
removeKeep({ commit }, names) { removeKeep({ commit }, names) {
commit('REMOVE_KEEP', names) commit('REMOVE_KEEP', names)
}, },
wxLogin({ dispatch }, { code, redirectUrl, appId }) {
ssoApi
.login({
code,
appId: window.$fetchConfig.appid,
state: 'snsapi_userinfo'
})
.then(({ code, data, message }) => {
let route = state.lastPath == 'crowdfunding' ? '' : state.lastPath || ''
route = route.replace('.', '/')
if (code == '0') {
util.setUserInfo(data)
util.setSessionId(data.sessionId)
dispatch('registerHttp', data.sessionId)
state.showWindow = true
let query = window.location.href.split('/split/')[1]
let pageQuery = query ? decodeURIComponent(query) : ''
pageQuery = pageQuery.replace(/\|/g, '&')
let url = `${redirectUrl}#/${route}`
if (pageQuery) url += `?${pageQuery}`
window.location.replace(url)
} else {
Notify(message)
}
})
},
getWxCode({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
let params = util.getPageQuery()
let arr = []
Object.keys(params).map(key => {
arr.push(`${key}=${params[key]}`)
})
if (arr.length) redirectUrl += `/split/${arr.join('|')}`
const isWxWork = util.getLocalStorage('is_wxwork')
const STORAGE_PARAMS = util.getLocalStorage('wx_scrm_link_params')
util.showLoading()
let { appid } = window.$fetchConfig
if (isWxWork && STORAGE_PARAMS && STORAGE_PARAMS.corpId) appid = STORAGE_PARAMS.corpId
let wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_userinfo`
if (isWxWork && STORAGE_PARAMS && STORAGE_PARAMS.agentId) wxUrl = `${wxUrl}&agentid=${STORAGE_PARAMS.agentId}`
util.setAppId(appid)
window.location.href = `${wxUrl}&state=STATE#wechat_redirect`
},
login({ dispatch }) { login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?') let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试 const isWxWork = util.getLocalStorage('is_wxwork')
const code = util.getPageQuery('code')
let appId = util.getAppId()
util.showLoading()
if (process.env.NODE_ENV == 'development') { if (process.env.NODE_ENV == 'development') {
const code = getParams('code') //本地开发
if (code) { if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId') const target = isWxWork ? 'wwLogin' : 'login'
ssoApi const PARAMS = isWxWork
.login({ ? {
code, code,
corpId, corpId: appId,
getUserInfoFlag: false getUserInfoFlag: false
}) }
.then(({ code, data, message }) => { : {
let route = state.lastPath == 'coupon' ? '' : state.lastPath || '' code,
route = route.replace('.', '/') appId: window.$fetchConfig.appid,
if (code == '0') { state: 'snsapi_userinfo'
if (data.loginList.length) { }
if (data.loginList.length > 1) { ssoApi[target](PARAMS).then(({ code, data, message }) => {
let userInfo = data.loginList[0] let route = state.lastPath == 'crowdfunding' ? '' : state.lastPath || ''
let { merchantId, accountName } = userInfo route = route.replace('.', '/')
let loginAccount = accountName if (code == '0') {
ssoApi let sessionId = '',
.selectAccount({ userInfo = {}
loginAccount, if (isWxWork) {
merchantId, userInfo = data.loginList[0]
loginToken: data.loginToken, sessionId = userInfo.sessionId
loginSource: 'WW',
loginType: 3
})
.then(res => {
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(res.data.sessionId)
dispatch('registerHttp', res.data.sessionId)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
})
} else {
let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
}
} else {
/**没有账号 */
Notify('没有账号')
// window.location.href = `${url}common/nothing`
}
} else { } else {
/**账号过期 (暂时没有字段判断是否过期) */ userInfo = data
Notify(message) sessionId = data.sessionId
// window.location.href = `${url}common/overdue`
} }
}) util.setUserInfo(userInfo)
util.setSessionId(sessionId)
dispatch('registerHttp', sessionId)
state.showWindow = true
let query = window.location.href.split('/split/')[1]
let pageQuery = query ? decodeURIComponent(query) : ''
pageQuery = pageQuery.replace(/\|/g, '&')
let url = `${redirectUrl}#/${route}`
if (pageQuery) url += `?${pageQuery}`
window.location.replace(url)
} else Notify(message)
})
} else dispatch('getWxCode')
} else {
if (isWxWork) {
let storage_params = util.getLocalStorage('wx_scrm_link_params') || {}
let url = `/dj-scrm-wx-work-main/#/?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${storage_params.corpId}`
if (storage_params.agentId) url = `${url}&agentId=${storage_params.agentId}`
window.location.href = url
} else { } else {
util.showLoading() if (code) dispatch('wxLogin', { redirectUrl, code, appId })
let appid = getParams('corpId') //从链接获取 else dispatch('getWxCode')
let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'wwc33bc9a3c72d45f3'
util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
} }
} else {
const { corpId, agentId } = util.getLocalStorage('dj_scrm_corpId')
const { baseURL } = window.$fetchConfig.request
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${corpId}&agentId=${agentId}`
} }
}, },
navigation({ dispatch }) { navigation({ dispatch }) {
let { sessionId, corpId, agentId } = getParams() const isWxWork = util.getLocalStorage('is_wxwork')
const storage_corpId = util.getLocalStorage('dj_scrm_corpId') let params = util.getPageQuery() //从链接获取
if (!corpId) corpId = storage_corpId && storage_corpId.corpId if (Object.keys(params).length) util.setLocalStorage('wx_scrm_link_params', params)
if (corpId && storage_corpId) { dispatch('registerHttp')
if (corpId != storage_corpId.corpId) {
util.removeLocalStorage('dj_scrm_userInfo')
util.clearSessionId()
}
}
let dj_scrm_storage = { corpId }
if (agentId) dj_scrm_storage.agentId = agentId
util.setLocalStorage('dj_scrm_corpId', dj_scrm_storage)
const storage_sessionId = util.getSessionId() const storage_sessionId = util.getSessionId()
if (sessionId || storage_sessionId) { if (isWxWork) {
const ww_sessionId = window.localStorage.getItem('dj_scrm_session_id')
if (params.sessionId || ww_sessionId || storage_sessionId) {
state.showWindow = true
let userInfo = util.getLocalStorage('dj_scrm_userInfo')
if (userInfo) util.setUserInfo(userInfo)
util.setSessionId(params.sessionId || ww_sessionId || storage_sessionId)
dispatch('registerHttp', params.sessionId || ww_sessionId || storage_sessionId)
} else dispatch('login')
return
} else if (storage_sessionId) {
state.showWindow = true state.showWindow = true
util.setSessionId(sessionId || storage_sessionId) dispatch('registerHttp', storage_sessionId)
dispatch('registerHttp', sessionId || storage_sessionId)
} else {
util.showLoading()
dispatch('registerHttp')
dispatch('login')
return return
} } else dispatch('login')
state.showWindow = true
}, },
registerHttp({}, sessionId = '') { registerHttp({}, sessionId = '') {
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } }) window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
......
var CryptoJSNew = CryptoJSNew || function(g, l) {
var e = {}, d = e.lib = {}, m = function() {}, k = d.Base = {
extend: function(a) {
m.prototype = this;
var c = new m;
a && c.mixIn(a);
c.hasOwnProperty("init") || (c.init = function() {
c.$super.init.apply(this, arguments)
});
c.init.prototype = c;
c.$super = this;
return c
},
create: function() {
var a = this.extend();
a.init.apply(a, arguments);
return a
},
init: function() {},
mixIn: function(a) {
for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
a.hasOwnProperty("toString") && (this.toString = a.toString)
},
clone: function() {
return this.init.prototype.extend(this)
}
},
p = d.WordArray = k.extend({
init: function(a, c) {
a = this.words = a || [];
this.sigBytes = c != l ? c : 4 * a.length
},
toString: function(a) {
return (a || n).stringify(this)
},
concat: function(a) {
var c = this.words,
q = a.words,
f = this.sigBytes;
a = a.sigBytes;
this.clamp();
if (f % 4)
for (var b = 0; b < a; b++) c[f + b >>> 2] |= (q[b >>> 2] >>> 24 - 8 * (b % 4) & 255) << 24 - 8 * ((f + b) % 4);
else if (65535 < q.length)
for (b = 0; b < a; b += 4) c[f + b >>> 2] = q[b >>> 2];
else c.push.apply(c, q);
this.sigBytes += a;
return this
},
clamp: function() {
var a = this.words,
c = this.sigBytes;
a[c >>> 2] &= 4294967295 << 32 - 8 * (c % 4);
a.length = g.ceil(c / 4)
},
clone: function() {
var a = k.clone.call(this);
a.words = this.words.slice(0);
return a
},
random: function(a) {
for (var c = [], b = 0; b < a; b += 4) c.push(4294967296 * g.random() | 0);
return new p.init(c, a)
}
}),
b = e.enc = {}, n = b.Hex = {
stringify: function(a) {
var c = a.words;
a = a.sigBytes;
for (var b = [], f = 0; f < a; f++) {
var d = c[f >>> 2] >>> 24 - 8 * (f % 4) & 255;
b.push((d >>> 4).toString(16));
b.push((d & 15).toString(16))
}
return b.join("")
},
parse: function(a) {
for (var c = a.length, b = [], f = 0; f < c; f += 2) b[f >>> 3] |= parseInt(a.substr(f, 2), 16) << 24 - 4 * (f % 8);
return new p.init(b, c / 2)
}
}, j = b.Latin1 = {
stringify: function(a) {
var c = a.words;
a = a.sigBytes;
for (var b = [], f = 0; f < a; f++) b.push(String.fromCharCode(c[f >>> 2] >>> 24 - 8 * (f % 4) & 255));
return b.join("")
},
parse: function(a) {
for (var c = a.length, b = [], f = 0; f < c; f++) b[f >>> 2] |= (a.charCodeAt(f) & 255) << 24 - 8 * (f % 4);
return new p.init(b, c)
}
}, h = b.Utf8 = {
stringify: function(a) {
try {
return decodeURIComponent(escape(j.stringify(a)))
} catch (c) {
throw Error("Malformed UTF-8 data");
}
},
parse: function(a) {
return j.parse(unescape(encodeURIComponent(a)))
}
},
r = d.BufferedBlockAlgorithm = k.extend({
reset: function() {
this._data = new p.init;
this._nDataBytes = 0
},
_append: function(a) {
"string" == typeof a && (a = h.parse(a));
this._data.concat(a);
this._nDataBytes += a.sigBytes
},
_process: function(a) {
var c = this._data,
b = c.words,
f = c.sigBytes,
d = this.blockSize,
e = f / (4 * d),
e = a ? g.ceil(e) : g.max((e | 0) - this._minBufferSize, 0);
a = e * d;
f = g.min(4 * a, f);
if (a) {
for (var k = 0; k < a; k += d) this._doProcessBlock(b, k);
k = b.splice(0, a);
c.sigBytes -= f
}
return new p.init(k, f)
},
clone: function() {
var a = k.clone.call(this);
a._data = this._data.clone();
return a
},
_minBufferSize: 0
});
d.Hasher = r.extend({
cfg: k.extend(),
init: function(a) {
this.cfg = this.cfg.extend(a);
this.reset()
},
reset: function() {
r.reset.call(this);
this._doReset()
},
update: function(a) {
this._append(a);
this._process();
return this
},
finalize: function(a) {
a && this._append(a);
return this._doFinalize()
},
blockSize: 16,
_createHelper: function(a) {
return function(b, d) {
return (new a.init(d)).finalize(b)
}
},
_createHmacHelper: function(a) {
return function(b, d) {
return (new s.HMAC.init(a, d)).finalize(b)
}
}
});
var s = e.algo = {};
return e
}(Math);
(function() {
var g = CryptoJSNew,
l = g.lib,
e = l.WordArray,
d = l.Hasher,
m = [],
l = g.algo.SHA1 = d.extend({
_doReset: function() {
this._hash = new e.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520])
},
_doProcessBlock: function(d, e) {
for (var b = this._hash.words, n = b[0], j = b[1], h = b[2], g = b[3], l = b[4], a = 0; 80 > a; a++) {
if (16 > a) m[a] = d[e + a] | 0;
else {
var c = m[a - 3] ^ m[a - 8] ^ m[a - 14] ^ m[a - 16];
m[a] = c << 1 | c >>> 31
}
c = (n << 5 | n >>> 27) + l + m[a];
c = 20 > a ? c + ((j & h | ~j & g) + 1518500249) : 40 > a ? c + ((j ^ h ^ g) + 1859775393) : 60 > a ? c + ((j & h | j & g | h & g) - 1894007588) : c + ((j ^ h ^ g) - 899497514);
l = g;
g = h;
h = j << 30 | j >>> 2;
j = n;
n = c
}
b[0] = b[0] + n | 0;
b[1] = b[1] + j | 0;
b[2] = b[2] + h | 0;
b[3] = b[3] + g | 0;
b[4] = b[4] + l | 0
},
_doFinalize: function() {
var d = this._data,
e = d.words,
b = 8 * this._nDataBytes,
g = 8 * d.sigBytes;
e[g >>> 5] |= 128 << 24 - g % 32;
e[(g + 64 >>> 9 << 4) + 14] = Math.floor(b / 4294967296);
e[(g + 64 >>> 9 << 4) + 15] = b;
d.sigBytes = 4 * e.length;
this._process();
return this._hash
},
clone: function() {
var e = d.clone.call(this);
e._hash = this._hash.clone();
return e
}
});
g.SHA1 = d._createHelper(l);
g.HmacSHA1 = d._createHmacHelper(l)
})();
(function() {
var g = CryptoJSNew,
l = g.enc.Utf8;
g.algo.HMAC = g.lib.Base.extend({
init: function(e, d) {
e = this._hasher = new e.init;
"string" == typeof d && (d = l.parse(d));
var g = e.blockSize,
k = 4 * g;
d.sigBytes > k && (d = e.finalize(d));
d.clamp();
for (var p = this._oKey = d.clone(), b = this._iKey = d.clone(), n = p.words, j = b.words, h = 0; h < g; h++) n[h] ^= 1549556828, j[h] ^= 909522486;
p.sigBytes = b.sigBytes = k;
this.reset()
},
reset: function() {
var e = this._hasher;
e.reset();
e.update(this._iKey)
},
update: function(e) {
this._hasher.update(e);
return this
},
finalize: function(e) {
var d = this._hasher;
e = d.finalize(e);
d.reset();
return d.finalize(this._oKey.clone().concat(e))
}
})
})();
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: limin * @Author: limin
* @Date: 2021-06-15 14:41:02 * @Date: 2021-06-15 14:41:02
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-05 14:28:46 * @LastEditTime: 2024-03-07 17:37:13
*/ */
export const STORE_USER_KEY = 'STORE_USER_KEY' export const STORE_USER_KEY = 'STORE_USER_KEY'
export const CAR_TYPE = ['问界M5', '问界M7', '问界M9'] export const CAR_TYPE = ['问界M5', '问界M7', '问界M9']
...@@ -24,6 +24,9 @@ export const ROLE_LIST = { ...@@ -24,6 +24,9 @@ export const ROLE_LIST = {
} }
export const AI_TYPE = { export const AI_TYPE = {
chat: 'chat', chat: 'chat',
sparring_sales: 'sparring_sales',
sparring_reply_sales: 'sparring_reply_sales',
summarize_sales: 'summarize_sales',
sparring: 'sparring', sparring: 'sparring',
sparring_reply: 'sparring_reply', sparring_reply: 'sparring_reply',
summarize: 'summarize' summarize: 'summarize'
...@@ -116,7 +119,7 @@ export const CAR_TYPE_DESC = [ ...@@ -116,7 +119,7 @@ export const CAR_TYPE_DESC = [
综合油耗(L/100km):7.2 综合油耗(L/100km):7.2
}` }`
] ]
export const CAR_TIPS = (identity,car) => { export const CAR_TIPS = (identity, car) => {
return ` return `
你需要扮演一个购车客户你的身份是${identity},模拟购车客户与我(销售人员)对话,你只能提问题,不要回答购车客户的问题,如果我提出了问题,你不要搭理我。对话风格尽量自然、简短,每次提问的信息点不超过2个,不要因为我回答的字数少,你自己回答自己的问题。 你需要扮演一个购车客户你的身份是${identity},模拟购车客户与我(销售人员)对话,你只能提问题,不要回答购车客户的问题,如果我提出了问题,你不要搭理我。对话风格尽量自然、简短,每次提问的信息点不超过2个,不要因为我回答的字数少,你自己回答自己的问题。
注意:将你的回复输出内容中的"购车客户:"删除 注意:将你的回复输出内容中的"购车客户:"删除
...@@ -138,6 +141,25 @@ export const CAR_TIPS = (identity,car) => { ...@@ -138,6 +141,25 @@ export const CAR_TIPS = (identity,car) => {
每次只生成一句话,等销售人员回答后再发起下一轮对话,记住你是购车客户,当前时间是2024-02-27。现在开始提问。 每次只生成一句话,等销售人员回答后再发起下一轮对话,记住你是购车客户,当前时间是2024-02-27。现在开始提问。
` `
} }
export const SALES_TIPS = car => {
return `
AI需要扮演一个4S店销售人员,模拟与一名购车客户对话,你需要回答购车客户的问题。对话风格尽量自然、简短,不超过80个字。
4S店在售车型包括【
问界M5:{插电混动车型,2023年4月上市,可选后驱、四驱版,售价25万~30万,中型SUV,1.5T发动机,手自一体变速箱,纯电255公里,综合续航640公里,零百加速4.5秒,综合油耗6.1L/百公里,优惠促销中,有赠品,智能化高,有激光、毫米波雷达,配合摄像头,超声波融合感知系统,主动避让、智能泊车、高速辅助、跟车辅助、变道辅助等,能在高效工况下运转,油耗更低,行驶更安静;低速行驶时,动力更强劲。主打日常通勤用途,短途出行。
问界M5竞品:[{特斯拉Model-Y,纯电,31w,价格略贵,造型相似,内饰偏简约,空间比问界M5小,只靠摄像头辅助驾驶},{岚图FREE,造型相似,价格略便宜,智能化略低}]
}
问界M7:{插电混动四驱车型,2023年9月上市,可选5座、6座版,售价29万~38万,中大型SUV,1.5T发动机,手自一体变速箱,纯电230公里,综合续航1220公里,零百加速4.9秒,综合油耗7.1L/百公里,优惠促销中,有赠品,智能化高,有激光、毫米波雷达,配合摄像头,超声波融合感知系统,主动避让、智能泊车、高速辅助、跟车辅助、变道辅助等,兼顾动力与续航,适合上下班日常代步,长途驾驶也更省心,
问界M7竞品:[{理想L7,增程,42w,动力略强,驾驶舒适性略差,销量火爆},{大众途昂,燃油车,33w,驾驶体验较差,智能化较差}]
}
问界M9:{插电混动车型,2023年12月上市,可选Ultra、Max版,售价55万~60万,D级豪华SUV,2.0T发动机,手自一体变速箱,纯电220公里,综合续航1020公里,零百加速4.3秒,综合油耗7.5L/百公里,可赠保养,智能化高,有激光、毫米波雷达,配合摄像头,超声波融合感知系统,主动避让、智能泊车、高速辅助、跟车辅助、变道辅助等,星光数字矩阵交互系统,100英寸大屏幕,主打豪华商务、科技感、更为先进的驾驶乘坐体验。
问界M9竞品:[{理想L9,45w,增程,油耗7.8,续航650公里,智能化略低}]
}
】
购车客户的意向车型是${car}
`
}
export const TIP_LIST = { export const TIP_LIST = {
M5: [ M5: [
'问界M5的发动机功率是200kW,如果您对问界M5感兴趣,我可以为您提供更详细的信息和购车指导。', '问界M5的发动机功率是200kW,如果您对问界M5感兴趣,我可以为您提供更详细的信息和购车指导。',
......
This diff could not be displayed because it is too large.
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
(function () {
var h = CryptoJS, j = h.lib.WordArray
h.enc.Base64 = {
stringify: function (b) {
var e = b.words, f = b.sigBytes, c = this._map
b.clamp()
b = []
for (var a = 0; a < f; a += 3)for (var d = (e[a >>> 2] >>> 24 - 8 * (a % 4) & 255) << 16 | (e[a + 1 >>> 2] >>> 24 - 8 * ((a + 1) % 4) & 255) << 8 | e[a + 2 >>> 2] >>> 24 - 8 * ((a + 2) % 4) & 255,
g = 0; 4 > g && a + 0.75 * g < f; g++)b.push(c.charAt(d >>> 6 * (3 - g) & 63))
if (e = c.charAt(64))for (; b.length % 4;)b.push(e);
return b.join('')
}, parse: function (b) {
var e = b.length, f = this._map, c = f.charAt(64)
c && (c = b.indexOf(c), -1 != c && (e = c))
for (var c = [], a = 0, d = 0; d <
e; d++)if (d % 4) {
var g = f.indexOf(b.charAt(d - 1)) << 2 * (d % 4), h = f.indexOf(b.charAt(d)) >>> 6 - 2 * (d % 4)
c[a >>> 2] |= (g | h) << 24 - 8 * (a % 4)
a++
}
return j.create(c, a)
}, _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
}
})()
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*h.random()|0);return new r.init(c,a)}}),l=f.enc={},k=l.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,
2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},
u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;g<a;g+=e)this._doProcessBlock(d,g);g=d.splice(0,a);c.sigBytes-=b}return new r.init(g,b)},clone:function(){var a=m.clone.call(this);
a._data=this._data.clone();return a},_minBufferSize:0});g.Hasher=u.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return(new a.init(d)).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return(new t.HMAC.init(a,
d)).finalize(c)}}});var t=f.algo={};return f}(Math);
(function(h){for(var s=CryptoJS,f=s.lib,g=f.WordArray,q=f.Hasher,f=s.algo,m=[],r=[],l=function(a){return 4294967296*(a-(a|0))|0},k=2,n=0;64>n;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]=
c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math);
(function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j<h;j++)k[j]^=1549556828,n[j]^=909522486;r.sigBytes=l.sigBytes=m;this.reset()},reset:function(){var f=this._hasher;f.reset();f.update(this._iKey)},update:function(f){this._hasher.update(f);return this},finalize:function(f){var g=
this._hasher;f=g.finalize(f);g.reset();return g.finalize(this._oKey.clone().concat(f))}})})();
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
import Vue from 'vue' import Vue from 'vue'
import { Toast, Dialog } from 'vant' import { Toast, Dialog } from 'vant'
/** /**
* 日期格式化 * 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') * let time = new Date().format('yyyy-MM-dd hh:mm:ss')
...@@ -26,6 +25,9 @@ Date.prototype.format = function (fmt) { ...@@ -26,6 +25,9 @@ Date.prototype.format = function (fmt) {
} }
return fmt return fmt
} }
const iosTimeFormat = time => {
return time.replace(/-/g, '/')
}
const throttle = (fn, gapTime) => { const throttle = (fn, gapTime) => {
if (gapTime == null || gapTime == undefined) { if (gapTime == null || gapTime == undefined) {
gapTime = 1500 gapTime = 1500
...@@ -39,6 +41,16 @@ const throttle = (fn, gapTime) => { ...@@ -39,6 +41,16 @@ const throttle = (fn, gapTime) => {
} }
} }
} }
const debounce = (fn, delay = 500) => {
// timer 是在闭包中的
let timer = null
return function () {
clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, arguments)
}, delay)
}
}
/**防止重复点击 */ /**防止重复点击 */
const showLoading = (title = '加载中...') => { const showLoading = (title = '加载中...') => {
Toast({ Toast({
...@@ -52,7 +64,7 @@ const hideLoading = () => { ...@@ -52,7 +64,7 @@ const hideLoading = () => {
Toast.clear() Toast.clear()
} }
/**num:要转换的数值,fixed:精确几位小数 */ /**num:要转换的数值,fixed:精确几位小数 */
const decimal = (num, fixed) => { const decimal = (num, fixed = 2) => {
let pow = Math.pow(10, fixed) let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow return Math.round(num * pow) / pow
} }
...@@ -78,19 +90,49 @@ const touchend = e => { ...@@ -78,19 +90,49 @@ const touchend = e => {
e.target.classList.remove('btn-on-leave') e.target.classList.remove('btn-on-leave')
} }
const setSessionId = val => { const setSessionId = val => {
window.localStorage.setItem('dj_scrm_session_id', val) window.localStorage.setItem('wx_scrm_session_id', val)
} }
const getSessionId = () => { const getSessionId = () => {
return window.localStorage.getItem('dj_scrm_session_id') return window.localStorage.getItem('wx_scrm_session_id')
} }
const clearSessionId = () => { const clearSessionId = () => {
window.localStorage.removeItem('wx_scrm_session_id')
window.localStorage.removeItem('dj_scrm_session_id') window.localStorage.removeItem('dj_scrm_session_id')
} }
const setAppId = val => {
window.localStorage.setItem('wx_scrm_app_id', val)
}
const getAppId = () => {
return window.localStorage.getItem('wx_scrm_app_id')
}
const setUserInfo = val => {
setLocalStorage('wx_scrm_user_info', val)
}
const getUserInfo = () => {
return getLocalStorage('wx_scrm_user_info')
}
const setLocalStorage = (key, item) => { const setLocalStorage = (key, item) => {
window.localStorage.setItem(key, JSON.stringify(item)) window.localStorage.setItem(key, JSON.stringify(item))
} }
const getLocalStorage = key => { const getLocalStorage = key => {
return JSON.parse(window.localStorage.getItem(key)) let store = JSON.parse(window.localStorage.getItem(key))
if (key == 'wx_scrm_link_params') {
if (!store || Object.keys(store).length < 0) {
store = getPageQuery()
}
}
return store
}
const getPageQuery = name => {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
} }
const removeLocalStorage = key => { const removeLocalStorage = key => {
window.localStorage.removeItem(key) window.localStorage.removeItem(key)
...@@ -103,7 +145,6 @@ const dialog = (params = {}) => { ...@@ -103,7 +145,6 @@ const dialog = (params = {}) => {
const makePhoneCall = phoneNumber => { const makePhoneCall = phoneNumber => {
window.location.href = `tel://${phoneNumber}` window.location.href = `tel://${phoneNumber}`
} }
/**是否全面屏 */ /**是否全面屏 */
const isFullSucreen = () => { const isFullSucreen = () => {
let result = false let result = false
...@@ -112,7 +153,6 @@ const isFullSucreen = () => { ...@@ -112,7 +153,6 @@ const isFullSucreen = () => {
result = rate > limit result = rate > limit
return result return result
} }
const jumpChildrenPage = (to, params) => { const jumpChildrenPage = (to, params) => {
let { name } = window.vm._route let { name } = window.vm._route
window.vm.$router.push({ name: `${name}.${to}`, params }) window.vm.$router.push({ name: `${name}.${to}`, params })
...@@ -126,29 +166,24 @@ const setClipboardData = data => { ...@@ -126,29 +166,24 @@ const setClipboardData = data => {
} }
}) })
} }
/**接口请求时失败让用户刷新 */ /**接口请求时失败让用户刷新 */
const refreshPage = (message = '系统异常') => { const refreshPage = (message = '系统异常', confirmButtonText) => {
return Dialog.alert({ return Dialog.alert({
message, message,
theme: 'round-button', theme: 'round-button',
confirmButtonText: '点击重试', confirmButtonText: confirmButtonText || '点击重试',
confirmButtonColor: '#FF7336' confirmButtonColor: '#f13c3d'
}) })
} }
const toTop = () => { const toTop = (top = 0) => {
let bodySrcollTop = document.body.scrollTop window.scrollTo({
if (bodySrcollTop !== 0) { top,
document.body.scrollTop = 0 left: 0,
return behavior: 'smooth'
} })
let docSrcollTop = document.documentElement.scrollTop
if (docSrcollTop !== 0) {
document.documentElement.scrollTop = 0
}
} }
const getParams = () => { const getParams = name => {
return window.vm.$route.params return name ? window.vm.$route.params[name] : window.vm.$route.params
} }
const getQuery = () => { const getQuery = () => {
return window.vm.$route.query return window.vm.$route.query
...@@ -163,63 +198,172 @@ const watchPageBack = () => { ...@@ -163,63 +198,172 @@ const watchPageBack = () => {
} }
/**分转元 */ /**分转元 */
const centsToyuan = price => { const centsToyuan = price => {
return decimal(price / 100, 2).toFixed(2) return decimal(Number(price) / 100, 2).toFixed(2)
} }
/**设置cookie */
const getVideoFirstFrame = (url)=> { const setCookie = (c_name, value, expiredays = 365) => {
return new Promise(function (resolve) { let exdate = new Date()
let dataURL = '' console.log(c_name, value)
let video = document.createElement("video") exdate.setDate(exdate.getDate() + expiredays)
video.setAttribute('crossOrigin', 'anonymous')//处理跨域 document.cookie = c_name + '=' + value + (expiredays == null ? '' : ';expires=' + exdate.toGMTString())
video.setAttribute('src', url) }
video.setAttribute('autoplay', 'autoplay') /**获取cookie */
video.addEventListener('canplaythrough', function () { const getCookie = c_name => {
video.setAttribute('width', video.videoWidth) if (document.cookie.length > 0) {
video.setAttribute('height', video.videoHeight) let c_start = document.cookie.indexOf(c_name + '=')
let canvas = document.createElement("canvas"), if (c_start != -1) {
width = video.width, //canvas的尺寸和图片一样 c_start = c_start + c_name.length + 1
height = video.height let c_end = document.cookie.indexOf(';', c_start)
canvas.width = width if (c_end == -1) c_end = document.cookie.length
canvas.height = height return unescape(document.cookie.substring(c_start, c_end))
canvas.getContext("2d").drawImage(video, 0, 0, width, height) //绘制canvas }
dataURL = canvas.toDataURL('image/jpeg') //转换为base64 }
//转换成file return ''
const arr = dataURL.split(",") }
const mime = arr[0].match(/:(.*?);/)[1] /*转中文 */
const bstr = window.atob(arr[1]) const toUnicode = (chineseStr = '') => {
let n = bstr.length let unicodeStr = ''
const u8arr = new Uint8Array(n) for (let i = 0, iLength = chineseStr.length; i < iLength; i++) {
while (n--) { unicodeStr += '@' + chineseStr.charCodeAt(i).toString(16)
u8arr[n] = bstr.charCodeAt(n) }
return unicodeStr
}
const isMobileDevice = () => {
//判断当前设备是否为移动端
const ua = navigator.userAgent.toLowerCase()
const t1 = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(ua)
const t2 = !ua.match('iphone') && navigator.maxTouchPoints > 1
return t1 || t2
}
/**秒数转天时分秒*/
const date_format = num => {
const addZero = i => (i < 10 ? `0${i}` : `${i}`)
//计算剩余的天数
let days = addZero(parseInt(num / 60 / 60 / 24, 10))
//计算剩余的小时
let hours = addZero(parseInt((num / 60 / 60) % 24, 10))
//计算剩余的分钟
let minutes = addZero(parseInt((num / 60) % 60, 10))
//计算剩余的秒数
let second = addZero(parseInt(num % 60, 10))
if (days == 0) {
return `${hours}:${minutes}:${second}`
}
return `${days}天${hours}:${minutes}:${second}`
}
const draggable = (drag, fun, target) => {
var startEvt, moveEvt, endEvt
// 判断是否支持触摸事件
if ('ontouchstart' in window) {
startEvt = 'touchstart'
moveEvt = 'touchmove'
endEvt = 'touchend'
} else {
startEvt = 'mousedown'
moveEvt = 'mousemove'
endEvt = 'mouseup'
}
drag.style.cursor = 'grab'
var disX, disY, left, top, starX, starY, oLeft, oTop
drag.addEventListener(startEvt, startFun)
function startFun(event) {
// console.log('event', )
let className = event.target.className
if (!drag.id || className.includes(target)) return
// 阻止页面的滚动,缩放
event.preventDefault()
// 兼容IE浏览器
drag.style.cursor = 'grabbing'
var e = event || window.event
oLeft = drag.offsetLeft
oTop = drag.offsetTop
// 手指按下时的坐标
starX = e.touches ? e.touches[0].clientX : e.clientX
starY = e.touches ? e.touches[0].clientY : e.clientY
// 手指相对于拖动元素左上角的位置
disX = starX - drag.offsetLeft
disY = starY - drag.offsetTop
// 按下之后才监听后续事件
document.addEventListener(moveEvt, moveFun)
document.addEventListener(endEvt, endFun)
}
function moveFun(event) {
// 兼容IE浏览器
var e = event || window.event
left = (e.touches ? e.touches[0].clientX : e.clientX) - disX
top = (e.touches ? e.touches[0].clientY : e.clientY) - disY
// 限制拖拽的X范围,不能拖出屏幕
if (left < 0) {
left = 0
} else if (left > document.documentElement.clientWidth - drag.offsetWidth) {
left = document.documentElement.clientWidth - drag.offsetWidth
}
// 限制拖拽的Y范围,不能拖出屏幕
if (top < 0) {
top = 0
} else if (top > window.innerHeight - drag.offsetHeight) {
top = window.innerHeight - drag.offsetHeight
}
drag.style.left = left + 'px'
drag.style.top = top + 'px'
}
function endFun(event) {
drag.style.cursor = ''
document.removeEventListener(moveEvt, moveFun)
document.removeEventListener(endEvt, endFun)
if (oLeft == drag.offsetLeft && oTop == drag.offsetTop && fun) {
// 点击
fun()
}
}
}
const clearObjNull = options => {
let obj = {}
Object.keys(options).map(e => {
if (options[e] != null && options[e] != undefined) {
if (typeof options[e] == 'object') {
Object.keys(options[e]).map(key => {
if (options[e][key] == null || options[e][key] == undefined) delete options[e][key]
})
} }
const FILE = new File([u8arr], 'cover'+Date.now()+'.jpeg', { type: mime }) obj[e] = options[e]
resolve({ }
dataURL, //预览路径
file:FILE, //上传的文件
})
})
}) })
return obj
} }
const utils = { const utils = {
getVideoFirstFrame,
removeLocalStorage, removeLocalStorage,
setClipboardData, setClipboardData,
jumpChildrenPage, jumpChildrenPage,
setLocalStorage, setLocalStorage,
getLocalStorage, getLocalStorage,
clearSessionId, clearSessionId,
isMobileDevice,
makePhoneCall, makePhoneCall,
isFullSucreen, isFullSucreen,
watchPageBack, watchPageBack,
iosTimeFormat,
setSessionId, setSessionId,
getPageQuery,
getSessionId, getSessionId,
clearObjNull,
showLoading, showLoading,
centsToyuan, centsToyuan,
setUserInfo,
getUserInfo,
hideLoading, hideLoading,
refreshPage, refreshPage,
date_format,
touchstart, touchstart,
showToast, showToast,
getParams, getParams,
toUnicode,
setCookie,
getCookie,
draggable,
setAppId,
getAppId,
debounce,
getQuery, getQuery,
touchend, touchend,
throttle, throttle,
...@@ -227,7 +371,6 @@ const utils = { ...@@ -227,7 +371,6 @@ const utils = {
dialog, dialog,
toTop toTop
} }
Object.keys(utils).map(key => { Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key] Vue.prototype[key] = utils[key]
}) })
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
</template> </template>
<div :class="['input-box flex isFullSucreen']"> <div :class="['input-box flex isFullSucreen']">
<template v-if="inputType == 1"> <template v-if="inputType == 1">
<!-- <van-icon name="volume-o" class="input-icon" @click="inputType = 2" /> --> <van-icon name="volume-o" class="input-icon" @click="inputType = 2" />
<van-field v-model="issue" :border="false" placeholder="您可输入内容与AI对答" enterKeyhint="send" @keydown="onkeydown" ref="input" maxlength="1000"></van-field> <van-field v-model="issue" :border="false" placeholder="您可输入内容与AI对答" enterKeyhint="send" @keydown="onkeydown" ref="input" maxlength="1000"></van-field>
<van-button @click="send()" :disabled="!isSend">发送</van-button> <van-button @click="send()" :disabled="!isSend">发送</van-button>
</template> </template>
...@@ -350,6 +350,28 @@ export default { ...@@ -350,6 +350,28 @@ export default {
line-height: 20px; line-height: 20px;
background: #f7f8fa; background: #f7f8fa;
border-radius: 19px; border-radius: 19px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-user-select: none;
-moz-user-focus: none;
-moz-user-select: none;
span {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-user-select: none;
-moz-user-focus: none;
-moz-user-select: none;
}
} }
.show-tips { .show-tips {
......
...@@ -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-03-01 13:53:18 * @LastEditTime: 2024-03-07 11:35:14
* @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
--> -->
...@@ -57,6 +57,7 @@ export default { ...@@ -57,6 +57,7 @@ export default {
return { return {
md: '', md: '',
resultAll: '', resultAll: '',
sales: false,
content: '', content: '',
advise: '', advise: '',
messageList: [], messageList: [],
...@@ -85,6 +86,7 @@ export default { ...@@ -85,6 +86,7 @@ export default {
mounted() { mounted() {
this.md = new MarkdownIt() this.md = new MarkdownIt()
this.history = this.$route.params.history this.history = this.$route.params.history
this.sales = this.$route.params.sales
this.content = this.content.replace(/\s{2,4}/g, '<br/>') this.content = this.content.replace(/\s{2,4}/g, '<br/>')
}, },
methods: { methods: {
...@@ -100,7 +102,7 @@ export default { ...@@ -100,7 +102,7 @@ export default {
defaultFun() { defaultFun() {
this.sendMessage( this.sendMessage(
JSON.stringify({ JSON.stringify({
type: AI_TYPE.summarize, type: this.sales ? AI_TYPE.summarize_sales : AI_TYPE.summarize,
question: '请按照对各个评估项目进行打分,给出每个单项的分数和总的分数 并给出具体理由和建议', question: '请按照对各个评估项目进行打分,给出每个单项的分数和总的分数 并给出具体理由和建议',
history: JSON.stringify(this.history) history: JSON.stringify(this.history)
}) })
...@@ -108,7 +110,7 @@ export default { ...@@ -108,7 +110,7 @@ export default {
}, },
//总结换行 //总结换行
summarize(msg) { summarize(msg) {
if(msg == '<rdfast stop>') return 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
......
...@@ -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 09:42:09 * @LastEditTime: 2024-03-07 10:31:54
* @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
--> -->
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<div class="ai-box"> <div class="ai-box">
<!-- <div class="ai-btn" @click="jumpX">AI学习</div> --> <!-- <div class="ai-btn" @click="jumpX">AI学习</div> -->
<div class="ai-btn" @click="jump">AI对练</div> <div class="ai-btn" @click="jump">AI对练</div>
<div class="ai-btn" @click="jumpSales">AI销售</div>
<div class="ai-btn" @click="jumpQuestion">AI问答</div> <div class="ai-btn" @click="jumpQuestion">AI问答</div>
</div> </div>
</div> </div>
...@@ -33,6 +34,9 @@ export default { ...@@ -33,6 +34,9 @@ export default {
} }
}) })
}, },
jumpSales() {
this.$router.push('ai/sales')
},
jump() { jump() {
this.$router.push('ai/car') this.$router.push('ai/car')
}, },
......
...@@ -51,20 +51,27 @@ ...@@ -51,20 +51,27 @@
</template> </template>
<div :class="['input-box flex isFullSucreen']"> <div :class="['input-box flex isFullSucreen']">
<template v-if="inputType == 1"> <template v-if="inputType == 1">
<van-icon name="volume-o" class="input-icon" @click="inputType = 2" />
<van-field v-model="issue" :border="false" placeholder="请输入文字向AI提问" enterKeyhint="send" @keydown="onkeydown" ref="input" maxlength="1000"></van-field> <van-field v-model="issue" :border="false" placeholder="请输入文字向AI提问" enterKeyhint="send" @keydown="onkeydown" ref="input" maxlength="1000"></van-field>
<van-button @click="send()" :disabled="!isSend">发送</van-button> <van-button @click="send()" :disabled="!isSend">发送</van-button>
</template> </template>
<template v-else> <template v-else>
<div class="audio-item" @touchstart="touchstart" @touchend="touchend">按住 说话</div> <van-icon name="notes-o" class="input-icon" @click="inputType = 1" />
<div class="audio-item" @touchstart="gotouchstart" @touchend="gotouchend">
<span v-if="isListening">语音识别中...</span>
<span v-else>长按语音识别</span>
</div>
</template> </template>
</div> </div>
<div class="audio-box" v-if="isListening"><img src="https://5b0988e595225.cdn.sohucs.com/q_70,c_zoom,w_640/images/20170914/549a29faf6774984a7f17aaf36e471a7.gif" /></div>
</div> </div>
</template> </template>
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import { Q_LIST ,AI_TYPE,ROLE_LIST} from '@/utils/constants' import { Q_LIST ,AI_TYPE,ROLE_LIST} from '@/utils/constants'
import Socket from '@/mixins/socket' import Socket from '@/mixins/socket'
import speech from '@/mixins/speech'
export default { export default {
mixins: [Socket], mixins: [Socket,speech],
props: { props: {
show: Boolean show: Boolean
}, },
...@@ -164,6 +171,21 @@ export default { ...@@ -164,6 +171,21 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.audio-box {
position: fixed;
bottom: 100px;
width: 100%;
height: calc(100vh - 50px - var(--envSafeAreaInsetBottom));
background-color: rgba(0, 0, 0, 0.9);
z-index: 100;
img {
width: 100%;
height: 100px;
position: absolute;
bottom: 0;
left: 0;
}
}
.chat-gpt-box { .chat-gpt-box {
height: calc(100vh - 50px - var(--constantSafeAreaInsetBottom)); height: calc(100vh - 50px - var(--constantSafeAreaInsetBottom));
height: calc(100vh - 50px - var(--envSafeAreaInsetBottom)); height: calc(100vh - 50px - var(--envSafeAreaInsetBottom));
...@@ -257,12 +279,15 @@ export default { ...@@ -257,12 +279,15 @@ export default {
.audio-item { .audio-item {
width: 300px; width: 300px;
height: 40px;
border: 1px solid #666;
text-align: center; text-align: center;
line-height: 40px;
font-size: 16px; font-size: 16px;
color: #333333; padding: 9px 16px;
font-size: 14px;
color: #999;
line-height: 20px;
background: #f7f8fa;
border-radius: 19px;
user-select: none;
} }
.show-tips { .show-tips {
...@@ -317,6 +342,11 @@ export default { ...@@ -317,6 +342,11 @@ export default {
padding: 7px 11px 7px 16px !important; padding: 7px 11px 7px 16px !important;
background: #ffffff !important; background: #ffffff !important;
.input-icon {
font-size: 26px;
margin-right: 5px;
}
.van-field { .van-field {
width: 278px; width: 278px;
padding: 9px 16px; padding: 9px 16px;
......
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 09:47:18
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-07 10:30:51
* @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
-->
<template>
<div class="ai-container">
<div class="header-box">
<div class="title">场景</div>
<div class="title-sub">AI需要扮演一个4S店销售人员,模拟与一名购车客户对话</div>
</div>
<div class="car-box">
<div class="card-title">购买车型</div>
<div class="card-box">
<div :class="{ 'card-item': true, checked: carIndex == index }" @click="handleSelectCar(index)" v-for="(item, index) in carList" :key="index">
<div class="card-desc">{{ item }}</div>
</div>
</div>
<div class="car-desc"></div>
<div class="popup-btn" @click="handleSure">确认</div>
</div>
</div>
</template>
<script>
import { CAR_TYPE } from '@/utils/constants'
export default {
data() {
return {
carList: CAR_TYPE,
carIndex: 0
}
},
methods: {
handleSelectCar(item) {
this.carIndex = item
},
handleSelectScene(item) {
this.sceneIndex = item
},
handleSure() {
this.$router.push({
path: 'salesChat',
query: {
carIndex: this.carIndex
}
})
}
}
}
</script>
<style scoped lang="scss">
.ai-container {
width: 100%;
box-sizing: border-box;
.header-box {
padding: 10px;
width: 100%;
line-height: 24px;
background: #3582ee;
color: #fff;
.title {
font-size: 16px;
}
.title-sub {
font-size: 12px;
}
}
}
.car-box {
margin-top: 40px;
}
.card-title {
padding-left: 20px;
color: #333;
font-weight: 600;
}
.car-input {
height: 40px;
border-radius: 4px;
width: 300px;
}
.car-desc {
padding: 10px 20px;
min-height: 150px;
}
.car-item {
.car-img {
width: 100%;
height: 100px;
}
.car-desc {
text-align: center;
height: 40px;
line-height: 40px;
background: #fff;
font-size: 16px;
color: #222222;
}
}
.card-box {
// display: grid;
// grid-template-columns: 1fr 1fr 1fr; /* 一行两列 */
display: flex;
flex-wrap: wrap;
gap: 10px;
padding: 10px 20px;
.card-item {
width: calc(33% - 20px);
text-align: center;
background: #ffffff;
border: 1px solid #dadde0;
border-radius: 14px;
padding: 5px;
&.checked {
background: #3975c61a;
.card-desc {
color: #3975c6;
}
}
.card-desc {
font-size: 14px;
color: #333;
}
.card-img {
margin-left: 10px;
width: 80px;
height: 80px;
}
}
}
.popup-btn {
color: #fff;
background-color: #3975c6;
width: 320px;
height: 40px;
line-height: 40px;
margin: 60px auto;
text-align: center;
font-size: 16px;
border-radius: 21px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!