|
|
@@ -378,7 +378,7 @@
|
|
|
bottom: 0;
|
|
|
background-color: white;
|
|
|
width: 100%;
|
|
|
- height: 360px;
|
|
|
+ height: 340px;
|
|
|
">
|
|
|
<div class="audio" v-if="shows">
|
|
|
<div class="wave"></div>
|
|
|
@@ -402,8 +402,8 @@
|
|
|
<div class="tip">{{ tips }}</div>
|
|
|
<div
|
|
|
style="position: absolute; width: 100%; height: 80px; z-index: 999999"
|
|
|
- @touchstart="lujin"
|
|
|
- @touchend="endlujin"></div>
|
|
|
+ @touchstart="startRecord"
|
|
|
+ @touchend="stopRecord"></div>
|
|
|
<van-icon :name="yt" size="40" style="top: 20px; left: 50%; margin-left: -20px" />
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -421,7 +421,7 @@ import tabBar from '@/components/tabBar';
|
|
|
import { getReportInfo } from '@/api';
|
|
|
import { aiDialogue } from '@/api/inventory';
|
|
|
import axios from 'axios';
|
|
|
-import { getPosition, getMapPoi, getkeywordPoi, getTicketFun } from '@/utils/TXApiFun';
|
|
|
+import { getPosition, getTicketFun } from '@/utils/TXApiFun';
|
|
|
export default {
|
|
|
name: 'ai',
|
|
|
components: { tabBar },
|
|
|
@@ -480,7 +480,7 @@ export default {
|
|
|
activated() {
|
|
|
this.onLoad();
|
|
|
// 授权
|
|
|
- getTicketFun(['getLocation', 'startRecord', 'stopRecord', 'onVoiceRecordEnd']);
|
|
|
+ getTicketFun(['getLocation', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'uploadVoice']);
|
|
|
},
|
|
|
methods: {
|
|
|
garbageManager() {
|
|
|
@@ -582,87 +582,57 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- lujin() {
|
|
|
+ startRecord() {
|
|
|
this.tips = '松开 发送';
|
|
|
- let url = window.location.href;
|
|
|
- let that = this;
|
|
|
- let wx = this.wx;
|
|
|
- let qiyeData;
|
|
|
- const instance = axios.create();
|
|
|
- instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
|
|
|
- instance
|
|
|
- .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
|
|
|
- params: {
|
|
|
- url: url,
|
|
|
- },
|
|
|
- })
|
|
|
- .then((response) => {
|
|
|
- if (response.status == 200) {
|
|
|
- qiyeData = response.data.data;
|
|
|
- wx.config({
|
|
|
- beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
|
|
- debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
- appId: qiyeData.appId, // 必填,企业微信的corpID
|
|
|
- timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
|
|
|
- nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
|
|
|
- signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
|
|
|
- jsApiList: ['ready', 'startRecord', 'stopRecord', 'onVoiceRecordEnd'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
|
|
|
- });
|
|
|
- wx.ready(function () {
|
|
|
- wx.startRecord();
|
|
|
- that.shows = true;
|
|
|
- wx.onVoiceRecordEnd({
|
|
|
- complete: function (res) {
|
|
|
- var localId = res.localId;
|
|
|
- that.shows = false;
|
|
|
- wx.uploadVoice({
|
|
|
- localId: localId,
|
|
|
- isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
|
- success: function (res) {
|
|
|
- aiDialogue({ type: 2, content: res.serverId }).then((response) => {
|
|
|
- if (response.code == 200) {
|
|
|
- // that.pageNum = 1;
|
|
|
- // that.Ggreet = [];
|
|
|
- // that.aiDialogueGgreet();
|
|
|
- this.Ggreet.push(...response.rows);
|
|
|
- that.garbageManager();
|
|
|
- }
|
|
|
- that.show = false;
|
|
|
- });
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
+ this.wx.startRecord();
|
|
|
+ this.shows = true;
|
|
|
+ this.wx.onVoiceRecordEnd({
|
|
|
+ // 录音时间超过一分钟没有停止的时候会执行 complete 回调
|
|
|
+ complete: (res) => {
|
|
|
+ var localId = res.localId;
|
|
|
+ this.shows = false;
|
|
|
+ this.wx.uploadVoice({
|
|
|
+ localId: localId,
|
|
|
+ isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
|
+ success: (res) => {
|
|
|
+ aiDialogue({ type: 2, content: res.serverId }).then((response) => {
|
|
|
+ if (response.code == 200) {
|
|
|
+ this.Ggreet.push(...response.rows);
|
|
|
+ this.garbageManager();
|
|
|
+ }
|
|
|
+ this.show = false;
|
|
|
});
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
},
|
|
|
- endlujin() {
|
|
|
- let wx = this.wx;
|
|
|
- var that = this;
|
|
|
- wx.stopRecord({
|
|
|
- success: function (res) {
|
|
|
+ stopRecord() {
|
|
|
+ this.wx.stopRecord({
|
|
|
+ success: (res) => {
|
|
|
var localId = res.localId;
|
|
|
- wx.uploadVoice({
|
|
|
+ this.wx.uploadVoice({
|
|
|
localId: localId,
|
|
|
isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
|
- success: function (res) {
|
|
|
+ success: (res) => {
|
|
|
aiDialogue({ type: 2, content: res.serverId }).then((response) => {
|
|
|
if (response.code == 200) {
|
|
|
- // that.pageNum = 1;
|
|
|
- // that.Ggreet = [];
|
|
|
- // that.aiDialogueGgreet();
|
|
|
- that.Ggreet.push(...response.rows);
|
|
|
- that.garbageManager();
|
|
|
+ this.Ggreet.push(...response.rows);
|
|
|
+ this.garbageManager();
|
|
|
}
|
|
|
- that.shows = false;
|
|
|
- that.show = false;
|
|
|
+ this.shows = false;
|
|
|
+ this.show = false;
|
|
|
});
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
+ // AI对话接口
|
|
|
+ // aiDialogue
|
|
|
typw(val) {
|
|
|
if (val == 1) {
|
|
|
this.one14 = true;
|
|
|
@@ -719,6 +689,7 @@ export default {
|
|
|
this.message = '';
|
|
|
},
|
|
|
showFn() {
|
|
|
+ this.tips = '按住 说话';
|
|
|
this.shows = false;
|
|
|
this.show = true;
|
|
|
},
|