lu_quan_dev
han 10 months ago
parent 2ab9979f5b
commit b7039826b6
  1. 2
      pages.json
  2. 16
      pages/index/index.vue
  3. 15
      subPageB/jiqiren/jiqiren/zhinengjiqiren.vue
  4. 292
      subPageC/Ai/index.vue
  5. 17
      uni_modules/zero-markdown-view/components/zero-markdown-view/zero-markdown-view.vue

@ -573,7 +573,7 @@
{ {
"path": "Ai/index", "path": "Ai/index",
"style": { "style": {
"navigationBarTitleText": "AI管家", "navigationBarTitleText": "行程规划",
"navigationBarBackgroundColor": "#f5f6fa" "navigationBarBackgroundColor": "#f5f6fa"
} }

@ -326,8 +326,7 @@
}; };
}, },
onReady() { onReady() {
let menuButtonInfo = uni.getMenuButtonBoundingClientRect() let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
console.log(menuButtonInfo.height, 'menuButtonInfo.height')
this.height = menuButtonInfo.height + menuButtonInfo.top; this.height = menuButtonInfo.height + menuButtonInfo.top;
}, },
onLoad(option) { onLoad(option) {
@ -489,10 +488,7 @@
}); });
break; break;
case 'tousu': case 'tousu':
this.onTokenJump('/subPageB/suggest/sug_list?type=1', 'navigateTo') this.onTokenJump('/subPageB/suggest/sug_list?type=1', 'navigateTo')
// uni.navigateTo({
// url: "/subPageB/suggest/sug_list?type=1",
// });
break; break;
} }
}, },
@ -730,9 +726,11 @@
url: "/subPageA/Audiovisual/AudiovisualList/AudiovisualList", url: "/subPageA/Audiovisual/AudiovisualList/AudiovisualList",
}); });
} else if (type == "Ai") { } else if (type == "Ai") {
uni.navigateTo({ this.judgeLogin((resa) => {
url: '/subPageC/Ai/index' uni.navigateTo({
}); url: '/subPageC/Ai/index'
});
});
} }
}, },
goToDetail: function(type, guid, region) { goToDetail: function(type, guid, region) {

@ -1,7 +1,7 @@
<template> <template>
<view class="jqr_dig_warp"> <view class="jqr_dig_warp">
<uni-nav-bar dark statusBar :fixed="true" background-color="transparent" :border="false" left-icon="left" <uni-nav-bar dark statusBar :fixed="true" background-color="transparent" :border="false" left-icon="left"
title="智能客服" @clickLeft="back" /> title="AI管家" @clickLeft="back" />
<!-- --> <!-- -->
<scroll-view id="scrollview" class="jqr_dig_scroll" scroll-y="true" <scroll-view id="scrollview" class="jqr_dig_scroll" scroll-y="true"
@ -138,7 +138,7 @@
created: function() { created: function() {
const res = uni.getSystemInfoSync(); const res = uni.getSystemInfoSync();
this.style.pageHeight = res.windowHeight; this.style.pageHeight = res.windowHeight;
this.style.contentViewHeight = res.windowHeight - uni.getSystemInfoSync().screenWidth / 350 * (100); // this.style.contentViewHeight = res.windowHeight - uni.getSystemInfoSync().screenWidth / 350 * (100) - 190; //
}, },
onLoad: function() { onLoad: function() {
this.getAllConlumn(); this.getAllConlumn();
@ -302,16 +302,11 @@
longpress() { longpress() {
const $this = this const $this = this
this.islongPress = true; this.islongPress = true;
if (this.islongPress == true) { if (this.islongPress == true) {
console.log("长安")
// //
const _permission = 'scope.record' const _permission = 'scope.record'
uni.getSetting({ uni.getSetting({
success: (res) => { success: (res) => {
console.log('res.authSetting', res, res.authSetting)
//
console.log('判断是否有相关权限属性', res.authSetting.hasOwnProperty(
'scope.record'))
if (res.authSetting.hasOwnProperty('scope.record')) { if (res.authSetting.hasOwnProperty('scope.record')) {
// false // false
console.log('属性存在,且为false,用户拒绝过权限', res.authSetting[_permission]) console.log('属性存在,且为false,用户拒绝过权限', res.authSetting[_permission])
@ -572,7 +567,7 @@
} }
.jqr_dig_scroll { .jqr_dig_scroll {
padding-bottom: 300rpx;
} }
.jqr_tol_box { .jqr_tol_box {

@ -6,17 +6,19 @@
<view class="list_item" :class="item.userType" v-for="(item,index) in list" :key="index"> <view class="list_item" :class="item.userType" v-for="(item,index) in list" :key="index">
<view v-if="item.userType=='self'"> <view v-if="item.userType=='self'">
<view class="text-name row flex-align-center"> <view class="text-name row flex-align-center">
<image class="img" mode="widthFix" <image class="img"
src="https://eluyou.ailuquan.cn/upload/image/2024/mapIcon/daolan/ai-self.png"></image> src="https://eluyou.ailuquan.cn/upload/image/2024/mapIcon/daolan/ai-self.png"></image>
<text>E鹿小助手</text> <text>E鹿小助手</text>
</view> </view>
<zero-markdown-view :markdown="item.content"></zero-markdown-view> <zero-markdown-view :markdown="item.content" v-if="item.content"></zero-markdown-view>
<view class="loading" v-else><text class="loading-dot"></text><text
class="loading-dot"></text><text class="loading-dot"></text></view>
</view> </view>
<view class="row flex-align-center" style="justify-content: flex-end;" <view class="row flex-align-center" style="justify-content: flex-end;"
v-if="item.userType=='friend'"> v-if="item.userType=='friend'">
<view class="text-box">{{item.content}}</view> <view class="text-box">{{item.content}}</view>
<view class="text-name row flex-align-center"> <view class="text-name row flex-align-center">
<image class="img" mode="widthFix" <image class="img"
src="https://eluyou.ailuquan.cn/upload/image/2024/mapIcon/daolan/ai-friend.png"></image> src="https://eluyou.ailuquan.cn/upload/image/2024/mapIcon/daolan/ai-friend.png"></image>
</view> </view>
</view> </view>
@ -35,7 +37,7 @@
<image src="https://eluyou.ailuquan.cn/upload/image/2024/mapIcon/daolan/icon-text.png" mode="widthFix" <image src="https://eluyou.ailuquan.cn/upload/image/2024/mapIcon/daolan/icon-text.png" mode="widthFix"
class="left-icon" @click="messageType='text'"> class="left-icon" @click="messageType='text'">
</image> </image>
<text class="voice-crl" @touchstart="touchstart" <text class="voice-crl" @click="clickSprink()" @touchstart="touchstart"
@touchend="touchend">{{ recordStart ? '松开 发送' : '按住 说话' }}</text> @touchend="touchend">{{ recordStart ? '松开 发送' : '按住 说话' }}</text>
</block> </block>
</view> </view>
@ -46,7 +48,6 @@
</view> </view>
</view> </view>
<f-login></f-login>
</view> </view>
</template> </template>
@ -58,12 +59,16 @@
mapMutations mapMutations
} from "vuex"; } from "vuex";
export default { export default {
components:{ZeroMarkdownView}, components: {
ZeroMarkdownView
},
computed: { computed: {
...mapState(["PrimaryColor", "userInfo"]) ...mapState(["PrimaryColor", "userInfo"])
}, },
data() { data() {
return { return {
//
rootPath: this.$config.ROOTPATH,
content: '', content: '',
list: [{ list: [{
content: "Hi,你好,E鹿小助手很高兴为您提供咨询服务。", content: "Hi,你好,E鹿小助手很高兴为您提供咨询服务。",
@ -90,7 +95,10 @@
clientTime: 10000, // clientTime: 10000, //
serverTimer: null, // serverTimer: null, //
serverTime: 30000, // serverTime: 30000, //
} },
//
islongPress: false,
timer: null, //
} }
}, },
onUnload() { onUnload() {
@ -98,10 +106,11 @@
}, },
onShow() { onShow() {
this.getUserInfo() this.getUserInfo()
this.connectWs()
}, },
methods: { methods: {
// //
getUserInfo() { getUserInfo() {
this.querUserInfo = { this.querUserInfo = {
"message": "", "message": "",
"dialogId": "", "dialogId": "",
@ -138,7 +147,6 @@
$this.heartBeat(); $this.heartBeat();
// //
let data = JSON.parse(res.data); let data = JSON.parse(res.data);
console.log("xinxi", data.content)
$this.handlerMessage(JSON.parse(data.content)); $this.handlerMessage(JSON.parse(data.content));
}); });
// ws // ws
@ -151,7 +159,7 @@
this.wsInfo.ws.onError((err) => { this.wsInfo.ws.onError((err) => {
$this.wsInfo.alive = false; $this.wsInfo.alive = false;
$this.reConnect(); $this.reConnect();
console.log("ws连接错误:", res); console.log("ws连接错误:", err);
}); });
}, },
// //
@ -176,7 +184,7 @@
}, $this.wsInfo.clientTime); }, $this.wsInfo.clientTime);
}, },
// //
handlerMessage(data) { handlerMessage(data) {
if (data.context !== null) { if (data.context !== null) {
this.list[this.list.length - 1].content += data.context this.list[this.list.length - 1].content += data.context
} }
@ -209,33 +217,29 @@
// //
sendMsg() { sendMsg() {
const $this = this const $this = this
this.judgeLogin((resa) => { this.getUserInfo()
this.getUserInfo() this.list.push({
this.connectWs() content: this.content,
this.list.push({ userType: 'friend',
content: this.content, })
userType: 'friend',
})
if (this.querUserInfo.identity == "") {
this.querUserInfo.identity = this.generateRandomString(8);
}
this.querUserInfo.message = this.content if (this.querUserInfo.identity == "") {
this.content = '' this.querUserInfo.identity = this.generateRandomString(8);
this.$Request.post(this.$config.aiSendMsg, $this.querUserInfo, "json", null, false, true) }
.then(res => {
this.inputDisabled = true
setTimeout(() => {
$this.list.push({
content: "",
userType: 'self',
})
$this.scrollToBottom()
}, 500)
});
}); this.querUserInfo.message = this.content
this.content = ''
this.$Request.post(this.$config.aiSendMsg, $this.querUserInfo, "json", null, false, true)
.then(res => {
this.inputDisabled = true
setTimeout(() => {
$this.list.push({
content: "",
userType: 'self',
})
$this.scrollToBottom()
}, 500)
});
}, },
// //
scrollToBottom() { scrollToBottom() {
@ -270,63 +274,100 @@
} }
}) })
}, },
// //
touchstart() { longpress() {
// const $this = this
const _permission = 'scope.record' this.islongPress = true;
uni.getSetting({ if (this.islongPress == true) {
success: (res) => { //
// const _permission = 'scope.record'
if (res.authSetting.hasOwnProperty(_permission)) { uni.getSetting({
// false success: (res) => {
if (!res.authSetting[_permission]) { if (res.authSetting.hasOwnProperty('scope.record')) {
this.authTips()
} else { if (!res.authSetting[_permission]) {
// $this.authTips()
this._recordAuth = true } else {
// //
recorderManager.start({ $this._recordAuth = true
format: 'pcm', //
}) recorderManager.start({
recorderManager.onStart(() => { format: 'pcm',
this.recordStart = true })
}) recorderManager.onStart(() => {
$this.recordStart = true
})
// //
recorderManager.onError((res) => { recorderManager.onError((res) => {
console.log('recorder error', res) console.log('recorder error', res)
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '系统出错,请重试' title: '系统出错,请重试'
})
$this.recordStart = false
}) })
this.recordStart = false }
} else {
//
console.log('属性不存在,需要授权')
uni.authorize({
scope: 'scope.record',
success: () => {
//
$this._recordAuth = true
console.log('授权成功')
},
fail: (res) => {
console.log('// 未授权隐私协议', res.errno)
/**
* 104 未授权隐私协议
* 用户可能拒绝官方隐私授权弹窗为了避免过度弹窗打扰用户开发者再次调用隐私相关接口时
* 若距上次用户拒绝不足10秒将不再触发弹窗直接给到开发者用户拒绝隐私授权弹窗的报错
*/
if (res.errno == 104) {
uni.showModal({
title: '温馨提示',
content: '您拒绝了隐私协议,请稍后再试',
confirmText: '知道了',
showCancel: false,
success: () => {}
})
} else {
//
console.log('// 用户拒绝授权')
$this.authTips()
}
}
}) })
} }
} else { }
// })
uni.authorize({ }
scope: _permission, },
success: () => { //
// authTips() {
this._recordAuth = true const $this = this
}, uni.showModal({
fail: (res) => { title: '提示',
/** content: '您拒绝了麦克风权限,将导致功能不能正常使用,去设置权限?',
* 104 未授权隐私协议 confirmText: '去设置',
* 用户可能拒绝官方隐私授权弹窗为了避免过度弹窗打扰用户开发者再次调用隐私相关接口时 cancelText: '取消',
* 若距上次用户拒绝不足10秒将不再触发弹窗直接给到开发者用户拒绝隐私授权弹窗的报错 success: (res) => {
*/ if (res.confirm) {
if (res.errno == 104) { uni.openSetting({
uni.showModal({ success: (res) => {
title: '温馨提示', if (res.authSetting['scope.record']) {
content: '您拒绝了隐私协议,请稍后再试', console.log("已授权麦克风");
confirmText: '知道了', $this._recordAuth = true
} else {
//
wx.showModal({
title: '提示',
content: '您未授权麦克风,功能将无法使用',
showCancel: false, showCancel: false,
success: () => {} confirmText: '知道了'
}) })
} else {
//
this.authTips()
} }
} }
}) })
@ -334,9 +375,22 @@
} }
}) })
}, },
//
touchstart() {
const $this = this
this.timer = setTimeout(() => {
$this.longpress();
}, 200)
},
// //
touchend() { touchend() {
const $this = this const $this = this
// click() islongPress fasle
clearTimeout(this.timer);
setTimeout(() => {
this.islongPress = false
}, 200)
if (!this._recordAuth || !this.recordStart) return if (!this._recordAuth || !this.recordStart) return
// //
recorderManager.stop(); recorderManager.stop();
@ -345,9 +399,10 @@
duration, duration,
tempFilePath tempFilePath
} = res } = res
this.recordStart = false $this.recordStart = false
wx.uploadFile({ wx.uploadFile({
url: 'http://192.168.130.157:48080/app-api/wechatshop/toolIdentify/identifySpeech', url: $this.rootPath + '/app-api/wechatshop/toolIdentify/identifySpeech',
filePath: tempFilePath, filePath: tempFilePath,
name: 'file', name: 'file',
formData: { formData: {
@ -355,13 +410,19 @@
}, },
success: function(res) { success: function(res) {
let data = JSON.parse(res.data) let data = JSON.parse(res.data)
$this.list.push({ console.log("dsfaD", data)
content: data.data, if (data.data) {
audioSrc: tempFilePath, $this.content = data.data
userType: 'self', $this.sendMsg()
messageType: 'voice' } else {
}) wx.showModal({
$this.scrollToBottom() title: '提示',
content: "没听清,请您再说一遍",
showCancel: false,
success: function(res) {}
});
}
}, },
fail: function(res) { fail: function(res) {
UTIL.log(res); UTIL.log(res);
@ -376,6 +437,20 @@
}); });
}) })
}, },
//
clickSprink() {
//
if (this.islongPress == false) {
wx.showModal({
title: '提示',
content: "说话时间太短",
showCancel: false,
success: function(res) {}
});
} else if (this.islongPress == true) {
console.log("长按事件");
}
},
// key // key
generateRandomString(length) { generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@ -401,6 +476,7 @@
/* #endif */ /* #endif */
box-sizing: border-box; box-sizing: border-box;
top: 0; top: 0;
padding-bottom: 60rpx;
} }
.v-pages.Ai { .v-pages.Ai {
@ -408,7 +484,7 @@
// background-repeat: no-repeat; // background-repeat: no-repeat;
// background-position: top; // background-position: top;
// background-size: cover; // background-size: cover;
min-height: 50vh;
} }
.v-ai-list { .v-ai-list {
@ -423,6 +499,7 @@
.img { .img {
width: 80rpx; width: 80rpx;
height: 80rpx;
} }
} }
@ -556,4 +633,25 @@
} }
} }
} }
.loading {
height: 40rpx;
}
.loading-dot {
display: inline-block;
width: 4px;
height: 4px;
border-radius: 4px;
background-color: #000;
animation: loading 1s infinite;
}
.loading-dot:nth-child(2) {
animation-delay: 0.2s;
}
.loading-dot:nth-child(3) {
animation-delay: 0.4s;
}
</style> </style>

@ -1,8 +1,9 @@
<template> <template>
<view class="zero-markdown-view"> <view class="zero-markdown-view">
<mp-html :key="mpkey" :selectable="selectable" :scroll-table='scrollTable' :tag-style="tagStyle" <mp-html :key="mpkey" :selectable="selectable" :scroll-table='scrollTable' :tag-style="tagStyle"
:markdown="true" :content="html"> :markdown="true" :content="html" v-if="html">
</mp-html> </mp-html>
</view> </view>
</template> </template>
@ -177,4 +178,18 @@
border-radius: 8rpx 16rpx 16rpx 16rpx; border-radius: 8rpx 16rpx 16rpx 16rpx;
background-color: #fff; background-color: #fff;
} }
@keyframes loading {
0% {
opacity: 0.2;
}
20% {
opacity: 1;
}
100% {
opacity: 0.2;
}
}
</style> </style>
Loading…
Cancel
Save